Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use workspace build with nargo compile --workspace #2266

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/abis/ecdsa_account_contract.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/abis/schnorr_account_contract.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion yarn-project/noir-compiler/src/noir-version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"tag": "aztec",
"commit": "39e1433a9c4184b72f3c5ab0368cfaa5d4ce537b"
"commit": "f173c05cbff96dfc48a22cc2f1f76396b968d5a0"
}
3 changes: 1 addition & 2 deletions yarn-project/noir-contracts/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ RUN ./scripts/install_noirup.sh $(pwd)
ENV PATH="/usr/src/yarn-project/noir-contracts/.nargo/bin:${PATH}"

RUN ./scripts/install_noir.sh
RUN ./scripts/install_noir_backend.sh
RUN ./scripts/compile_ci.sh
RUN ./scripts/compile_all.sh
RUN ./scripts/nargo_test_ci.sh
6 changes: 3 additions & 3 deletions yarn-project/noir-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
"noir:clean": "rm -rf ./src/artifacts ./src/types && mkdir -p ../aztec.js/src/abis/ && find ../aztec.js/src/abis/ -mindepth 1 -delete",
"noir:clean": "rm -rf ./src/artifacts ./src/types && mkdir -p ../aztec.js/src/abis/ && find ../aztec.js/src/abis/ -mindepth 1 -delete && rm -rf target/",
"noir:build": "./src/scripts/compile.sh",
"noir:build:all": "yarn noir:clean && ./src/scripts/compile.sh $(./scripts/get_all_contracts.sh)",
"noir:types:all": "./scripts/types.sh $(./scripts/get_all_contracts.sh)"
"noir:build:all": "yarn noir:clean && ./scripts/compile_all.sh && ./scripts/types_all.sh",
"noir:types:all": "./scripts/types_all.sh"
},
"inherits": [
"../package.common.json"
Expand Down
19 changes: 19 additions & 0 deletions yarn-project/noir-contracts/scripts/catch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Handler for SIGCHLD, cleanup if child exit with error, used by nargo_test.sh and compile.sh
handle_sigchld() {
for pid in "${pids[@]}"; do
# If process is no longer running
if ! kill -0 "$pid" 2>/dev/null; then
# Wait for the process and get exit status
wait "$pid"
status=$?

# If exit status is error
if [ $status -ne 0 ]; then
# Create error file
touch "$error_file"
fi
fi
done
}
32 changes: 5 additions & 27 deletions yarn-project/noir-contracts/scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,16 @@

# Compiles noir contracts in parallel, bubbling any compilation errors

source ./scripts/catch.sh
source ./scripts/nargo_check.sh

ROOT=$(pwd)

# Error flag file
error_file="/tmp/error.$$"
# Array of child PIDs
pids=()

# Handler for SIGCHLD, cleanup if child exit with error
handle_sigchld() {
for pid in "${pids[@]}"; do
# If process is no longer running
if ! kill -0 "$pid" 2>/dev/null; then
# Wait for the process and get exit status
wait "$pid"
status=$?

# If exit status is error
if [ $status -ne 0 ]; then
# Create error file
touch "$error_file"
fi
fi
done
}

# Set SIGCHLD handler
trap handle_sigchld SIGCHLD # Trap any ERR signal and call the custom error handler

Expand All @@ -41,15 +26,8 @@ build() {
nargo compile --package $CONTRACT_FOLDER --output-debug;
}

# Check nargo version matches the expected one
echo "Using $(nargo --version)"
EXPECTED_VERSION=$(jq -r '.commit' ../noir-compiler/src/noir-version.json)
FOUND_VERSION=$(nargo --version | grep -oP 'git version hash: \K[0-9a-f]+')
if [ "$EXPECTED_VERSION" != "$FOUND_VERSION" ]; then
echo "Expected nargo version $EXPECTED_VERSION but found version $FOUND_VERSION. Aborting."
exit 1
fi

# Check nargo version
nargo_check

# Build contracts
for CONTRACT_NAME in "$@"; do
Expand Down
12 changes: 12 additions & 0 deletions yarn-project/noir-contracts/scripts/compile_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Compiles all noir contracts

source ./scripts/nargo_check.sh

echo "Checking noir version"
nargo_check

# Runs the compile scripts for all contracts.
echo "Compiling all contracts"

nargo compile --workspace
5 changes: 0 additions & 5 deletions yarn-project/noir-contracts/scripts/compile_ci.sh

This file was deleted.

13 changes: 0 additions & 13 deletions yarn-project/noir-contracts/scripts/install_noir_backend.sh

This file was deleted.

12 changes: 12 additions & 0 deletions yarn-project/noir-contracts/scripts/nargo_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Check nargo version matches the expected one
nargo_check() {
echo "Using $(nargo --version)"
EXPECTED_VERSION=$(jq -r '.commit' ../noir-compiler/src/noir-version.json)
FOUND_VERSION=$(nargo --version | grep -oP 'git version hash: \K[0-9a-f]+')
if [ "$EXPECTED_VERSION" != "$FOUND_VERSION" ]; then
echo "Expected nargo version $EXPECTED_VERSION but found version $FOUND_VERSION. Aborting."
exit 1
fi
}
22 changes: 3 additions & 19 deletions yarn-project/noir-contracts/scripts/nargo_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# If testing multiple libraries:
# ./scripts/test.sh LIB <LIBRARY_NAME> <LIBRARY_NAME> <LIBRARY_NAME> <LIBRARY_NAME> ...

source ./scripts/catch.sh

ROOT=$(pwd)

# Get the project type from the first argument
Expand All @@ -23,24 +25,6 @@ error_file="/tmp/error.$$"
# Array of child PIDs
pids=()

# Handler for SIGCHLD, cleanup if child exit with error
handle_sigchld() {
for pid in "${pids[@]}"; do
# If process is no longer running
if ! kill -0 "$pid" 2>/dev/null; then
# Wait for the process and get exit status
wait "$pid"
status=$?

# If exit status is error
if [ $status -ne 0 ]; then
# Create error file
touch "$error_file"
fi
fi
done
}

# Set SIGCHLD handler
trap handle_sigchld SIGCHLD # Trap any ERR signal and call the custom error handler

Expand All @@ -51,7 +35,7 @@ test() {
CONTRACT_FOLDER="${PROJECT_NAME}_contract"
echo "Testing contract $PROJECT_NAME..."
cd src/contracts/$CONTRACT_FOLDER
nargo test
nargo test --package ${PROJECT_NAME}_contract
else
echo "Testing library $PROJECT_NAME..."
cd ../noir-libs/$PROJECT_NAME
Expand Down
2 changes: 0 additions & 2 deletions yarn-project/noir-contracts/scripts/nargo_test_ci.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

#!/bin/bash

# Runs tests scripts for all contracts, then for all libraries.

./scripts/nargo_test.sh CONTRACT $(./scripts/get_all_contracts.sh)
./scripts/nargo_test.sh LIB $(./scripts/get_all_libraries.sh)
3 changes: 2 additions & 1 deletion yarn-project/noir-contracts/src/scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ set -euo pipefail;

# Run build scripts
./scripts/compile.sh "$@"
./scripts/types.sh "$@"
echo "Generating types"
./scripts/types.sh "$@"
2 changes: 1 addition & 1 deletion yarn-project/yarn-project-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ WORKDIR /usr/src/yarn-project/noir-contracts

# Run yarn build to have the json ABIs available for the types generator
RUN yarn build
RUN ./scripts/types_ci.sh
RUN ./scripts/types_all.sh
# Run yarn build again to build the types
RUN yarn build

Expand Down