Skip to content

Commit

Permalink
chore: switch over to constructing gates report in bash (AztecProtoco…
Browse files Browse the repository at this point in the history
…l#6491)

This PR switches us over to using `gates_report.sh` rather than `nargo
info`
  • Loading branch information
TomAFrench committed May 16, 2024
1 parent 8685acc commit 1fa5963
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 5 additions & 3 deletions noir-projects/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ format:

gates-report:
FROM +build
WORKDIR /usr/src/noir-projects/noir-protocol-circuits
WORKDIR /usr/src/noir-projects

COPY ./gates_report.sh ./gates_report.sh
COPY ../barretenberg/cpp/+preset-clang-assert/bin/bb /usr/src/barretenberg/cpp/build/bin/bb

RUN NARGO_BACKEND_PATH=/usr/src/barretenberg/cpp/build/bin/bb nargo info --json > gates_report.json
ENV BB_BIN /usr/src/barretenberg/cpp/build/bin/bb
RUN ./gates_report.sh

SAVE ARTIFACT gates_report.json gates_report.json
SAVE ARTIFACT ./noir-protocol-circuits/gates_report.json gates_report.json
16 changes: 6 additions & 10 deletions noir-projects/gates_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,23 @@ set -eu
# The script needs some slight updating as `nargo info` expects a complete JSON object, while this script expects a single object field
# representing a list of circuit reports for a program.
# The ACIR tests in barretenberg also expect every target bytecode to have the name `acir.gz` while this script expects the same name of the package
echo "Compile noir-protocol-circuits for gates report..."
cd noir-protocol-circuits
PROTOCOL_CIRCUITS_DIR=$PWD

# Compile programs into artifacts that the backend expects
NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo}
$NARGO compile --only-acir

BB_BIN=${BB_BIN:-../../barretenberg/cpp/build/bin/bb}

echo "{\"programs\": [" > gates_report.json

# Bound for checking where to place last parentheses
NUM_ARTIFACTS=$(ls -1q "$PROTOCOL_CIRCUITS_DIR/target"/*.gz | wc -l)
NUM_ARTIFACTS=$(ls -1q "$PROTOCOL_CIRCUITS_DIR/target"/*.json | wc -l)

ITER="1"
for pathname in "$PROTOCOL_CIRCUITS_DIR/target"/*.gz; do
ARTIFACT_NAME=$(basename -s .gz "$pathname")
for pathname in "$PROTOCOL_CIRCUITS_DIR/target"/*.json; do
ARTIFACT_NAME=$(basename -s .json "$pathname")

echo "{\"package_name\": \"$ARTIFACT_NAME\"," >> gates_report.json
$BB_BIN gates -b "./target/$ARTIFACT_NAME.gz" >> gates_report.json
GATES_INFO=$($BB_BIN gates -b "./target/$ARTIFACT_NAME.json")
MAIN_FUNCTION_INFO=$(echo $GATES_INFO | jq -r '.functions[0] | .name = "main"')
echo "{\"package_name\": \"$ARTIFACT_NAME\", \"functions\": [$MAIN_FUNCTION_INFO]" >> gates_report.json

if (($ITER == $NUM_ARTIFACTS)); then
echo "}" >> gates_report.json
Expand Down

0 comments on commit 1fa5963

Please sign in to comment.