Skip to content

Commit c050764

Browse files
committed
[1 changes] fix: (LSP) only add cached files relevant to workspace (noir-lang/noir#5775)
chore: make spans non-optional on `UnresolvedType` (noir-lang/noir#5773)
1 parent 91042c7 commit c050764

File tree

260 files changed

+7375
-2975
lines changed

Some content is hidden

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

260 files changed

+7375
-2975
lines changed

.noir-sync-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0ebf1fee471641db0bffcc8307d20327613c78c1
1+
1958a7932642e2fa556a903a3186b142a70e3e48

noir/noir-repo/.github/workflows/gates_report.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
8181
- name: Compare gates reports
8282
id: gates_diff
83-
uses: vezenovm/noir-gates-diff@acf12797860f237117e15c0d6e08d64253af52b6
83+
uses: noir-lang/noir-gates-diff@1931aaaa848a1a009363d6115293f7b7fc72bb87
8484
with:
8585
report: gates_report.json
8686
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Report Brillig bytecode size 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/rust-toolchain@1.74.1
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+
compare_brillig_bytecode_size_reports:
46+
needs: [build-nargo]
47+
runs-on: ubuntu-latest
48+
permissions:
49+
pull-requests: write
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Download nargo binary
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: nargo
58+
path: ./nargo
59+
60+
- name: Set nargo on PATH
61+
run: |
62+
nargo_binary="${{ github.workspace }}/nargo/nargo"
63+
chmod +x $nargo_binary
64+
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
65+
export PATH="$PATH:$(dirname $nargo_binary)"
66+
nargo -V
67+
68+
- name: Generate Brillig bytecode size report
69+
working-directory: ./test_programs
70+
run: |
71+
chmod +x gates_report_brillig.sh
72+
./gates_report_brillig.sh
73+
mv gates_report_brillig.json ../gates_report_brillig.json
74+
75+
- name: Compare Brillig bytecode size reports
76+
id: brillig_bytecode_diff
77+
uses: noir-lang/noir-gates-diff@3fb844067b25d1b59727ea600b614503b33503f4
78+
with:
79+
report: gates_report_brillig.json
80+
header: |
81+
# Changes to Brillig bytecode sizes
82+
brillig_report: true
83+
summaryQuantile: 0.9 # only display the 10% most significant bytecode size diffs in the summary (defaults to 20%)
84+
85+
- name: Add bytecode size diff to sticky comment
86+
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
87+
uses: marocchino/sticky-pull-request-comment@v2
88+
with:
89+
header: brillig
90+
# delete the comment in case changes no longer impact brillig bytecode sizes
91+
delete: ${{ !steps.brillig_bytecode_diff.outputs.markdown }}
92+
message: ${{ steps.brillig_bytecode_diff.outputs.markdown }}

noir/noir-repo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ tooling/noir_js/lib
3333
!compiler/wasm/noir-script/target
3434

3535
gates_report.json
36+
gates_report_brillig.json
3637

3738
# Github Actions scratch space
3839
# This gives a location to download artifacts into the repository in CI without making git dirty.

noir/noir-repo/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

noir/noir-repo/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ rust-version = "1.74.1"
5050
license = "MIT OR Apache-2.0"
5151
repository = "https://github.com/noir-lang/noir/"
5252

53+
[workspace.lints.rust]
54+
trivial_casts = "warn"
55+
trivial_numeric_casts = "warn"
56+
unused_import_braces = "warn"
57+
unused_qualifications = "warn"
58+
5359
[workspace.dependencies]
5460

5561
# ACVM workspace dependencies

noir/noir-repo/acvm-repo/acir/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl ErrorSelector {
103103
impl Serialize for ErrorSelector {
104104
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
105105
where
106-
S: serde::Serializer,
106+
S: Serializer,
107107
{
108108
self.0.to_string().serialize(serializer)
109109
}
@@ -112,7 +112,7 @@ impl Serialize for ErrorSelector {
112112
impl<'de> Deserialize<'de> for ErrorSelector {
113113
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
114114
where
115-
D: serde::Deserializer<'de>,
115+
D: Deserializer<'de>,
116116
{
117117
let s: String = Deserialize::deserialize(deserializer)?;
118118
let as_u64 = s.parse().map_err(serde::de::Error::custom)?;
@@ -224,7 +224,7 @@ impl<F> Circuit<F> {
224224
}
225225

226226
impl<F: Serialize> Program<F> {
227-
fn write<W: std::io::Write>(&self, writer: W) -> std::io::Result<()> {
227+
fn write<W: Write>(&self, writer: W) -> std::io::Result<()> {
228228
let buf = bincode::serialize(self).unwrap();
229229
let mut encoder = flate2::write::GzEncoder::new(writer, Compression::default());
230230
encoder.write_all(&buf)?;
@@ -250,7 +250,7 @@ impl<F: Serialize> Program<F> {
250250
}
251251

252252
impl<F: for<'a> Deserialize<'a>> Program<F> {
253-
fn read<R: std::io::Read>(reader: R) -> std::io::Result<Self> {
253+
fn read<R: Read>(reader: R) -> std::io::Result<Self> {
254254
let mut gz_decoder = flate2::read::GzDecoder::new(reader);
255255
let mut buf_d = Vec::new();
256256
gz_decoder.read_to_end(&mut buf_d)?;

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ use super::{
22
brillig::{BrilligFunctionId, BrilligInputs, BrilligOutputs},
33
directives::Directive,
44
};
5+
6+
pub mod function_id;
7+
pub use function_id::AcirFunctionId;
8+
59
use crate::native_types::{Expression, Witness};
610
use acir_field::AcirField;
711
use serde::{Deserialize, Serialize};
@@ -125,7 +129,7 @@ pub enum Opcode<F> {
125129
Call {
126130
/// Id for the function being called. It is the responsibility of the executor
127131
/// to fetch the appropriate circuit from this id.
128-
id: u32,
132+
id: AcirFunctionId,
129133
/// Inputs to the function call
130134
inputs: Vec<Witness>,
131135
/// Outputs of the function call
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, Hash)]
4+
#[serde(transparent)]
5+
pub struct AcirFunctionId(pub u32);
6+
7+
impl AcirFunctionId {
8+
pub fn as_usize(&self) -> usize {
9+
self.0 as usize
10+
}
11+
}
12+
13+
impl std::fmt::Display for AcirFunctionId {
14+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15+
write!(f, "{}", self.0)
16+
}
17+
}

noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::collections::BTreeSet;
1414
use acir::{
1515
circuit::{
1616
brillig::{BrilligBytecode, BrilligFunctionId, BrilligInputs, BrilligOutputs},
17-
opcodes::{BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
17+
opcodes::{AcirFunctionId, BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
1818
Circuit, Opcode, Program, PublicInputs,
1919
},
2020
native_types::{Expression, Witness},
@@ -381,13 +381,13 @@ fn nested_acir_call_circuit() {
381381
// x
382382
// }
383383
let nested_call = Opcode::Call {
384-
id: 1,
384+
id: AcirFunctionId(1),
385385
inputs: vec![Witness(0), Witness(1)],
386386
outputs: vec![Witness(2)],
387387
predicate: None,
388388
};
389389
let nested_call_two = Opcode::Call {
390-
id: 1,
390+
id: AcirFunctionId(1),
391391
inputs: vec![Witness(0), Witness(1)],
392392
outputs: vec![Witness(3)],
393393
predicate: None,
@@ -419,7 +419,7 @@ fn nested_acir_call_circuit() {
419419
q_c: FieldElement::one() + FieldElement::one(),
420420
});
421421
let call = Opcode::Call {
422-
id: 2,
422+
id: AcirFunctionId(2),
423423
inputs: vec![Witness(2), Witness(1)],
424424
outputs: vec![Witness(3)],
425425
predicate: None,

noir/noir-repo/acvm-repo/acir_field/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

noir/noir-repo/acvm-repo/acir_field/src/field_element.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<F: PrimeField> From<i128> for FieldElement<F> {
115115
}
116116
}
117117

118-
impl<T: ark_ff::PrimeField> Serialize for FieldElement<T> {
118+
impl<T: PrimeField> Serialize for FieldElement<T> {
119119
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
120120
where
121121
S: serde::Serializer,
@@ -124,7 +124,7 @@ impl<T: ark_ff::PrimeField> Serialize for FieldElement<T> {
124124
}
125125
}
126126

127-
impl<'de, T: ark_ff::PrimeField> Deserialize<'de> for FieldElement<T> {
127+
impl<'de, T: PrimeField> Deserialize<'de> for FieldElement<T> {
128128
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
129129
where
130130
D: serde::Deserializer<'de>,

noir/noir-repo/acvm-repo/acir_field/src/generic_ark.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use num_bigint::BigUint;
22

33
/// This trait is extremely unstable and WILL have breaking changes.
44
pub trait AcirField:
5-
std::marker::Sized
5+
Sized
66
+ std::fmt::Display
77
+ std::fmt::Debug
88
+ Default
@@ -24,7 +24,7 @@ pub trait AcirField:
2424
// + From<u8>
2525
+ From<bool>
2626
+ std::hash::Hash
27-
+ std::cmp::Eq
27+
+ Eq
2828
{
2929
fn one() -> Self;
3030
fn zero() -> Self;

noir/noir-repo/acvm-repo/acvm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[dependencies]

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use acir::{
66
brillig::ForeignCallResult,
77
circuit::{
88
brillig::{BrilligBytecode, BrilligFunctionId},
9-
opcodes::{BlockId, ConstantOrWitnessEnum, FunctionInput},
9+
opcodes::{AcirFunctionId, BlockId, ConstantOrWitnessEnum, FunctionInput},
1010
AssertionPayload, ErrorSelector, ExpressionOrMemory, Opcode, OpcodeLocation,
1111
RawAssertionPayload, ResolvedAssertionPayload, STRING_ERROR_SELECTOR,
1212
},
@@ -575,7 +575,7 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
575575
else {
576576
unreachable!("Not executing a Call opcode");
577577
};
578-
if *id == 0 {
578+
if *id == AcirFunctionId(0) {
579579
return Err(OpcodeResolutionError::AcirMainCallAttempted {
580580
opcode_location: ErrorLocation::Resolved(OpcodeLocation::Acir(
581581
self.instruction_pointer(),
@@ -716,7 +716,7 @@ pub(crate) fn is_predicate_false<F: AcirField>(
716716
#[derive(Debug, Clone, PartialEq)]
717717
pub struct AcirCallWaitInfo<F> {
718718
/// Index in the list of ACIR function's that should be called
719-
pub id: u32,
719+
pub id: AcirFunctionId,
720720
/// Initial witness for the given circuit to be called
721721
pub initial_witness: WitnessMap<F>,
722722
}

noir/noir-repo/acvm-repo/acvm_js/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license.workspace = true
1010
rust-version.workspace = true
1111
repository.workspace = true
1212

13+
[lints]
14+
workspace = true
15+
1316
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1417

1518
[lib]

noir/noir-repo/acvm-repo/acvm_js/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function run_if_available {
2525
require_command jq
2626
require_command cargo
2727
require_command wasm-bindgen
28-
#require_command wasm-opt
28+
require_command wasm-opt
2929

3030
self_path=$(dirname "$(readlink -f "$0")")
3131
pname=$(cargo read-manifest | jq -r '.name')

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'a, B: BlackBoxFunctionSolver<FieldElement>> ProgramExecutor<'a, B> {
250250
acvm.resolve_pending_foreign_call(result);
251251
}
252252
ACVMStatus::RequiresAcirCall(call_info) => {
253-
let acir_to_call = &self.functions[call_info.id as usize];
253+
let acir_to_call = &self.functions[call_info.id.as_usize()];
254254
let initial_witness = call_info.initial_witness;
255255
let call_solved_witness = self
256256
.execute_circuit(acir_to_call, initial_witness, witness_stack)
@@ -267,7 +267,7 @@ impl<'a, B: BlackBoxFunctionSolver<FieldElement>> ProgramExecutor<'a, B> {
267267
}
268268
}
269269
acvm.resolve_pending_acir_call(call_resolved_outputs);
270-
witness_stack.push(call_info.id, call_solved_witness.clone());
270+
witness_stack.push(call_info.id.0, call_solved_witness.clone());
271271
}
272272
}
273273
}

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@ impl JsExecutionError {
5454
None => JsValue::UNDEFINED,
5555
};
5656
let assertion_payload = match assertion_payload {
57-
Some(raw) => <wasm_bindgen::JsValue as JsValueSerdeExt>::from_serde(&raw)
57+
Some(raw) => <JsValue as JsValueSerdeExt>::from_serde(&raw)
5858
.expect("Cannot serialize assertion payload"),
5959
None => JsValue::UNDEFINED,
6060
};
6161

6262
let brillig_function_id = match brillig_function_id {
63-
Some(function_id) => {
64-
<wasm_bindgen::JsValue as JsValueSerdeExt>::from_serde(&function_id)
65-
.expect("Cannot serialize Brillig function id")
66-
}
63+
Some(function_id) => <JsValue as JsValueSerdeExt>::from_serde(&function_id)
64+
.expect("Cannot serialize Brillig function id"),
6765
None => JsValue::UNDEFINED,
6866
};
6967

0 commit comments

Comments
 (0)