Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 4daea04

Browse files
committed
feat(prover): integrate new Raiko APIs (openAPI)
1 parent 15cf108 commit 4daea04

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

prover/proof_producer/sgx_producer.go

+34-38
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,34 @@ type SGXProofProducer struct {
3737
DummyProofProducer
3838
}
3939

40-
// SGXRequestProofBody represents the JSON body for requesting the proof.
41-
type SGXRequestProofBody struct {
42-
JsonRPC string `json:"jsonrpc"` //nolint:revive,stylecheck
43-
ID *big.Int `json:"id"`
44-
Method string `json:"method"`
45-
Params []*SGXRequestProofBodyParam `json:"params"`
40+
// RaikoRequestProofBody represents the JSON body for requesting the proof.
41+
type RaikoRequestProofBody struct {
42+
L2RPC string `json:"rpc"`
43+
L1RPC string `json:"l1_rpc"`
44+
L1BeaconRPC string `json:"beacon_rpc"`
45+
Block *big.Int `json:"block_number"`
46+
Prover string `json:"prover"`
47+
Graffiti string `json:"graffiti"`
48+
Type string `json:"proof_type"`
49+
SGX *SGXRequestProofBodyParam `json:"sgx"`
50+
RISC0 RISC0RequestProofBodyParam `json:"risc0"`
4651
}
4752

48-
// SGXRequestProofBodyParam represents the JSON body of RequestProofBody's `param` field.
53+
// SGXRequestProofBodyParam represents the JSON body of RaikoRequestProofBody's `sgx` field.
4954
type SGXRequestProofBodyParam struct {
50-
Type string `json:"proof_type"`
51-
Block *big.Int `json:"block_number"`
52-
L2RPC string `json:"rpc"`
53-
L1RPC string `json:"l1_rpc"`
54-
L1BeaconRPC string `json:"beacon_rpc"`
55-
Prover string `json:"prover"`
56-
Graffiti string `json:"graffiti"`
57-
ProofParam *ProofParam `json:"sgx"`
58-
}
59-
60-
// ProofParam represents the JSON body of SGXRequestProofBodyParam's `sgx` field.
61-
type ProofParam struct {
6255
Setup bool `json:"setup"`
6356
Bootstrap bool `json:"bootstrap"`
6457
Prove bool `json:"prove"`
6558
}
6659

60+
// RISC0RequestProofBodyParam represents the JSON body of RaikoRequestProofBody's `risc0` field.
61+
type RISC0RequestProofBodyParam struct {
62+
Bonsai bool `json:"bonsai"`
63+
Snark bool `json:"snark"`
64+
Profile bool `json:"profile"`
65+
ExecutionPo2 *big.Int `json:"execution_po2"`
66+
}
67+
6768
// SGXRequestProofBodyResponse represents the JSON body of the response of the proof requests.
6869
type SGXRequestProofBodyResponse struct {
6970
JsonRPC string `json:"jsonrpc"` //nolint:revive,stylecheck
@@ -162,32 +163,27 @@ func (s *SGXProofProducer) callProverDaemon(ctx context.Context, opts *ProofRequ
162163

163164
// requestProof sends a RPC request to proverd to try to get the requested proof.
164165
func (s *SGXProofProducer) requestProof(opts *ProofRequestOptions) (*RaikoHostOutput, error) {
165-
reqBody := SGXRequestProofBody{
166-
JsonRPC: "2.0",
167-
ID: common.Big1,
168-
Method: "proof",
169-
Params: []*SGXRequestProofBodyParam{{
170-
Type: s.ProofType,
171-
Block: opts.BlockID,
172-
L2RPC: s.L2Endpoint,
173-
L1RPC: s.L1Endpoint,
174-
L1BeaconRPC: s.L1BeaconEndpoint,
175-
Prover: opts.ProverAddress.Hex()[2:],
176-
Graffiti: opts.Graffiti,
177-
ProofParam: &ProofParam{
178-
Setup: false,
179-
Bootstrap: false,
180-
Prove: true,
181-
},
182-
}},
166+
reqBody := RaikoRequestProofBody{
167+
Type: s.ProofType,
168+
Block: opts.BlockID,
169+
L2RPC: s.L2Endpoint,
170+
L1RPC: s.L1Endpoint,
171+
L1BeaconRPC: s.L1BeaconEndpoint,
172+
Prover: opts.ProverAddress.Hex()[2:],
173+
Graffiti: opts.Graffiti,
174+
SGX: &SGXRequestProofBodyParam{
175+
Setup: false,
176+
Bootstrap: false,
177+
Prove: true,
178+
},
183179
}
184180

185181
jsonValue, err := json.Marshal(reqBody)
186182
if err != nil {
187183
return nil, err
188184
}
189185

190-
res, err := http.Post(s.RaikoHostEndpoint, "application/json", bytes.NewBuffer(jsonValue))
186+
res, err := http.Post(s.RaikoHostEndpoint+"/proof", "application/json", bytes.NewBuffer(jsonValue))
191187
if err != nil {
192188
return nil, err
193189
}

0 commit comments

Comments
 (0)