Skip to content

Commit

Permalink
fix: Cleanup gen_inner_proof_files.sh script. (#3242)
Browse files Browse the repository at this point in the history
Not sure I understand why this was so overengineered.
Looks like we just mindlessly copied what run_acir_tests did, which
allows different flows for executing different test flows (as i hoped
the README made clear).

Hopefully this can serve as an example of what should have been.
  • Loading branch information
charlielye authored Nov 6, 2023
1 parent a062026 commit ee57e00
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 113 deletions.
19 changes: 19 additions & 0 deletions barretenberg/acir_tests/clone_test_vectors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eu

# Pull down the test vectors from the noir repo, if we don't have the folder already.
if [ ! -d acir_tests ]; then
if [ -n "${TEST_SRC:-}" ]; then
cp -R $TEST_SRC acir_tests
else
rm -rf noir
git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git
cd noir
git sparse-checkout init --cone
git sparse-checkout set tooling/nargo_cli/tests/acir_artifacts
git checkout
cd ..
mv noir/tooling/nargo_cli/tests/acir_artifacts acir_tests
rm -rf noir
fi
fi
8 changes: 0 additions & 8 deletions barretenberg/acir_tests/flows/proof_as_fields.sh

This file was deleted.

21 changes: 0 additions & 21 deletions barretenberg/acir_tests/flows/prove.sh

This file was deleted.

8 changes: 0 additions & 8 deletions barretenberg/acir_tests/flows/vk_as_fields.sh

This file was deleted.

8 changes: 0 additions & 8 deletions barretenberg/acir_tests/flows/write_vk.sh

This file was deleted.

69 changes: 18 additions & 51 deletions barretenberg/acir_tests/gen_inner_proof_inputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,42 @@
set -eu

BIN=${BIN:-../cpp/build/bin/bb}
WRITE_VK_FLOW=${FLOW:-write_vk}
VK_FIELDS_FLOW=${FLOW:-vk_as_fields}
PROVE_FLOW=${FLOW:-prove}
PROOF_FIELDS_FLOW=${FLOW:-proof_as_fields}
CRS_PATH=~/.bb-crs
BRANCH=master
VERBOSE=${VERBOSE:-}
RECURSIVE=true
PROOF_NAME="proof_a"

WRITE_VK_FLOW_SCRIPT=$(realpath ./flows/${WRITE_VK_FLOW}.sh)
VK_FIELDS_FLOW_SCRIPT=$(realpath ./flows/${VK_FIELDS_FLOW}.sh)
PROVE_FLOW_SCRIPT=$(realpath ./flows/${PROVE_FLOW}.sh)
PROOF_FIELDS_FLOW_SCRIPT=$(realpath ./flows/${PROOF_FIELDS_FLOW}.sh)

if [ -f $BIN ]; then
BIN=$(realpath $BIN)
else
BIN=$(realpath $(which $BIN))
fi

export BIN CRS_PATH VERBOSE RECURSIVE PROOF_NAME

# Pull down the test vectors from the noir repo, if we don't have the folder already.
if [ ! -d acir_tests ]; then
if [ -n "${TEST_SRC:-}" ]; then
cp -R $TEST_SRC acir_tests
else
rm -rf noir
git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git
cd noir
git sparse-checkout init --cone
git sparse-checkout set tooling/nargo_cli/tests/acir_artifacts
git checkout
cd ..
mv noir/tooling/nargo_cli/tests/acir_artifacts acir_tests
rm -rf noir
fi
fi
export BRANCH

cd acir_tests
./clone_test_vectors.sh

cd assert_statement
cd acir_tests/assert_statement

PROOF_DIR=$PWD/proofs
PROOF_PATH=$PROOF_DIR/$PROOF_NAME
VFLAG=${VERBOSE:+-v}
RFLAG=${RECURSIVE:+-r}

echo -e "Write VK to file for assert_statement..\n"
set +e
$WRITE_VK_FLOW_SCRIPT
set -eu
echo "Write VK to file for assert_statement..."
$BIN write_vk $VFLAG -c $CRS_PATH -o

echo -e "Write VK as fields for recursion...\n"
set +e
$VK_FIELDS_FLOW_SCRIPT
set -eu
echo "Write VK as fields for recursion..."
$BIN vk_as_fields $VFLAG -c $CRS_PATH

echo -e "Generate proof to file...\n"
set +e
if [ ! -d "$PROOF_DIR" ]; then
mkdir $PWD/proofs
fi
if [ ! -e "$PROOF_PATH" ]; then
touch $PROOF_PATH
fi
$PROVE_FLOW_SCRIPT
set -eu
echo "Generate proof to file..."
[ -d "$PROOF_DIR" ] || mkdir $PWD/proofs
[ -e "$PROOF_PATH" ] || touch $PROOF_PATH
$BIN prove $VFLAG -c $CRS_PATH -b ./target/acir.gz -o "./proofs/$PROOF_NAME" $RFLAG

echo -e "Write proof as fields for recursion...\n"
set +e
$PROOF_FIELDS_FLOW_SCRIPT
set -eu
echo "Write proof as fields for recursion..."
$BIN proof_as_fields $VFLAG -c $CRS_PATH -p "./proofs/$PROOF_NAME"

cat ./proofs/${PROOF_NAME}_fields.json
echo
19 changes: 2 additions & 17 deletions barretenberg/acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,9 @@ else
BIN=$(realpath $(which $BIN))
fi

export BIN CRS_PATH VERBOSE
export BIN CRS_PATH VERBOSE BRANCH

# Pull down the test vectors from the noir repo, if we don't have the folder already.
if [ ! -d acir_tests ]; then
if [ -n "${TEST_SRC:-}" ]; then
cp -R $TEST_SRC acir_tests
else
rm -rf noir
git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git
cd noir
git sparse-checkout init --cone
git sparse-checkout set tooling/nargo_cli/tests/acir_artifacts
git checkout
cd ..
mv noir/tooling/nargo_cli/tests/acir_artifacts acir_tests
rm -rf noir
fi
fi
./clone_test_vectors.sh

cd acir_tests

Expand Down

0 comments on commit ee57e00

Please sign in to comment.