Skip to content

Commit

Permalink
fix(anvil): fix off by one blocknumber (#3737)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 22, 2022
1 parent f872fb9 commit 3fe82a1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,15 @@ impl EthApi {
block_number: Option<BlockId>,
) -> Result<U256> {
let block_request = self.block_request(block_number).await?;

if let BlockRequest::Number(number) = &block_request {
if let Some(fork) = self.get_fork() {
if fork.predates_fork_inclusive(number.as_u64()) {
return Ok(fork.get_nonce(address, number.as_u64()).await?)
}
}
}

let nonce = self.backend.get_nonce(address, Some(block_request)).await?;

Ok(nonce)
Expand Down

0 comments on commit 3fe82a1

Please sign in to comment.