Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sync from noir #8008

Merged
merged 29 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9aca22f
[1 changes] chore: split LSP completion.rs into several files (https:…
AztecBot Aug 15, 2024
9346baa
chore: apply sync fixes
AztecBot Aug 15, 2024
c1e585e
[1 changes] feat: suggest trait methods in LSP completion (https://gi…
AztecBot Aug 16, 2024
e6354cf
chore: apply sync fixes
AztecBot Aug 16, 2024
76e6166
feat: suggest trait methods in LSP completion (https://github.com/noi…
AztecBot Aug 16, 2024
f446a2b
[1 changes] feat: LSP auto-import completion (https://github.com/noir…
AztecBot Aug 17, 2024
f988fa7
chore: apply sync fixes
AztecBot Aug 17, 2024
e011546
feat: LSP auto-import completion (https://github.com/noir-lang/noir/p…
AztecBot Aug 17, 2024
eb12a64
[1 changes] feat: LSP auto-import completion (https://github.com/noir…
AztecBot Aug 18, 2024
a06ae44
chore: apply sync fixes
AztecBot Aug 18, 2024
0aefb87
feat: LSP auto-import completion (https://github.com/noir-lang/noir/p…
AztecBot Aug 18, 2024
912174b
[1 changes] feat: LSP auto-import completion (https://github.com/noir…
AztecBot Aug 19, 2024
31df5b5
chore: apply sync fixes
AztecBot Aug 19, 2024
f2295c6
feat: LSP auto-import completion (https://github.com/noir-lang/noir/p…
AztecBot Aug 19, 2024
17f026f
Merge remote-tracking branch 'origin/master' into sync-noir
ludamad Aug 19, 2024
8abb411
Fix after merge
asterite Aug 19, 2024
b62b53a
nargo fmt
asterite Aug 19, 2024
55baef2
zeroed moved to another module
asterite Aug 19, 2024
bdc0c65
Fix more usages of zeroed
asterite Aug 19, 2024
babc7b9
[1 changes] feat: user `super::` in LSP autocompletion if possible (h…
AztecBot Aug 20, 2024
551576d
chore: apply sync fixes
AztecBot Aug 20, 2024
173225e
feat: user `super::` in LSP autocompletion if possible (https://githu…
AztecBot Aug 20, 2024
7e37bfd
fmt verify_honk_proof
vezenovm Aug 20, 2024
6946f7f
[1 changes] feat(optimization): Follow past `array_set`s when optimiz…
AztecBot Aug 20, 2024
dfbd8b1
chore: apply sync fixes
AztecBot Aug 20, 2024
8e40f4a
feat(optimization): Follow past `array_set`s when optimizing `array_g…
AztecBot Aug 20, 2024
7fd99bb
upda BITSIZE_TOO_BIG_ERROR
vezenovm Aug 20, 2024
7a3d288
Merge branch 'master' into sync-noir
vezenovm Aug 20, 2024
9303436
.
TomAFrench Aug 20, 2024
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 @@
4ea25dbde87488e758139619a3ce4edf93c6ebd6
090501dfaf7c569b1aa944856bf68ad663572ae4
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::state_vars::{
shared_mutable::{scheduled_value_change::ScheduledValueChange, scheduled_delay_change::ScheduledDelayChange}
};
use crate::oracle::storage::storage_read;
use dep::std::unsafe::zeroed;
use dep::std::mem::zeroed;

mod test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
};

use dep::protocol_types::address::AztecAddress;
use dep::std::{test::OracleMock, unsafe::zeroed};
use dep::std::{test::OracleMock, mem::zeroed};

global new_value = 17;

Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/utils/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn verify_collapse_hints<T, let N: u32>(
} else {
// BoundedVec assumes that the unused parts of the storage are zeroed out (e.g. in the Eq impl), so we make
// sure that this property holds.
assert_eq(collapsed.get_unchecked(i), std::unsafe::zeroed(), "Dirty collapsed vec storage");
assert_eq(collapsed.get_unchecked(i), std::mem::zeroed(), "Dirty collapsed vec storage");
}
}
// We now know that:
Expand Down
2 changes: 1 addition & 1 deletion noir/noir-repo/.github/workflows/gates_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:

- name: Compare gates reports
id: gates_diff
uses: vezenovm/noir-gates-diff@acf12797860f237117e15c0d6e08d64253af52b6
uses: noir-lang/noir-gates-diff@1931aaaa848a1a009363d6115293f7b7fc72bb87
with:
report: gates_report.json
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
Expand Down
92 changes: 92 additions & 0 deletions noir/noir-repo/.github/workflows/gates_report_brillig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Report Brillig bytecode size diff

on:
push:
branches:
- master
pull_request:

jobs:
build-nargo:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]

steps:
- name: Checkout Noir repo
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/[email protected]

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}

- name: Build Nargo
run: cargo build --package nargo_cli --release

- name: Package artifacts
run: |
mkdir dist
cp ./target/release/nargo ./dist/nargo
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nargo
path: ./dist/*
retention-days: 3

compare_brillig_bytecode_size_reports:
needs: [build-nargo]
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- uses: actions/checkout@v4

- name: Download nargo binary
uses: actions/download-artifact@v4
with:
name: nargo
path: ./nargo

- name: Set nargo on PATH
run: |
nargo_binary="${{ github.workspace }}/nargo/nargo"
chmod +x $nargo_binary
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
export PATH="$PATH:$(dirname $nargo_binary)"
nargo -V

- name: Generate Brillig bytecode size report
working-directory: ./test_programs
run: |
chmod +x gates_report_brillig.sh
./gates_report_brillig.sh
mv gates_report_brillig.json ../gates_report_brillig.json

- name: Compare Brillig bytecode size reports
id: brillig_bytecode_diff
uses: noir-lang/noir-gates-diff@3fb844067b25d1b59727ea600b614503b33503f4
with:
report: gates_report_brillig.json
header: |
# Changes to Brillig bytecode sizes
brillig_report: true
summaryQuantile: 0.9 # only display the 10% most significant bytecode size diffs in the summary (defaults to 20%)

- name: Add bytecode size diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: brillig
# delete the comment in case changes no longer impact brillig bytecode sizes
delete: ${{ !steps.brillig_bytecode_diff.outputs.markdown }}
message: ${{ steps.brillig_bytecode_diff.outputs.markdown }}
1 change: 1 addition & 0 deletions noir/noir-repo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tooling/noir_js/lib
!compiler/wasm/noir-script/target

gates_report.json
gates_report_brillig.json

# Github Actions scratch space
# This gives a location to download artifacts into the repository in CI without making git dirty.
Expand Down
1 change: 1 addition & 0 deletions noir/noir-repo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions noir/noir-repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ rust-version = "1.74.1"
license = "MIT OR Apache-2.0"
repository = "https://github.com/noir-lang/noir/"

[workspace.lints.rust]
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_import_braces = "warn"
unused_qualifications = "warn"

[workspace.dependencies]

# ACVM workspace dependencies
Expand Down
3 changes: 3 additions & 0 deletions noir/noir-repo/acvm-repo/acir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license.workspace = true
rust-version.workspace = true
repository.workspace = true

[lints]
workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
8 changes: 4 additions & 4 deletions noir/noir-repo/acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl ErrorSelector {
impl Serialize for ErrorSelector {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
S: Serializer,
{
self.0.to_string().serialize(serializer)
}
Expand All @@ -112,7 +112,7 @@ impl Serialize for ErrorSelector {
impl<'de> Deserialize<'de> for ErrorSelector {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
D: Deserializer<'de>,
{
let s: String = Deserialize::deserialize(deserializer)?;
let as_u64 = s.parse().map_err(serde::de::Error::custom)?;
Expand Down Expand Up @@ -224,7 +224,7 @@ impl<F> Circuit<F> {
}

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

impl<F: for<'a> Deserialize<'a>> Program<F> {
fn read<R: std::io::Read>(reader: R) -> std::io::Result<Self> {
fn read<R: Read>(reader: R) -> std::io::Result<Self> {
let mut gz_decoder = flate2::read::GzDecoder::new(reader);
let mut buf_d = Vec::new();
gz_decoder.read_to_end(&mut buf_d)?;
Expand Down
6 changes: 5 additions & 1 deletion noir/noir-repo/acvm-repo/acir/src/circuit/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ use super::{
brillig::{BrilligFunctionId, BrilligInputs, BrilligOutputs},
directives::Directive,
};

pub mod function_id;
pub use function_id::AcirFunctionId;

use crate::native_types::{Expression, Witness};
use acir_field::AcirField;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -125,7 +129,7 @@ pub enum Opcode<F> {
Call {
/// Id for the function being called. It is the responsibility of the executor
/// to fetch the appropriate circuit from this id.
id: u32,
id: AcirFunctionId,
/// Inputs to the function call
inputs: Vec<Witness>,
/// Outputs of the function call
Expand Down
17 changes: 17 additions & 0 deletions noir/noir-repo/acvm-repo/acir/src/circuit/opcodes/function_id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, Hash)]
#[serde(transparent)]
pub struct AcirFunctionId(pub u32);

impl AcirFunctionId {
pub fn as_usize(&self) -> usize {
self.0 as usize
}
}

impl std::fmt::Display for AcirFunctionId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::collections::BTreeSet;
use acir::{
circuit::{
brillig::{BrilligBytecode, BrilligFunctionId, BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
opcodes::{AcirFunctionId, BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
Circuit, Opcode, Program, PublicInputs,
},
native_types::{Expression, Witness},
Expand Down Expand Up @@ -381,13 +381,13 @@ fn nested_acir_call_circuit() {
// x
// }
let nested_call = Opcode::Call {
id: 1,
id: AcirFunctionId(1),
inputs: vec![Witness(0), Witness(1)],
outputs: vec![Witness(2)],
predicate: None,
};
let nested_call_two = Opcode::Call {
id: 1,
id: AcirFunctionId(1),
inputs: vec![Witness(0), Witness(1)],
outputs: vec![Witness(3)],
predicate: None,
Expand Down Expand Up @@ -419,7 +419,7 @@ fn nested_acir_call_circuit() {
q_c: FieldElement::one() + FieldElement::one(),
});
let call = Opcode::Call {
id: 2,
id: AcirFunctionId(2),
inputs: vec![Witness(2), Witness(1)],
outputs: vec![Witness(3)],
predicate: None,
Expand Down
3 changes: 3 additions & 0 deletions noir/noir-repo/acvm-repo/acir_field/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license.workspace = true
rust-version.workspace = true
repository.workspace = true

[lints]
workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions noir/noir-repo/acvm-repo/acir_field/src/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<F: PrimeField> From<i128> for FieldElement<F> {
}
}

impl<T: ark_ff::PrimeField> Serialize for FieldElement<T> {
impl<T: PrimeField> Serialize for FieldElement<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -124,7 +124,7 @@ impl<T: ark_ff::PrimeField> Serialize for FieldElement<T> {
}
}

impl<'de, T: ark_ff::PrimeField> Deserialize<'de> for FieldElement<T> {
impl<'de, T: PrimeField> Deserialize<'de> for FieldElement<T> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down
4 changes: 2 additions & 2 deletions noir/noir-repo/acvm-repo/acir_field/src/generic_ark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use num_bigint::BigUint;

/// This trait is extremely unstable and WILL have breaking changes.
pub trait AcirField:
std::marker::Sized
Sized
+ std::fmt::Display
+ std::fmt::Debug
+ Default
Expand All @@ -24,7 +24,7 @@ pub trait AcirField:
// + From<u8>
+ From<bool>
+ std::hash::Hash
+ std::cmp::Eq
+ Eq
{
fn one() -> Self;
fn zero() -> Self;
Expand Down
3 changes: 3 additions & 0 deletions noir/noir-repo/acvm-repo/acvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license.workspace = true
rust-version.workspace = true
repository.workspace = true

[lints]
workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions noir/noir-repo/acvm-repo/acvm/src/pwg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use acir::{
brillig::ForeignCallResult,
circuit::{
brillig::{BrilligBytecode, BrilligFunctionId},
opcodes::{BlockId, ConstantOrWitnessEnum, FunctionInput},
opcodes::{AcirFunctionId, BlockId, ConstantOrWitnessEnum, FunctionInput},
AssertionPayload, ErrorSelector, ExpressionOrMemory, Opcode, OpcodeLocation,
RawAssertionPayload, ResolvedAssertionPayload, STRING_ERROR_SELECTOR,
},
Expand Down Expand Up @@ -575,7 +575,7 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> ACVM<'a, F, B> {
else {
unreachable!("Not executing a Call opcode");
};
if *id == 0 {
if *id == AcirFunctionId(0) {
return Err(OpcodeResolutionError::AcirMainCallAttempted {
opcode_location: ErrorLocation::Resolved(OpcodeLocation::Acir(
self.instruction_pointer(),
Expand Down Expand Up @@ -716,7 +716,7 @@ pub(crate) fn is_predicate_false<F: AcirField>(
#[derive(Debug, Clone, PartialEq)]
pub struct AcirCallWaitInfo<F> {
/// Index in the list of ACIR function's that should be called
pub id: u32,
pub id: AcirFunctionId,
/// Initial witness for the given circuit to be called
pub initial_witness: WitnessMap<F>,
}
3 changes: 3 additions & 0 deletions noir/noir-repo/acvm-repo/acvm_js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license.workspace = true
rust-version.workspace = true
repository.workspace = true

[lints]
workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
Expand Down
4 changes: 2 additions & 2 deletions noir/noir-repo/acvm-repo/acvm_js/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a, B: BlackBoxFunctionSolver<FieldElement>> ProgramExecutor<'a, B> {
acvm.resolve_pending_foreign_call(result);
}
ACVMStatus::RequiresAcirCall(call_info) => {
let acir_to_call = &self.functions[call_info.id as usize];
let acir_to_call = &self.functions[call_info.id.as_usize()];
let initial_witness = call_info.initial_witness;
let call_solved_witness = self
.execute_circuit(acir_to_call, initial_witness, witness_stack)
Expand All @@ -267,7 +267,7 @@ impl<'a, B: BlackBoxFunctionSolver<FieldElement>> ProgramExecutor<'a, B> {
}
}
acvm.resolve_pending_acir_call(call_resolved_outputs);
witness_stack.push(call_info.id, call_solved_witness.clone());
witness_stack.push(call_info.id.0, call_solved_witness.clone());
}
}
}
Expand Down
Loading
Loading