Skip to content

Commit

Permalink
Merge branch 'master' into mocked-backend
Browse files Browse the repository at this point in the history
* master:
  feat: Add support for brillig call stacks in runtime errors (#2549)
  feat: add `noirc_abi_wasm` crate for ABI encoding in JS (#1945)
  chore: move CRS files into their own directory (#2558)
  • Loading branch information
TomAFrench committed Sep 5, 2023
2 parents 809cfb2 + a077391 commit d68307e
Show file tree
Hide file tree
Showing 37 changed files with 7,156 additions and 77 deletions.
26 changes: 26 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup

inputs:
working-directory:
default: ./
required: false

runs:
using: composite
steps:
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18.15
- name: Cache
uses: actions/cache@v3
id: cache
with:
path: "**/node_modules"
key: yarn-v1-${{ hashFiles('**/yarn.lock') }}
- name: Install
run: |
cd ${{ inputs.working-directory }}
yarn --immutable
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
122 changes: 122 additions & 0 deletions .github/workflows/abi_wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: ABI Wasm test

on:
pull_request:
merge_group:

# This will cancel previous runs when a branch or PR is updated
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
cancel-in-progress: true

jobs:
noirc-abi-wasm-build:
runs-on: ubuntu-latest
env:
CACHED_PATH: /tmp/nix-cache

steps:
- name: Checkout sources
uses: actions/checkout@v3

- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-23.05
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Restore nix store cache
uses: actions/cache/restore@v3
id: cache
with:
path: ${{ env.CACHED_PATH }}
key: ${{ runner.os }}-flake-abi-wasm-${{ hashFiles('*.lock') }}

# Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26
- name: Copy cache into nix store
if: steps.cache.outputs.cache-hit == 'true'
# We don't check the signature because we're the one that created the cache
run: |
for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do
path=$(head -n 1 "$narinfo" | awk '{print $2}')
nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path"
done
- name: Build noirc_abi_wasm
run: |
nix build -L .#noirc_abi_wasm
- name: Export cache from nix store
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
run: |
nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd&parallel-compression=true" .#noirc-abi-wasm-cargo-artifacts
- uses: actions/cache/save@v3
# Don't create cache entries for the merge queue.
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
with:
path: ${{ env.CACHED_PATH }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Dereference symlink
run: echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: noirc_abi_wasm
path: ${{ env.UPLOAD_PATH }}
retention-days: 10

noirc-abi-wasm-test-node:
needs: [noirc-abi-wasm-build]
name: Node.js Tests
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: noirc_abi_wasm
path: ./result

- name: Set up test environment
uses: ./.github/actions/setup
with:
working-directory: ./crates/noirc_abi_wasm

- name: Run node tests
working-directory: ./crates/noirc_abi_wasm
run: yarn test

noirc-abi-wasm-test-browser:
needs: [noirc-abi-wasm-build]
name: Browser Tests
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: noirc_abi_wasm
path: ./result

- name: Set up test environment
uses: ./.github/actions/setup
with:
working-directory: ./crates/noirc_abi_wasm

- name: Install playwright deps
working-directory: ./crates/noirc_abi_wasm
run: |
npx playwright install
npx playwright install-deps
- name: Run browser tests
working-directory: ./crates/noirc_abi_wasm
run: yarn test:browser
75 changes: 61 additions & 14 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"crates/fm",
"crates/arena",
"crates/noirc_abi",
"crates/noirc_abi_wasm",
"crates/iter-extended",
"crates/wasm",
]
Expand All @@ -28,7 +29,7 @@ edition = "2021"
rust-version = "1.66"

[workspace.dependencies]
acvm = "0.24.1"
acvm = "0.25.0"
arena = { path = "crates/arena" }
fm = { path = "crates/fm" }
iter-extended = { path = "crates/iter-extended" }
Expand Down
14 changes: 13 additions & 1 deletion crates/acvm_backend_barretenberg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ impl Backend {
}

fn backend_directory(&self) -> PathBuf {
backends_directory().join(&self.name)
// If an explicit path to a backend binary has been provided then place CRS, etc. in same directory.
if let Some(binary_path) = std::env::var_os("NARGO_BACKEND_PATH") {
PathBuf::from(binary_path)
.parent()
.expect("backend binary should have a parent directory")
.to_path_buf()
} else {
backends_directory().join(&self.name)
}
}

fn crs_directory(&self) -> PathBuf {
self.backend_directory().join("crs")
}

fn binary_path(&self) -> PathBuf {
Expand Down
8 changes: 4 additions & 4 deletions crates/acvm_backend_barretenberg/src/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Backend {
write_to_file(serialized_circuit.as_bytes(), &circuit_path);

let binary_path = assert_binary_exists(self);
GatesCommand { crs_path: self.backend_directory(), bytecode_path: circuit_path }
GatesCommand { crs_path: self.crs_directory(), bytecode_path: circuit_path }
.run(&binary_path)
}

Expand Down Expand Up @@ -81,7 +81,7 @@ impl Backend {
let binary_path = assert_binary_exists(self);
// Create proof and store it in the specified path
ProveCommand {
crs_path: self.backend_directory(),
crs_path: self.crs_directory(),
is_recursive,
bytecode_path,
witness_path,
Expand Down Expand Up @@ -139,7 +139,7 @@ impl Backend {

let binary_path = assert_binary_exists(self);
WriteVkCommand {
crs_path: self.backend_directory(),
crs_path: self.crs_directory(),
is_recursive,
bytecode_path,
vk_path_output: vk_path.clone(),
Expand All @@ -148,7 +148,7 @@ impl Backend {

// Verify the proof
let valid_proof =
VerifyCommand { crs_path: self.backend_directory(), is_recursive, proof_path, vk_path }
VerifyCommand { crs_path: self.crs_directory(), is_recursive, proof_path, vk_path }
.run(&binary_path);

Ok(valid_proof)
Expand Down
4 changes: 2 additions & 2 deletions crates/acvm_backend_barretenberg/src/smart_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Backend {

let binary_path = assert_binary_exists(self);
WriteVkCommand {
crs_path: self.backend_directory(),
crs_path: self.crs_directory(),
is_recursive: false,
bytecode_path,
vk_path_output: vk_path.clone(),
Expand All @@ -35,7 +35,7 @@ impl Backend {

let contract_path = temp_directory_path.join("contract");
ContractCommand {
crs_path: self.backend_directory(),
crs_path: self.crs_directory(),
vk_path,
contract_path: contract_path.clone(),
}
Expand Down
Loading

0 comments on commit d68307e

Please sign in to comment.