Skip to content

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Sep 12, 2025

closes #11623

this previously forward eth_getAccount which isnt supported by all endpoints, instead we need to fetch balance,code,nonce individually here

grandizzy
grandizzy previously approved these changes Sep 12, 2025
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, makes sense!

@mattsse mattsse added T-bug Type: bug C-anvil Command: anvil labels Sep 12, 2025
@mattsse mattsse enabled auto-merge (squash) September 12, 2025 14:32
@grandizzy grandizzy changed the title fix: specialize eth_getAccountInfo in fork mode fix(anvil): specialize eth_getAccountInfo in fork mode Sep 12, 2025
@mattsse mattsse merged commit 6bcfb82 into master Sep 12, 2025
25 checks passed
@mattsse mattsse deleted the matt/specialize-eth_getAccountInfo-in-fork branch September 12, 2025 14:46
@github-project-automation github-project-automation bot moved this to Done in Foundry Sep 12, 2025
MerkleBoy pushed a commit to MerkleBoy/foundry that referenced this pull request Sep 17, 2025
* fix: specialize eth_getAccountInfo in fork mode

* typo
@winnsterx
Copy link

winnsterx commented Sep 18, 2025

Hey @mattsse! While this fix works correctly for blocks that predate the fork, the bug still exists when querying the current state (blocks at or after the fork point). Reproduction:

anvil --fork-url <RPC_URL> --fork-block-number 61629270

# Historical query (predates fork) - WORKS
cast rpc eth_getAccountInfo 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c "0x3ac6355" --rpc-url http://127.0.0.1:8545
# Returns: {"balance":"0x1196b741251f34f3ff8cb","nonce":"0x1",...}

# Current state query - BROKEN  
cast rpc eth_getAccountInfo 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c "latest" --rpc-url http://127.0.0.1:8545  
# Returns: {"balance":"0x0","nonce":"0x0",...}

# But individual queries work fine:
cast balance 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c --rpc-url http://127.0.0.1:8545
# Returns: 1328967138206161849999779 (correct balance)

The fix here only triggers when fork.predates_fork(number) is true. For current state queries, it falls back to the regular get_account() path which has the original bug. Could you apply the same individual fetch logic to all fork mode queries, not just historical ones? Otherwise, the underlying get_account() method needs to be fixed for fork mod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-bug Type: bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

reopen: eth_getAccountInfo always returns zero balance and nonce in forked environments
4 participants