From 952f40dbd824937fdd07f2d57fea3329ec9b5c85 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 12 Sep 2025 16:25:19 +0200 Subject: [PATCH 1/2] fix: specialize eth_getAccountInfo in fork mode --- crates/anvil/src/eth/api.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index deeab711981c4..938777b91cf8d 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -766,12 +766,31 @@ impl EthApi { } /// Returns the account information including balance, nonce, code and storage + /// + /// Note: This isn't support by all providers pub async fn get_account_info( &self, address: Address, block_number: Option, ) -> Result { node_info!("eth_getAccountInfo"); + + if let Some(fork) = self.get_fork() { + // check if the number predates the fork, if in fork mode + if let BlockRequest::Number(number) = self.block_request(block_number).await? + && fork.predates_fork(number) + { + // if this predates the fork we need to fetch balance, nonce, code individually + // becasue the provider might not support this endpoint + let balance = self.balance(address, Some(number.into())); + let code = self.get_code(address, Some(number.into())); + let nonce = self.get_transaction_count(address, Some(number.into())); + let (balance, code, nonce) = try_join!(balance, code, nonce)?; + + return Ok(alloy_rpc_types::eth::AccountInfo { balance, nonce, code }); + } + } + let account = self.get_account(address, block_number); let code = self.get_code(address, block_number); let (account, code) = try_join!(account, code)?; From 515b00249d2c123cb444ea1136793412531bd224 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 12 Sep 2025 16:31:20 +0200 Subject: [PATCH 2/2] typo --- crates/anvil/src/eth/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index 938777b91cf8d..61c8af5f98ff2 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -781,7 +781,7 @@ impl EthApi { && fork.predates_fork(number) { // if this predates the fork we need to fetch balance, nonce, code individually - // becasue the provider might not support this endpoint + // because the provider might not support this endpoint let balance = self.balance(address, Some(number.into())); let code = self.get_code(address, Some(number.into())); let nonce = self.get_transaction_count(address, Some(number.into()));