foundry icon indicating copy to clipboard operation
foundry copied to clipboard

`forge config --json` returns evm version that is not compatible with solc version

Open 0xalpharush opened this issue 1 year ago • 6 comments

Component

Forge, Chisel

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 (84d9842 2024-02-02T00:19:34.098872000Z)

What command(s) is the bug in?

forge config --json

Operating System

macOS (Apple Silicon)

Describe the bug

When the EVM version isn't set in the foundry.toml but the solc version is, Foundry may incorrectly use EvmVersion::Paris without validating that it is available for the given solc verison e.g. solc 0.8.17. I would expect to be able to pass the output of forge config --json to solc without running into errors related solc configurations. I'd also expect incompatibilities that are explicitly defined in the foundry.tom to be reported in a diagnostic.

I looked into fixing this but I'm not familiar with the figment provider library and wasn't sure how to add a call to normalize_version that will produce a correct solc version and evm version combo cleanly (I assume someone with more knowledge of the toolchain and architecture can consolidate the validation and error handling better than myself).

Relevant code for forge config https://github.com/foundry-rs/foundry/blob/7922fd5482f9561699e0fe5a903c90b3fa1fc50d/crates/config/src/lib.rs#L1774 Relevant code for chisel which I believe also performs insufficient validation i.e it can produce other misconfigurations for solc version and evm version pairs besides 0.8.17 and Paris. https://github.com/foundry-rs/foundry/blob/7922fd5482f9561699e0fe5a903c90b3fa1fc50d/crates/chisel/src/session_source.rs#L108-L121

Also, probably here and here could use the same fix.

For more info, see also https://github.com/crytic/slither/issues/2287

0xalpharush avatar Feb 05 '24 19:02 0xalpharush

this only affects the config part, right? because before invoking solc this should always get normalized

mattsse avatar Feb 05 '24 23:02 mattsse

I only experienced the bug in forge config. The rest of these are just areas where it doesn't seem to be normalized like it is when creating the standard json input for solc here. I'm not sure how the configuration works for chisel in order to test it

0xalpharush avatar Feb 06 '24 00:02 0xalpharush

@0xalpharush Do you have any suggestions on how to improve the chisel version check?

mattsse avatar Feb 06 '24 01:02 mattsse

I think we also need this validation when auto_detect_solc is used (default IIRC)

0xalpharush avatar Feb 06 '24 23:02 0xalpharush

should I add a normalization step specifically for forge config?

mattsse avatar Feb 07 '24 01:02 mattsse

Yes, I think it is taken care of for forge build and forge test already

0xalpharush avatar Feb 07 '24 04:02 0xalpharush

Note: looks like this is still an active issue - for future reference

When no solc_version has been set it yields:

{
  "evm_version": "paris",
}

With solc_version set to 0.8.15 in foundry.toml it correctly yields:

{
  "evm_version": "london",
}

Related: https://github.com/crytic/slither/issues/2422#issuecomment-2054159134

zerosnacks avatar Jul 10 '24 17:07 zerosnacks