Skip to content

Commit

Permalink
Merge 38a8ed0 into 12356d9
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunkar authored Jan 29, 2024
2 parents 12356d9 + 38a8ed0 commit b0cb534
Show file tree
Hide file tree
Showing 291 changed files with 11,170 additions and 1,573 deletions.
4 changes: 0 additions & 4 deletions noir/.github/ISSUE_TEMPLATE/config.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Idea Action Plan
description: Outline the scope and steps for implementing an enhancement. Start with "Ideas" instead to request and discuss new features.
name: Feature Request
description: Suggest an idea for this project.
labels: ["enhancement"]
body:
- type: markdown
Expand Down
4 changes: 2 additions & 2 deletions noir/.github/scripts/wasm-bindgen-install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu

curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo-binstall wasm-bindgen-cli --version 0.2.86 -y
# TODO call this script directly
./scripts/install_wasm-bindgen.sh
9 changes: 9 additions & 0 deletions noir/.github/workflows/docs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.71.1

- uses: Swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-gnu
cache-on-failure: false
save-if: false

- name: Install Yarn dependencies
uses: ./.github/actions/setup

Expand Down
51 changes: 32 additions & 19 deletions noir/.github/workflows/publish-es-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
run-name: Publish ES Packages from ${{ inputs.noir-ref }} under @${{ inputs.npm-tag }} tag.

jobs:
build-noir_wasm:
build-noirc_abi_wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -32,40 +32,52 @@ jobs:

- name: Build wasm package
run: |
nix build -L .#noir_wasm
nix build -L .#noirc_abi_wasm
- uses: actions/upload-artifact@v3
with:
name: noir_wasm
name: noirc_abi_wasm
path: |
result/noir_wasm/nodejs
result/noir_wasm/web
result/noirc_abi_wasm/nodejs
result/noirc_abi_wasm/web
build-noirc_abi_wasm:
build-noir_wasm:
needs: [build-noirc_abi_wasm]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.noir-ref }}

- name: Setup Nix
uses: ./.github/actions/nix
- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.71.1

- uses: Swatinem/rust-cache@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: "noir"
cachix-auth-token: ${{ secrets.CACHIXAUTHTOKEN }}

- name: Build wasm package
run: |
nix build -L .#noirc_abi_wasm
key: noir-wasm
save-if: false

- uses: actions/upload-artifact@v3
- name: Download noirc_abi_wasm package artifact
uses: actions/download-artifact@v3
with:
name: noirc_abi_wasm
path: ./tooling/noirc_abi_wasm

- name: Install Yarn dependencies
uses: ./.github/actions/setup

- name: Build noir_wasm
run: yarn workspace @noir-lang/noir_wasm build

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: noir_wasm
path: |
result/noirc_abi_wasm/nodejs
result/noirc_abi_wasm/web
./compiler/wasm/dist
./compiler/wasm/build
retention-days: 3

build-acvm_js:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -97,7 +109,6 @@ jobs:
runs-on: ubuntu-latest
needs: [build-acvm_js, build-noirc_abi_wasm, build-noir_wasm]
steps:

- name: Checkout sources
uses: actions/checkout@v4
with:
Expand All @@ -107,10 +118,12 @@ jobs:
with:
name: acvm_js
path: acvm-repo/acvm_js

- uses: actions/download-artifact@v3
with:
name: noir_wasm
path: compiler/wasm

- uses: actions/download-artifact@v3
with:
name: noirc_abi_wasm
Expand Down
11 changes: 8 additions & 3 deletions noir/.github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
outputs:
release-pr: ${{ steps.release.outputs.pr }}
tag-name: ${{ steps.release.outputs.tag_name }}
pending-release-semver: v${{ steps.release.outputs.major }}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}}
runs-on: ubuntu-latest
steps:
- name: Run release-please
Expand Down Expand Up @@ -80,9 +79,15 @@ jobs:
- name: Install Yarn dependencies
uses: ./.github/actions/setup

- name: Query new noir version
id: noir-version
run: |
NOIR_VERSION=$(grep '^version =' ./Cargo.toml | sed -E 's/version = "([^"]+)"/v\1/')
echo "semver=$NOIR_VERSION" >> $GITHUB_OUTPUT
- name: Cut a new version
working-directory: ./docs
run: yarn docusaurus docs:version ${{ needs.release-please.outputs.pending-release-semver }}
run: yarn docusaurus docs:version ${{ steps.noir-version.outputs.semver }}

- name: Configure git
run: |
Expand All @@ -92,7 +97,7 @@ jobs:
- name: Commit new documentation version
run: |
git add .
git commit -m "chore(docs): cut new docs version for tag ${{ needs.release-please.outputs.pending-release-semver }}"
git commit -m "chore(docs): cut new docs version for tag ${{ steps.noir-version.outputs.semver }}"
git push
build-binaries:
Expand Down
4 changes: 2 additions & 2 deletions noir/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/noir-lang/noir
branch = aztec-packages
commit = 2c463bc1a8a9791e1f352e398156c5c03bf89959
parent = ac25ff737a934a5f260605f4497e4074c3ed5824
commit = ea6aebcc4e190d9dbadaf1dd0f70950651eed615
parent = 37cb60587bb2c8f4b7b9275110e23b0f6babda3d
method = merge
cmdver = 0.4.6
1 change: 0 additions & 1 deletion noir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ repository = "https://github.com/noir-lang/noir/"
acir_field = { version = "0.39.0", path = "acvm-repo/acir_field", default-features = false }
acir = { version = "0.39.0", path = "acvm-repo/acir", default-features = false }
acvm = { version = "0.39.0", path = "acvm-repo/acvm" }
stdlib = { version = "0.37.1", package = "acvm_stdlib", path = "acvm-repo/stdlib", default-features = false }
brillig = { version = "0.39.0", path = "acvm-repo/brillig", default-features = false }
brillig_vm = { version = "0.39.0", path = "acvm-repo/brillig_vm", default-features = false }
acvm_blackbox_solver = { version = "0.39.0", path = "acvm-repo/blackbox_solver", default-features = false }
Expand Down
10 changes: 10 additions & 0 deletions noir/acvm-repo/acvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ pub enum ExpressionWidth {
Unbounded,
Bounded { width: usize },
}

impl From<usize> for ExpressionWidth {
fn from(width: usize) -> ExpressionWidth {
if width == 0 {
ExpressionWidth::Unbounded
} else {
ExpressionWidth::Bounded { width }
}
}
}
6 changes: 3 additions & 3 deletions noir/acvm-repo/brillig_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<'a, B: BlackBoxFunctionSolver> VM<'a, B> {
self.registers.set(register_index, value);
}

pub fn get_memory(&self) -> &Vec<Value> {
pub fn get_memory(&self) -> &[Value] {
self.memory.values()
}

Expand Down Expand Up @@ -741,7 +741,7 @@ mod tests {

let opcodes = [&start[..], &loop_body[..]].concat();
let vm = brillig_execute_and_get_vm(memory, &opcodes);
vm.get_memory().clone()
vm.get_memory().to_vec()
}

let memory = brillig_write_memory(vec![Value::from(0u128); 5]);
Expand Down Expand Up @@ -897,7 +897,7 @@ mod tests {

let opcodes = [&start[..], &recursive_fn[..]].concat();
let vm = brillig_execute_and_get_vm(memory, &opcodes);
vm.get_memory().clone()
vm.get_memory().to_vec()
}

let memory = brillig_recursive_write_memory(vec![Value::from(0u128); 5]);
Expand Down
2 changes: 1 addition & 1 deletion noir/acvm-repo/brillig_vm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Memory {
}

/// Returns the values of the memory
pub fn values(&self) -> &Vec<Value> {
pub fn values(&self) -> &[Value] {
&self.inner
}
}
35 changes: 18 additions & 17 deletions noir/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@ const MAX_CONTRACT_FUNCTIONS: usize = 2_usize.pow(FUNCTION_TREE_HEIGHT);

#[derive(Debug, Clone)]
pub enum AztecMacroError {
AztecNotFound,
AztecComputeNoteHashAndNullifierNotFound { span: Span },
AztecContractHasTooManyFunctions { span: Span },
AztecContractConstructorMissing { span: Span },
AztecDepNotFound,
ComputeNoteHashAndNullifierNotFound { span: Span },
ContractHasTooManyFunctions { span: Span },
ContractConstructorMissing { span: Span },
UnsupportedFunctionArgumentType { span: Span, typ: UnresolvedTypeData },
}

impl From<AztecMacroError> for MacroError {
fn from(err: AztecMacroError) -> Self {
match err {
AztecMacroError::AztecNotFound {} => MacroError {
AztecMacroError::AztecDepNotFound {} => MacroError {
primary_message: "Aztec dependency not found. Please add aztec as a dependency in your Cargo.toml. For more information go to https://docs.aztec.network/dev_docs/debugging/aztecnr-errors#aztec-dependency-not-found-please-add-aztec-as-a-dependency-in-your-nargotoml".to_owned(),
secondary_message: None,
span: None,
},
AztecMacroError::AztecComputeNoteHashAndNullifierNotFound { span } => MacroError {
AztecMacroError::ComputeNoteHashAndNullifierNotFound { span } => MacroError {
primary_message: "compute_note_hash_and_nullifier function not found. Define it in your contract. For more information go to https://docs.aztec.network/dev_docs/debugging/aztecnr-errors#compute_note_hash_and_nullifier-function-not-found-define-it-in-your-contract".to_owned(),
secondary_message: None,
span: Some(span),
},
AztecMacroError::AztecContractHasTooManyFunctions { span } => MacroError {
AztecMacroError::ContractHasTooManyFunctions { span } => MacroError {
primary_message: format!("Contract can only have a maximum of {} functions", MAX_CONTRACT_FUNCTIONS),
secondary_message: None,
span: Some(span),
},
AztecMacroError::AztecContractConstructorMissing { span } => MacroError {
AztecMacroError::ContractConstructorMissing { span } => MacroError {
primary_message: "Contract must have a constructor function".to_owned(),
secondary_message: None,
span: Some(span),
Expand Down Expand Up @@ -222,7 +222,9 @@ fn transform(

// Covers all functions in the ast
for submodule in ast.submodules.iter_mut().filter(|submodule| submodule.is_contract) {
if transform_module(&mut submodule.contents, crate_id, context)? {
if transform_module(&mut submodule.contents, crate_id, context)
.map_err(|(err, file_id)| (err.into(), file_id))?
{
check_for_aztec_dependency(crate_id, context)?;
include_relevant_imports(&mut submodule.contents);
}
Expand Down Expand Up @@ -264,7 +266,7 @@ fn check_for_aztec_dependency(
if has_aztec_dependency {
Ok(())
} else {
Err((AztecMacroError::AztecNotFound.into(), crate_graph.root_file_id))
Err((AztecMacroError::AztecDepNotFound.into(), crate_graph.root_file_id))
}
}

Expand Down Expand Up @@ -323,7 +325,7 @@ fn transform_module(
module: &mut SortedModule,
crate_id: &CrateId,
context: &HirContext,
) -> Result<bool, (MacroError, FileId)> {
) -> Result<bool, (AztecMacroError, FileId)> {
let mut has_transformed_module = false;

// Check for a user defined storage struct
Expand All @@ -332,8 +334,7 @@ fn transform_module(
if storage_defined && !check_for_compute_note_hash_and_nullifier_definition(module) {
let crate_graph = &context.crate_graph[crate_id];
return Err((
AztecMacroError::AztecComputeNoteHashAndNullifierNotFound { span: Span::default() }
.into(),
AztecMacroError::ComputeNoteHashAndNullifierNotFound { span: Span::default() },
crate_graph.root_file_id,
));
}
Expand All @@ -350,11 +351,11 @@ fn transform_module(
let crate_graph = &context.crate_graph[crate_id];
if is_custom_attribute(&secondary_attribute, "aztec(private)") {
transform_function("Private", func, storage_defined)
.map_err(|err| (err.into(), crate_graph.root_file_id))?;
.map_err(|err| (err, crate_graph.root_file_id))?;
has_transformed_module = true;
} else if is_custom_attribute(&secondary_attribute, "aztec(public)") {
transform_function("Public", func, storage_defined)
.map_err(|err| (err.into(), crate_graph.root_file_id))?;
.map_err(|err| (err, crate_graph.root_file_id))?;
has_transformed_module = true;
}
}
Expand All @@ -371,7 +372,7 @@ fn transform_module(
if module.functions.len() > MAX_CONTRACT_FUNCTIONS {
let crate_graph = &context.crate_graph[crate_id];
return Err((
AztecMacroError::AztecContractHasTooManyFunctions { span: Span::default() }.into(),
AztecMacroError::ContractHasTooManyFunctions { span: Span::default() },
crate_graph.root_file_id,
));
}
Expand All @@ -380,7 +381,7 @@ fn transform_module(
if !constructor_defined {
let crate_graph = &context.crate_graph[crate_id];
return Err((
AztecMacroError::AztecContractConstructorMissing { span: Span::default() }.into(),
AztecMacroError::ContractConstructorMissing { span: Span::default() },
crate_graph.root_file_id,
));
}
Expand Down
2 changes: 1 addition & 1 deletion noir/compiler/noirc_driver/src/abi_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn into_abi_params(context: &Context, params: Vec<Param>) -> Vec<AbiParameter> {
// Takes each abi parameter and shallowly maps to the expected witness range in which the
// parameter's constituent values live.
fn param_witnesses_from_abi_param(
abi_params: &Vec<AbiParameter>,
abi_params: &[AbiParameter],
input_witnesses: Vec<Witness>,
) -> BTreeMap<String, Vec<Range<Witness>>> {
let mut idx = 0_usize;
Expand Down
4 changes: 2 additions & 2 deletions noir/compiler/noirc_driver/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum ContractFunctionType {
Unconstrained,
}

#[derive(Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CompiledContract {
pub noir_version: String,

Expand All @@ -51,7 +51,7 @@ pub struct CompiledContract {
/// A contract function unlike a regular Noir program
/// however can have additional properties.
/// One of these being a function type.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContractFunction {
pub name: String,

Expand Down
Loading

0 comments on commit b0cb534

Please sign in to comment.