diff --git a/crates/rbuilder/src/utils/provider_factory_reopen.rs b/crates/rbuilder/src/utils/provider_factory_reopen.rs index 32576a88..237cc6a9 100644 --- a/crates/rbuilder/src/utils/provider_factory_reopen.rs +++ b/crates/rbuilder/src/utils/provider_factory_reopen.rs @@ -133,21 +133,18 @@ pub fn check_provider_factory_health( current_block_number: u64, provider_factory: &ProviderFactory, ) -> 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(())