Skip to content

Commit ae4a180

Browse files
feat(avm): tx fuzzer harness (#18895)
The basic tx fuzzer, still missing a few mutations but utilises the fuzzer_data to generate bytecode --------- Co-authored-by: Álvaro Rodríguez <[email protected]>
1 parent 6ea1e87 commit ae4a180

File tree

25 files changed

+2026
-1123
lines changed

25 files changed

+2026
-1123
lines changed

barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/control_flow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int predict_block_size(ProgramBlock* block)
253253
auto set_16_instruction =
254254
SET_16_Instruction{ .value_tag = bb::avm2::MemoryTag::U1,
255255
.result_address =
256-
ResultAddressRef{ .address = address, .mode = AddressingMode::Direct },
256+
AddressRef{ .address = address, .mode = AddressingMode::Direct },
257257
.value = 0 };
258258
block->process_instruction(set_16_instruction);
259259
bytecode_length = static_cast<int>(create_bytecode(block->get_instructions()).size());

barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Tx create_default_tx(const AztecAddress& contract_address,
5959
.hash = TRANSACTION_HASH,
6060
.gas_settings = GasSettings{
6161
.gas_limits = gas_limit,
62-
.max_fees_per_gas = GasFees{ .fee_per_da_gas = FEE_PER_DA_GAS, .fee_per_l2_gas = FEE_PER_L2_GAS },
62+
.max_fees_per_gas = GasFees{ .fee_per_da_gas = 10000, .fee_per_l2_gas = 10000 },
6363
},
6464
.effective_gas_fees = EFFECTIVE_GAS_FEES,
6565
.non_revertible_accumulated_data = AccumulatedData{
@@ -97,7 +97,7 @@ SimulatorResult fuzz(FuzzerData& fuzzer_data)
9797
for (const auto& cfg_instruction : fuzzer_data.cfg_instructions) {
9898
control_flow.process_cfg_instruction(cfg_instruction);
9999
}
100-
fuzz_info("Fuzzer data: ", fuzzer_data);
100+
fuzz_info("Fuzzer data: ", fuzzer_data.instruction_blocks);
101101

102102
auto bytecode = control_flow.build_bytecode(fuzzer_data.return_options);
103103
fuzz_info("Bytecode: ", bytecode);
@@ -136,8 +136,8 @@ SimulatorResult fuzz(FuzzerData& fuzzer_data)
136136

137137
// If the results does not match
138138
if (!compare_simulator_results(cpp_result, js_result)) {
139-
vinfo("CppSimulator ", cpp_result);
140-
vinfo("JsSimulator ", js_result);
139+
fuzz_info("CppSimulator ", cpp_result);
140+
fuzz_info("JsSimulator ", js_result);
141141
throw std::runtime_error("Simulator results are different");
142142
}
143143
fuzz_info("Simulator results match successfully");

barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.test.cpp

Lines changed: 228 additions & 232 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)