-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
"EvmError: NotActivated" when trying to use a deployed contract compiled with Shanghai but with evm_version set to Paris for scripts #6228
Comments
I'm not sure I understand. you're running anvil and deploying a contract with forge? in that case, both need set their evm version to shanghai. One does not automatically set the other. |
|
@Evalir This probably happens because the EVM version for fork in which script is running defaults to the EVM version contracts were compiled with. This is also valid for tests using forking environments. Right now it is impossible to do fork-testing of contract compiled with Minimal repro for this looks like this: pragma solidity 0.8.20;
import {Test} from "forge-std/Test.sol";
interface ICreate2Deployer {
function computeAddress(bytes32 salt, bytes32 codeHash) external view returns (address);
}
contract TestEVMVersion is Test {
function test() public {
vm.createSelectFork("mainnet");
ICreate2Deployer(0x35Da41c476fA5c6De066f20556069096A1F39364).computeAddress(bytes32(0), bytes32(0));
}
} Running This will get worse over the time as more contracts will be deployed with PUSH0, and projects still compiling with This can be solved by automatically enabling shanghai for chains from SHANGHAI_ENABLED_CHAINS when running tests/scripts in forks, but it does not seem to be a best fix as this list would have to be updated every time some other chain enables shanghai support |
This makes sense, we probably need to decouple these and have:
Right now those two are coupled |
@mds1 I think we can assume that this issue mostly affects projects which are compiling contracts with If we will have global setting for |
Thanks for the clarification. So:
I think that should solve this issue, and avoid the need for an extra flag. How does that sound? |
Yes, this sounds reasonable.
Managing such mapping seems like something out of foundry's scope and it will be hard to include all existing chains into it. It might make sense to also add a |
somewhat related #6440 |
same issue here when interactivating with a contract created by |
I am on solc 0.8.22 and shanghai (set both in foundry.toml as a flag when running Interestingly, this is happening on an already-deployed create2 factory I call to deploy a new contract using create2. here is the factory deployer: EDIT: Found the issue. The contract on mainnet used a new opcode from cancun upgrade (MCOPY). So my attempts to run using shanghai failed, but |
related #8614 |
Component
Forge, Anvil
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (fa6b39c 2023-11-04T00:17:54.146286000Z)
What command(s) is the bug in?
No response
Operating System
None
Describe the bug
It seems there are some mixup with anvil evm emulation / forge script simulation when working with different evm versions.
When trying to deploy a contract compiled with Paris using a create2deployer deployed with Shanghai, an error is thrown:
EvmError: NotActivated
at thecomputeAddress
step.A deployment with ABI Ninja works
https://etherscan.io/tx/0x85d5353fa0924f8b0ed23fa624c09000e6d2a531676e256ba1b76f4e693afce3
A computeAddress with ABI Ninja works:
The codeHash used was obtain by compiling contract with evm version set to Paris
But with anvil / forge script
computeAddress
fails withEvmError: NotActivated
Here is a repo to replicate the issue https://github.com/obatirou/foundry-bug-replication
It will only pass if the evm version is set to Shanghai in the repo.
CC @Evalir
The text was updated successfully, but these errors were encountered: