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

Foundry does not create a new, clean EVM environment when the chainId is changed #6008

Closed
2 tasks done
pcaversaccio opened this issue Oct 8, 2023 · 2 comments
Closed
2 tasks done
Labels
T-bug Type: bug

Comments

@pcaversaccio
Copy link
Contributor

pcaversaccio commented Oct 8, 2023

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (87283bc 2023-10-07T00:16:07.431446791Z)

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

Foundry does not create a new, clean EVM environment when the chainId is changed, and a deployment of a contract to the same address therefore fails. To solve this problem currently, I return to the original snapshot state.

Simple repro:

  • CREATE2 deploy a contract
  • Change chainId to an ID via vm.chainId that is not equal to the original chainId
  • Redeploy via CREATE2
  • Will revert due to EIP-684
@pcaversaccio pcaversaccio added the T-bug Type: bug label Oct 8, 2023
@Evalir
Copy link
Member

Evalir commented Dec 18, 2023

Hmm, this seems like expected behavior and not an issue? I understand there's a point to clean up the evm state if you change chain IDs, but, it severely overloads the chainId cheatcode. I'll close this for now but feel free to reopen if you think this should be discussed further. I can see how the current behavior is useful for simulation or CTF purposes

@Evalir Evalir closed this as completed Dec 18, 2023
@pcaversaccio
Copy link
Contributor Author

@Evalir fwiw, you should probably close this issue as Not Planned instead of Completed. The reason why such a feature is desirable to me is that in my CreateX tests I had to mock contract creation frontrunning and redeployment events on other chains, and snapshot reverts can become annoying. But maybe it's an edge case...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

2 participants