Skip to content

Commit

Permalink
feat: add bash script to test batch inclusion easily
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Oct 7, 2024
1 parent 6d53937 commit 4c8e83c
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# cd to the directory of this script so that this can be run from anywhere
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 ; pwd -P )

# At this point we are in aligned-example
cd "$parent_path" || exit 1

# check if the number of arguments is correct
if [ "$#" -ne 3 ]; then
echo "Usage: verify_batch_inclusion.sh <FIBONACCI_VALIDATOR_ADDRESS> <DATA_FILE_NAME> <VERIFIER_ID>"
exit 1
fi

FIBONACCI_VALIDATOR_ADDRESS=$1
DATA_FILE_NAME=$2
VERIFIER_ID=$3

if [ -z "$RPC_URL" ]; then
echo "RPC_URL is not set. Please set it in .env"
exit 1
fi

if [ -z "$PRIVATE_KEY" ]; then
echo "PRIVATE_KEY is not set. Please set it in .env"
exit 1
fi

proof_commitment=$(jq -r '.proof_commitment' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
pub_input_commitment=$(jq -r '.pub_input_commitment' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
program_id_commitment=$(jq -r '.program_id_commitment' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
proof_generator_addr=$(jq -r '.proof_generator_addr' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
batch_merkle_root=$(jq -r '.batch_merkle_root' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
merkle_proof=$(jq -r '.merkle_proof' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
verification_data_batch_index=$(jq -r '.verification_data_batch_index' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")
pub_input=$(jq -r '.pub_input' "../aligned-integration/batch_inclusion_data/$DATA_FILE_NAME.json")

cast send --rpc-url $RPC_URL $FIBONACCI_VALIDATOR_ADDRESS \
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256, bytes, string)" \
$proof_commitment \
$pub_input_commitment \
$program_id_commitment \
$proof_generator_addr \
$batch_merkle_root \
$merkle_proof \
$verification_data_batch_index \
$pub_input \
$VERIFIER_ID \
--private-key $PRIVATE_KEY

0 comments on commit 4c8e83c

Please sign in to comment.