Skip to content

Commit

Permalink
avoid checking negative blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanCorDX committed Oct 28, 2024
1 parent 7ff6fe1 commit cb0606e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/rbuilder/src/utils/provider_factory_reopen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,18 @@ pub fn check_provider_factory_health<DB: Database>(
current_block_number: u64,
provider_factory: &ProviderFactory<DB>,
) -> eyre::Result<()> {
// evm must have access to block hashed of 256 of the previous blocks
for i in 1u64..=256 {
// evm must have access to block hashes of 256 of the previous blocks
let blocks_to_check = current_block_number.min(256);
for i in 1..=blocks_to_check {
let num = current_block_number - i;
let hash = provider_factory.block_hash(num)?;
if hash.is_none() {
eyre::bail!(
"Missing historical block hash for block {}, current block: {}",
current_block_number - i,
num,
current_block_number
);
}

if num == 0 {
break;
}
}

Ok(())
Expand Down

0 comments on commit cb0606e

Please sign in to comment.