bug: `forge clone` returns wrong evm version
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (0dceb53 2024-07-04T00:18:38.827591668Z)
What command(s) is the bug in?
forge clone
Operating System
Linux
Describe the bug
```forge clone` returns the evm version "constantinople" for the USDC contract on mainnet:
forge clone 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
The compiled bytecode does not match the on-chain bytecode. With the correct evm version "byzantium", the bytecode is identical.
The generated foundry.toml from the command above is:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
auto_detect_remappings = false
chain_id = 1
auto_detect_solc = false
solc_version = "0.4.24"
evm_version = "constantinople"
optimizer = false
optimizer_runs = 200
libraries = []
hmm, yeah this is slightly problematic.
etherscan does not return the evm version but instead returns Default so we try to detect the evm version based on the solc version.
Constantinople was introduced in 0.4.21, which explains why we detect this.
this is a bit ambiguous, so not sure how to improve this...
this is a bit ambiguous, so not sure how to improve this...
should we add a mapping version -> default evm version to block-explorers? It should be possible to parse from solc --help output, so would require a simple script
--evm-version version
Select desired EVM version. Either homestead,
tangerineWhistle, spuriousDragon, byzantium,
constantinople, petersburg, istanbul (default) or
berlin.
edit: actually, seems like most of updates are mentioned in changelog: https://raw.githubusercontent.com/ethereum/solidity/develop/Changelog.md (search for "default evm")
I guess if it's ambiguous, we could also try compile and match the bytecode.
but this would be a lot of effort, not sure it's worth it
Possibly related: https://github.com/foundry-rs/foundry/issues/8446
Potentially related: https://github.com/foundry-rs/compilers/pull/189
considering there is no practical solution, going to mark as resolved with updated docs PR https://github.com/foundry-rs/foundry/pull/8369 Please reopen if disagree. thank you!