Skip to content

Commit 6a6f72e

Browse files
Merge pull request #41 from Certora/cnandi/evmversion
CERT-5925 support for evm-version
2 parents a97670e + 31af55f commit 6a6f72e

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ Mutants can be used to evaluate test suites or specs used for formal
161161

162162
## Installation
163163

164-
You can download prebuilt Gambit binaries for Mac and Linux from our
165-
[releases](https://github.com/Certora/gambit/releases) page.
164+
You can download prebuilt Gambit binaries for Linux x86-64 and Mac from our
165+
[releases](https://github.com/Certora/gambit/releases) page. For Windows and Linux ARM, you must build Gambit from source.
166+
167+
<!-- ANCHOR: (build-gambit-from-source)= -->
168+
### Building Gambit from source
166169

167170
To build Gambit from source, clone [the Gambit repository](https://github.com/Certora/gambit) and run
168171

@@ -317,6 +320,10 @@ For projects that have complex dependencies and imports, you may need to:
317320
--solc_remappings @openzeppelin=node_modules/@openzeppelin @foo=node_modules/@foo
318321
```
319322

323+
```{warning}
324+
The paths should ***NOT*** end with a trailing /
325+
```
326+
320327
* **Specify allow paths:** To include additional allowed paths via `solc`'s
321328
[`--allow-paths`][allowed] argument, use `--solc_allow_paths`:
322329

@@ -344,9 +351,7 @@ For projects that have complex dependencies and imports, you may need to:
344351
[basepath]: https://docs.soliditylang.org/en/v0.8.17/path-resolution.html#base-path-and-include-paths
345352
[allowed]: https://docs.soliditylang.org/en/v0.8.17/path-resolution.html#allowed-paths
346353

347-
348-
<!-- ANCHOR: (gambit-config)= -->
349-
### Example 5: The `--sourceroot` option
354+
### Example 5: The `--sourceroot` option
350355

351356
Gambit needs to track the location of source files that it mutates within a
352357
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.
423428

424429
Gambit prints an error and exits.
425430

431+
<!-- ANCHOR: (gambit-config)= -->
426432
### Example 6: Running Gambit using a configuration file
427433

428434
To run gambit with a configuration file, use the `--json` argument:

src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ pub struct MutateParams {
141141
#[serde(default = "default_solc_optimize")]
142142
pub solc_optimize: bool,
143143

144+
/// Run solc with the `--evm-version` flag
145+
#[arg(long)]
146+
pub solc_evm_version: Option<String>,
147+
144148
/// Specify function names to mutate
145149
#[arg(long, num_args(1..))]
146150
pub functions: Option<Vec<String>>,

src/compile.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static INCLUDEPATH: &str = "--include-path";
2020
static BASEPATH: &str = "--base-path";
2121
static OPTIMIZE: &str = "--optimize";
2222
static DOT_JSON: &str = ".json";
23+
static EVM_VERSION: &str = "--evm-version";
2324

2425
/// Compilation configurations. This exists across compilations of individual
2526
/// files
@@ -33,6 +34,7 @@ pub struct Solc {
3334
include_path: Option<String>,
3435
remappings: Option<Vec<String>>,
3536
optimize: bool,
37+
evm_version: Option<String>,
3638
}
3739

3840
impl Solc {
@@ -45,20 +47,14 @@ impl Solc {
4547
include_path: None,
4648
remappings: None,
4749
optimize: false,
50+
evm_version: None,
4851
}
4952
}
5053

5154
pub fn output_directory(&self) -> &Path {
5255
&self.output_directory
5356
}
5457

55-
pub fn basepath(&self) -> Option<&String> {
56-
match &self.basepath {
57-
Some(bp) => Some(bp),
58-
None => None,
59-
}
60-
}
61-
6258
pub fn with_basepath(&mut self, basepath: String) -> &Self {
6359
self.basepath = Some(basepath);
6460
self
@@ -83,6 +79,11 @@ impl Solc {
8379
self.optimize = optimize;
8480
self
8581
}
82+
83+
pub fn with_evm_version(&mut self, evm_version: String) -> &Self {
84+
self.evm_version = Some(evm_version);
85+
self
86+
}
8687
}
8788

8889
impl Solc {
@@ -320,6 +321,11 @@ impl Solc {
320321
flags.push(OPTIMIZE.into());
321322
}
322323

324+
if let Some(evm_version) = &self.evm_version {
325+
flags.push(EVM_VERSION.into());
326+
flags.push(evm_version.clone());
327+
}
328+
323329
flags
324330
}
325331
}

src/mutator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ impl From<&MutateParams> for Mutator {
7575
.into(),
7676
);
7777
solc.with_optimize(value.solc_optimize);
78+
79+
if let Some(evm_version) = value.solc_evm_version.clone() {
80+
solc.with_evm_version(evm_version);
81+
}
7882
if let Some(basepath) = value.solc_base_path.clone() {
7983
solc.with_basepath(basepath);
8084
}

0 commit comments

Comments
 (0)