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