Skip to content

Commit

Permalink
Merge branch 'master' into michaeljklein/parse-error-3768
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljklein authored Jan 25, 2024
2 parents bfba500 + 4421ce4 commit b04ec5f
Show file tree
Hide file tree
Showing 56 changed files with 1,489 additions and 704 deletions.
4 changes: 0 additions & 4 deletions .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
9 changes: 9 additions & 0 deletions .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/[email protected]

- 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 .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/[email protected]

- 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 .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
10 changes: 10 additions & 0 deletions 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 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 @@ -748,7 +748,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 @@ -904,7 +904,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 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
}
}
2 changes: 1 addition & 1 deletion 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
18 changes: 16 additions & 2 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![warn(unreachable_pub)]
#![warn(clippy::semicolon_if_nothing_returned)]

use acvm::ExpressionWidth;
use clap::Args;
use fm::{FileId, FileManager};
use iter_extended::vecmap;
Expand All @@ -16,7 +17,6 @@ use noirc_frontend::hir::Context;
use noirc_frontend::macros_api::MacroProcessor;
use noirc_frontend::monomorphization::monomorphize;
use noirc_frontend::node_interner::FuncId;
use serde::{Deserialize, Serialize};
use std::path::Path;
use tracing::info;

Expand All @@ -43,8 +43,12 @@ pub const NOIRC_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const NOIR_ARTIFACT_VERSION_STRING: &str =
concat!(env!("CARGO_PKG_VERSION"), "+", env!("GIT_COMMIT"));

#[derive(Args, Clone, Debug, Default, Serialize, Deserialize)]
#[derive(Args, Clone, Debug, Default)]
pub struct CompileOptions {
/// Override the expression width requested by the backend.
#[arg(long, value_parser = parse_expression_width)]
pub expression_width: Option<ExpressionWidth>,

/// Force a full recompilation.
#[arg(long = "force")]
pub force_compile: bool,
Expand Down Expand Up @@ -81,6 +85,16 @@ pub struct CompileOptions {
pub show_monomorphized: bool,
}

fn parse_expression_width(input: &str) -> Result<ExpressionWidth, std::io::Error> {
use std::io::{Error, ErrorKind};

let width = input
.parse::<usize>()
.map_err(|err| Error::new(ErrorKind::InvalidInput, err.to_string()))?;

Ok(ExpressionWidth::from(width))
}

/// Helper type used to signify where only warnings are expected in file diagnostics
pub type Warnings = Vec<FileDiagnostic>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ fn execute_brillig(
// It may be finished, in-progress, failed, or may be waiting for results of a foreign call.
// If it's finished then we can omit the opcode and just write in the return values.
match vm_status {
VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().clone())),
VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().to_vec())),
VMStatus::InProgress => unreachable!("Brillig VM has not completed execution"),
VMStatus::Failure { .. } => {
// TODO: Return an error stating that the brillig function failed.
Expand Down
Loading

0 comments on commit b04ec5f

Please sign in to comment.