Skip to content

Commit 6f926a4

Browse files
authored
fix(anvil): eth_getAccountInfo check if predates fork inclusive (#12101)
1 parent 481f569 commit 6f926a4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

crates/anvil/src/eth/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ impl EthApi {
777777
if let Some(fork) = self.get_fork() {
778778
// check if the number predates the fork, if in fork mode
779779
if let BlockRequest::Number(number) = self.block_request(block_number).await?
780-
&& fork.predates_fork(number)
780+
&& fork.predates_fork_inclusive(number)
781781
{
782782
// if this predates the fork we need to fetch balance, nonce, code individually
783783
// because the provider might not support this endpoint

crates/anvil/tests/it/fork.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,22 @@ async fn test_fork_get_account_info() {
16391639
code: Default::default(),
16401640
}
16411641
);
1642+
1643+
// Check account info at block number, see https://github.com/foundry-rs/foundry/issues/12072
1644+
let info = provider
1645+
.get_account_info(address!("0x19e53a7397bE5AA7908fE9eA991B03710bdC74Fd"))
1646+
// predates fork
1647+
.number(BLOCK_NUMBER)
1648+
.await
1649+
.unwrap();
1650+
assert_eq!(
1651+
info,
1652+
AccountInfo {
1653+
balance: U256::from(14352720829244098514u64),
1654+
nonce: 6690,
1655+
code: Default::default(),
1656+
}
1657+
);
16421658
}
16431659

16441660
fn assert_hardfork_config(

0 commit comments

Comments
 (0)