From cb0606ed25874390e26cf1884e5fa89fbe2df8a8 Mon Sep 17 00:00:00 2001 From: Daniel Xifra Date: Mon, 28 Oct 2024 13:30:04 -0300 Subject: [PATCH] avoid checking negative blocks. --- crates/rbuilder/src/utils/provider_factory_reopen.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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(())