-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
076a46c
commit 42d07b5
Showing
34 changed files
with
780 additions
and
120 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ members = [ | |
"solidity_adapter", | ||
"coverage_watcher", | ||
"benchmark_analyzer", | ||
"fuzz" | ||
] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
url = "https://github.com/matter-labs/era-compiler-llvm" | ||
<<<<<<< HEAD | ||
branch = "v1.4.1" | ||
======= | ||
branch = "main" | ||
>>>>>>> d020375 (Final sync with the private repo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"binaries": { | ||
"0.8.25": { | ||
"is_enabled": true, | ||
"protocol": "file", | ||
"source": "./solc-bin/solc-${VERSION}", | ||
"destination": "./solc-bin/solc-${VERSION}" | ||
} | ||
}, | ||
"platforms": { | ||
"linux-amd64": "linux-amd64", | ||
"linux-arm64": "linux-arm64", | ||
"macos-amd64": "macosx-amd64", | ||
"macos-arm64": "macosx-arm64" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"binaries": { | ||
"0.8.25": { | ||
"is_enabled": true, | ||
"protocol": "https", | ||
"source": "https://github.com/matter-labs/era-solidity/releases/download/${VERSION}-1.0.0/solc-${PLATFORM}-${VERSION}-1.0.0", | ||
"destination": "./solc-bin/solc-${VERSION}" | ||
} | ||
}, | ||
"platforms": { | ||
"linux-amd64": "linux-amd64", | ||
"linux-arm64": "linux-arm64", | ||
"macos-amd64": "macosx-amd64", | ||
"macos-arm64": "macosx-arm64" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "compiler-tester-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
era-compiler-llvm-context = { git = "https://github.com/matter-labs/era-compiler-llvm-context", branch = "main" } | ||
era-compiler-solidity = { git = "https://github.com/matter-labs/era-compiler-solidity", branch = "main" } | ||
zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.4.1" } | ||
zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.4.1" } | ||
anyhow = "1.0" | ||
semver = { version = "1.0", features = ["serde"] } | ||
|
||
[dependencies.compiler-tester] | ||
path = "../compiler_tester" | ||
|
||
[dependencies.solidity-adapter] | ||
path = "../solidity_adapter" | ||
|
||
|
||
[[bin]] | ||
name = "demo" | ||
path = "fuzz_targets/demo.rs" | ||
test = false | ||
doc = false | ||
bench = false | ||
|
||
[[bin]] | ||
name = "optimizer_bug" | ||
path = "fuzz_targets/optimizer_bug.rs" | ||
test = false | ||
doc = false | ||
bench = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Solidity Contracts Fuzzing | ||
|
||
This is the skeleton for Solidity smart contracts fuzzing based on the [Rust fuzz](https://rust-fuzz.github.io/book/introduction.html) engine. | ||
|
||
## Project structure | ||
|
||
The project consists of the following directories: | ||
|
||
- `fuzz_contracts` - Solidity smart contracts to be fuzzed. | ||
- `fuzz_targets` - fuzzing targets definitions. | ||
|
||
### Fuzzing targets | ||
|
||
Each fuzzing target is a separate Rust binary crate and defined in the `fuzz_targets` directory. The `Cargo.toml` file in the root directory contains the dependencies and the configuration for the fuzzing engine. | ||
|
||
For example, the `simple` fuzzing target is defined in the `fuzz_targets/simple.rs` file. The `Cargo.toml` file contains the following section: | ||
|
||
```properties | ||
[[bin]] | ||
name = "simple" | ||
path = "fuzz_targets/simple.rs" | ||
... | ||
``` | ||
|
||
`cargo fuzz add <target_name>` command can be used to add a new empty fuzzing target. | ||
|
||
## Running fuzzing | ||
|
||
To run the fuzzing, execute the following command: | ||
|
||
```bash | ||
cargo fuzz run <target_name> | ||
``` | ||
|
||
## Supported targets | ||
|
||
- [`demo`](./fuzz_contracts/demo/demo.md) - demonstrates the basic fuzzing setup. | ||
- `optimizer_bug` - demonstrates fuzzer finding a bug in the optimizer. | ||
|
||
## Current limitations | ||
|
||
- The current setup uses the fixed hardcoded version of optimization settings (`Y+M3B3`) and `solc` compiler version (`0.8.24`). | ||
- The current targets are using the simplest contracts and fuzzing strategy that mutates only the function arguments. | ||
- The current setup uses only EraVM as the execution engine as well as `EthereumTest` as the test type. | ||
|
||
## Roadmap | ||
|
||
- [ ] Add the ability to specify the optimization settings and compiler versions. | ||
- [ ] Support for more complex contracts (real-life use cases). | ||
- [ ] Support on-the-fly fuzzing function generation. | ||
- [ ] Support mutating of the contract source code with Solidity vocabulary. | ||
- [ ] Support CI execution in OSS Fuzz infrastructure. |
Oops, something went wrong.