From b9902476e09862962ff5eb07273b933da3dfa870 Mon Sep 17 00:00:00 2001 From: Chandrakana Nandi Date: Mon, 22 Apr 2024 15:46:54 -0700 Subject: [PATCH 1/2] support for evm-version --- src/cli.rs | 4 ++++ src/compile.rs | 20 +++++++++++++------- src/mutator.rs | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index b1c95ce..dd8119c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -141,6 +141,10 @@ pub struct MutateParams { #[serde(default = "default_solc_optimize")] pub solc_optimize: bool, + /// Run solc with the `--evm-version` flag + #[arg(long)] + pub solc_evm_version: Option, + /// Specify function names to mutate #[arg(long, num_args(1..))] pub functions: Option>, diff --git a/src/compile.rs b/src/compile.rs index c266265..bd0cfee 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -20,6 +20,7 @@ static INCLUDEPATH: &str = "--include-path"; static BASEPATH: &str = "--base-path"; static OPTIMIZE: &str = "--optimize"; static DOT_JSON: &str = ".json"; +static EVM_VERSION: &str = "--evm-version"; /// Compilation configurations. This exists across compilations of individual /// files @@ -33,6 +34,7 @@ pub struct Solc { include_path: Option, remappings: Option>, optimize: bool, + evm_version: Option, } impl Solc { @@ -45,6 +47,7 @@ impl Solc { include_path: None, remappings: None, optimize: false, + evm_version: None, } } @@ -52,13 +55,6 @@ impl Solc { &self.output_directory } - pub fn basepath(&self) -> Option<&String> { - match &self.basepath { - Some(bp) => Some(bp), - None => None, - } - } - pub fn with_basepath(&mut self, basepath: String) -> &Self { self.basepath = Some(basepath); self @@ -83,6 +79,11 @@ impl Solc { self.optimize = optimize; self } + + pub fn with_evm_version(&mut self, evm_version: String) -> &Self { + self.evm_version = Some(evm_version); + self + } } impl Solc { @@ -320,6 +321,11 @@ impl Solc { flags.push(OPTIMIZE.into()); } + if let Some(evm_version) = &self.evm_version { + flags.push(EVM_VERSION.into()); + flags.push(evm_version.clone()); + } + flags } } diff --git a/src/mutator.rs b/src/mutator.rs index 6d05831..82571b5 100644 --- a/src/mutator.rs +++ b/src/mutator.rs @@ -75,6 +75,10 @@ impl From<&MutateParams> for Mutator { .into(), ); solc.with_optimize(value.solc_optimize); + + if let Some(evm_version) = value.solc_evm_version.clone() { + solc.with_evm_version(evm_version); + } if let Some(basepath) = value.solc_base_path.clone() { solc.with_basepath(basepath); } From 31af55f338e45a5d5fca3143b2da3537d284225e Mon Sep 17 00:00:00 2001 From: Chandrakana Nandi Date: Mon, 22 Apr 2024 16:02:38 -0700 Subject: [PATCH 2/2] sync docs with rtd --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7f48ed3..91747cb 100644 --- a/README.md +++ b/README.md @@ -161,8 +161,11 @@ Mutants can be used to evaluate test suites or specs used for formal ## Installation -You can download prebuilt Gambit binaries for Mac and Linux from our -[releases](https://github.com/Certora/gambit/releases) page. +You can download prebuilt Gambit binaries for Linux x86-64 and Mac from our +[releases](https://github.com/Certora/gambit/releases) page. For Windows and Linux ARM, you must build Gambit from source. + + +### Building Gambit from source To build Gambit from source, clone [the Gambit repository](https://github.com/Certora/gambit) and run @@ -317,6 +320,10 @@ For projects that have complex dependencies and imports, you may need to: --solc_remappings @openzeppelin=node_modules/@openzeppelin @foo=node_modules/@foo ``` + ```{warning} + The paths should ***NOT*** end with a trailing / + ``` + * **Specify allow paths:** To include additional allowed paths via `solc`'s [`--allow-paths`][allowed] argument, use `--solc_allow_paths`: @@ -344,9 +351,7 @@ For projects that have complex dependencies and imports, you may need to: [basepath]: https://docs.soliditylang.org/en/v0.8.17/path-resolution.html#base-path-and-include-paths [allowed]: https://docs.soliditylang.org/en/v0.8.17/path-resolution.html#allowed-paths - - -### Example 5: The `--sourceroot` option +### Example 5: The `--sourceroot` option Gambit needs to track the location of source files that it mutates within a project: for instance, imagine there are files `foo/Foo.sol` and `bar/Foo.sol`. @@ -423,6 +428,7 @@ Here are some examples of using the `--sourceroot` option. Gambit prints an error and exits. + ### Example 6: Running Gambit using a configuration file To run gambit with a configuration file, use the `--json` argument: