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

feat(cast): add ability to specify --solc-version for manually defining version to compile with #9939

Open
2 tasks done
maxweisspoker opened this issue Feb 23, 2025 · 3 comments
Assignees
Labels
C-cast Command: cast first issue A good way to start contributing T-feature Type: feature

Comments

@maxweisspoker
Copy link

maxweisspoker commented Feb 23, 2025

Component

Cast

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

cast Version: 1.0.0-nightly Commit SHA: c609884 Build Timestamp: 2025-02-23T00:22:54.429897389Z (1740270174) Build Profile: maxperf

What version of Foundryup are you on?

N/A manual download of nightly

What command(s) is the bug in?

cast storage

Operating System

Linux

Describe the bug

When attempting to analyze the ByBit hack, I ran the following command to check its storage prior to the hack:

$ cast storage 0x1Db92e2EeBC8E0c075a02BeA49a2935BcD2dFCF4 --block 218952370

This produces the following error:

Contract at 0x1Db92e2EeBC8E0c075a02BeA49a2935BcD2dFCF4 is a proxy, trying to fetch source at 0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F...
Error: Compiler run failed:
Error (2314): Expected '(' but got ','
Contract.sol:136:40: ParserError: Expected '(' but got ','
            let success := call(sub(gas, 10000), token, 0, add(data, 0x20), mload(data), 0, 0)
                                       ^

I believe that error is occuring because the Gnosis Safe Mastercopy contract was written in Solidity version 0.5, but cast is attempting to parse the assembly with a newer version, and the Yul for the gas variable is slightly different. I don't actually know Yul so I might be incorrect, but that's my guess based on the error.

I also have not tried specifying an older compiler version, so this may in fact not be a "bug" if specifying a 0.5 compiler is the correct solution.

@maxweisspoker maxweisspoker added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Feb 23, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 23, 2025
@zerosnacks
Copy link
Member

Hi @maxweisspoker, thanks for flagging

This appears to stem from the Gnosis Safe contract specifying compatibility with pragma solidity >=0.5.0 <0.7.0; whereas it is not compatible with version 0.6.*.

When cloned locally I can confirm it compiles correctly with 0.5.0 but setting FOUNDRY_SOLC_VERSION=0.5.0 does not seem to have an effect nor is there a way to conveniently pass in the --solc-version as a CLI argument.

The EVM version is selected correctly when the solc version is set.

I'll change this ticket to be a feature.

@zerosnacks zerosnacks added the C-cast Command: cast label Feb 24, 2025
@zerosnacks zerosnacks changed the title Cast storage uses newer solidity to parse old contracts from Etherscan feat(cast): add ability to specify --solc-version for manually defining version to compile with Feb 24, 2025
@zerosnacks zerosnacks added T-feature Type: feature first issue A good way to start contributing and removed T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Feb 24, 2025
@startup-dreamer
Copy link
Contributor

As I am already working on cast related issue would like to take this one also.

@maxweisspoker
Copy link
Author

Fantastic, thanks so much both of you for the lightning speed response and investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cast Command: cast first issue A good way to start contributing T-feature Type: feature
Projects
Status: Todo
Development

No branches or pull requests

3 participants