Skip to content

Commit

Permalink
fix ethersdb.rs forking
Browse files Browse the repository at this point in the history
EthersDB::with_runtime and EthersDB::with_handle were added in v11 for reasons involving async. Unlike EthersDB::new, these two functions always fork the latest block (even when a historical block is specified). This commit fixes that.
  • Loading branch information
onlyblackstars authored Feb 1, 2025
1 parent 62be6f6 commit 11eae6c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/revm/src/db/ethersdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ impl<M: Middleware> EthersDB<M> {
rt,
};

instance.block_number = Some(BlockId::from(
instance.block_on(instance.client.get_block_number()).ok()?,
));
if block_number.is_none() {
instance.block_number = Some(BlockId::from(
instance.block_on(instance.client.get_block_number()).ok()?,
));
};
Some(instance)
}

Expand All @@ -86,9 +88,11 @@ impl<M: Middleware> EthersDB<M> {
rt,
};

instance.block_number = Some(BlockId::from(
instance.block_on(instance.client.get_block_number()).ok()?,
));
if block_number.is_none() {
instance.block_number = Some(BlockId::from(
instance.block_on(instance.client.get_block_number()).ok()?,
));
};
Some(instance)
}

Expand Down

0 comments on commit 11eae6c

Please sign in to comment.