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

Draft
wants to merge 62 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 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
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
32 changes: 32 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 @@ -75,6 +76,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
20 changes: 18 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,14 @@ 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, vec![], bb_solver, profiling_active);
let vm = VM::new(
calldata,
brillig_bytecode,
vec![],
bb_solver,
profiling_active,
with_branch_to_feature_map,
);
Ok(vm)
}

Expand All @@ -149,6 +161,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 @@
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 @@ -55,7 +56,7 @@
RequiresForeignCall(ForeignCallWaitInfo<F>),

/// The ACVM has encountered a request for an ACIR [call][acir::circuit::Opcode]
/// to execute a separate ACVM instance. The result of the ACIR call must be passd back to the ACVM.

Check warning on line 59 in acvm-repo/acvm/src/pwg/mod.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (passd)
///
/// Once this is done, the ACVM can be restarted to solve the remaining opcodes.
RequiresAcirCall(AcirCallWaitInfo<F>),
Expand Down Expand Up @@ -209,6 +210,14 @@
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 @@
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 @@
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 @@
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 @@
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 @@
self.instruction_pointer,
*id,
self.profiling_active,
self.brillig_branch_to_feature_map,
);
match solver {
Ok(solver) => StepResult::IntoBrillig(solver),
Expand Down
Loading
Loading