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: forge clone returns wrong evm version #8356

Closed
2 tasks done
stiefn opened this issue Jul 4, 2024 · 6 comments
Closed
2 tasks done

bug: forge clone returns wrong evm version #8356

stiefn opened this issue Jul 4, 2024 · 6 comments
Labels
C-forge Command: forge Cmd-forge-clone Command: forge clone T-bug Type: bug T-to-discuss Type: requires discussion

Comments

@stiefn
Copy link

stiefn commented Jul 4, 2024

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 (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 = []
@stiefn stiefn added the T-bug Type: bug label Jul 4, 2024
@mattsse
Copy link
Member

mattsse commented Jul 5, 2024

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...

@klkvr
Copy link
Member

klkvr commented Jul 5, 2024

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")

@mattsse
Copy link
Member

mattsse commented Jul 5, 2024

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

@zerosnacks
Copy link
Member

Possibly related: #8446

@zerosnacks zerosnacks changed the title forge clone returns wrong evm version bug: forge clone returns wrong evm version Jul 16, 2024
@zerosnacks zerosnacks added C-forge Command: forge Cmd-forge-clone Command: forge clone labels Jul 16, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@ZhangZhuoSJTU
Copy link
Contributor

Potentially related: foundry-rs/compilers#189

@grandizzy
Copy link
Collaborator

considering there is no practical solution, going to mark as resolved with updated docs PR #8369 Please reopen if disagree. thank you!

@grandizzy grandizzy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-clone Command: forge clone T-bug Type: bug T-to-discuss Type: requires discussion
Projects
None yet
Development

No branches or pull requests

7 participants