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
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ impl<'ssa, W: Write> Interpreter<'ssa, W> {
let index = self.lookup_u32(index, "array get index")?;
let mut index = index - offset.to_u32();

let element = if array.elements.borrow().len() == 0 {
let element = if array.elements.borrow().is_empty() {
// Accessing an array of 0-len is replaced by asserting
// the branch is not-taken during acir-gen and
// a zeroed type is used in case of array get
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_toml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ impl PackageConfig {
/// Contains all the information about a package, as loaded from a `Nargo.toml`.
#[derive(Debug, Deserialize, Clone)]
#[serde(untagged)]
#[allow(clippy::large_enum_variant)]
pub enum Config {
/// Represents a `Nargo.toml` with package fields.
Package {
Expand Down
3 changes: 3 additions & 0 deletions tooling/ssa_fuzzer/fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ license.workspace = true
[package.metadata]
cargo-fuzz = true

[lints]
workspace = true

[dependencies]
libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] }
noirc_evaluator.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/fuzz_target_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub(crate) fn fuzz_target(data: FuzzerData, options: FuzzerOptions) -> Option<Fi

let mut fuzzer = Fuzzer::new(data.instruction_blocks, values, options);
for func in data.functions {
log::debug!("initial_witness: {:?}", witness_map);
log::debug!("initial_witness: {witness_map:?}");
log::debug!("commands: {:?}", func.commands);
fuzzer.process_function(func, types.clone());
}
Expand Down Expand Up @@ -745,9 +745,9 @@ mod tests {
0,
FuzzerFunctionCommand::InsertSimpleInstructionBlock { instruction_block_idx: 4 },
); // add true boolean
log::debug!("commands: {:?}", commands);
log::debug!("commands: {commands:?}");
blocks.push(add_boolean_block);
log::debug!("blocks: {:?}", blocks);
log::debug!("blocks: {blocks:?}");
let main_func = FunctionData {
commands,
return_instruction_block_idx: 3,
Expand Down
86 changes: 43 additions & 43 deletions tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ use noirc_driver::CompileOptions;

/// Options for the instructions that can be used in the SSA blocks
#[derive(Clone, Copy, Debug)]
pub struct InstructionOptions {
pub cast_enabled: bool,
pub xor_enabled: bool,
pub and_enabled: bool,
pub or_enabled: bool,
pub not_enabled: bool,
pub add_enabled: bool,
pub sub_enabled: bool,
pub mul_enabled: bool,
pub mod_enabled: bool,
pub div_enabled: bool,
pub shl_enabled: bool,
pub shr_enabled: bool,
pub eq_enabled: bool,
pub lt_enabled: bool,
pub load_enabled: bool,
pub store_enabled: bool,
pub alloc_enabled: bool,
pub(crate) struct InstructionOptions {
pub(crate) cast_enabled: bool,
pub(crate) xor_enabled: bool,
pub(crate) and_enabled: bool,
pub(crate) or_enabled: bool,
pub(crate) not_enabled: bool,
pub(crate) add_enabled: bool,
pub(crate) sub_enabled: bool,
pub(crate) mul_enabled: bool,
pub(crate) mod_enabled: bool,
pub(crate) div_enabled: bool,
pub(crate) shl_enabled: bool,
pub(crate) shr_enabled: bool,
pub(crate) eq_enabled: bool,
pub(crate) lt_enabled: bool,
pub(crate) load_enabled: bool,
pub(crate) store_enabled: bool,
pub(crate) alloc_enabled: bool,
}

impl Default for InstructionOptions {
Expand Down Expand Up @@ -48,31 +48,31 @@ impl Default for InstructionOptions {

/// Options for the SSA block
#[derive(Clone, Debug)]
pub struct SsaBlockOptions {
pub(crate) struct SsaBlockOptions {
/// If false, we don't add constraints for idempotent morphing results
pub constrain_idempotent_enabled: bool,
pub(crate) constrain_idempotent_enabled: bool,
/// Options for the instructions that can be used in the SSA block
pub instruction_options: InstructionOptions,
pub(crate) instruction_options: InstructionOptions,
}

/// Options of the program context
#[derive(Clone, Debug)]
pub struct FunctionContextOptions {
pub(crate) struct FunctionContextOptions {
/// If false, we don't add constraints for idempotent morphing results
pub idempotent_morphing_enabled: bool,
pub(crate) idempotent_morphing_enabled: bool,
/// Options for the program compilation
pub compile_options: CompileOptions,
pub(crate) compile_options: CompileOptions,
/// Maximum number of SSA blocks in the program
pub max_ssa_blocks_num: usize,
pub(crate) max_ssa_blocks_num: usize,
/// Maximum number of instructions inserted in the program
pub max_instructions_num: usize,
pub(crate) max_instructions_num: usize,
/// Options for the instructions that can be used in the SSA block
pub instruction_options: InstructionOptions,
pub(crate) instruction_options: InstructionOptions,
/// Options for the fuzzer commands that can be used in the SSA block
pub fuzzer_command_options: FuzzerCommandOptions,
pub(crate) fuzzer_command_options: FuzzerCommandOptions,

/// Maximum number of iterations in the program
pub max_iterations_num: usize,
pub(crate) max_iterations_num: usize,
}

impl From<FunctionContextOptions> for SsaBlockOptions {
Expand All @@ -86,14 +86,14 @@ impl From<FunctionContextOptions> for SsaBlockOptions {

/// Options for the fuzzer commands that can be used in the program context
#[derive(Clone, Copy, Debug)]
pub struct FuzzerCommandOptions {
pub(crate) struct FuzzerCommandOptions {
/// If false, we don't insert jmp_if
pub jmp_if_enabled: bool,
pub(crate) jmp_if_enabled: bool,
/// If false, we don't insert jmp command
pub jmp_block_enabled: bool,
pub(crate) jmp_block_enabled: bool,
/// If false, we don't switch to the next block
pub switch_to_next_block_enabled: bool,
pub loops_enabled: bool,
pub(crate) switch_to_next_block_enabled: bool,
pub(crate) loops_enabled: bool,
}

impl Default for FuzzerCommandOptions {
Expand All @@ -108,15 +108,15 @@ impl Default for FuzzerCommandOptions {
}

#[derive(Clone)]
pub struct FuzzerOptions {
pub constrain_idempotent_morphing_enabled: bool,
pub constant_execution_enabled: bool,
pub compile_options: CompileOptions,
pub max_ssa_blocks_num: usize,
pub max_instructions_num: usize,
pub max_iterations_num: usize,
pub instruction_options: InstructionOptions,
pub fuzzer_command_options: FuzzerCommandOptions,
pub(crate) struct FuzzerOptions {
pub(crate) constrain_idempotent_morphing_enabled: bool,
pub(crate) constant_execution_enabled: bool,
pub(crate) compile_options: CompileOptions,
pub(crate) max_ssa_blocks_num: usize,
pub(crate) max_instructions_num: usize,
pub(crate) max_iterations_num: usize,
pub(crate) instruction_options: InstructionOptions,
pub(crate) fuzzer_command_options: FuzzerCommandOptions,
}

impl Default for FuzzerOptions {
Expand Down
4 changes: 2 additions & 2 deletions tooling/ssa_fuzzer/fuzzer/src/fuzz_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ libfuzzer_sys::fuzz_target!(|data: &[u8]| -> Corpus {
"FULL" => compile_options.show_ssa = true,
"FINAL" => {
compile_options.show_ssa_pass =
vec!["After Dead Instruction Elimination - ACIR".to_string()]
vec!["After Dead Instruction Elimination - ACIR".to_string()];
}
"FIRST_AND_FINAL" => {
compile_options.show_ssa_pass = vec![
"After Removing Unreachable Functions (1)".to_string(),
"After Dead Instruction Elimination - ACIR".to_string(),
]
];
}
_ => (),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ pub(crate) fn mutate_vec_fuzzer_command(
match BASIC_FUZZER_COMMAND_MUTATION_CONFIGURATION.select(rng) {
FuzzerCommandMutationOptions::Random => RandomMutation::mutate(rng, vec_fuzzer_command),
FuzzerCommandMutationOptions::RemoveCommand => {
RemoveCommandMutation::mutate(rng, vec_fuzzer_command)
RemoveCommandMutation::mutate(rng, vec_fuzzer_command);
}
FuzzerCommandMutationOptions::AddCommand => {
AddCommandMutation::mutate(rng, vec_fuzzer_command)
AddCommandMutation::mutate(rng, vec_fuzzer_command);
}
FuzzerCommandMutationOptions::ReplaceCommand => {
ReplaceCommandMutation::mutate(rng, vec_fuzzer_command)
ReplaceCommandMutation::mutate(rng, vec_fuzzer_command);
}
}
}
8 changes: 4 additions & 4 deletions tooling/ssa_fuzzer/fuzzer/src/mutations/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ impl MutateFunctionVec for FunctionInsertionMutation {
pub(crate) fn mutate(vec_fuzzer_command: &mut Vec<FunctionData>, rng: &mut StdRng) {
match BASIC_FUNCTION_VEC_MUTATION_CONFIGURATION.select(rng) {
FunctionVecMutationOptions::CopyFunction => {
CopyFunctionMutation::mutate(rng, vec_fuzzer_command)
CopyFunctionMutation::mutate(rng, vec_fuzzer_command);
}
FunctionVecMutationOptions::Remove => {
RemoveFunctionMutation::mutate(rng, vec_fuzzer_command)
RemoveFunctionMutation::mutate(rng, vec_fuzzer_command);
}
FunctionVecMutationOptions::Insertion => {
FunctionInsertionMutation::mutate(rng, vec_fuzzer_command)
FunctionInsertionMutation::mutate(rng, vec_fuzzer_command);
}
FunctionVecMutationOptions::InsertEmpty => {
InsertEmptyFunctionMutation::mutate(rng, vec_fuzzer_command)
InsertEmptyFunctionMutation::mutate(rng, vec_fuzzer_command);
}
FunctionVecMutationOptions::MutateFunction => {
MutateFunction::mutate(rng, vec_fuzzer_command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ pub(crate) fn argument_mutator(argument: &mut Argument, rng: &mut StdRng) {
match BASIC_ARGUMENT_MUTATION_CONFIGURATION.select(rng) {
ArgumentMutationOptions::Random => RandomMutation::mutate(rng, argument),
ArgumentMutationOptions::IncrementIndex => {
IncrementArgumentIndexMutation::mutate(rng, argument)
IncrementArgumentIndexMutation::mutate(rng, argument);
}
ArgumentMutationOptions::DecrementIndex => {
DecrementArgumentIndexMutation::mutate(rng, argument)
DecrementArgumentIndexMutation::mutate(rng, argument);
}
ArgumentMutationOptions::ChangeType => ChangeTypeMutation::mutate(rng, argument),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ pub(crate) fn instruction_block_mutator(
match BASIC_INSTRUCTION_BLOCK_MUTATION_CONFIGURATION.select(rng) {
InstructionBlockMutationOptions::Random => RandomMutation::mutate(rng, instruction_block),
InstructionBlockMutationOptions::InstructionDeletion => {
InstructionBlockDeletionMutation::mutate(rng, instruction_block)
InstructionBlockDeletionMutation::mutate(rng, instruction_block);
}
InstructionBlockMutationOptions::InstructionInsertion => {
InstructionBlockInsertionMutation::mutate(rng, instruction_block)
InstructionBlockInsertionMutation::mutate(rng, instruction_block);
}
InstructionBlockMutationOptions::InstructionMutation => {
InstructionBlockInstructionMutation::mutate(rng, instruction_block)
InstructionBlockInstructionMutation::mutate(rng, instruction_block);
}
InstructionBlockMutationOptions::InstructionSwap => {
InstructionBlockInstructionSwapMutation::mutate(rng, instruction_block)
InstructionBlockInstructionSwapMutation::mutate(rng, instruction_block);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub(crate) fn instruction_mutator(instruction: &mut Instruction, rng: &mut StdRn
match BASIC_INSTRUCTION_MUTATION_CONFIGURATION.select(rng) {
InstructionMutationOptions::Random => RandomMutation::mutate(rng, instruction),
InstructionMutationOptions::ArgumentMutation => {
InstructionArgumentsMutation::mutate(rng, instruction)
InstructionArgumentsMutation::mutate(rng, instruction);
}
}
}
10 changes: 5 additions & 5 deletions tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ impl MutateVecInstructionBlock for InstructionBlockInstructionSwapMutation {
pub(crate) fn mutate(vec_instruction_block: &mut Vec<InstructionBlock>, rng: &mut StdRng) {
match BASIC_VECTOR_OF_INSTRUCTION_BLOCKS_MUTATION_CONFIGURATION.select(rng) {
VectorOfInstructionBlocksMutationOptions::Random => {
RandomMutation::mutate(rng, vec_instruction_block)
RandomMutation::mutate(rng, vec_instruction_block);
}
VectorOfInstructionBlocksMutationOptions::InstructionBlockDeletion => {
InstructionBlockDeletionMutation::mutate(rng, vec_instruction_block)
InstructionBlockDeletionMutation::mutate(rng, vec_instruction_block);
}
VectorOfInstructionBlocksMutationOptions::InstructionBlockInsertion => {
InstructionBlockInsertionMutation::mutate(rng, vec_instruction_block)
InstructionBlockInsertionMutation::mutate(rng, vec_instruction_block);
}
VectorOfInstructionBlocksMutationOptions::InstructionBlockMutation => {
InstructionBlockInstructionMutation::mutate(rng, vec_instruction_block)
InstructionBlockInstructionMutation::mutate(rng, vec_instruction_block);
}
VectorOfInstructionBlocksMutationOptions::InstructionBlockSwap => {
InstructionBlockInstructionSwapMutation::mutate(rng, vec_instruction_block)
InstructionBlockInstructionSwapMutation::mutate(rng, vec_instruction_block);
}
}
}
4 changes: 2 additions & 2 deletions tooling/ssa_fuzzer/fuzzer/src/mutations/witness_mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ pub(crate) fn mutate(witness_value: &mut WitnessValue, rng: &mut StdRng) {
WitnessMutationOptions::MaxValue => MaxValueMutation::mutate(rng, witness_value),
WitnessMutationOptions::MinValue => MinValueMutation::mutate(rng, witness_value),
WitnessMutationOptions::SmallAddSub => {
WitnessSmallAddSubMutation::mutate(rng, witness_value)
WitnessSmallAddSubMutation::mutate(rng, witness_value);
}
WitnessMutationOptions::PowerOfTwoAddSub => {
WitnessAddSubPowerOfTwoMutation::mutate(rng, witness_value)
WitnessAddSubPowerOfTwoMutation::mutate(rng, witness_value);
}
}
}
Loading