Skip to content

Commit

Permalink
fix: sanitize settings.optimizer.details.inliner (#216)
Browse files Browse the repository at this point in the history
Ref
foundry-rs/foundry#9322 (comment)

ethereum/solidity#15576 (comment)

Set inliner to None since it is properly supported from 0.8.5 version(
see `Standard JSON: Properly allow the inliner setting under
settings.optimizer.details`
https://soliditylang.org/blog/2021/06/10/solidity-0.8.5-release-announcement/)

---------

Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
  • Loading branch information
grandizzy and DaniPopes authored Nov 18, 2024
1 parent 5b6e6eb commit d8dc871
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/artifacts/solc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ impl Settings {
self.via_ir = None;
}

const V0_8_5: Version = Version::new(0, 8, 5);
if *version < V0_8_5 {
// introduced in 0.8.5 <https://github.com/ethereum/solidity/releases/tag/v0.8.5>
if let Some(optimizer_details) = &mut self.optimizer.details {
optimizer_details.inliner = None;
}
}

const V0_8_7: Version = Version::new(0, 8, 7);
if *version < V0_8_7 {
// lower the disable version from 0.8.10 to 0.8.7, due to `divModNoSlacks`,
Expand Down Expand Up @@ -2221,4 +2229,20 @@ mod tests {
let content = fs::read_to_string(path).unwrap();
let _output: CompilerOutput = serde_json::from_str(&content).unwrap();
}

// <https://github.com/foundry-rs/foundry/issues/9322>
#[test]
fn can_sanitize_optimizer_inliner() {
let version: Version = "0.8.4".parse().unwrap();
let settings = Settings::default().with_via_ir_minimum_optimization();

let input =
SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings };

let i = input.clone().sanitized(&version);
assert!(i.settings.optimizer.details.unwrap().inliner.is_none());

let i = input.sanitized(&Version::new(0, 8, 5));
assert_eq!(i.settings.optimizer.details.unwrap().inliner, Some(false));
}
}

0 comments on commit d8dc871

Please sign in to comment.