Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
826b18a10630471c19c25ab745f9bfe045813e69
a5b47df4d7c1da746f5377f9c1d35b5a06ea5648
18 changes: 9 additions & 9 deletions noir/noir-repo/.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
2 changes: 2 additions & 0 deletions noir/noir-repo/.github/workflows/publish-nargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
cargo build --package nargo_cli --release --target ${{ matrix.target }} --no-default-features --features "${{ inputs.features }}"
cargo build --package noir_profiler --release --target ${{ matrix.target }} --no-default-features --features "${{ inputs.features }}"
cargo build --package noir_inspector --release --target ${{ matrix.target }} --no-default-features --features "${{ inputs.features }}"

- name: Package artifacts
run: |
mkdir dist
Expand Down Expand Up @@ -237,3 +238,4 @@ jobs:
overwrite: true
tag: ${{ format('{0}-{1}', 'nightly', steps.date.outputs.date) }}


3 changes: 3 additions & 0 deletions noir/noir-repo/.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
4 changes: 2 additions & 2 deletions noir/noir-repo/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
20 changes: 16 additions & 4 deletions noir/noir-repo/acvm-repo/acir/src/native_types/witness_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
47 changes: 46 additions & 1 deletion noir/noir-repo/acvm-repo/acvm/src/pwg/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,52 @@ mod tests {
use acir::FieldElement;

#[test]
fn expression_solver_smoke_test() {
fn solves_simple_assignment() {
let a = Witness(0);

// a - 1 == 0;
let opcode_a = Expression {
mul_terms: vec![],
linear_combinations: vec![(FieldElement::one(), a)],
q_c: -FieldElement::one(),
};

let mut values = WitnessMap::new();
assert_eq!(ExpressionSolver::solve(&mut values, &opcode_a), Ok(()));

assert_eq!(values.get(&a).unwrap(), &FieldElement::from(1_i128));
}

#[test]
fn solves_unknown_in_mul_term() {
let a = Witness(0);
let b = Witness(1);
let c = Witness(2);
let d = Witness(3);

// a * b - b - c - d == 0;
let opcode_a = Expression {
mul_terms: vec![(FieldElement::one(), a, b)],
linear_combinations: vec![
(-FieldElement::one(), b),
(-FieldElement::one(), c),
(-FieldElement::one(), d),
],
q_c: FieldElement::zero(),
};

let mut values = WitnessMap::new();
values.insert(b, FieldElement::from(2_i128));
values.insert(c, FieldElement::from(1_i128));
values.insert(d, FieldElement::from(1_i128));

assert_eq!(ExpressionSolver::solve(&mut values, &opcode_a), Ok(()));

assert_eq!(values.get(&a).unwrap(), &FieldElement::from(2_i128));
}

#[test]
fn solves_unknown_in_linear_term() {
let a = Witness(0);
let b = Witness(1);
let c = Witness(2);
Expand Down
9 changes: 4 additions & 5 deletions noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ pub(crate) fn solve_poseidon2_permutation_opcode<F: AcirField>(
}

// Read witness assignments
let mut state = Vec::new();
for input in inputs.iter() {
let witness_assignment = input_to_value(initial_witness, *input, false)?;
state.push(witness_assignment);
}
let state: Vec<F> = inputs
.iter()
.map(|input| input_to_value(initial_witness, *input, false))
.collect::<Result<_, _>>()?;

let state = backend.poseidon2_permutation(&state, len)?;

Expand Down
33 changes: 33 additions & 0 deletions noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,36 @@ pub(crate) fn solve_range_opcode<F: AcirField>(
}
Ok(())
}

#[cfg(test)]
mod tests {
use std::collections::BTreeMap;

use acir::{
FieldElement,
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
};

use crate::pwg::blackbox::solve_range_opcode;

#[test]
fn rejects_too_large_inputs() {
let witness_map =
WitnessMap::from(BTreeMap::from([(Witness(0), FieldElement::from(256u32))]));
let input: FunctionInput<FieldElement> = FunctionInput::witness(Witness(0), 8);
assert!(solve_range_opcode(&witness_map, &input, false).is_err());
}

#[test]
fn accepts_valid_inputs() {
let values: [u32; 4] = [0, 1, 8, 255];

for value in values {
let witness_map =
WitnessMap::from(BTreeMap::from([(Witness(0), FieldElement::from(value))]));
let input: FunctionInput<FieldElement> = FunctionInput::witness(Witness(0), 8);
assert!(solve_range_opcode(&witness_map, &input, false).is_ok());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub trait BlackBoxFunctionSolver<F> {
) -> Result<(F, F, F), BlackBoxResolutionError>;
fn poseidon2_permutation(
&self,
_inputs: &[F],
_len: u32,
inputs: &[F],
len: u32,
) -> Result<Vec<F>, BlackBoxResolutionError>;
}

Expand Down
Loading