Skip to content

Commit

Permalink
Merge branch 'master' into tf/remove-redundant-abi-validation
Browse files Browse the repository at this point in the history
* master:
  chore(errors): Refactor errors representation in compiler (#2760)
  chore(ci): run `noir_js` tests in CI (#2843)
  • Loading branch information
TomAFrench committed Sep 26, 2023
2 parents 12faf30 + 340386a commit 2083269
Show file tree
Hide file tree
Showing 28 changed files with 553 additions and 391 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/acvm-test-acvm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: acvm-js
path: ./acvm-repo/result
path: ./result

- name: Move build artifacts
run: |
mv ./result/acvm_js/nodejs ./acvm-repo/acvm_js/nodejs
mv ./result/acvm_js/web ./acvm-repo/acvm_js/web
- name: Set up test environment
uses: ./.github/actions/setup
Expand All @@ -72,7 +77,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: acvm-js
path: ./acvm-repo/result
path: ./result

- name: Move build artifacts
run: |
mv ./result/acvm_js/nodejs ./acvm-repo/acvm_js/nodejs
mv ./result/acvm_js/web ./acvm-repo/acvm_js/web
- name: Set up test environment
uses: ./.github/actions/setup
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/test-noir-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Noir JS

on:
pull_request:
merge_group:
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30

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

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

- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.66.0
with:
targets: wasm32-unknown-unknown

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

- name: Install jq
run: sudo apt-get install jq

- name: Install wasm-bindgen-cli
uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen-cli@0.2.86

- name: Install toml2json
uses: taiki-e/install-action@v2
with:
tool: toml2json@1.3.1

- name: Install wasm-opt
run: |
npm i wasm-opt -g
- name: Build acvm_js
run: yarn workspace @noir-lang/acvm_js build

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

- name: Run noir_js tests
run: |
yarn workspace @noir-lang/noir_js build
yarn workspace @noir-lang/noir_js test
14 changes: 5 additions & 9 deletions acvm-repo/acvm_js/.gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/target
.DS_Store
examples/**/target/
examples/9
.vscode
node_modules
pkg/
lib/

# Build outputs
result
.direnv
**/outputs
nodejs
web

# Yarn
.pnp.*
Expand All @@ -17,4 +13,4 @@ result
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions
11 changes: 7 additions & 4 deletions acvm-repo/acvm_js/buildPhaseCargoCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ function run_if_available {

export self_path=$(dirname "$(readlink -f "$0")")


NODE_DIR=$self_path/nodejs/
BROWSER_DIR=$self_path/web/

# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack.
if [ -d ./pkg/ ]; then
rm -rf $self_path/pkg/
rm -r $NODE_DIR
rm -r $BROWSER_DIR
fi

TARGET=wasm32-unknown-unknown
WASM_BINARY=$CARGO_TARGET_DIR/$TARGET/release/${pname}.wasm

NODE_DIR=$self_path/pkg/nodejs/
BROWSER_DIR=$self_path/pkg/web/
NODE_WASM=${NODE_DIR}/${pname}_bg.wasm
BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm

Expand All @@ -36,4 +39,4 @@ run_or_fail cargo build --lib --release --target $TARGET --package ${pname}
run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs
run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --typescript --target web
run_if_available wasm-opt $NODE_WASM -o $NODE_WASM -O
run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O
run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O
16 changes: 6 additions & 10 deletions acvm-repo/acvm_js/installPhase.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env bash
export self_path=$(dirname "$(readlink -f "$0")")

mkdir -p $out
cp $self_path/README.md $out/
cp -r $self_path/pkg/* $out/
export out_path=$out/acvm_js

# The main package.json contains several keys which are incorrect/unwanted when distributing.
cat $self_path/package.json \
| jq 'del(.private, .devDependencies, .scripts, .packageManager)' \
> $out/package.json

# Cleanup temporary pkg directory
rm -r $self_path/pkg
mkdir -p $out_path
cp $self_path/README.md $out_path/
cp $self_path/package.json $out_path/
cp -r $self_path/nodejs $out_path/
cp -r $self_path/web $out_path/
37 changes: 0 additions & 37 deletions acvm-repo/acvm_js/nix/wasm-bindgen-cli/default.nix

This file was deleted.

2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/browser/execute_circuit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import initACVM, {
WitnessMap,
initLogLevel,
ForeignCallHandler,
} from "../../../result/";
} from "@noir-lang/acvm_js";

beforeEach(async () => {
await initACVM();
Expand Down
5 changes: 4 additions & 1 deletion acvm-repo/acvm_js/test/browser/witness_conversion.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { expect } from "@esm-bundle/chai";
import initACVM, { compressWitness, decompressWitness } from "../../../result/";
import initACVM, {
compressWitness,
decompressWitness,
} from "@noir-lang/acvm_js";
import {
expectedCompressedWitnessMap,
expectedWitnessMap,
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/node/build_info.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { BuildInfo, buildInfo } from "../../../result/";
import { BuildInfo, buildInfo } from "@noir-lang/acvm_js";
import child_process from "child_process";
import pkg from "../../package.json";

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/node/execute_circuit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
WasmBlackBoxFunctionSolver,
WitnessMap,
ForeignCallHandler,
} from "../../../result/";
} from "@noir-lang/acvm_js";

it("successfully executes circuit and extracts return value", async () => {
const { bytecode, initialWitnessMap, resultWitness, expectedResult } =
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/node/witness_conversion.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { compressWitness, decompressWitness } from "../../../result/";
import { compressWitness, decompressWitness } from "@noir-lang/acvm_js";
import {
expectedCompressedWitnessMap,
expectedWitnessMap,
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/shared/addition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WitnessMap } from "../../../result/";
import { WitnessMap } from "@noir-lang/acvm_js";

// See `addition_circuit` integration test in `acir/tests/test_program_serialization.rs`.
export const bytecode = Uint8Array.from([
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/shared/complex_foreign_call.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WitnessMap } from "../../../result/";
import { WitnessMap } from "@noir-lang/acvm_js";

// See `complex_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`.
export const bytecode = Uint8Array.from([
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/shared/foreign_call.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WitnessMap } from "../../../result/";
import { WitnessMap } from "@noir-lang/acvm_js";

// See `simple_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`.
export const bytecode = Uint8Array.from([
Expand Down
6 changes: 5 additions & 1 deletion compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ pub fn check_crate(
deny_warnings: bool,
) -> CompilationResult<()> {
let mut errors = vec![];
CrateDefMap::collect_defs(crate_id, context, &mut errors);
let diagnostics = CrateDefMap::collect_defs(crate_id, context);
errors.extend(diagnostics.into_iter().map(|(error, file_id)| {
let diagnostic: CustomDiagnostic = error.into();
diagnostic.in_file(file_id)
}));

if has_errors(&errors, deny_warnings) {
Err(errors)
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_errors/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl std::fmt::Display for CustomDiagnostic {

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CustomLabel {
message: String,
pub message: String,
pub span: Span,
}

Expand Down
Loading

0 comments on commit 2083269

Please sign in to comment.