Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions tools/fuzzing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,25 @@ fn main() {
.long("fuzzcase")
.value_name("FILE"),
)
.arg(
clap::Arg::new("seed")
.short('s')
.long("seed")
.default_value("42")
.value_parser(clap::value_parser!(u64)),
)
.get_matches();

let mut child = Command::new(
&std::env::var("OCAML_TRANSACTION_FUZZER_PATH").unwrap_or_else(|_| {
format!(
"{}/mina/_build/default/src/app/transaction_fuzzer/transaction_fuzzer.exe",
std::env::var("HOME").unwrap()
)
}),
&std::env::var("OCAML_TRANSACTION_FUZZER_PATH").unwrap_or_else(
#[coverage(off)]
|_| {
format!(
"{}/mina/_build/default/src/app/transaction_fuzzer/transaction_fuzzer.exe",
std::env::var("HOME").unwrap()
)
},
),
)
.arg("execute")
.stdin(Stdio::piped())
Expand All @@ -302,8 +312,12 @@ fn main() {
println!("Reproducing fuzzcase from file: {}", fuzzcase);
transaction_fuzzer::reproduce(stdin, stdout, fuzzcase);
} else {
println!("Running the fuzzer...");
transaction_fuzzer::fuzz(stdin, stdout, true, 42, 1000);
let Some(seed) = matches.get_one::<u64>("seed") else {
unreachable!()
};

println!("Running the fuzzer with seed {seed}...");
transaction_fuzzer::fuzz(stdin, stdout, true, *seed, 1000);
}
}
}
24 changes: 23 additions & 1 deletion tools/fuzzing/src/transaction_fuzzer/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::transaction_fuzzer::{
};
use ark_ff::fields::arithmetic::InvalidBigInt;
use ark_ff::Zero;
use ledger::scan_state::currency::{Amount, Fee, Length, Magnitude, Nonce, Signed, Slot};
use ledger::scan_state::transaction_logic::protocol_state::{
protocol_state_view, EpochData, EpochLedger, ProtocolStateView,
};
Expand All @@ -15,6 +14,10 @@ use ledger::scan_state::transaction_logic::transaction_applied::{
use ledger::scan_state::transaction_logic::{
apply_transactions, Transaction, TransactionStatus, UserCommand,
};
use ledger::scan_state::{
currency::{Amount, Fee, Length, Magnitude, Nonce, Signed, Slot},
transaction_logic::transaction_applied,
};
use ledger::sparse_ledger::LedgerIntf;
use ledger::staged_ledger::staged_ledger::StagedLedger;
use ledger::{dummy, Account, AccountId, Database, Mask, Timing, TokenId};
Expand Down Expand Up @@ -1103,6 +1106,25 @@ impl FuzzerCtx {
// For now we work with one transaction at a time
let applied = &applied[0];

match &applied.varying {
transaction_applied::Varying::Command(command_applied) => {
match command_applied {
transaction_applied::CommandApplied::SignedCommand(
_signed_command_applied,
) => {}
transaction_applied::CommandApplied::ZkappCommand(
zkapp_command_applied,
) => zkapp_command_applied
.command
.data
.account_updates
.accumulate_hashes(), // Needed because of delayed hashing
}
}
transaction_applied::Varying::FeeTransfer(_fee_transfer_applied) => {}
transaction_applied::Varying::Coinbase(_coinbase_applied) => {}
}

if expected_apply_result.apply_result.len() != 1 {
println!(
"!!! Apply failed in OCaml (error: {}) but it didn't in Rust: {:?}",
Expand Down
Loading