Skip to content

Commit

Permalink
Avoid checking illegal blocks. (#230)
Browse files Browse the repository at this point in the history
## πŸ“ Summary

There was a bug if the block number was 0 (block_hash got 2^64-1 as a
parameter)

## πŸ’‘ Motivation and Context

Broke devnet tests for Pectra upgrade.

---

## βœ… I have completed the following steps:

* [X] Run `make lint`
* [X] Run `make test`
* [ ] Added tests (if applicable)
  • Loading branch information
ZanCorDX authored Oct 28, 2024
1 parent 7ff6fe1 commit 112fb17
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 112fb17

Please sign in to comment.