From d014cde3f5c87ea182fef3d3ec9328b3c98f13c8 Mon Sep 17 00:00:00 2001 From: ananas-block Date: Sat, 22 Jun 2024 01:51:38 +0100 Subject: [PATCH] rename utxo to compressed account in readme bench.sh generate_keys.sh --- light-prover/README.md | 8 ++--- light-prover/bench.sh | 34 ++++++++++---------- light-prover/scripts/generate_keys.sh | 46 +++++++++++++-------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/light-prover/README.md b/light-prover/README.md index 39c99e5e80..4229da3f9a 100644 --- a/light-prover/README.md +++ b/light-prover/README.md @@ -16,15 +16,15 @@ through [gnark](https://github.com/ConsenSys/gnark)). This part explains the existing cli commands. -1. setup - builds a circuit with provided number of utxos and depth, compiles it and writes it to a file. +1. setup - builds a circuit with provided number of compressed accounts and depth, compiles it and writes it to a file. Flags: 1. output *file path* - A path used to output a file 2. tree-depth *n* - Merkle tree depth - 3. utxos *n* - Number of UTXOs -2. gen-test-params - Generates test params given the number of utxos and tree depth. + 3. compressedAccounts *n* - Number of COMPRESSED_ACCOUNTs +2. gen-test-params - Generates test params given the number of compressedAccounts and tree depth. Flags: 1. tree-depth *n* - Depth of the mock merkle tree - 2. utxos *n* - Number of UTXOs + 2. compressedAccounts *n* - Number of COMPRESSED_ACCOUNTs 3. start - starts a api server with /prove and /metrics endpoints Flags: 1. config: Config file, which may contain the following fields: diff --git a/light-prover/bench.sh b/light-prover/bench.sh index 6a9b375ea8..39f799df70 100755 --- a/light-prover/bench.sh +++ b/light-prover/bench.sh @@ -9,33 +9,33 @@ gnark() { } generate_and_test() { - local utxos=$1 + local compressedAccounts=$1 mkdir -p circuits - CIRCUIT_FILE="/tmp/circuit_${DEPTH}_${utxos}.key" - TEST_FILE="/tmp/inputs_${DEPTH}_${utxos}.json" + CIRCUIT_FILE="/tmp/circuit_${DEPTH}_${compressedAccounts}.key" + TEST_FILE="/tmp/inputs_${DEPTH}_${compressedAccounts}.json" if [ ! -f "${CIRCUIT_FILE}" ]; then echo "Prover setup..." - gnark setup --circuit inclusion --utxos "$utxos" --tree-depth "$DEPTH" --output "${CIRCUIT_FILE}" + gnark setup --circuit inclusion --compressedAccounts "$compressedAccounts" --tree-depth "$DEPTH" --output "${CIRCUIT_FILE}" fi if [ ! -f "${TEST_FILE}" ]; then echo "Generating test inputs..." - gnark gen-test-params --utxos "$utxos" --tree-depth "$DEPTH" > "${TEST_FILE}" + gnark gen-test-params --compressedAccounts "$compressedAccounts" --tree-depth "$DEPTH" > "${TEST_FILE}" fi } run_benchmark() { - local utxos=$1 - echo "Benchmarking with $utxos utxos..." - TEST_FILE="/tmp/inputs_${DEPTH}_${utxos}.json" + local compressedAccounts=$1 + echo "Benchmarking with $compressedAccounts compressedAccounts..." + TEST_FILE="/tmp/inputs_${DEPTH}_${compressedAccounts}.json" curl -s -S -X POST -d @"${TEST_FILE}" "$URL" -o /dev/null sleep 1 } start_server() { - utxos_arr=$1 - for utxos in "${utxos_arr[@]}" + compressedAccounts_arr=$1 + for compressedAccounts in "${compressedAccounts_arr[@]}" do - keys_file+="--keys-file /tmp/circuit_${DEPTH}_${utxos}.key " + keys_file+="--keys-file /tmp/circuit_${DEPTH}_${compressedAccounts}.key " done echo "Starting server with keys: $keys_file" gnark start \ @@ -47,24 +47,24 @@ start_server() { } # Define an array containing the desired values -declare -a utxos_arr=("1" "2" "3" "4" "8") +declare -a compressedAccounts_arr=("1" "2" "3" "4" "8") # Kill the server killall light-prover # Generate keys and test inputs -for utxos in "${utxos_arr[@]}" +for compressedAccounts in "${compressedAccounts_arr[@]}" do - generate_and_test $utxos + generate_and_test $compressedAccounts done # Start the server -start_server "${utxos_arr[@]}" +start_server "${compressedAccounts_arr[@]}" # Run the benchmarks -for utxos in "${utxos_arr[@]}" +for compressedAccounts in "${compressedAccounts_arr[@]}" do - run_benchmark $utxos + run_benchmark $compressedAccounts done echo "Done. Benchmarking results are in log.txt." diff --git a/light-prover/scripts/generate_keys.sh b/light-prover/scripts/generate_keys.sh index 5e94e7c96a..7dc7824ae3 100755 --- a/light-prover/scripts/generate_keys.sh +++ b/light-prover/scripts/generate_keys.sh @@ -8,32 +8,32 @@ gnark() { } generate() { - local INCLUSION_UTXOS=$1 - local NON_INCLUSION_UTXOS=$2 + local INCLUSION_COMPRESSED_ACCOUNTS=$1 + local NON_INCLUSION_COMPRESSED_ACCOUNTS=$2 local CIRCUIT_TYPE=$3 mkdir -p circuits if [ "$CIRCUIT_TYPE" == "inclusion" ]; then - UTXOS=$INCLUSION_UTXOS + COMPRESSED_ACCOUNTS=$INCLUSION_COMPRESSED_ACCOUNTS CIRCUIT_TYPE_RS="inclusion" elif [ "$CIRCUIT_TYPE" == "non-inclusion" ]; then - UTXOS=$NON_INCLUSION_UTXOS + COMPRESSED_ACCOUNTS=$NON_INCLUSION_COMPRESSED_ACCOUNTS # rust file names cannot include dashes CIRCUIT_TYPE_RS="non_inclusion" else - UTXOS="${INCLUSION_UTXOS}_${NON_INCLUSION_UTXOS}" + COMPRESSED_ACCOUNTS="${INCLUSION_COMPRESSED_ACCOUNTS}_${NON_INCLUSION_COMPRESSED_ACCOUNTS}" CIRCUIT_TYPE_RS="combined" fi - CIRCUIT_FILE="./proving-keys/${CIRCUIT_TYPE}_${DEPTH}_${UTXOS}.key" - CIRCUIT_VKEY_FILE="./proving-keys/${CIRCUIT_TYPE}_${DEPTH}_${UTXOS}.vkey" - CIRCUIT_VKEY_RS_FILE="../circuit-lib/verifier/src/verifying_keys/${CIRCUIT_TYPE_RS}_${DEPTH}_${UTXOS}.rs" + CIRCUIT_FILE="./proving-keys/${CIRCUIT_TYPE}_${DEPTH}_${COMPRESSED_ACCOUNTS}.key" + CIRCUIT_VKEY_FILE="./proving-keys/${CIRCUIT_TYPE}_${DEPTH}_${COMPRESSED_ACCOUNTS}.vkey" + CIRCUIT_VKEY_RS_FILE="../circuit-lib/verifier/src/verifying_keys/${CIRCUIT_TYPE_RS}_${DEPTH}_${COMPRESSED_ACCOUNTS}.rs" - echo "Generating ${CIRCUIT_TYPE} circuit for ${UTXOS} UTXOs..." - echo "go run . setup --circuit ${CIRCUIT_TYPE} --inclusion-utxos ${INCLUSION_UTXOS} --non-inclusion-utxos ${NON_INCLUSION_UTXOS} --inclusion-tree-depth ${DEPTH} --non-inclusion-tree-depth ${DEPTH} --output ${CIRCUIT_FILE} --output-vkey ${CIRCUIT_VKEY_FILE}" + echo "Generating ${CIRCUIT_TYPE} circuit for ${COMPRESSED_ACCOUNTS} COMPRESSED_ACCOUNTs..." + echo "go run . setup --circuit ${CIRCUIT_TYPE} --inclusion-compressedAccounts ${INCLUSION_COMPRESSED_ACCOUNTS} --non-inclusion-compressedAccounts ${NON_INCLUSION_COMPRESSED_ACCOUNTS} --inclusion-tree-depth ${DEPTH} --non-inclusion-tree-depth ${DEPTH} --output ${CIRCUIT_FILE} --output-vkey ${CIRCUIT_VKEY_FILE}" gnark setup \ --circuit "${CIRCUIT_TYPE}" \ - --inclusion-utxos "$INCLUSION_UTXOS" \ - --non-inclusion-utxos "$NON_INCLUSION_UTXOS" \ + --inclusion-compressedAccounts "$INCLUSION_COMPRESSED_ACCOUNTS" \ + --non-inclusion-compressedAccounts "$NON_INCLUSION_COMPRESSED_ACCOUNTS" \ --inclusion-tree-depth "$DEPTH" \ --non-inclusion-tree-depth "$DEPTH" \ --output "${CIRCUIT_FILE}" \ @@ -41,27 +41,27 @@ generate() { cargo xtask generate-vkey-rs --input-path "${CIRCUIT_VKEY_FILE}" --output-path "${CIRCUIT_VKEY_RS_FILE}" } -declare -a inclusion_utxos_arr=("1" "2" "3" "4" "8") +declare -a inclusion_compressedAccounts_arr=("1" "2" "3" "4" "8") -for utxos in "${inclusion_utxos_arr[@]}" +for compressedAccounts in "${inclusion_compressedAccounts_arr[@]}" do - generate "$utxos" "0" "inclusion" + generate "$compressedAccounts" "0" "inclusion" done -declare -a non_inclusion_utxos_arr=("1" "2") +declare -a non_inclusion_compressedAccounts_arr=("1" "2") -for utxos in "${non_inclusion_utxos_arr[@]}" +for compressedAccounts in "${non_inclusion_compressedAccounts_arr[@]}" do - generate "0" "$utxos" "non-inclusion" + generate "0" "$compressedAccounts" "non-inclusion" done -declare -a combined_inclusion_utxos_arr=("1" "2" "3" "4") -declare -a combined_non_inclusion_utxos_arr=("1" "2") +declare -a combined_inclusion_compressedAccounts_arr=("1" "2" "3" "4") +declare -a combined_non_inclusion_compressedAccounts_arr=("1" "2") -for i_utxos in "${combined_inclusion_utxos_arr[@]}" +for i_compressedAccounts in "${combined_inclusion_compressedAccounts_arr[@]}" do - for ni_utxos in "${combined_non_inclusion_utxos_arr[@]}" + for ni_compressedAccounts in "${combined_non_inclusion_compressedAccounts_arr[@]}" do - generate "$i_utxos" "$ni_utxos" "combined" + generate "$i_compressedAccounts" "$ni_compressedAccounts" "combined" done done