Skip to content

Commit 4f45d68

Browse files
committed
feat: add vm asm fuzzer
1 parent 5133b15 commit 4f45d68

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
if !code.is_ascii() {
9+
return Corpus::Reject;
10+
}
11+
12+
let code = match Code::assemble(&code) {
13+
Ok(code) => code,
14+
Err(_) => return Corpus::Reject,
15+
};
16+
17+
let mut vm = VmState::builder()
18+
.with_code(code)
19+
.with_smc_info(CustomSmcInfo {
20+
version: VmState::DEFAULT_VERSION,
21+
c7: SafeRc::new(Vec::new()),
22+
})
23+
.with_gas(GasParams::getter())
24+
.build();
25+
26+
_ = vm.run();
27+
Corpus::Keep
28+
});

0 commit comments

Comments
 (0)