Skip to content

Commit 45f62a0

Browse files
0xdeafbeefRexagon
authored andcommitted
feat: add vm asm fuzzer
1 parent 5133b15 commit 45f62a0

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ tracing = "0.1"
3939
tracing-subscriber = "0.3"
4040
tracing-test = "0.2"
4141

42+
everscale-asm = { git = "https://github.com/broxus/everscale-asm.git", rev = "95ec11ccad067726a9495b0bd2c700e64171c6af" }
4243
everscale-asm-macros = { git = "https://github.com/broxus/everscale-asm.git", rev = "95ec11ccad067726a9495b0bd2c700e64171c6af" }
4344

4445
tycho-vm = { path = "./vm" }

fuzz/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ test = false
1414
doc = false
1515
bench = false
1616

17+
[[bin]]
18+
name = "vm_asm"
19+
path = "fuzz_targets/vm_asm.rs"
20+
test = false
21+
doc = false
22+
bench = false
23+
1724
[[bin]]
1825
name = "action_phase_real"
1926
path = "fuzz_targets/action_phase_real.rs"
@@ -34,3 +41,4 @@ everscale-types = { workspace = true, features = ["arbitrary", "base64"] }
3441
libfuzzer-sys = { workspace = true }
3542
tycho-executor = { path = "../executor" }
3643
tycho-vm = { path = "../vm", features = ["arbitrary"] }
44+
everscale-asm = { workspace = true }

fuzz/fuzz_targets/vm_asm.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![no_main]
2+
3+
use everscale_asm::Code;
4+
use libfuzzer_sys::{fuzz_target, Corpus};
5+
use tycho_vm::{CustomSmcInfo, GasParams, SafeRc, VmState};
6+
7+
fuzz_target!(|code: String| -> Corpus {
8+
let code = match Code::assemble(&code) {
9+
Ok(code) => code,
10+
Err(_) => return Corpus::Reject,
11+
};
12+
13+
let mut vm = VmState::builder()
14+
.with_code(code)
15+
.with_smc_info(CustomSmcInfo {
16+
version: VmState::DEFAULT_VERSION,
17+
c7: SafeRc::new(Vec::new()),
18+
})
19+
.with_gas(GasParams::getter())
20+
.build();
21+
22+
_ = vm.run();
23+
Corpus::Keep
24+
});

0 commit comments

Comments
 (0)