Skip to content

Commit

Permalink
bump compilers (#8153)
Browse files Browse the repository at this point in the history
* [do not merge] patch compilers

* fix import

* fix doc

* update patch

* rm patch
  • Loading branch information
klkvr authored Jun 17, 2024
1 parent f673066 commit 55ac4e4
Show file tree
Hide file tree
Showing 36 changed files with 173 additions and 89 deletions.
85 changes: 76 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ foundry-wallets = { path = "crates/wallets" }
foundry-linking = { path = "crates/linking" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.4.0", default-features = false }
foundry-compilers = { version = "0.7.0", default-features = false }
foundry-block-explorers = { version = "0.4.1", default-features = false }
foundry-compilers = { version = "0.8.0", default-features = false }

## revm
# no default features to avoid c-kzg
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/bin/cmd/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use foundry_cli::{
utils::{self, handle_traces, parse_ether_value, TraceResult},
};
use foundry_common::ens::NameOrAddress;
use foundry_compilers::EvmVersion;
use foundry_compilers::artifacts::EvmVersion;
use foundry_config::{find_project_root_path, Config};
use foundry_evm::{executors::TracingExecutor, opts::EvmOpts};
use std::str::FromStr;
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/bin/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use foundry_cli::{
utils::{handle_traces, init_progress, TraceResult},
};
use foundry_common::{is_known_system_sender, SYSTEM_TRANSACTION_TYPE};
use foundry_compilers::EvmVersion;
use foundry_compilers::artifacts::EvmVersion;
use foundry_config::{find_project_root_path, Config};
use foundry_evm::{
executors::{EvmError, TracingExecutor},
Expand Down
9 changes: 6 additions & 3 deletions crates/cast/bin/cmd/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ use foundry_common::{
ens::NameOrAddress,
};
use foundry_compilers::{
artifacts::StorageLayout,
compilers::{solc::SolcCompiler, Compiler, CompilerSettings},
Artifact, ConfigurableContractArtifact, Project, Solc,
artifacts::{ConfigurableContractArtifact, StorageLayout},
compilers::{
solc::{Solc, SolcCompiler},
Compiler, CompilerSettings,
},
Artifact, Project,
};
use foundry_config::{
figment::{self, value::Dict, Metadata, Profile},
Expand Down
2 changes: 1 addition & 1 deletion crates/chisel/benches/session_source.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chisel::session_source::{SessionSource, SessionSourceConfig};
use criterion::{criterion_group, Criterion};
use foundry_compilers::Solc;
use foundry_compilers::solc::Solc;
use once_cell::sync::Lazy;
use semver::Version;
use std::hint::black_box;
Expand Down
2 changes: 1 addition & 1 deletion crates/chisel/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ impl<'a> Iterator for InstructionIter<'a> {
#[cfg(test)]
mod tests {
use super::*;
use foundry_compilers::{error::SolcError, Solc};
use foundry_compilers::{error::SolcError, solc::Solc};
use semver::Version;
use std::sync::Mutex;

Expand Down
23 changes: 11 additions & 12 deletions crates/chisel/src/session_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use eyre::Result;
use forge_fmt::solang_ext::SafeUnwrap;
use foundry_compilers::{
artifacts::{Settings, Source, Sources},
CompilerOutput, Solc, SolcInput,
artifacts::{CompilerOutput, Settings, SolcInput, Source, Sources},
compilers::solc::Solc,
};
use foundry_config::{Config, SolcReq};
use foundry_evm::{backend::Backend, opts::EvmOpts};
Expand Down Expand Up @@ -115,16 +115,15 @@ impl SessionSourceConfig {
}
}

let solc =
if let Some(solc) = Solc::find_svm_installed_version(version.to_string())? {
solc
} else {
if self.foundry_config.offline {
eyre::bail!("can't install missing solc {version} in offline mode")
}
println!("{}", format!("Installing solidity version {version}...").green());
Solc::blocking_install(&version)?
};
let solc = if let Some(solc) = Solc::find_svm_installed_version(&version)? {
solc
} else {
if self.foundry_config.offline {
eyre::bail!("can't install missing solc {version} in offline mode")
}
println!("{}", format!("Installing solidity version {version}...").green());
Solc::blocking_install(&version)?
};
Ok(solc)
}
SolcReq::Local(solc) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/chisel/tests/cache.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chisel::session::ChiselSession;
use foundry_compilers::EvmVersion;
use foundry_compilers::artifacts::EvmVersion;
use foundry_config::{Config, SolcReq};
use semver::Version;
use serial_test::serial;
Expand Down
6 changes: 4 additions & 2 deletions crates/cli/src/opts/build/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ use crate::{opts::CompilerArgs, utils::LoadConfig};
use clap::{Parser, ValueHint};
use eyre::Result;
use foundry_compilers::{
artifacts::RevertStrings, compilers::multi::MultiCompiler, remappings::Remapping,
utils::canonicalized, Project,
artifacts::{remappings::Remapping, RevertStrings},
compilers::multi::MultiCompiler,
utils::canonicalized,
Project,
};
use foundry_config::{
figment,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/opts/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, EvmVersion};
use foundry_compilers::artifacts::{output_selection::ContractOutputSelection, EvmVersion};
use serde::Serialize;

mod core;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/opts/build/paths.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::{Parser, ValueHint};
use eyre::Result;
use foundry_compilers::remappings::Remapping;
use foundry_compilers::artifacts::remappings::Remapping;
use foundry_config::{
figment,
figment::{
Expand Down
11 changes: 7 additions & 4 deletions crates/common/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color
use eyre::{Context, Result};
use foundry_block_explorers::contract::Metadata;
use foundry_compilers::{
artifacts::{BytecodeObject, ContractBytecodeSome, Libraries, Source},
compilers::{multi::MultiCompilerLanguage, solc::SolcCompiler, Compiler},
remappings::Remapping,
artifacts::{remappings::Remapping, BytecodeObject, ContractBytecodeSome, Libraries, Source},
compilers::{
multi::MultiCompilerLanguage,
solc::{Solc, SolcCompiler},
Compiler,
},
report::{BasicStdoutReporter, NoReporter, Report},
Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, Solc, SolcConfig,
Artifact, Project, ProjectBuilder, ProjectCompileOutput, ProjectPathsConfig, SolcConfig,
};
use foundry_linking::Linker;
use num_format::{Locale, ToFormattedString};
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/term.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! terminal utils
use foundry_compilers::{
remappings::Remapping,
artifacts::remappings::Remapping,
report::{self, BasicStdoutReporter, Reporter},
};
use once_cell::sync::Lazy;
Expand Down
26 changes: 13 additions & 13 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ use figment::{
use foundry_compilers::{
artifacts::{
output_selection::{ContractOutputSelection, OutputSelection},
serde_helpers, BytecodeHash, DebuggingSettings, Libraries, ModelCheckerSettings,
ModelCheckerTarget, Optimizer, OptimizerDetails, RevertStrings, Settings, SettingsMetadata,
Severity,
remappings::{RelativeRemapping, Remapping},
serde_helpers, BytecodeHash, DebuggingSettings, EvmVersion, Libraries,
ModelCheckerSettings, ModelCheckerTarget, Optimizer, OptimizerDetails, RevertStrings,
Settings, SettingsMetadata, Severity,
},
cache::SOLIDITY_FILES_CACHE_FILENAME,
compilers::{
multi::{MultiCompiler, MultiCompilerSettings},
solc::SolcCompiler,
solc::{Solc, SolcCompiler},
vyper::{Vyper, VyperSettings},
Compiler,
},
error::SolcError,
remappings::{RelativeRemapping, Remapping},
ConfigurableArtifacts, EvmVersion, Project, ProjectPathsConfig, Solc,
ConfigurableArtifacts, Project, ProjectPathsConfig,
};
use inflector::Inflector;
use regex::Regex;
Expand Down Expand Up @@ -851,7 +851,7 @@ impl Config {
if let Some(ref solc) = self.solc {
let solc = match solc {
SolcReq::Version(version) => {
if let Some(solc) = Solc::find_svm_installed_version(version.to_string())? {
if let Some(solc) = Solc::find_svm_installed_version(version)? {
solc
} else {
if self.offline {
Expand Down Expand Up @@ -913,12 +913,12 @@ impl Config {
/// # Example
///
/// ```
/// use foundry_compilers::Solc;
/// use foundry_compilers::solc::Solc;
/// use foundry_config::Config;
/// let config = Config::load_with_root(".").sanitized();
/// let paths = config.project_paths::<Solc>();
/// ```
pub fn project_paths<C>(&self) -> ProjectPathsConfig<C> {
pub fn project_paths<L>(&self) -> ProjectPathsConfig<L> {
let mut builder = ProjectPathsConfig::builder()
.cache(self.cache_path.join(SOLIDITY_FILES_CACHE_FILENAME))
.sources(&self.src)
Expand Down Expand Up @@ -1240,7 +1240,8 @@ impl Config {

/// Returns all libraries with applied remappings. Same as `self.solc_settings()?.libraries`.
pub fn libraries_with_remappings(&self) -> Result<Libraries, SolcError> {
Ok(self.parsed_libraries()?.with_applied_remappings(&self.project_paths()))
let paths: ProjectPathsConfig = self.project_paths();
Ok(self.parsed_libraries()?.apply(|libs| paths.apply_lib_remappings(libs)))
}

/// Returns the configured `solc` `Settings` that includes:
Expand Down Expand Up @@ -2816,9 +2817,8 @@ mod tests {
etherscan::ResolvedEtherscanConfigs,
};
use figment::error::Kind::InvalidType;
use foundry_compilers::{
artifacts::{ModelCheckerEngine, YulDetails},
compilers::vyper::settings::VyperOptimizationMode,
use foundry_compilers::artifacts::{
vyper::VyperOptimizationMode, ModelCheckerEngine, YulDetails,
};
use similar_asserts::assert_eq;
use std::{collections::BTreeMap, fs::File, io::Write};
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/providers/remappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use figment::{
value::{Dict, Map},
Error, Metadata, Profile, Provider,
};
use foundry_compilers::remappings::{RelativeRemapping, Remapping};
use foundry_compilers::artifacts::remappings::{RelativeRemapping, Remapping};
use std::{
borrow::Cow,
collections::{btree_map::Entry, BTreeMap, HashSet},
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::Config;
use alloy_primitives::U256;
use eyre::WrapErr;
use figment::value::Value;
use foundry_compilers::{
use foundry_compilers::artifacts::{
remappings::{Remapping, RemappingError},
EvmVersion,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/vyper.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Vyper specific configuration types.
use foundry_compilers::compilers::vyper::settings::VyperOptimizationMode;
use foundry_compilers::artifacts::vyper::VyperOptimizationMode;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

Expand Down
4 changes: 3 additions & 1 deletion crates/debugger/src/tui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
use super::context::{BufferKind, DebuggerContext};
use crate::op::OpcodeParam;
use alloy_primitives::U256;
use foundry_compilers::{compilers::multi::MultiCompilerLanguage, sourcemap::SourceElement};
use foundry_compilers::{
artifacts::sourcemap::SourceElement, compilers::multi::MultiCompilerLanguage,
};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
Expand Down
Loading

0 comments on commit 55ac4e4

Please sign in to comment.