Skip to content

Commit

Permalink
Merge branch 'master' into mv/restrict-mut-captures
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm authored Mar 3, 2025
2 parents c751272 + c2022f4 commit 10e4639
Show file tree
Hide file tree
Showing 370 changed files with 2,750 additions and 2,547 deletions.
18 changes: 9 additions & 9 deletions .github/benchmark_projects.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define: &AZ_COMMIT a90f08e245add379fa0257c81f8e2819beb190cb
define: &AZ_COMMIT cca90e5e655ed9a2d2bb969f034e42ac15f87439
projects:
private-kernel-inner:
repo: AztecProtocol/aztec-packages
Expand Down Expand Up @@ -35,19 +35,19 @@ projects:
path: noir-projects/noir-protocol-circuits/crates/rollup-base-private
num_runs: 5
timeout: 15
compilation-timeout: 10
execution-timeout: 0.5
compilation-memory-limit: 1100
execution-memory-limit: 500
compilation-timeout: 20
execution-timeout: 1
compilation-memory-limit: 1500
execution-memory-limit: 650
rollup-base-public:
repo: AztecProtocol/aztec-packages
ref: *AZ_COMMIT
path: noir-projects/noir-protocol-circuits/crates/rollup-base-public
num_runs: 5
timeout: 15
compilation-timeout: 8
execution-timeout: 0.4
compilation-memory-limit: 1000
compilation-timeout: 15
execution-timeout: 0.75
compilation-memory-limit: 1300
execution-memory-limit: 500
rollup-block-root-empty:
repo: AztecProtocol/aztec-packages
Expand All @@ -73,7 +73,7 @@ projects:
path: noir-projects/noir-protocol-circuits/crates/rollup-block-root
num_runs: 1
timeout: 60
compilation-timeout: 110
compilation-timeout: 120
execution-timeout: 40
compilation-memory-limit: 8000
execution-memory-limit: 1500
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ codegen

**/cspell.json
!./cspell.json

mutants.out
mutants.out.old
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resolver = "2"
version = "1.0.0-beta.3"
# x-release-please-end
authors = ["The Noir Team <team@noir-lang.org>"]
edition = "2021"
edition = "2024"
rust-version = "1.85.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/noir-lang/noir/"
Expand Down
4 changes: 2 additions & 2 deletions EXTERNAL_NOIR_LIBRARIES.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define: &AZ_COMMIT a90f08e245add379fa0257c81f8e2819beb190cb
define: &AZ_COMMIT cca90e5e655ed9a2d2bb969f034e42ac15f87439
libraries:
noir_check_shuffle:
repo: noir-lang/noir_check_shuffle
Expand Down Expand Up @@ -29,7 +29,7 @@ libraries:
timeout: 250
noir_base64:
repo: noir-lang/noir_base64
timeout: 3
timeout: 5
noir_string_search:
repo: noir-lang/noir_string_search
timeout: 2
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/benches/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use std::{collections::BTreeSet, time::Duration};

use acir::{
FieldElement,
circuit::{Circuit, ExpressionWidth, Opcode, Program, PublicInputs},
native_types::{Expression, Witness},
FieldElement,
};

use pprof::criterion::{Output, PProfProfiler};
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{io::prelude::*, num::ParseIntError, str::FromStr};

use base64::Engine;
use flate2::Compression;
use serde::{de::Error as DeserializationError, Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeserializationError};

use std::collections::BTreeSet;

Expand Down Expand Up @@ -375,8 +375,8 @@ mod tests {
use std::collections::BTreeSet;

use super::{
opcodes::{BlackBoxFuncCall, FunctionInput},
Circuit, Compression, Opcode, PublicInputs,
opcodes::{BlackBoxFuncCall, FunctionInput},
};
use crate::{
circuit::{ExpressionWidth, Program},
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ mod reflection {

use crate::{
circuit::{
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, BlockType, ConstantOrWitnessEnum, FunctionInput},
AssertionPayload, Circuit, ExpressionOrMemory, ExpressionWidth, Opcode, OpcodeLocation,
Program,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, BlockType, ConstantOrWitnessEnum, FunctionInput},
},
native_types::{Witness, WitnessMap, WitnessStack},
};
Expand Down
6 changes: 1 addition & 5 deletions acvm-repo/acir/src/native_types/expression/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ impl<F: Ord> Expression<F> {

fn cmp_max(m1: Option<Witness>, m2: Option<Witness>) -> Ordering {
if let Some(m1) = m1 {
if let Some(m2) = m2 {
m1.cmp(&m2)
} else {
Ordering::Greater
}
if let Some(m2) = m2 { m1.cmp(&m2) } else { Ordering::Greater }
} else if m2.is_some() {
Ordering::Less
} else {
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/src/native_types/witness_map.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{
collections::{btree_map, BTreeMap},
collections::{BTreeMap, btree_map},
io::Read,
ops::Index,
};

use flate2::Compression;
use flate2::bufread::GzDecoder;

Check warning on line 8 in acvm-repo/acir/src/native_types/witness_map.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (bufread)
use flate2::bufread::GzEncoder;

Check warning on line 9 in acvm-repo/acir/src/native_types/witness_map.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (bufread)
use flate2::Compression;
use serde::{Deserialize, Serialize};
use thiserror::Error;

Expand Down
22 changes: 17 additions & 5 deletions acvm-repo/acir/src/native_types/witness_stack.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::io::Read;

use flate2::Compression;
use flate2::bufread::GzDecoder;

Check warning on line 4 in acvm-repo/acir/src/native_types/witness_stack.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (bufread)
use flate2::bufread::GzEncoder;

Check warning on line 5 in acvm-repo/acir/src/native_types/witness_stack.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (bufread)
use flate2::Compression;
use serde::{Deserialize, Serialize};
use thiserror::Error;

Expand All @@ -12,6 +12,9 @@ use super::WitnessMap;
enum SerializationError {
#[error(transparent)]
Deflate(#[from] std::io::Error),

#[error(transparent)]
BincodeError(#[from] bincode::Error),
}

#[derive(Debug, Error)]
Expand Down Expand Up @@ -57,26 +60,35 @@ impl<F> From<WitnessMap<F>> for WitnessStack<F> {
}
}

impl<F: Serialize> TryFrom<WitnessStack<F>> for Vec<u8> {
impl<F: Serialize> TryFrom<&WitnessStack<F>> for Vec<u8> {
type Error = WitnessStackError;

fn try_from(val: WitnessStack<F>) -> Result<Self, Self::Error> {
let buf = bincode::serialize(&val).unwrap();
fn try_from(val: &WitnessStack<F>) -> Result<Self, Self::Error> {
let buf = bincode::serialize(val).map_err(|e| WitnessStackError(e.into()))?;
let mut deflater = GzEncoder::new(buf.as_slice(), Compression::best());
let mut buf_c = Vec::new();
deflater.read_to_end(&mut buf_c).map_err(|err| WitnessStackError(err.into()))?;
Ok(buf_c)
}
}

impl<F: Serialize> TryFrom<WitnessStack<F>> for Vec<u8> {
type Error = WitnessStackError;

fn try_from(val: WitnessStack<F>) -> Result<Self, Self::Error> {
Self::try_from(&val)
}
}

impl<F: for<'a> Deserialize<'a>> TryFrom<&[u8]> for WitnessStack<F> {
type Error = WitnessStackError;

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
let mut deflater = GzDecoder::new(bytes);
let mut buf_d = Vec::new();
deflater.read_to_end(&mut buf_d).map_err(|err| WitnessStackError(err.into()))?;
let witness_stack = bincode::deserialize(&buf_d).unwrap();
let witness_stack =
bincode::deserialize(&buf_d).map_err(|e| WitnessStackError(e.into()))?;
Ok(witness_stack)
}
}
2 changes: 1 addition & 1 deletion acvm-repo/acir/tests/test_program_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::collections::BTreeSet;

use acir::{
circuit::{
Circuit, Opcode, Program, PublicInputs,
brillig::{BrilligBytecode, BrilligFunctionId, BrilligInputs, BrilligOutputs},
opcodes::{AcirFunctionId, BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
Circuit, Opcode, Program, PublicInputs,
},
native_types::{Expression, Witness},
};
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir_field/benches/field_element.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use acir_field::{AcirField, FieldElement};
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use std::hint::black_box;

fn criterion_benchmark(c: &mut Criterion) {
Expand Down
12 changes: 2 additions & 10 deletions acvm-repo/acir_field/src/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ impl<F: PrimeField> From<u32> for FieldElement<F> {

impl<F: PrimeField> From<bool> for FieldElement<F> {
fn from(boolean: bool) -> FieldElement<F> {
if boolean {
FieldElement::one()
} else {
FieldElement::zero()
}
if boolean { FieldElement::one() } else { FieldElement::zero() }
}
}

Expand Down Expand Up @@ -183,11 +179,7 @@ impl<F: PrimeField> AcirField for FieldElement<F> {
/// For example, a max bit size of 254 would give a max byte size of 32.
fn max_num_bytes() -> u32 {
let num_bytes = Self::max_num_bits() / 8;
if Self::max_num_bits() % 8 == 0 {
num_bytes
} else {
num_bytes + 1
}
if Self::max_num_bits() % 8 == 0 { num_bytes } else { num_bytes + 1 }
}

fn modulus() -> BigUint {
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use acir::{
circuit::{AssertionPayload, Circuit, ExpressionWidth, OpcodeLocation},
AcirField,
circuit::{AssertionPayload, Circuit, ExpressionWidth, OpcodeLocation},
};

// The various passes that we can use over ACIR
Expand All @@ -14,7 +14,7 @@ pub use optimizers::optimize;
use optimizers::optimize_internal;
pub use simulator::CircuitSimulator;
use transformers::transform_internal;
pub use transformers::{transform, MIN_EXPRESSION_WIDTH};
pub use transformers::{MIN_EXPRESSION_WIDTH, transform};

/// This module moves and decomposes acir opcodes. The transformation map allows consumers of this module to map
/// metadata they had about the opcodes to the new opcode structure generated after the transformation.
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/compiler/optimizers/general.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acir::{
native_types::{Expression, Witness},
AcirField,
native_types::{Expression, Witness},
};
use indexmap::IndexMap;

Expand Down
10 changes: 5 additions & 5 deletions acvm-repo/acvm/src/compiler/optimizers/merge_expressions.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::{BTreeMap, BTreeSet, HashMap};

use acir::{
AcirField,
circuit::{
Circuit, Opcode,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::BlockId,
Circuit, Opcode,
},
native_types::{Expression, Witness},
AcirField,
};

use crate::compiler::CircuitSimulator;
Expand Down Expand Up @@ -258,16 +258,16 @@ impl<F: AcirField> MergeExpressionsOptimizer<F> {

#[cfg(test)]
mod tests {
use crate::compiler::{optimizers::MergeExpressionsOptimizer, CircuitSimulator};
use crate::compiler::{CircuitSimulator, optimizers::MergeExpressionsOptimizer};
use acir::{
FieldElement,
acir_field::AcirField,
circuit::{
Circuit, ExpressionWidth, Opcode, PublicInputs,
brillig::{BrilligFunctionId, BrilligOutputs},
opcodes::{BlackBoxFuncCall, FunctionInput},
Circuit, ExpressionWidth, Opcode, PublicInputs,
},
native_types::{Expression, Witness},
FieldElement,
};
use std::collections::BTreeSet;

Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/compiler/optimizers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acir::{
circuit::{Circuit, Opcode},
AcirField,
circuit::{Circuit, Opcode},
};

// mod constant_backpropagation;
Expand All @@ -17,7 +17,7 @@ use tracing::info;
// use self::constant_backpropagation::ConstantBackpropagationOptimizer;
use self::unused_memory::UnusedMemoryOptimizer;

use super::{transform_assert_messages, AcirTransformationMap};
use super::{AcirTransformationMap, transform_assert_messages};

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] independent optimizations to a [`Circuit`].
pub fn optimize<F: AcirField>(acir: Circuit<F>) -> (Circuit<F>, AcirTransformationMap) {
Expand Down
8 changes: 4 additions & 4 deletions acvm-repo/acvm/src/compiler/optimizers/redundant_range.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use acir::{
AcirField,
circuit::{
opcodes::{BlackBoxFuncCall, ConstantOrWitnessEnum},
Circuit, Opcode,
opcodes::{BlackBoxFuncCall, ConstantOrWitnessEnum},
},
native_types::Witness,
AcirField,
};
use std::collections::{BTreeMap, HashSet};

Expand Down Expand Up @@ -163,12 +163,12 @@ mod tests {

use crate::compiler::optimizers::redundant_range::RangeOptimizer;
use acir::{
FieldElement,
circuit::{
opcodes::{BlackBoxFuncCall, FunctionInput},
Circuit, ExpressionWidth, Opcode, PublicInputs,
opcodes::{BlackBoxFuncCall, FunctionInput},
},
native_types::{Expression, Witness},
FieldElement,
};

fn test_circuit(ranges: Vec<(Witness, u32)>) -> Circuit<FieldElement> {
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/compiler/optimizers/unused_memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use acir::circuit::{brillig::BrilligInputs, opcodes::BlockId, Circuit, Opcode};
use acir::circuit::{Circuit, Opcode, brillig::BrilligInputs, opcodes::BlockId};
use std::collections::HashSet;

/// `UnusedMemoryOptimizer` will remove initializations of memory blocks which are unused.
Expand Down
6 changes: 3 additions & 3 deletions acvm-repo/acvm/src/compiler/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use acir::{
AcirField,
circuit::{
Circuit, Opcode,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlockId, FunctionInput},
Circuit, Opcode,
},
native_types::{Expression, Witness},
AcirField,
};
use std::collections::{BTreeSet, HashMap, HashSet};

Expand Down Expand Up @@ -215,10 +215,10 @@ mod tests {

use crate::compiler::CircuitSimulator;
use acir::{
FieldElement,
acir_field::AcirField,
circuit::{Circuit, ExpressionWidth, Opcode, PublicInputs},
native_types::{Expression, Witness},
FieldElement,
};

fn test_circuit(
Expand Down
Loading

0 comments on commit 10e4639

Please sign in to comment.