Skip to content

Commit

Permalink
Merge branch 'master' into chore/async-debugger-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mverzilli authored Nov 28, 2023
2 parents 9ca748c + d983a08 commit 785efbe
Show file tree
Hide file tree
Showing 25 changed files with 348 additions and 51 deletions.
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Dockerfile*
.dockerignore

packages
**/package.tgz
**/target
**/node_modules
**/outputs

# Source resolver
compiler/source-resolver/lib
compiler/source-resolver/lib-node

# Noir.js
tooling/noir_js/lib

# Wasm build artifacts
compiler/wasm/nodejs
compiler/wasm/web
tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
tooling/noir_js/lib
27 changes: 27 additions & 0 deletions .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,32 @@ jobs:
- name: Run browser tests
run: yarn workspace @noir-lang/noirc_abi test:browser

test-noir-js-backend-barretenberg:
needs: [build-noirc-abi]
name: noir-js-backend-barretenberg
runs-on: ubuntu-latest
timeout-minutes: 30

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

- name: Download 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_js_types
run: yarn workspace @noir-lang/types build

- name: Run barretenberg wrapper tests
run: |
yarn workspace @noir-lang/backend_barretenberg test
test-noir-js:
needs: [build-acvm-js, build-noirc-abi]
name: Noir JS
Expand Down Expand Up @@ -401,6 +427,7 @@ jobs:
- test-acvm_js-node
- test-acvm_js-browser
- test-noirc-abi
- test-noir-js-backend-barretenberg
- test-noir-js
- test-source-resolver
- test-noir-wasm
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
tooling/noir_js/lib

**/package.tgz
packages

# docs autogen build
/docs/docs/noir_js/reference/
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM rust:alpine3.17
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
build-base \
bash
WORKDIR /usr/src/noir
COPY . .
RUN ./scripts/bootstrap_native.sh

# When running the container, mount the current working directory to /project.
FROM alpine:3.17
COPY --from=0 /usr/src/noir/target/release/nargo /usr/src/noir/target/release/nargo
WORKDIR /project
ENTRYPOINT ["/usr/src/noir/target/release/nargo"]
19 changes: 19 additions & 0 deletions Dockerfile.packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust:alpine3.17
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
build-base \
pkgconfig \
openssl-dev \
npm \
yarn \
bash \
jq
WORKDIR /usr/src/noir
COPY . .
RUN ./scripts/bootstrap_packages.sh

FROM scratch
COPY --from=0 /usr/src/noir/packages /usr/src/noir/packages
# For some unknown reason, on alpine only, we need this to exist.
COPY --from=0 /usr/src/noir/node_modules/@noir-lang /usr/src/noir/node_modules/@noir-lang
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export CARGO_TARGET_DIR=$self_path/target
rm -rf $self_path/outputs >/dev/null 2>&1
rm -rf $self_path/result >/dev/null 2>&1

if [ -v out ]; then
if [ -n "$out" ]; then
echo "Will install package to $out (defined outside installPhase.sh script)"
else
export out="$self_path/outputs/out"
Expand Down
5 changes: 2 additions & 3 deletions aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl MacroProcessor for AztecMacro {

#[derive(Debug, Clone)]
pub enum AztecMacroError {
// TODO(benesjan): https://github.com/AztecProtocol/aztec-packages/issues/2905
AztecNotFound,
AztecComputeNoteHashAndNullifierNotFound { span: Span },
}
Expand All @@ -42,12 +41,12 @@ impl From<AztecMacroError> for MacroError {
fn from(err: AztecMacroError) -> Self {
match err {
AztecMacroError::AztecNotFound {} => MacroError {
primary_message: "Aztec dependency not found. Please add aztec as a dependency in your Cargo.toml".to_owned(),
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 {
primary_message: "compute_note_hash_and_nullifier function not found. Define it in your contract.".to_owned(),
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),
},
Expand Down
19 changes: 19 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eu

cd $(dirname "$0")

CMD=${1:-}

if [ -n "$CMD" ]; then
if [ "$CMD" = "clean" ]; then
git clean -fdx
exit 0
else
echo "Unknown command: $CMD"
exit 1
fi
fi

./scripts/bootstrap_native.sh
./scripts/bootstrap_packages.sh
2 changes: 1 addition & 1 deletion compiler/wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export CARGO_TARGET_DIR=$self_path/target
rm -rf $self_path/outputs >/dev/null 2>&1
rm -rf $self_path/result >/dev/null 2>&1

if [ -v out ]; then
if [ -n "$out" ]; then
echo "Will install package to $out (defined outside installPhase.sh script)"
else
export out="$self_path/outputs/out"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ example:
```rust
fn main()
{
let hash1 = std::hash::poseidon::bn254::hash_2([1, 2]);
assert(hash1 == 0x115cc0f5e7d690413df64c6b9662e9cf2a3617f2743245519e19607a4417189a);
let hash_2 = std::hash::poseidon::bn254::hash_2([1, 2]);
assert(hash2 == 0x115cc0f5e7d690413df64c6b9662e9cf2a3617f2743245519e19607a4417189a);
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test": "yarn workspaces foreach run test",
"test:integration": "yarn workspace integration-tests test",
"clean:workspaces": "yarn workspaces foreach --exclude @noir-lang/root run clean",
"clean:root": "rm -rf ./result ./target",
"clean:root": "rm -rf ./result ./target ./packages",
"clean": "yarn clean:workspaces && yarn clean:root",
"lint": "yarn workspaces foreach --verbose run lint",
"install:acvm_js": "yarn workspace @noir-lang/acvm_js run install:from:nix",
Expand Down
14 changes: 14 additions & 0 deletions scripts/bootstrap_native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -eu

cd $(dirname "$0")/..

# If this project has been subrepod into another project, set build data manually.
if [ -f ".gitrepo" ]; then
export SOURCE_DATE_EPOCH=$(date +%s)
export GIT_DIRTY=false
export GIT_COMMIT=$(awk '/commit =/ {print $3}' .gitrepo)
fi

# Build native.
cargo build --features="noirc_frontend/aztec" --release
32 changes: 32 additions & 0 deletions scripts/bootstrap_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -eu

cd $(dirname "$0")/..

./scripts/install_wasm-bindgen.sh

# If this project has been subrepod into another project, set build data manually.
if [ -f ".gitrepo" ]; then
export SOURCE_DATE_EPOCH=$(date +%s)
export GIT_DIRTY=false
export GIT_COMMIT=$(awk '/commit =/ {print $3}' .gitrepo)
fi

export cargoExtraArgs="--features noirc_frontend/aztec"

yarn
yarn build

# We create a folder called packages, that contains each package as it would be published to npm, named correctly.
# These can be useful for testing, or portaling into other projects.
yarn workspaces foreach pack

rm -rf packages && mkdir -p packages
tar zxfv acvm-repo/acvm_js/package.tgz -C packages && mv packages/package packages/acvm_js
tar zxfv compiler/source-resolver/package.tgz -C packages && mv packages/package packages/source-resolver
tar zxfv compiler/wasm/package.tgz -C packages && mv packages/package packages/noir_wasm
tar zxfv tooling/noir_codegen/package.tgz -C packages && mv packages/package packages/noir_codegen
tar zxfv tooling/noir_js/package.tgz -C packages && mv packages/package packages/noir_js
tar zxfv tooling/noir_js_backend_barretenberg/package.tgz -C packages && mv packages/package packages/backend_barretenberg
tar zxfv tooling/noir_js_types/package.tgz -C packages && mv packages/package packages/types
tar zxfv tooling/noirc_abi_wasm/package.tgz -C packages && mv packages/package packages/noirc_abi
10 changes: 10 additions & 0 deletions scripts/install_wasm-bindgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

cd $(dirname "$0")/..

# Install wasm-bindgen-cli.
if [ "$(wasm-bindgen --version | cut -d' ' -f2)" != "0.2.86" ]; then
echo "Building wasm-bindgen..."
RUSTFLAGS="-Ctarget-feature=-crt-static" cargo install -f wasm-bindgen-cli --version 0.2.86
fi
Loading

0 comments on commit 785efbe

Please sign in to comment.