generated from succinctlabs/sp1-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aligned.sh
executable file
·107 lines (92 loc) · 2.33 KB
/
aligned.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
NETWORK=holesky
RPC_URL=https://ethereum-holesky-rpc.publicnode.com
# Deposits 0.1 ether to the batcher contract
deposit() {
local keystore_path=$1
aligned deposit-to-batcher \
--rpc_url $RPC_URL \
--network $NETWORK \
--keystore_path "$keystore_path" \
--amount 0.1ether
}
# Reads the keystore and prints balance
balance() {
local keystore_path=$1
local address=$(cast wallet address --keystore "$keystore_path")
aligned get-user-balance \
--rpc_url $RPC_URL \
--network $NETWORK \
--user_addr "$address"
}
# Submit the final aggregated proof only
submitagg() {
local keystore_path=$1
local json_path=$2
local proof_path="${json_path%.json}.agg.proof"
local pub_path="${json_path%.json}.agg.pub"
if [ ! -f "$proof_path" ] || [ ! -f "$pub_path" ]; then
echo "Required files not found: $proof_path or $pub_path"
exit 1
fi
# submit using aggregator elf
aligned submit \
--proving_system SP1 \
--proof "$proof_path" \
--public_input "$pub_path" \
--vm_program ./elf/riscv32im-succinct-aggregator-elf \
--batcher_url wss://batcher.alignedlayer.com \
--keystore_path "$keystore_path" \
--network $NETWORK \
--rpc_url $RPC_URL
}
# Submit all proofs that resulted from the batched proofs
submit() {
local keystore_path=$1
local json_path=$2
local index=0
while true; do
local proof_path="${json_path%.json}.$index.proof"
local pub_path="${json_path%.json}.$index.pub"
if [ ! -f "$proof_path" ] || [ ! -f "$pub_path" ]; then
echo "Submitted $index proofs in total."
break
fi
echo "Submitting proof $index"
# submit using VNNS elf
aligned submit \
--proving_system SP1 \
--proof "$proof_path" \
--public_input "$pub_path" \
--vm_program ./elf/riscv32im-succinct-vnns-elf \
--batcher_url wss://batcher.alignedlayer.com \
--keystore_path "$keystore_path" \
--network $NETWORK \
--rpc_url $RPC_URL
index=$((index + 1))
done
}
### Main ###
if [ $# -lt 2 ]; then
echo "Usage: $0 <function_name> <keystore_path>"
exit 1
fi
function_name=$1
case $function_name in
deposit)
deposit $2
;;
balance)
balance $2
;;
submit-agg)
submitagg $2 $3
;;
submit)
submit $2 $3
;;
*)
echo "Invalid function name: $function_name"
exit 1
;;
esac