Skip to content

Commit

Permalink
fix: meaningless block header hash matching (#53)
Browse files Browse the repository at this point in the history
* Fix meaningless Block header hash matching

* fix: replace wrap with by ok or else
  • Loading branch information
nishuzumi authored Jan 17, 2025
1 parent 48053d9 commit 3e1e085
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/executor/host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ impl<T: Transport + Clone, P: Provider<T, AnyNetwork> + Clone> HostExecutor<T, P
{
// Fetch the current block and the previous block from the provider.
tracing::info!("fetching the current block and the previous block");
let current_block = self
let origin_current_block = self
.provider
.get_block_by_number(block_number.into(), true)
.await?
.map(|block| Block::try_from(block.inner))
.ok_or(eyre!("couldn't fetch block: {}", block_number))??;
.ok_or_else(|| eyre!("couldn't fetch block: {}", block_number))?;

let current_block = Block::try_from(origin_current_block.clone().inner)?;

let previous_block = self
.provider
.get_block_by_number((block_number - 1).into(), true)
Expand Down Expand Up @@ -185,8 +187,7 @@ impl<T: Transport + Clone, P: Provider<T, AnyNetwork> + Clone> HostExecutor<T, P
current_block.requests.as_ref().map(|r| proofs::calculate_requests_root(&r.0));

// Assert the derived header is correct.
assert_eq!(header.hash_slow(), current_block.header.hash_slow(), "header mismatch");

assert_eq!(header.hash_slow(), origin_current_block.inner.header.hash, "header mismatch");
// Log the result.
tracing::info!(
"successfully executed block: block_number={}, block_hash={}, state_root={}",
Expand Down

0 comments on commit 3e1e085

Please sign in to comment.