Skip to content

Commit 112fb17

Browse files
authored
Avoid checking illegal blocks. (#230)
## πŸ“ 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)
1 parent 7ff6fe1 commit 112fb17

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

β€Žcrates/rbuilder/src/utils/provider_factory_reopen.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,18 @@ pub fn check_provider_factory_health<DB: Database>(
133133
current_block_number: u64,
134134
provider_factory: &ProviderFactory<DB>,
135135
) -> eyre::Result<()> {
136-
// evm must have access to block hashed of 256 of the previous blocks
137-
for i in 1u64..=256 {
136+
// evm must have access to block hashes of 256 of the previous blocks
137+
let blocks_to_check = current_block_number.min(256);
138+
for i in 1..=blocks_to_check {
138139
let num = current_block_number - i;
139140
let hash = provider_factory.block_hash(num)?;
140141
if hash.is_none() {
141142
eyre::bail!(
142143
"Missing historical block hash for block {}, current block: {}",
143-
current_block_number - i,
144+
num,
144145
current_block_number
145146
);
146147
}
147-
148-
if num == 0 {
149-
break;
150-
}
151148
}
152149

153150
Ok(())

0 commit comments

Comments
Β (0)