Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fuzzer for noir programs #6770

Merged
merged 125 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
f098748
something
Rumata888 Nov 21, 2024
1c5d23f
we have a coverage fuzzer
Rumata888 Nov 21, 2024
587fc79
wip
Rumata888 Nov 28, 2024
22508d1
int mutator
Rumata888 Nov 29, 2024
26f9cc2
fast power schedule and dictionary from inputs
Rumata888 Nov 29, 2024
68c1c50
Update mutation count window
Rumata888 Nov 29, 2024
3eff9d7
json
Rumata888 Dec 2, 2024
f32287a
unused cleanup
Rumata888 Dec 2, 2024
917c8cd
listing all
Rumata888 Dec 2, 2024
4348f2e
Remove uint strategy
Rumata888 Dec 4, 2024
41cca17
Fix, better string mutator, acir coverage
Rumata888 Dec 9, 2024
6d06e9d
Useful errors
Rumata888 Dec 9, 2024
b641342
Disk corpus
Rumata888 Dec 11, 2024
b7cea21
remove incorrect prioritization and add splicing
Rumata888 Dec 12, 2024
e98a52d
fix int mutator
Rumata888 Dec 13, 2024
fd2ecb0
Primitive parallelism
Rumata888 Dec 16, 2024
91bf283
relatively fast parallelism
Rumata888 Dec 17, 2024
41c04f3
some cleanup
Rumata888 Dec 23, 2024
368d118
Tracing conditional mov
Rumata888 Dec 23, 2024
2fecd1f
Stupid cmp coverage in brillig
Rumata888 Dec 23, 2024
6813907
Comparison coverage
Rumata888 Dec 23, 2024
cf72aba
refactor start
Rumata888 Dec 23, 2024
3f34dac
fixed parallelism
Rumata888 Dec 26, 2024
1bf3d63
connected show output
Rumata888 Jan 1, 2025
6a48a2e
autoejection from corpus and better update times
Rumata888 Jan 3, 2025
588a680
remove noisy print
Rumata888 Jan 3, 2025
1fe9b6e
Separate asserts
Rumata888 Jan 3, 2025
ed4e87b
storing failing inputs
Rumata888 Jan 3, 2025
8cbcbd0
started refactoring
Rumata888 Jan 6, 2025
1f5b788
Merge branch 'master' into my domain
Rumata888 Jan 6, 2025
a31afef
fixes
Rumata888 Jan 6, 2025
0613f61
some refactoring
Rumata888 Jan 6, 2025
aa5e26f
refactoring, continued
Rumata888 Jan 6, 2025
9f21a45
refactored field mutations
Rumata888 Jan 7, 2025
4083782
feat: don't simplify SSA instructions when creating them from a strin…
asterite Jan 6, 2025
f98b966
feat: lock on Nargo.toml on several nargo commands (#6941)
asterite Jan 6, 2025
07457c0
feat!: turn CannotReexportItemWithLessVisibility into an error (#6952)
asterite Jan 6, 2025
38c89f4
chore: Separate unconstrained functions during monomorphization (#6894)
jfecher Jan 6, 2025
b728151
chore: Move comment as part of #6945 (#6959)
vezenovm Jan 6, 2025
6c60f92
feat(ssa): Immediately simplify away RefCount instructions in ACIR fu…
aakoshh Jan 6, 2025
8e870ed
chore: simplify boolean in a mul of a mul (#6951)
guipublic Jan 6, 2025
368356f
feat: don't report warnings for dependencies (#6926)
asterite Jan 6, 2025
432c477
fix: error on missing function parameters (#6967)
asterite Jan 7, 2025
ca46630
fix: don't fail parsing macro if there are parser warnings (#6969)
asterite Jan 7, 2025
9ceb9f9
feat!: turn TypeIsMorePrivateThenItem into an error (#6953)
asterite Jan 7, 2025
e9c0fed
fix: Start RC at 1 again (#6958)
jfecher Jan 7, 2025
df4b035
fix: wrong module to lookup trait when using crate or super (#6974)
asterite Jan 7, 2025
1c19ac2
feat!: update `aes128_encrypt` to return an array (#6973)
TomAFrench Jan 7, 2025
9cca916
feat: `--pedantic-solving` flag (#6716)
michaeljklein Jan 7, 2025
30514fe
feat!: type-check trait default methods (#6645)
asterite Jan 7, 2025
8879eee
feat!: require trait method calls (`foo.bar()`) to have the trait in …
asterite Jan 8, 2025
6d85cd6
fix: do not panic on indices which are not valid `u32`s (#6976)
TomAFrench Jan 8, 2025
6078d5c
docs and race fix
Rumata888 Jan 8, 2025
f9a033b
String mutation refactor
Rumata888 Jan 9, 2025
bdf5b57
a bit more of field and string refactor + added swap to string mutators
Rumata888 Jan 13, 2025
dc0a0b4
Int mutator refactor
Rumata888 Jan 13, 2025
e41f68f
comments
Rumata888 Jan 15, 2025
306f2a6
Merge branch 'master' into my domain
Rumata888 Jan 15, 2025
a82f65f
separate out the dictionary
Rumata888 Jan 16, 2025
2bb2f31
renamed folder
Rumata888 Jan 16, 2025
f610496
moved configs and started working on array splicing
Rumata888 Jan 17, 2025
d96a820
Mutations almost completely refactored
Rumata888 Jan 22, 2025
3f56abf
coverage docs
Rumata888 Jan 28, 2025
687adc7
fixes
Rumata888 Jan 28, 2025
255a191
fixed foreign calls
Rumata888 Jan 30, 2025
1b146d9
More refactoring and comments
Rumata888 Jan 30, 2025
0e6dd10
nice metrics
Rumata888 Jan 30, 2025
5095811
minifix
Rumata888 Jan 30, 2025
6ac9481
merged into a single loop
Rumata888 Feb 4, 2025
5cddc53
Removed unused code from past corpus initialization
Rumata888 Feb 4, 2025
087b29d
fixes and refactor
Rumata888 Feb 4, 2025
d1f5f10
fix
Rumata888 Feb 4, 2025
8cd1708
Merge branch 'master' into is/fuzzer
Rumata888 Feb 5, 2025
70a77b8
refactoring
Rumata888 Feb 7, 2025
e643ab2
refactoring
Rumata888 Feb 7, 2025
7c685d7
refactoring
Rumata888 Feb 7, 2025
d5ff3e3
fix
Rumata888 Feb 7, 2025
fa50d57
Merge branch 'master' into is/fuzzer
Rumata888 Feb 7, 2025
ee503c8
fixes
Rumata888 Feb 7, 2025
03dbf91
fixes
Rumata888 Feb 7, 2025
958d86e
Specify corpus folder
Rumata888 Feb 10, 2025
1cf0868
Pretty
Rumata888 Feb 10, 2025
0a6027c
stupid corpus minimization
Rumata888 Feb 10, 2025
ee4d071
added timeout
Rumata888 Feb 11, 2025
0867ce0
tests for field mutator
Rumata888 Feb 11, 2025
816871d
More comments
Rumata888 Feb 12, 2025
3219bee
comments
Rumata888 Feb 12, 2025
d2dbfd4
debugger fixes
Rumata888 Feb 13, 2025
03ab9ab
refactoring
Rumata888 Feb 13, 2025
393f1ae
First tests
Rumata888 Feb 17, 2025
501b662
tests
Rumata888 Feb 18, 2025
87b239d
fix
Rumata888 Feb 18, 2025
6a09e5a
Merge branch 'master' into is/fuzzer
Rumata888 Feb 18, 2025
fe21c01
minidocs
Rumata888 Feb 19, 2025
65c60cb
Merge branch 'master' into is/fuzzer
Rumata888 Feb 19, 2025
1af6647
clippy
Rumata888 Feb 19, 2025
df60cdf
issues
Rumata888 Feb 19, 2025
a43280b
clippy
Rumata888 Feb 19, 2025
fb93054
fixes
Rumata888 Feb 19, 2025
3d1cf1a
formatting
Rumata888 Feb 24, 2025
f3dad61
Moved the readme and addes some stuff
Rumata888 Feb 24, 2025
667d2d5
moved the readme
Rumata888 Feb 24, 2025
06a23f8
address comments
Rumata888 Mar 6, 2025
14c02e6
Merge branch 'master' into is/fuzzer (mutations are broken now)
Rumata888 Mar 13, 2025
b8ae4fa
wip, everything is brokent
Rumata888 Mar 17, 2025
781e785
Merge branch 'master' into is/fuzzer
Rumata888 Mar 21, 2025
b900cef
u128 comparisons work!
Rumata888 Mar 21, 2025
02c093e
Deduplicate foreign executor
Rumata888 Mar 24, 2025
d983c5e
some clippy stuff
Rumata888 Mar 24, 2025
71c6975
Deduplication
Rumata888 Mar 24, 2025
02737ca
Moved unbalanced splice config
Rumata888 Mar 24, 2025
09afeec
field comparison test
Rumata888 Mar 24, 2025
9af2e60
clippiism
Rumata888 Mar 24, 2025
4b835df
Formatting
Rumata888 Mar 24, 2025
48e1d25
Merge branch 'master' into is/fuzzer
Rumata888 Mar 24, 2025
e7de9c8
clippy
Rumata888 Mar 24, 2025
9cf762f
docs
Rumata888 Mar 24, 2025
645a7cc
fmt
Rumata888 Mar 24, 2025
4ce5788
Disable sha256 features
Rumata888 Mar 24, 2025
76b5ced
Double test time for fuzzing
Rumata888 Mar 24, 2025
9ca1e93
Merge branch 'master' into is/fuzzer
Rumata888 Mar 25, 2025
c628ce6
Small quality-of-life improvement
Rumata888 Mar 25, 2025
ba2a5e5
Address comments
Rumata888 Mar 25, 2025
aad5d6c
Merge branch 'master' into is/fuzzer
Rumata888 Mar 25, 2025
ae25b73
clippy was created to make me suffer
Rumata888 Mar 25, 2025
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
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
# Crates related to tooling built on top of the Noir compiler
"tooling/lsp",
"tooling/debugger",
"tooling/greybox_fuzzer",
"tooling/fuzzer",
"tooling/nargo",
"tooling/nargo_fmt",
Expand Down Expand Up @@ -82,6 +83,7 @@ noirc_frontend = { path = "compiler/noirc_frontend" }
noirc_printable_type = { path = "compiler/noirc_printable_type" }

# Noir tooling workspace dependencies
noir_greybox_fuzzer = { path = "tooling/greybox_fuzzer" }
noir_fuzzer = { path = "tooling/fuzzer" }
nargo = { path = "tooling/nargo" }
nargo_fmt = { path = "tooling/nargo_fmt" }
Expand Down
19 changes: 17 additions & 2 deletions acvm-repo/acvm/src/pwg/brillig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use acir::{
AcirField,
};
use acvm_blackbox_solver::BlackBoxFunctionSolver;
use brillig_vm::{BrilligProfilingSamples, FailureReason, MemoryValue, VMStatus, VM};
use brillig_vm::{
BranchToFeatureMap, BrilligProfilingSamples, FailureReason, MemoryValue, VMStatus, VM,
};
use serde::{Deserialize, Serialize};

use crate::{pwg::OpcodeNotSolvable, OpcodeResolutionError};
Expand Down Expand Up @@ -67,6 +69,7 @@ impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B> {
acir_index: usize,
brillig_function_id: BrilligFunctionId,
profiling_active: bool,
with_branch_to_feature_map: Option<&BranchToFeatureMap>,
) -> Result<Self, OpcodeResolutionError<F>> {
let vm = Self::setup_brillig_vm(
initial_witness,
Expand All @@ -75,6 +78,7 @@ impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B> {
brillig_bytecode,
bb_solver,
profiling_active,
with_branch_to_feature_map,
)?;
Ok(Self { vm, acir_index, function_id: brillig_function_id })
}
Expand All @@ -86,6 +90,7 @@ impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B> {
brillig_bytecode: &'b [BrilligOpcode<F>],
bb_solver: &'b B,
profiling_active: bool,
with_branch_to_feature_map: Option<&BranchToFeatureMap>,
) -> Result<VM<'b, F, B>, OpcodeResolutionError<F>> {
// Set input values
let mut calldata: Vec<F> = Vec::new();
Expand Down Expand Up @@ -133,7 +138,13 @@ impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B> {

// Instantiate a Brillig VM given the solved calldata
// along with the Brillig bytecode.
let vm = VM::new(calldata, brillig_bytecode, bb_solver, profiling_active);
let vm = VM::new(
calldata,
brillig_bytecode,
bb_solver,
profiling_active,
with_branch_to_feature_map,
);
Ok(vm)
}

Expand All @@ -149,6 +160,10 @@ impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B> {
self.vm.get_call_stack()
}

pub fn get_fuzzing_trace(&self) -> Vec<u32> {
self.vm.get_fuzzing_trace()
}

pub(crate) fn solve(&mut self) -> Result<BrilligSolverStatus<F>, OpcodeResolutionError<F>> {
let status = self.vm.process_opcodes();
self.handle_vm_status(status)
Expand Down
42 changes: 41 additions & 1 deletion acvm-repo/acvm/src/pwg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use acir::{
AcirField, BlackBoxFunc,
};
use acvm_blackbox_solver::BlackBoxResolutionError;
use brillig_vm::BranchToFeatureMap;

use self::{
arithmetic::ExpressionSolver, blackbox::bigint::AcvmBigIntSolver, memory_op::MemoryOpSolver,
Expand Down Expand Up @@ -209,6 +210,14 @@ pub struct ACVM<'a, F, B: BlackBoxFunctionSolver<F>> {
profiling_active: bool,

profiling_samples: ProfilingSamples,

// Whether we need to trace brillig execution for fuzzing
brillig_fuzzing_active: bool,

// Brillig branch to feature map
brillig_branch_to_feature_map: Option<&'a BranchToFeatureMap>,

brillig_fuzzing_trace: Option<Vec<u32>>,
}

impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
Expand Down Expand Up @@ -236,6 +245,9 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
assertion_payloads,
profiling_active: false,
profiling_samples: Vec::new(),
brillig_fuzzing_active: false,
brillig_branch_to_feature_map: None,
brillig_fuzzing_trace: None,
}
}

Expand All @@ -244,6 +256,24 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
self.profiling_active = profiling_active;
}

// Enable brillig fuzzing
pub fn with_brillig_fuzzing(
&mut self,
brillig_fuzzing_active: bool,
brillig_branch_to_feature_map: Option<&'a BranchToFeatureMap>,
) {
self.brillig_fuzzing_active = brillig_fuzzing_active;
if brillig_fuzzing_active {
self.brillig_branch_to_feature_map = brillig_branch_to_feature_map;
} else {
self.brillig_branch_to_feature_map = None;
}
}

pub fn get_brillig_fuzzing_trace(&self) -> Option<Vec<u32>> {
self.brillig_fuzzing_trace.clone()
}

/// Returns a reference to the current state of the ACVM's [`WitnessMap`].
///
/// Once execution has completed, the witness map can be extracted using [`ACVM::finalize`]
Expand Down Expand Up @@ -510,10 +540,16 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
self.instruction_pointer,
*id,
self.profiling_active,
self.brillig_branch_to_feature_map,
)?,
};

let result = solver.solve()?;
let result = solver.solve().map_err(|err| {
if self.brillig_fuzzing_active {
self.brillig_fuzzing_trace = Some(solver.get_fuzzing_trace());
};
err
})?;

match result {
BrilligSolverStatus::ForeignCallWait(foreign_call) => {
Expand All @@ -525,6 +561,9 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
unreachable!("Brillig solver still in progress")
}
BrilligSolverStatus::Finished => {
if self.brillig_fuzzing_active {
self.brillig_fuzzing_trace = Some(solver.get_fuzzing_trace());
}
// Write execution outputs
if self.profiling_active {
let profiling_info =
Expand Down Expand Up @@ -586,6 +625,7 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
self.instruction_pointer,
*id,
self.profiling_active,
self.brillig_branch_to_feature_map,
);
match solver {
Ok(solver) => StepResult::IntoBrillig(solver),
Expand Down
Loading
Loading