Open Vectorized opened 10 months ago
yeah, we kind of want this in one form or another.
I think this is some form of configuration conditional where a library can allow/disallow certain files based on the configured version
all of this needs to be solved during preprocessing, independently from solc.
I can see how this will become important with new cancun opcodes and already is problematic with push0...
Because this depends on the file itself, I can imagine this could be solved with some natspec custom modifier and via the config like you suggested.
I think it's most important to prevent compilation if evm version is invalid. but I wonder if the ideal DX would be something like, "if cancun use cancun.sol variant of that file, if < cancun use this file"
but this is likely a niche feature only for certain libraries like solady and should probably be solved via a package manager solution instead.
But adding rules into the config would be possible and we should start with that.
Component
Forge
Describe the feature you would like
Suppose I want to include 2 different
ReentracyGuard
files in Solady.ReentrancyGuard.sol
(uses regular oldsstore
).ReentrancyGuard.cancun.sol
(uses thetstore
opcode probably available in solc 0.8.23 in the future).Compilation will throw an error when using
"solc_version" < "0.8.23"
or"evm_version" < "cancun"
.Suggestion
Suppose Solady's
foundry.toml
has:Ideally any library that installs Solady via forge must be able to compile with
solc >= 0.8.4
(minimum supported version by Solady).But if their
foundry.toml
specifies"solc_version" = "0.0.23"
and"evm_version" = "cancun"
, they will be able to include and compileReentrancyGuard.cancun.sol
.A project that targets many EVM chains (e.g. for canonical create2 deployments with vanity addresses) would use
"solc_version" = "0.0.23"
(or any other version that supports paris) and"evm_version" = "paris"
. They will include the traditionalReentrancyGuard.sol
in files.A project that only targets Ethereum mainnet would use
"solc_version" = "0.0.23"
and"evm_version" = "cancun"
. They will includeReentrancyGuard.cancun.sol
in files instead.Why?
I mean... we cannot expect L2s (and Solidity) to be shipping as fast and hardcore as the Foundry team.
PUSH0 was a good test of what's to come.
Additional context
No response