From 50873194db7212a4bb78e31e65ac373bc41c0fd4 Mon Sep 17 00:00:00 2001 From: refcell Date: Fri, 16 Aug 2024 10:32:37 -0700 Subject: [PATCH] fixes --- bin/host/src/fetcher/mod.rs | 24 +++++++++++++----------- justfile | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/bin/host/src/fetcher/mod.rs b/bin/host/src/fetcher/mod.rs index d04ad414f..d0f947008 100644 --- a/bin/host/src/fetcher/mod.rs +++ b/bin/host/src/fetcher/mod.rs @@ -174,17 +174,19 @@ where anyhow::bail!("Invalid hint data length: {}", hint_data.len()); } - let data = &hint_data[0..32]; - let hash: B256 = - data.try_into().map_err(|e| anyhow!("Failed to convert bytes to B256: {e}"))?; - let data = &hint_data[32..40]; - let index = u64::from_be_bytes( - data.try_into().map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?, - ); - let data = &hint_data[40..48]; - let timestamp = u64::from_be_bytes( - data.try_into().map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?, - ); + let hash_data_bytes: [u8; 32] = hint_data[0..32] + .try_into() + .map_err(|e| anyhow!("Failed to convert bytes to B256: {e}"))?; + let index_data_bytes: [u8; 8] = hint_data[32..40] + .try_into() + .map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?; + let timestamp_data_bytes: [u8; 8] = hint_data[40..48] + .try_into() + .map_err(|e| anyhow!("Failed to convert bytes to u64: {e}"))?; + + let hash: B256 = hash_data_bytes.into(); + let index = u64::from_be_bytes(index_data_bytes); + let timestamp = u64::from_be_bytes(timestamp_data_bytes); let partial_block_ref = BlockInfo { timestamp, ..Default::default() }; let indexed_hash = IndexedBlobHash { index: index as usize, hash }; diff --git a/justfile b/justfile index f7369a5c8..a148d8191 100644 --- a/justfile +++ b/justfile @@ -78,7 +78,7 @@ build-cannon *args='': --platform linux/amd64 \ -v `pwd`/:/workdir \ -w="/workdir" \ - ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo build --workspace --all -Zbuild-std $@ --exclude kona-host --exclude trusted-sync + ghcr.io/ethereum-optimism/kona/cannon-builder:main cargo build --workspace --all -Zbuild-std $@ --exclude kona-host --exclude trusted-sync --exclude kdn # Build for the `asterisc` target. Any crates that require the stdlib are excluded from the build for this target. build-asterisc *args='': @@ -87,7 +87,7 @@ build-asterisc *args='': --platform linux/amd64 \ -v `pwd`/:/workdir \ -w="/workdir" \ - ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build --workspace --all -Zbuild-std $@ --exclude kona-host --exclude trusted-sync + ghcr.io/ethereum-optimism/kona/asterisc-builder:main cargo build --workspace --all -Zbuild-std $@ --exclude kona-host --exclude trusted-sync --exclude kdn # Build the `trusted-sync` docker image docker-build-ts *args='':