Component
Anvil
What version of Foundry are you on?
anvil 1.8.1, and master at 4cd4320 (1.8.4-dev) behaves the same
What command(s) is the bug in?
eth_getStorageAt, eth_getProof (any historical state read) after anvil_set*
Operating System
macOS (Apple Silicon)
Describe the bug
After anvil_setStorageAt (or anvil_setBalance / anvil_setCode) followed by a mine, reads at the previous block return the new value. The proof root for that block matches no block header.
cast rpc anvil_setCode 0x…aa 0x00
cast rpc anvil_setStorageAt 0x…aa 0x…01 0x…11 && cast rpc evm_mine # block 1
cast rpc anvil_setStorageAt 0x…aa 0x…01 0x…22 && cast rpc evm_mine # block 2
cast storage 0x…aa 1 --block 1 # 0x…22, expected 0x…11
The same change made through real transactions reads back correctly. It looks like the state for block N is snapshotted when N+1 starts mining, so it's really the pre-state of N+1. Moving the snapshot to right after N would break tracing of N+1 transactions that rely on a cheat, so it probably needs a separate post-state when state changes between blocks. Happy to do that if you're ok with the approach.
Component
Anvil
What version of Foundry are you on?
anvil 1.8.1, and master at 4cd4320 (1.8.4-dev) behaves the same
What command(s) is the bug in?
eth_getStorageAt,eth_getProof(any historical state read) afteranvil_set*Operating System
macOS (Apple Silicon)
Describe the bug
After
anvil_setStorageAt(oranvil_setBalance/anvil_setCode) followed by a mine, reads at the previous block return the new value. The proof root for that block matches no block header.The same change made through real transactions reads back correctly. It looks like the state for block N is snapshotted when N+1 starts mining, so it's really the pre-state of N+1. Moving the snapshot to right after N would break tracing of N+1 transactions that rely on a cheat, so it probably needs a separate post-state when state changes between blocks. Happy to do that if you're ok with the approach.