Skip to content

Commit 17f6e1d

Browse files
AztecBotTomAFrenchsirasistant
authored
feat: Sync from noir (#6631)
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE feat: Consider block parameters in variable liveness (noir-lang/noir#5097) chore(docs): Link to evmdiff for supported EVM chains (noir-lang/noir#5107) chore: Avoid creating witness for simple multiplications (noir-lang/noir#5100) feat: Add intrinsic to get if running inside an unconstrained context (noir-lang/noir#5098) chore: Move turbofish changes to the elaborator (noir-lang/noir#5094) fix: Apply self type from generic trait constraint before instantiating identifiers (noir-lang/noir#5087) chore: reactivate gates report (noir-lang/noir#5084) chore: automatically clear any unwanted directories in `test_programs` (noir-lang/noir#5081) chore: update `nargo info` table to remove circuit size column feat: Activate return_data in ACIR opcodes (noir-lang/noir#5080) fix: Use plain integer addresses for opcodes in DAP disassembly view (noir-lang/noir#4941) chore(experimental): Elaborate globals (noir-lang/noir#5069) chore(experimental): Add types and traits to the elaborator (noir-lang/noir#5066) feat: remove conditional compilation of `bn254_blackbox_solver` (noir-lang/noir#5058) chore: use `bbup` to install `bb` (noir-lang/noir#5073) feat: Sync from aztec-packages (noir-lang/noir#5070) chore: update docs to represent zksync supporting necessary precompiles (noir-lang/noir#5071) feat(stdlib)!: eddsa function using turbofish (noir-lang/noir#5050) fix(frontend): Correctly monomorphize turbofish functions (noir-lang/noir#5049) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <[email protected]> Co-authored-by: sirasistant <[email protected]>
1 parent 523905f commit 17f6e1d

File tree

85 files changed

+1492
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1492
-658
lines changed

.noir-sync-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
89846cfbc4961c5258d91b5973f027be80885a20
1+
e4eb5f539f377fd3c2e1a874707ffce62a5bc10a

noir/Earthfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ examples:
6060

6161
ENV BACKEND=/usr/src/barretenberg/cpp/build/bin/bb
6262

63-
WORKDIR noir-repo/examples/codegen-verifier
63+
WORKDIR noir-repo/examples/codegen_verifier
6464
RUN ./test.sh
6565

6666
WORKDIR ../prove_and_verify
Lines changed: 93 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,94 @@
1-
# name: Report gates diff
2-
3-
# on:
4-
# push:
5-
# branches:
6-
# - master
7-
# pull_request:
8-
9-
# jobs:
10-
# build-nargo:
11-
# runs-on: ubuntu-latest
12-
# strategy:
13-
# matrix:
14-
# target: [x86_64-unknown-linux-gnu]
15-
16-
# steps:
17-
# - name: Checkout Noir repo
18-
# uses: actions/checkout@v4
19-
20-
# - name: Setup toolchain
21-
# uses: dtolnay/[email protected]
22-
23-
# - uses: Swatinem/rust-cache@v2
24-
# with:
25-
# key: ${{ matrix.target }}
26-
# cache-on-failure: true
27-
# save-if: ${{ github.event_name != 'merge_group' }}
28-
29-
# - name: Build Nargo
30-
# run: cargo build --package nargo_cli --release
31-
32-
# - name: Package artifacts
33-
# run: |
34-
# mkdir dist
35-
# cp ./target/release/nargo ./dist/nargo
36-
# 7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz
37-
38-
# - name: Upload artifact
39-
# uses: actions/upload-artifact@v4
40-
# with:
41-
# name: nargo
42-
# path: ./dist/*
43-
# retention-days: 3
44-
45-
46-
# compare_gas_reports:
47-
# needs: [build-nargo]
48-
# runs-on: ubuntu-latest
49-
# permissions:
50-
# pull-requests: write
51-
52-
# steps:
53-
# - uses: actions/checkout@v4
54-
55-
# - name: Download nargo binary
56-
# uses: actions/download-artifact@v4
57-
# with:
58-
# name: nargo
59-
# path: ./nargo
60-
61-
# - name: Set nargo on PATH
62-
# run: |
63-
# nargo_binary="${{ github.workspace }}/nargo/nargo"
64-
# chmod +x $nargo_binary
65-
# echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
66-
# export PATH="$PATH:$(dirname $nargo_binary)"
67-
# nargo -V
68-
69-
# - name: Generate gates report
70-
# working-directory: ./test_programs
71-
# run: |
72-
# ./gates_report.sh
73-
# mv gates_report.json ../gates_report.json
1+
name: Report gates diff
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
build-nargo:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
target: [x86_64-unknown-linux-gnu]
15+
16+
steps:
17+
- name: Checkout Noir repo
18+
uses: actions/checkout@v4
19+
20+
- name: Setup toolchain
21+
uses: dtolnay/[email protected]
22+
23+
- uses: Swatinem/rust-cache@v2
24+
with:
25+
key: ${{ matrix.target }}
26+
cache-on-failure: true
27+
save-if: ${{ github.event_name != 'merge_group' }}
28+
29+
- name: Build Nargo
30+
run: cargo build --package nargo_cli --release
31+
32+
- name: Package artifacts
33+
run: |
34+
mkdir dist
35+
cp ./target/release/nargo ./dist/nargo
36+
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz
37+
38+
- name: Upload artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: nargo
42+
path: ./dist/*
43+
retention-days: 3
44+
45+
46+
compare_gates_reports:
47+
needs: [build-nargo]
48+
runs-on: ubuntu-latest
49+
permissions:
50+
pull-requests: write
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install `bb`
56+
run: |
57+
./scripts/install_bb.sh
58+
echo "$HOME/.bb/" >> $GITHUB_PATH
59+
60+
- name: Download nargo binary
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: nargo
64+
path: ./nargo
65+
66+
- name: Set nargo on PATH
67+
run: |
68+
nargo_binary="${{ github.workspace }}/nargo/nargo"
69+
chmod +x $nargo_binary
70+
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
71+
export PATH="$PATH:$(dirname $nargo_binary)"
72+
nargo -V
73+
74+
- name: Generate gates report
75+
working-directory: ./test_programs
76+
run: |
77+
./rebuild.sh
78+
./gates_report.sh
79+
mv gates_report.json ../gates_report.json
7480
75-
# - name: Compare gates reports
76-
# id: gates_diff
77-
# uses: vezenovm/noir-gates-diff@acf12797860f237117e15c0d6e08d64253af52b6
78-
# with:
79-
# report: gates_report.json
80-
# summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
81-
82-
# - name: Add gates diff to sticky comment
83-
# if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
84-
# uses: marocchino/sticky-pull-request-comment@v2
85-
# with:
86-
# # delete the comment in case changes no longer impact circuit sizes
87-
# delete: ${{ !steps.gates_diff.outputs.markdown }}
88-
# message: ${{ steps.gates_diff.outputs.markdown }}
81+
- name: Compare gates reports
82+
id: gates_diff
83+
uses: vezenovm/noir-gates-diff@acf12797860f237117e15c0d6e08d64253af52b6
84+
with:
85+
report: gates_report.json
86+
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
87+
88+
- name: Add gates diff to sticky comment
89+
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
90+
uses: marocchino/sticky-pull-request-comment@v2
91+
with:
92+
# delete the comment in case changes no longer impact circuit sizes
93+
delete: ${{ !steps.gates_diff.outputs.markdown }}
94+
message: ${{ steps.gates_diff.outputs.markdown }}

noir/noir-repo/.github/workflows/test-js-packages.yml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ jobs:
399399
- name: Checkout
400400
uses: actions/checkout@v4
401401

402-
- name: Download bb binary
402+
- name: Install `bb`
403403
run: |
404-
# Adds `bb` to PATH
405404
./scripts/install_bb.sh
405+
echo "$HOME/.bb/" >> $GITHUB_PATH
406406
407407
- name: Download nargo binary
408408
uses: actions/download-artifact@v4
@@ -453,7 +453,7 @@ jobs:
453453
test-integration-browser:
454454
name: Integration Tests (Browser)
455455
runs-on: ubuntu-latest
456-
needs: [build-acvm-js, build-noir-wasm, build-nargo, build-noirc-abi]
456+
needs: [build-acvm-js, build-noir-wasm, build-noirc-abi]
457457
timeout-minutes: 30
458458

459459
steps:
@@ -495,6 +495,46 @@ jobs:
495495
run: |
496496
yarn test:browser
497497
498+
test-examples:
499+
name: Example scripts
500+
runs-on: ubuntu-latest
501+
needs: [build-nargo]
502+
timeout-minutes: 30
503+
504+
steps:
505+
- name: Checkout
506+
uses: actions/checkout@v4
507+
508+
- name: Install Foundry
509+
uses: foundry-rs/[email protected]
510+
511+
- name: Install `bb`
512+
run: |
513+
./scripts/install_bb.sh
514+
echo "$HOME/.bb/" >> $GITHUB_PATH
515+
516+
- name: Download nargo binary
517+
uses: actions/download-artifact@v4
518+
with:
519+
name: nargo
520+
path: ./nargo
521+
522+
- name: Set nargo on PATH
523+
run: |
524+
nargo_binary="${{ github.workspace }}/nargo/nargo"
525+
chmod +x $nargo_binary
526+
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
527+
export PATH="$PATH:$(dirname $nargo_binary)"
528+
nargo -V
529+
530+
- name: Run `prove_and_verify`
531+
working-directory: ./examples/prove_and_verify
532+
run: ./test.sh
533+
534+
- name: Run `codegen_verifier`
535+
working-directory: ./examples/codegen_verifier
536+
run: ./test.sh
537+
498538
# This is a job which depends on all test jobs and reports the overall status.
499539
# This allows us to add/remove test jobs without having to update the required workflows.
500540
tests-end:
@@ -512,6 +552,7 @@ jobs:
512552
- test-noir-codegen
513553
- test-integration-node
514554
- test-integration-browser
555+
- test-examples
515556

516557
steps:
517558
- name: Report overall success

noir/noir-repo/acvm-repo/acir/src/circuit/opcodes.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ pub enum BlockType {
1818
ReturnData,
1919
}
2020

21+
impl BlockType {
22+
pub fn is_databus(&self) -> bool {
23+
matches!(self, BlockType::CallData | BlockType::ReturnData)
24+
}
25+
}
26+
2127
#[allow(clippy::large_enum_variant)]
2228
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
2329
pub enum Opcode {

noir/noir-repo/acvm-repo/acvm/src/compiler/optimizers/unused_memory.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ impl UnusedMemoryOptimizer {
4444
let mut optimized_opcodes = Vec::with_capacity(self.circuit.opcodes.len());
4545
for (idx, opcode) in self.circuit.opcodes.into_iter().enumerate() {
4646
match opcode {
47-
Opcode::MemoryInit { block_id, .. }
48-
if self.unused_memory_initializations.contains(&block_id) =>
47+
Opcode::MemoryInit { block_id, block_type, .. }
48+
if !block_type.is_databus()
49+
&& self.unused_memory_initializations.contains(&block_id) =>
4950
{
5051
// Drop opcode
5152
}

noir/noir-repo/acvm-repo/acvm/src/compiler/transformers/csat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,16 @@ impl CSatTransformer {
210210
}
211211
} else {
212212
// No more usable elements left in the old opcode
213-
opcode.linear_combinations = remaining_linear_terms;
214213
break;
215214
}
216215
}
216+
opcode.linear_combinations.extend(remaining_linear_terms);
217+
217218
// Constraint this intermediate_opcode to be equal to the temp variable by adding it into the IndexMap
218219
// We need a unique name for our intermediate variable
219220
// XXX: Another optimization, which could be applied in another algorithm
220221
// If two opcodes have a large fan-in/out and they share a few common terms, then we should create intermediate variables for them
221222
// Do some sort of subset matching algorithm for this on the terms of the polynomial
222-
223223
let inter_var = Self::get_or_create_intermediate_vars(
224224
intermediate_variables,
225225
intermediate_opcode,

noir/noir-repo/acvm-repo/acvm_js/src/execute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ async fn execute_program_with_native_program_and_return(
117117
initial_witness: JsWitnessMap,
118118
foreign_call_executor: &ForeignCallHandler,
119119
) -> Result<WitnessStack, Error> {
120-
let solver = Bn254BlackBoxSolver::initialize().await;
120+
let blackbox_solver = Bn254BlackBoxSolver;
121121
let executor = ProgramExecutor::new(
122122
&program.functions,
123123
&program.unconstrained_functions,
124-
&solver,
124+
&blackbox_solver,
125125
foreign_call_executor,
126126
);
127127
let witness_stack = executor.execute(initial_witness.into()).await?;

noir/noir-repo/acvm-repo/bn254_blackbox_solver/benches/criterion.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ fn bench_poseidon2(c: &mut Criterion) {
1515

1616
fn bench_pedersen_commitment(c: &mut Criterion) {
1717
let inputs = [FieldElement::one(); 2];
18-
let solver = Bn254BlackBoxSolver::new();
1918

2019
c.bench_function("pedersen_commitment", |b| {
21-
b.iter(|| solver.pedersen_commitment(black_box(&inputs), 0))
20+
b.iter(|| Bn254BlackBoxSolver.pedersen_commitment(black_box(&inputs), 0))
2221
});
2322
}
2423

2524
fn bench_pedersen_hash(c: &mut Criterion) {
2625
let inputs = [FieldElement::one(); 2];
27-
let solver = Bn254BlackBoxSolver::new();
2826

29-
c.bench_function("pedersen_hash", |b| b.iter(|| solver.pedersen_hash(black_box(&inputs), 0)));
27+
c.bench_function("pedersen_hash", |b| {
28+
b.iter(|| Bn254BlackBoxSolver.pedersen_hash(black_box(&inputs), 0))
29+
});
3030
}
3131

3232
fn bench_schnorr_verify(c: &mut Criterion) {
33-
let solver = Bn254BlackBoxSolver::new();
34-
3533
let pub_key_x = FieldElement::from_hex(
3634
"0x04b260954662e97f00cab9adb773a259097f7a274b83b113532bce27fa3fb96a",
3735
)
@@ -51,7 +49,7 @@ fn bench_schnorr_verify(c: &mut Criterion) {
5149

5250
c.bench_function("schnorr_verify", |b| {
5351
b.iter(|| {
54-
solver.schnorr_verify(
52+
Bn254BlackBoxSolver.schnorr_verify(
5553
black_box(&pub_key_x),
5654
black_box(&pub_key_y),
5755
black_box(&sig_bytes),

noir/noir-repo/acvm-repo/bn254_blackbox_solver/src/lib.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,9 @@ use ark_ec::AffineRepr;
1515
pub use embedded_curve_ops::{embedded_curve_add, multi_scalar_mul};
1616
pub use poseidon2::poseidon2_permutation;
1717

18+
#[derive(Default)]
1819
pub struct Bn254BlackBoxSolver;
1920

20-
impl Bn254BlackBoxSolver {
21-
pub async fn initialize() -> Bn254BlackBoxSolver {
22-
Bn254BlackBoxSolver
23-
}
24-
25-
#[cfg(not(target_arch = "wasm32"))]
26-
pub fn new() -> Bn254BlackBoxSolver {
27-
Bn254BlackBoxSolver
28-
}
29-
}
30-
31-
#[cfg(not(target_arch = "wasm32"))]
32-
impl Default for Bn254BlackBoxSolver {
33-
fn default() -> Self {
34-
Self::new()
35-
}
36-
}
37-
3821
impl BlackBoxFunctionSolver for Bn254BlackBoxSolver {
3922
fn schnorr_verify(
4023
&self,

0 commit comments

Comments
 (0)