|
| 1 | +#!/bin/bash |
| 2 | +source $(git rev-parse --show-toplevel)/ci3/source |
| 3 | + |
| 4 | +# export bb as it is needed when using exported functions |
| 5 | +export bb=$(./find-bb) |
| 6 | +cd .. |
| 7 | + |
| 8 | +# NOTE: We pin the captured IVC inputs to a known master commit, exploiting that there won't be frequent changes. |
| 9 | +# This allows us to compare the generated VKs here with ones we compute freshly, detecting breaking protocol changes. |
| 10 | +# IF A VK CHANGE IS EXPECTED - we need to redo this: |
| 11 | +# - Generate inputs: $root/yarn-project/end-to-end/bootstrap.sh build_bench |
| 12 | +# - Compress the results: tar -czf bb-civc-inputs.tar.gz -C example-app-ivc-inputs-out . |
| 13 | +# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz |
| 14 | +# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz |
| 15 | +# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0 |
| 16 | +pinned_short_hash="1176062e" |
| 17 | +pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-${pinned_short_hash}.tar.gz" |
| 18 | + |
| 19 | +function compress_and_upload { |
| 20 | + # 1) Compress the results |
| 21 | + echo "Compressing the generated inputs..." |
| 22 | + tar -czf bb-civc-inputs.tar.gz -C $1 . |
| 23 | + |
| 24 | + # 2) Compute a short hash for versioning |
| 25 | + echo "Computing SHA256 hash for versioning..." |
| 26 | + full_hash=$(sha256sum bb-civc-inputs.tar.gz | awk '{ print $1 }') |
| 27 | + short_hash=${full_hash:0:8} |
| 28 | + echo "Short hash is: $short_hash" |
| 29 | + |
| 30 | + # 3) Upload to S3 |
| 31 | + s3_key="bb-civc-inputs-${short_hash}.tar.gz" |
| 32 | + s3_uri="s3://aztec-ci-artifacts/protocol/${s3_key}" |
| 33 | + echo "Uploading bb-civc-inputs.tar.gz to ${s3_uri}..." |
| 34 | + aws s3 cp bb-civc-inputs.tar.gz "${s3_uri}" |
| 35 | + |
| 36 | + echo "Done. New inputs available at:" |
| 37 | + echo " ${s3_uri}" |
| 38 | + echo "Update the pinned_civc_inputs_url in this script to point to the new location." |
| 39 | +} |
| 40 | + |
| 41 | +# For easily rerunning the inputs generation |
| 42 | +if [[ "${1:-}" == "--update_inputs" ]]; then |
| 43 | + set -eu |
| 44 | + echo "Updating pinned IVC inputs..." |
| 45 | + |
| 46 | + # Generate new inputs |
| 47 | + echo "Running bootstrap to generate new IVC inputs..." |
| 48 | + |
| 49 | + BOOTSTRAP_TO=yarn-project ../../bootstrap.sh # bootstrap aztec-packages from root |
| 50 | + ../../yarn-project/end-to-end/bootstrap.sh build_bench # build bench to generate IVC inputs |
| 51 | + |
| 52 | + compress_and_upload ../../yarn-project/end-to-end/example-app-ivc-inputs-out |
| 53 | + |
| 54 | + exit 0 |
| 55 | +fi |
| 56 | + |
| 57 | +export inputs_tmp_dir=$(mktemp -d) |
| 58 | +trap 'rm -rf "$inputs_tmp_dir" bb-civc-inputs.tar.gz' EXIT SIGINT |
| 59 | + |
| 60 | +curl -s -f "$pinned_civc_inputs_url" | tar -xzf - -C "$inputs_tmp_dir" &>/dev/null |
| 61 | + |
| 62 | +function check_circuit_vks { |
| 63 | + set -eu |
| 64 | + local flow_folder="$inputs_tmp_dir/$1" |
| 65 | + |
| 66 | + if [[ "${2:-}" == "--update_inputs" ]]; then |
| 67 | + $bb check --update_inputs --scheme client_ivc --ivc_inputs_path "$flow_folder/ivc-inputs.msgpack" || { echo_stderr "Error: Likely VK change detected in $flow_folder! Updating inputs."; exit 1; } |
| 68 | + else |
| 69 | + $bb check --scheme client_ivc --ivc_inputs_path "$flow_folder/ivc-inputs.msgpack" || { echo_stderr "Error: Likely VK change detected in $flow_folder!"; exit 1; } |
| 70 | + fi |
| 71 | +} |
| 72 | + |
| 73 | +export -f check_circuit_vks |
| 74 | + |
| 75 | +# Run on one public and one private input. |
| 76 | +ls "$inputs_tmp_dir" |
| 77 | + |
| 78 | +if [[ "${1:-}" == "--update_fast" ]]; then |
| 79 | + parallel -v --line-buffer --tag check_circuit_vks {} --update_inputs ::: $(ls "$inputs_tmp_dir") \ |
| 80 | + && echo "No VK changes detected. Short hash is: ${pinned_short_hash}" \ |
| 81 | + || compress_and_upload $inputs_tmp_dir |
| 82 | +else |
| 83 | + parallel -v --line-buffer --tag check_circuit_vks {} ::: $(ls "$inputs_tmp_dir") \ |
| 84 | + && echo "No VK changes detected. Short hash is: ${pinned_short_hash}" \ |
| 85 | + || (echo "VK changes detected. Please re-run the script with --update_fast or --update_inputs" && exit 1) |
| 86 | +fi |
0 commit comments