Skip to content

Commit fc7397c

Browse files
R9295dnjscksdn98
authored andcommitted
SRLabs: initialize fuzzing harness (polkadot-evm#1677)
* SRLabs: initialize fuzzer * update license * fmt * fmt * lint * auth list * clippy * allow uppercase acronyms * clippy * clippy
1 parent 1b52bac commit fc7397c

File tree

6 files changed

+625
-0
lines changed

6 files changed

+625
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ members = [
5252
"precompiles",
5353
"precompiles/macro",
5454
"precompiles/tests-external",
55+
"template/fuzz",
5556
]
5657
resolver = "2"
5758

template/fuzz/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
output
2+
target

template/fuzz/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "fuzz"
3+
version = "0.1.0"
4+
authors.workspace = true
5+
edition.workspace = true
6+
repository.workspace = true
7+
8+
[dependencies]
9+
arbitrary = { version = "1.4.1", features = ["derive"] }
10+
evm = { workspace = true }
11+
frame-system = { workspace = true }
12+
fuzzed_runtime = { path = "../runtime", package = "frontier-template-runtime" }
13+
hex.workspace = true
14+
pallet-balances = { workspace = true }
15+
pallet-evm = { workspace = true }
16+
sp-consensus-aura = { workspace = true }
17+
sp-core = { workspace = true }
18+
sp-runtime = { workspace = true }
19+
sp-state-machine = { workspace = true }
20+
ziggy = { version = "1.3.2", default-features = false }
21+
[features]
22+
fuzzing = []
23+
default = ["std"]
24+
std = [
25+
"fuzzed_runtime/std",
26+
"sp-runtime/std",
27+
"sp-state-machine/std",
28+
"sp-consensus-aura/std",
29+
"sp-core/std",
30+
"pallet-evm/std",
31+
]

template/fuzz/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Approach to fuzzing
2+
This fuzzing harness uses a "structure-aware" approach by using [arbitrary](https://github.com/rust-fuzz/arbitrary) to fuzz the Runtime.
3+
4+
The harness has multiple substrate invariants, but two frontier specific ones:
5+
1. The proof size must never exceed the supplied max proof size
6+
4. The execution time MUST be within a reasonable thresold.
7+
8+
Important notes:
9+
1. Since the fuzzing happens in ``debug`` mode, the EVM execution will be notably slower. Set a reasonably high timeout, five or six seconds is a good starter.
10+
2. You will need to use ``SKIP_WASM_BUILD=1`` to fuzz due to some polkadot-sdk wasm conflicts.
11+
12+
## Orchestrating the campaign
13+
Fuzzing is orchestrated by [ziggy](https://github.com/srlabs/ziggy/).
14+
15+
It uses [AFL++](https://github.com/AFLplusplus/AFLplusplus/) and [honggfuzz](https://github.com/google/honggfuzz) under the hood.
16+
17+
Please refer to its documentation for details.
18+
19+
Quickstart command to fuzz:
20+
21+
``` bash
22+
SKIP_WASM_BUILD=1 cargo ziggy fuzz -j$(nproc) -t5
23+
```

0 commit comments

Comments
 (0)