Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(anvil): anvil_reset seems to not reset the addresses contract code #8684

Closed
2 tasks done
Tracked by #8269
Raiden1411 opened this issue Aug 16, 2024 · 0 comments · Fixed by #8768
Closed
2 tasks done
Tracked by #8269

bug(anvil): anvil_reset seems to not reset the addresses contract code #8684

Raiden1411 opened this issue Aug 16, 2024 · 0 comments · Fixed by #8768
Labels
C-anvil Command: anvil T-bug Type: bug
Milestone

Comments

@Raiden1411
Copy link

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

No response

What command(s) is the bug in?

anvil -f "FORK_URL" --port PORT --fork-block-number BLOCK_NUMBER

Operating System

Linux

Describe the bug

Running anvil_reset doesn't seem to reset the addresses contract code.

For example say that I ran anvil -f "FORK_URL" --port PORT --fork-block-number BLOCK_NUMBER where the FORK_URL is some eth mainnet endpoint and then running

curl -X POST \
      -H "Content-Type: application/json" \
      --data '{"jsonrpc":"2.0","method":"eth_call","params": [{"to": "0x16Fc5058F25648194471939df75CF27A2fdC48BC", "data": "0x54fd4d50"}, "latest"],"id":69}' \
      "http://localhost:6969/"

This results is {"jsonrpc":"2.0","id":69,"result":"0x"}

This is expected since 0x16Fc5058F25648194471939df75CF27A2fdC48BC is the portalAddress contract on Mainnet Sepolia.

However when running anvil_reset and then running the above curl command the result is the same {"jsonrpc":"2.0","id":69,"result":"0x"}

curl -X POST \
            -H "Content-Type: application/json" \
            --data '{"jsonrpc": "2.0", "id": 31337, "method": "anvil_reset", "params": [{"forking": {"jsonRpcUrl": "MAIN_NET_SEPOLIA_URL", "blockNumber":"6511079" }}]}' \
            "http://localhost:6969/"

This seems to be working as expected with Hardhat when using hardhat_reset where the result is instead
{"jsonrpc":"2.0","id":69,"result":"0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006332e31302e300000000000000000000000000000000000000000000000000000"} as it's the expected outcome when querying the contract on sepolia.

The address 0x16Fc5058F25648194471939df75CF27A2fdC48BC on mainnet doesn't contain contract code but then on Sepolia it does and I believe that this code is not being updated on the reset call.

This can be check with

curl -X POST \
           -H "Content-Type: application/json" \
           --data '{"jsonrpc": "2.0", "id": 31337, "method": "eth_getCode", "params": ["0x16Fc5058F25648194471939df75CF27A2fdC48BC", "latest"]}' \
           "http://localhost:6969"/

This results is {"jsonrpc":"2.0","id":31337,"result":"0x"}

I believe it might be because the fork creates a default storage but not entirely sure.

Not sure this is the intended behavior, but it would be great to have a similar behavior as hardhat_reset

@Raiden1411 Raiden1411 added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Aug 16, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Aug 16, 2024
@zerosnacks zerosnacks changed the title anvil_reset seems to not reset the addresses contract code bug(anvil): anvil_reset seems to not reset the addresses contract code Aug 16, 2024
@zerosnacks zerosnacks added T-to-investigate Type: to investigate C-anvil Command: anvil and removed T-needs-triage Type: this issue needs to be labelled labels Aug 16, 2024
@yash-atreya yash-atreya removed the T-to-investigate Type: to investigate label Sep 4, 2024
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants