Skip to content

Commit 2d37050

Browse files
committed
feat(script): add prove.sh
1 parent 80ef0c2 commit 2d37050

File tree

2 files changed

+128
-104
lines changed

2 files changed

+128
-104
lines changed

script/prove-batch.sh

+2-104
Original file line numberDiff line numberDiff line change
@@ -8,108 +8,6 @@ proof="$2"
88
batch_id="$3"
99
# Use the fourth parameter(s) as the batch number as a range
1010
batch_proposal_height="$4"
11+
aggregate="${5:-"false"}"
1112

12-
13-
# Check the chain name and set the corresponding RPC values
14-
if [ "$chain" == "ethereum" ]; then
15-
l1_network="ethereum"
16-
elif [ "$chain" == "holesky" ]; then
17-
l1_network="holesky"
18-
elif [ "$chain" == "taiko_mainnet" ]; then
19-
l1_network="ethereum"
20-
elif [ "$chain" == "taiko_a7" ]; then
21-
l1_network="holesky"
22-
elif [ "$chain" == "taiko_dev" ]; then
23-
l1_network="taiko_dev_l1"
24-
else
25-
echo "Using customized chain name $1. Please double check the RPCs."
26-
l1_network="holesky"
27-
fi
28-
29-
if [ "$proof" == "native" ]; then
30-
proofParam='
31-
"proof_type": "NATIVE",
32-
"blob_proof_type": "proof_of_equivalence",
33-
"native" : {
34-
"json_guest_input": null
35-
}
36-
'
37-
elif [ "$proof" == "sp1" ]; then
38-
proofParam='
39-
"proof_type": "sp1",
40-
"blob_proof_type": "proof_of_equivalence",
41-
"sp1": {
42-
"recursion": "plonk",
43-
"prover": "network",
44-
"verify": true
45-
}
46-
'
47-
elif [ "$proof" == "sp1-aggregation" ]; then
48-
proofParam='
49-
"proof_type": "sp1",
50-
"blob_proof_type": "proof_of_equivalence",
51-
"sp1": {
52-
"recursion": "compressed",
53-
"prover": "network",
54-
"verify": false
55-
}
56-
'
57-
elif [ "$proof" == "sgx" ]; then
58-
proofParam='
59-
"proof_type": "sgx",
60-
"sgx" : {
61-
"instance_id": 123,
62-
"setup": false,
63-
"bootstrap": false,
64-
"prove": true,
65-
"input_path": null
66-
}
67-
'
68-
elif [ "$proof" == "risc0" ]; then
69-
proofParam='
70-
"proof_type": "risc0",
71-
"blob_proof_type": "proof_of_equivalence",
72-
"risc0": {
73-
"bonsai": false,
74-
"snark": false,
75-
"profile": true,
76-
"execution_po2": 18
77-
}
78-
'
79-
elif [ "$proof" == "risc0-bonsai" ]; then
80-
proofParam='
81-
"proof_type": "risc0",
82-
"blob_proof_type": "proof_of_equivalence",
83-
"risc0": {
84-
"bonsai": true,
85-
"snark": true,
86-
"profile": false,
87-
"execution_po2": 20
88-
}
89-
'
90-
else
91-
echo "Invalid proof name. Please use 'native', 'risc0[-bonsai]', 'sp1', or 'sgx'."
92-
exit 1
93-
fi
94-
95-
96-
prover="0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
97-
graffiti="8008500000000000000000000000000000000000000000000000000000000000"
98-
99-
100-
echo "- proving batch $batch_id @ $batch_proposal_height on $chain with $proof proof"
101-
curl --location --request POST 'http://localhost:8080/v3/proof/batch' \
102-
--header 'Content-Type: application/json' \
103-
--header 'Authorization: Bearer' \
104-
--data-raw "{
105-
\"network\": \"$chain\",
106-
\"l1_network\": \"$l1_network\",
107-
\"batches\": [{\"batch_id\": $batch_id, \"l1_inclusion_block_number\": $batch_proposal_height}],
108-
\"prover\": \"$prover\",
109-
\"graffiti\": \"$graffiti\",
110-
$proofParam
111-
}"
112-
set +x
113-
echo ""
114-
115-
sleep 1.0
13+
$(dirname "$0")/prove.sh batch "$chain" "$proof" "$batch_id":"$batch_proposal_height" "$aggregate"

script/prove.sh

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/usr/bin/env bash
2+
3+
prover=${prover:-"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"}
4+
graffiti=${graffiti:-"8008500000000000000000000000000000000000000000000000000000000000"}
5+
raiko_endpoint=${raiko_endpoint:-"http://localhost:8080"}
6+
raiko_api_key=${raiko_api_key:-"4cbd753fbcbc2639de804f8ce425016a50e0ecd53db00cb5397912e83f5e570e"}
7+
8+
usage() {
9+
echo "Usage:"
10+
echo " prove.sh batch <chain> <proof_type> [<batch_id>:<batch_proposal_height>,...] [aggregate(default: false)]"
11+
echo " prove.sh block <chain> <proof_type> <block_id> [aggregate(default: false)]"
12+
exit 1
13+
}
14+
15+
# Check the chain name and set the corresponding RPC values
16+
get_l1_network() {
17+
local chain="$1"
18+
local l1_network
19+
20+
if [ "$chain" == "ethereum" ]; then
21+
l1_network="ethereum"
22+
elif [ "$chain" == "holesky" ]; then
23+
l1_network="holesky"
24+
elif [ "$chain" == "taiko_mainnet" ]; then
25+
l1_network="ethereum"
26+
elif [ "$chain" == "taiko_a7" ]; then
27+
l1_network="holesky"
28+
elif [ "$chain" == "taiko_dev" ]; then
29+
l1_network="taiko_dev_l1"
30+
else
31+
echo "Invalid chain name. Please use 'ethereum', 'holesky', 'taiko_mainnet', 'taiko_a7', or 'taiko_dev'."
32+
exit 1
33+
fi
34+
35+
echo "$l1_network"
36+
}
37+
38+
prove_batch() {
39+
local chain="${1?"chain is required"}"
40+
local proof_type="${2?"proof_type is required"}"
41+
local batch_inputs="${3?"batch inputs are required"}"
42+
local aggregate="${4:-"false"}"
43+
local l1_network="${5?"l1_network is required"}"
44+
45+
# Convert comma-separated batch inputs into JSON array
46+
local batches_json="["
47+
local first=true
48+
IFS=',' read -ra BATCHES <<< "$batch_inputs"
49+
for batch in "${BATCHES[@]}"; do
50+
IFS=':' read -r batch_id batch_proposal_height <<< "$batch"
51+
if [ "$first" = true ]; then
52+
first=false
53+
else
54+
batches_json+=","
55+
fi
56+
batches_json+="{\"batch_id\": $batch_id, \"l1_inclusion_block_number\": $batch_proposal_height}"
57+
done
58+
batches_json+="]"
59+
60+
set -x
61+
curl --location --request POST "$raiko_endpoint/v3/proof/batch" \
62+
--header "Content-Type: application/json" \
63+
--header "Authorization: Bearer $raiko_api_key" \
64+
--data-raw "{
65+
\"network\": \"$chain\",
66+
\"l1_network\": \"$l1_network\",
67+
\"batches\": $batches_json,
68+
\"prover\": \"$prover\",
69+
\"graffiti\": \"$graffiti\",
70+
\"aggregate\": $aggregate,
71+
\"proof_type\": \"$proof_type\"
72+
}"
73+
set +x
74+
}
75+
76+
prove_block() {
77+
local chain="${1?"chain is required"}"
78+
local proof_type="${2?"proof_type is required"}"
79+
local block_id="${3?"block_id is required"}"
80+
local aggregate="${4:-"false"}"
81+
local l1_network="${5?"l1_network is required"}"
82+
83+
set -x
84+
curl --location --request POST "$raiko_endpoint/v2/proof" \
85+
--header "Content-Type: application/json" \
86+
--header "Authorization: Bearer $raiko_api_key" \
87+
--data-raw "{
88+
\"network\": \"$chain\",
89+
\"l1_network\": \"$l1_network\",
90+
\"block_numbers\": [[$block_id, null], [$(($block_id+1)), null]],
91+
\"block_number\": $block_id,
92+
\"prover\": \"$prover\",
93+
\"graffiti\": \"$graffiti\",
94+
\"aggregate\": $aggregate,
95+
\"proof_type\": \"$proof_type\"
96+
}"
97+
set +x
98+
}
99+
100+
main() {
101+
mode="$1"
102+
case "$mode" in
103+
batch)
104+
chain="$2"
105+
proof_type="$3"
106+
batch_inputs="$4"
107+
aggregate="${5:-"false"}"
108+
l1_network=$(get_l1_network "$chain")
109+
prove_batch "$chain" "$proof_type" "$batch_inputs" "$aggregate" "$l1_network"
110+
;;
111+
block)
112+
chain="$2"
113+
proof_type="$3"
114+
block_id="$4"
115+
aggregate="${5:-"false"}"
116+
l1_network=$(get_l1_network "$chain")
117+
prove_block "$chain" "$proof_type" "$block_id" "$aggregate" "$l1_network"
118+
;;
119+
*)
120+
usage
121+
;;
122+
esac
123+
echo ""
124+
}
125+
126+
main "$@"

0 commit comments

Comments
 (0)