Skip to content

Commit 7522b3a

Browse files
authored
Merge branch 'master' into gd/issue_7272
2 parents e5de933 + cbbfc38 commit 7522b3a

File tree

21 files changed

+116
-73
lines changed

21 files changed

+116
-73
lines changed

.github/workflows/formatting.yml

+27
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ jobs:
6565
- name: Run `cargo fmt`
6666
run: cargo fmt --all --check
6767

68+
rustdoc:
69+
name: cargo doc
70+
runs-on: ubuntu-22.04
71+
timeout-minutes: 30
72+
env:
73+
RUSTDOCFLAGS: -Dwarnings
74+
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
79+
- name: Setup toolchain
80+
uses: dtolnay/rust-toolchain@1.85.0
81+
with:
82+
targets: x86_64-unknown-linux-gnu
83+
components: clippy, rustfmt
84+
85+
- uses: Swatinem/rust-cache@v2
86+
with:
87+
key: x86_64-unknown-linux-gnu
88+
cache-on-failure: true
89+
save-if: ${{ github.event_name != 'merge_group' }}
90+
91+
- name: Run `cargo doc`
92+
run: cargo doc --no-deps --document-private-items --workspace
93+
6894
eslint:
6995
name: eslint
7096
runs-on: ubuntu-22.04
@@ -143,6 +169,7 @@ jobs:
143169
needs:
144170
- clippy
145171
- rustfmt
172+
- rustdoc
146173
- eslint
147174
- nargo_fmt
148175

acvm-repo/acir/src/circuit/mod.rs

-22
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,6 @@ impl<'de> Deserialize<'de> for ErrorSelector {
123123
}
124124
}
125125

126-
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
127-
pub struct RawAssertionPayload<F> {
128-
pub selector: ErrorSelector,
129-
pub data: Vec<F>,
130-
}
131-
132-
#[derive(Clone, PartialEq, Eq, Debug)]
133-
pub enum ResolvedAssertionPayload<F> {
134-
String(String),
135-
Raw(RawAssertionPayload<F>),
136-
}
137-
138-
#[derive(Debug, Copy, Clone)]
139-
/// The opcode location for a call to a separate ACIR circuit
140-
/// This includes the function index of the caller within a [program][Program]
141-
/// and the index in the callers ACIR to the specific call opcode.
142-
/// This is only resolved and set during circuit execution.
143-
pub struct ResolvedOpcodeLocation {
144-
pub acir_function_index: usize,
145-
pub opcode_location: OpcodeLocation,
146-
}
147-
148126
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
149127
#[cfg_attr(feature = "arb", derive(proptest_derive::Arbitrary))]
150128
/// Opcodes are locatable so that callers can

acvm-repo/acvm/src/pwg/brillig.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use acir::{
44
AcirField,
55
brillig::{ForeignCallParam, ForeignCallResult, Opcode as BrilligOpcode},
66
circuit::{
7-
ErrorSelector, OpcodeLocation, RawAssertionPayload, ResolvedAssertionPayload,
7+
OpcodeLocation,
88
brillig::{BrilligFunctionId, BrilligInputs, BrilligOutputs},
99
opcodes::BlockId,
1010
},
@@ -16,7 +16,10 @@ use serde::{Deserialize, Serialize};
1616

1717
use crate::{OpcodeResolutionError, pwg::OpcodeNotSolvable};
1818

19-
use super::{get_value, insert_value, memory_op::MemoryOpSolver};
19+
use super::{
20+
ErrorSelector, RawAssertionPayload, ResolvedAssertionPayload, get_value, insert_value,
21+
memory_op::MemoryOpSolver,
22+
};
2023

2124
#[derive(Debug)]
2225
pub enum BrilligSolverStatus<F> {

acvm-repo/acvm/src/pwg/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use acir::{
77
brillig::ForeignCallResult,
88
circuit::{
99
AssertionPayload, ErrorSelector, ExpressionOrMemory, Opcode, OpcodeLocation,
10-
RawAssertionPayload, ResolvedAssertionPayload,
1110
brillig::{BrilligBytecode, BrilligFunctionId},
1211
opcodes::{
1312
AcirFunctionId, BlockId, ConstantOrWitnessEnum, FunctionInput, InvalidInputBitSize,
@@ -34,6 +33,7 @@ mod memory_op;
3433

3534
pub use self::brillig::{BrilligSolver, BrilligSolverStatus};
3635
pub use brillig::ForeignCallWaitInfo;
36+
use serde::{Deserialize, Serialize};
3737

3838
#[derive(Debug, Clone, PartialEq)]
3939
pub enum ACVMStatus<F> {
@@ -117,6 +117,18 @@ impl std::fmt::Display for ErrorLocation {
117117
}
118118
}
119119

120+
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
121+
pub struct RawAssertionPayload<F> {
122+
pub selector: ErrorSelector,
123+
pub data: Vec<F>,
124+
}
125+
126+
#[derive(Clone, PartialEq, Eq, Debug)]
127+
pub enum ResolvedAssertionPayload<F> {
128+
String(String),
129+
Raw(RawAssertionPayload<F>),
130+
}
131+
120132
#[derive(Clone, PartialEq, Eq, Debug, Error)]
121133
pub enum OpcodeResolutionError<F> {
122134
#[error("Cannot solve opcode: {0}")]

acvm-repo/acvm_js/src/execute.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::{future::Future, pin::Pin};
22

3-
use acvm::acir::circuit::ResolvedAssertionPayload;
43
use acvm::acir::circuit::brillig::BrilligBytecode;
54
use acvm::{BlackBoxFunctionSolver, FieldElement};
65
use acvm::{
76
acir::circuit::{Circuit, Program},
87
acir::native_types::{WitnessMap, WitnessStack},
9-
pwg::{ACVM, ACVMStatus, ErrorLocation, OpcodeResolutionError},
8+
pwg::{ACVM, ACVMStatus, ErrorLocation, OpcodeResolutionError, ResolvedAssertionPayload},
109
};
1110
use bn254_blackbox_solver::Bn254BlackBoxSolver;
1211

acvm-repo/acvm_js/src/js_execution_error.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use acvm::{
22
FieldElement,
3-
acir::circuit::{OpcodeLocation, RawAssertionPayload, brillig::BrilligFunctionId},
3+
acir::circuit::{OpcodeLocation, brillig::BrilligFunctionId},
4+
pwg::RawAssertionPayload,
45
};
56
use gloo_utils::format::JsValueSerdeExt;
67
use js_sys::{Array, Error, JsString, Reflect};

compiler/integration-tests/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "NODE_NO_WARNINGS=1 eslint . --max-warnings 0"
1414
},
1515
"dependencies": {
16-
"@aztec/bb.js": "0.77.1",
16+
"@aztec/bb.js": "0.81.0",
1717
"@noir-lang/noir_js": "workspace:*",
1818
"@noir-lang/noir_wasm": "workspace:*",
1919
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",

compiler/noirc_evaluator/src/acir/mod.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1392,22 +1392,21 @@ impl<'a> Context<'a> {
13921392
// Get operations to call-data parameters are replaced by a get to the call-data-bus array
13931393
let call_data =
13941394
self.data_bus.call_data.iter().find(|cd| cd.index_map.contains_key(&array)).cloned();
1395-
if let Some(call_data) = call_data {
1395+
let mut value = if let Some(call_data) = call_data {
13961396
let call_data_block = self.ensure_array_is_initialized(call_data.array_id, dfg)?;
13971397
let bus_index = self
13981398
.acir_context
13991399
.add_constant(FieldElement::from(call_data.index_map[&array] as i128));
14001400
let mut current_index = self.acir_context.add_var(bus_index, var_index)?;
1401-
let result = self.get_from_call_data(&mut current_index, call_data_block, &res_typ)?;
1402-
self.define_result(dfg, instruction, result.clone());
1403-
return Ok(result);
1404-
}
1405-
// Compiler sanity check
1406-
assert!(
1407-
!res_typ.contains_slice_element(),
1408-
"ICE: Nested slice result found during ACIR generation"
1409-
);
1410-
let mut value = self.array_get_value(&res_typ, block_id, &mut var_index)?;
1401+
self.get_from_call_data(&mut current_index, call_data_block, &res_typ)?
1402+
} else {
1403+
// Compiler sanity check
1404+
assert!(
1405+
!res_typ.contains_slice_element(),
1406+
"ICE: Nested slice result found during ACIR generation"
1407+
);
1408+
self.array_get_value(&res_typ, block_id, &mut var_index)?
1409+
};
14111410

14121411
if let AcirValue::Var(value_var, typ) = &value {
14131412
let array_typ = dfg.type_of_value(array);

examples/recursion/generate_recursive_proof.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ FULL_PROOF_AS_FIELDS="$($BACKEND prove -b ./target/sum.json -w ./target/sum_witn
1616

1717
echo $FULL_PROOF_AS_FIELDS | jq 'length'
1818
# sum has 3 public inputs
19-
PUBLIC_INPUTS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[3:6]')
20-
PROOF_AS_FIELDS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[:3] + .[6:]')
19+
PUBLIC_INPUTS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[:3]')
20+
PROOF_AS_FIELDS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[3:]')
2121

2222
RECURSE_LEAF_PROVER_TOML=./recurse_leaf/Prover.toml
2323
echo -n "" > $RECURSE_LEAF_PROVER_TOML
@@ -46,8 +46,8 @@ VK_AS_FIELDS=$(jq -r '.[0:]' ./target/recurse_leaf_vk_as_fields)
4646

4747
FULL_PROOF_AS_FIELDS="$($BACKEND prove -b ./target/recurse_leaf.json -w ./target/recurse_leaf_witness.gz --honk_recursion 1 --init_kzg_accumulator --output_format fields -o -)"
4848
# recurse_leaf has 4 public inputs (excluding aggregation object)
49-
PUBLIC_INPUTS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[3:7]')
50-
PROOF_AS_FIELDS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[:3] + .[7:]')
49+
PUBLIC_INPUTS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[:4]')
50+
PROOF_AS_FIELDS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[4:]')
5151

5252
RECURSE_NODE_PROVER_TOML=./recurse_node/Prover.toml
5353
echo -n "" > $RECURSE_NODE_PROVER_TOML

examples/recursion/recurse_leaf/src/main.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
global ULTRA_HONK_VK_SIZE: u32 = 128;
2-
global ULTRA_HONK_PROOF_SIZE: u32 = 459;
2+
global ULTRA_HONK_PROOF_SIZE: u32 = 456;
33
global NUM_NON_ACCUMULATOR_PUBLIC_INPUTS: u32 = 3;
44
global HONK_IDENTIFIER: u32 = 1;
55

examples/recursion/recurse_node/src/main.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
global ULTRA_HONK_VK_SIZE: u32 = 128;
2-
global ULTRA_HONK_PROOF_SIZE: u32 = 459; // Number of fields when recursion is enabled
2+
global ULTRA_HONK_PROOF_SIZE: u32 = 456; // Number of fields when recursion is enabled
33
global NUM_NON_ACCUMULATOR_PUBLIC_INPUTS: u32 = 4;
44
global HONK_IDENTIFIER: u32 = 1;
55

examples/solidity_verifier/solidity_verifier.sh

+4-7
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@ PROOF_HEX=$(cat $PROOF_PATH | od -An -v -t x1 | tr -d $' \n' | sed 's/^.\{8\}//'
2323

2424
NUM_PUBLIC_INPUTS=2
2525
PUBLIC_INPUT_HEX_CHARS=$((32 * $NUM_PUBLIC_INPUTS * 2)) # Each public input is 32 bytes, 2 chars per byte
26-
PUBLIC_INPUT_OFFSET_CHARS=$((96 * 2)) # First 96 bytes are the proof header
2726

28-
# Extract public inputs from proof - from 96th byte to 96 + 32 * NUM_PUBLIC_INPUTS bytes
29-
HEX_PUBLIC_INPUTS=${PROOF_HEX:$PUBLIC_INPUT_OFFSET_CHARS:$PUBLIC_INPUT_HEX_CHARS}
27+
# Extract public inputs from proof - first 32 * NUM_PUBLIC_INPUTS bytes
28+
HEX_PUBLIC_INPUTS=${PROOF_HEX:0:$PUBLIC_INPUT_HEX_CHARS}
3029
# Split public inputs into strings where each string represents a `bytes32`.
3130
SPLIT_HEX_PUBLIC_INPUTS=$(sed -e 's/.\{64\}/0x&,/g' <<<$HEX_PUBLIC_INPUTS)
3231

33-
# Extract proof without public inputs - from 0 to 96 bytes + the part after public inputs
34-
PROOF_WITHOUT_PUBLIC_INPUTS_START=${PROOF_HEX:0:$PUBLIC_INPUT_OFFSET_CHARS}
35-
PROOF_WITHOUT_PUBLIC_INPUTS_END=${PROOF_HEX:$(($PUBLIC_INPUT_OFFSET_CHARS + $PUBLIC_INPUT_HEX_CHARS))}
36-
PROOF_WITHOUT_PUBLIC_INPUTS="${PROOF_WITHOUT_PUBLIC_INPUTS_START}${PROOF_WITHOUT_PUBLIC_INPUTS_END}"
32+
# Extract proof without public inputs
33+
PROOF_WITHOUT_PUBLIC_INPUTS=${PROOF_HEX:$PUBLIC_INPUT_HEX_CHARS}
3734

3835
# Spin up an anvil node to deploy the contract to
3936
anvil &

scripts/install_bb.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
VERSION="0.77.1"
3+
VERSION="0.81.0"
44

55
BBUP_PATH=~/.bb/bbup
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "regression_7612"
3+
type = "bin"
4+
authors = [""]
5+
6+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
array = [{ counter = 8, fields = ["0x200000000"] }]
2+
x = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub struct Data {
2+
fields: [Field; 1],
3+
counter: u32,
4+
}
5+
6+
fn main(array: call_data(0) [Data; 1], x: bool) {
7+
let index = if x { 0 } else { 1 };
8+
if index != 0 {
9+
assert(array[index - 1].counter < 3);
10+
}
11+
}

tooling/nargo/src/errors.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ use std::collections::BTreeMap;
22

33
use acvm::{
44
AcirField, FieldElement,
5-
acir::circuit::{
6-
ErrorSelector, OpcodeLocation, RawAssertionPayload, ResolvedAssertionPayload,
7-
ResolvedOpcodeLocation, brillig::BrilligFunctionId,
8-
},
9-
pwg::{ErrorLocation, OpcodeResolutionError},
5+
acir::circuit::{ErrorSelector, OpcodeLocation, brillig::BrilligFunctionId},
6+
pwg::{ErrorLocation, OpcodeResolutionError, RawAssertionPayload, ResolvedAssertionPayload},
107
};
118
use noirc_abi::{Abi, AbiErrorType, display_abi_error};
129
use noirc_errors::{CustomDiagnostic, debug_info::DebugInfo, reporter::ReportedErrors};
@@ -86,6 +83,16 @@ impl<F: AcirField> NargoError<F> {
8683
}
8784
}
8885

86+
#[derive(Debug, Copy, Clone)]
87+
/// The opcode location for a call to a separate ACIR circuit
88+
/// This includes the function index of the caller within a [program][acvm::acir::circuit::Program]
89+
/// and the index in the callers ACIR to the specific call opcode.
90+
/// This is only resolved and set during circuit execution.
91+
pub struct ResolvedOpcodeLocation {
92+
pub acir_function_index: usize,
93+
pub opcode_location: OpcodeLocation,
94+
}
95+
8996
#[derive(Debug, Error)]
9097
pub enum ExecutionError<F: AcirField> {
9198
#[error("Failed assertion")]

tooling/nargo/src/ops/execute.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
use acvm::acir::circuit::brillig::BrilligBytecode;
2-
use acvm::acir::circuit::{
3-
OpcodeLocation, Program, ResolvedAssertionPayload, ResolvedOpcodeLocation,
4-
};
2+
use acvm::acir::circuit::{OpcodeLocation, Program};
53
use acvm::acir::native_types::WitnessStack;
64
use acvm::pwg::{
75
ACVM, ACVMStatus, ErrorLocation, OpcodeNotSolvable, OpcodeResolutionError, ProfilingSamples,
6+
ResolvedAssertionPayload,
87
};
98
use acvm::{AcirField, BlackBoxFunctionSolver};
109
use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap};
1110

1211
use crate::NargoError;
13-
use crate::errors::ExecutionError;
12+
use crate::errors::{ExecutionError, ResolvedOpcodeLocation};
1413
use crate::foreign_calls::ForeignCallExecutor;
1514

1615
struct ProgramExecutor<'a, F: AcirField, B: BlackBoxFunctionSolver<F>, E: ForeignCallExecutor<F>> {

tooling/nargo_cli/build.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ fn generate_execution_success_tests(test_file: &mut File, test_data_dir: &Path)
261261
String::new()
262262
};
263263
264+
// Remove any trailing newlines added by some editors
265+
let stdout = stdout.trim();
266+
let expected_stdout = expected_stdout.trim();
267+
264268
if stdout != expected_stdout {
265-
println!("stdout does not match expected output. Expected:\n{}\n\nActual:\n{}", stdout, expected_stdout);
269+
println!("stdout does not match expected output. Expected:\n{expected_stdout}\n\nActual:\n{stdout}");
266270
assert_eq!(stdout, expected_stdout);
267271
}
268272
"#

tooling/noirc_abi_wasm/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ use getrandom as _;
77

88
use acvm::{
99
FieldElement,
10-
acir::{
11-
circuit::RawAssertionPayload,
12-
native_types::{WitnessMap, WitnessStack},
13-
},
10+
acir::native_types::{WitnessMap, WitnessStack},
11+
pwg::RawAssertionPayload,
1412
};
1513
use iter_extended::try_btree_map;
1614
use noirc_abi::{

yarn.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ __metadata:
238238
languageName: node
239239
linkType: hard
240240

241-
"@aztec/bb.js@npm:0.77.1":
242-
version: 0.77.1
243-
resolution: "@aztec/bb.js@npm:0.77.1"
241+
"@aztec/bb.js@npm:0.81.0":
242+
version: 0.81.0
243+
resolution: "@aztec/bb.js@npm:0.81.0"
244244
dependencies:
245245
comlink: "npm:^4.4.1"
246246
commander: "npm:^12.1.0"
@@ -250,7 +250,7 @@ __metadata:
250250
tslib: "npm:^2.4.0"
251251
bin:
252252
bb.js: dest/node/main.js
253-
checksum: 10/fdfb27a52b326d5fc9c5119ce70bc8277fdccc8c7e5edcc7d4100904af25de3fffb59eb61cb3d0edbab9eac51555b86a81638946f1288d3b227566c7e6ad83a2
253+
checksum: 10/0ef05d95590f4126d1deca033f7443e89a66c3cd8985b93fe71a2c90a570e54085deb1ab67379de1c2c7ec32e9e75532f45b7e1df194fd056a4f070cfe822acd
254254
languageName: node
255255
linkType: hard
256256

@@ -18699,7 +18699,7 @@ __metadata:
1869918699
version: 0.0.0-use.local
1870018700
resolution: "integration-tests@workspace:compiler/integration-tests"
1870118701
dependencies:
18702-
"@aztec/bb.js": "npm:0.77.1"
18702+
"@aztec/bb.js": "npm:0.81.0"
1870318703
"@noir-lang/noir_js": "workspace:*"
1870418704
"@noir-lang/noir_wasm": "workspace:*"
1870518705
"@nomicfoundation/hardhat-chai-matchers": "npm:^2.0.8"

0 commit comments

Comments
 (0)