Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix(solc): omit remappings & revertStrings for yul compiler input #1686

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub(crate) type VersionedSources = BTreeMap<Solc, (Version, Sources)>;
pub(crate) type VersionedFilteredSources = BTreeMap<Solc, (Version, FilteredSources)>;

const SOLIDITY: &str = "Solidity";
const YUL: &str = "Yul";

/// Input type `solc` expects
#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -88,7 +89,7 @@ impl CompilerInput {
}
if !yul_sources.is_empty() {
res.push(Self {
language: "Yul".to_string(),
language: YUL.to_string(),
sources: yul_sources,
settings: Default::default(),
});
Expand Down Expand Up @@ -137,7 +138,19 @@ impl CompilerInput {

/// Sets the settings for compilation
#[must_use]
pub fn settings(mut self, settings: Settings) -> Self {
pub fn settings(mut self, mut settings: Settings) -> Self {
if self.is_yul() {
if !settings.remappings.is_empty() {
warn!("omitting remappings supplied for the yul sources");
settings.remappings = vec![];
}
if let Some(debug) = settings.debug.as_mut() {
if debug.revert_strings.is_some() {
warn!("omitting revertStrings supplied for the yul sources");
debug.revert_strings = None;
}
}
}
self.settings = settings;
self
}
Expand Down Expand Up @@ -168,7 +181,11 @@ impl CompilerInput {

#[must_use]
pub fn with_remappings(mut self, remappings: Vec<Remapping>) -> Self {
self.settings.remappings = remappings;
if self.is_yul() {
warn!("omitting remappings supplied for the yul sources");
} else {
self.settings.remappings = remappings;
}
self
}

Expand Down Expand Up @@ -200,6 +217,12 @@ impl CompilerInput {
self.settings = self.settings.with_base_path(base);
self.strip_prefix(base)
}

/// The flag indicating whether the current [CompilerInput] is
/// constructed for the yul sources
pub fn is_yul(&self) -> bool {
self.language == YUL
}
}

/// A `CompilerInput` representation used for verify
Expand Down