-
Notifications
You must be signed in to change notification settings - Fork 48
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
Incorrect Default EVM Version for Solidity Compiler 0.4.21-0.5.4 #189
Conversation
Additionally, in Solidity 0.8.24, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pending @klkvr
I dont think we were aiming for "solc's default" but rather the latest evm version supported at the given cersion? |
@DaniPopes I think based on our usage of the /// Returns the contract's compiler settings.
#[cfg(feature = "foundry-compilers")]
pub fn settings(&self) -> Result<Settings> {
let mut settings = self.source_code.settings()?.unwrap_or_default();
if self.optimization_used == 1 && !settings.optimizer.enabled.unwrap_or_default() {
settings.optimizer.enable();
settings.optimizer.runs(self.runs as usize);
}
settings.evm_version = self.evm_version()?;
Ok(settings)
}
...
/// Parses the EVM version.
#[cfg(feature = "foundry-compilers")]
pub fn evm_version(&self) -> Result<Option<EvmVersion>> {
match self.evm_version.to_lowercase().as_str() {
"" | "default" => {
Ok(EvmVersion::default().normalize_version_solc(&self.compiler_version()?))
}
_ => {
let evm_version = self
.evm_version
.parse()
.map_err(|e| EtherscanError::Unknown(format!("bad evm version: {e}")))?;
Ok(Some(evm_version))
}
}
} compilers/crates/artifacts/solc/src/lib.rs Lines 820 to 852 in 3f08085
|
the comment in the function itself suggests otherwise, "cap at the highest possible fork" basically if a user specifies cancun, but the solc version only knows up to shanghai (even if the default is paris), then we'll cap to shanghai |
@DaniPopes, thank you for your prompt response! I apologize if I'm misunderstanding something, but I have a couple of questions for clarification:
|
Or, maybe it is the block-explorer repo that misuses the API. In that case, I guess a proper patch is to introduce a new API in the |
Yeah, this logic in block-explorers is not great, we should probably keep a similar mapping from solc version to default EVM version for it.
Primary purpose of this is to support multi-version projects. E.g. if some of user contracts are getting compiled with 0.8.25, and some with 0.8.18, and he has |
0e9e9de
to
5685c0a
Compare
@DaniPopes @klkvr I've updated a new patch, where we introduce a new function named If it is a proper patch, I will also change the code in Thanks again! |
@DaniPopes @klkvr @mattsse kindly pinging for your review when you have a moment. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit hacky, but still works better than current approach for determining default EVM version.
if this turns out not great, we can always add a similar mapping from solc version to default EVM version
The default EVM version for Solidity compilers ranging from 0.4.21 to 0.5.4 is incorrectly implemented. Specifically, although the
Constantinople
hard fork had been introduced during this period, the default EVM version remains asByzantium
. After version 0.5.5, the default EVM version shifts toPetersburg
.That is,
Constantinople
is never used as the default EVM version for Solidity compilers.This can be confirmed by running
solc --help
, with the output indicating the default EVM version as follows:$ solc --help solc, the Solidity commandline compiler. ... Allowed options: --help Show help message and exit. --version Show version and exit. --license Show licensing information and exit. --evm-version version Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, byzantium (default) or constantinople. ... $ solc --version solc, the Solidity commandline interface Version: 0.4.24+commit.e67f0147.Linux.g++