From fea1cbe594460365d63f6d08815bc95b50bb4af1 Mon Sep 17 00:00:00 2001 From: Gavin Yu Date: Mon, 20 May 2024 16:47:39 +0800 Subject: [PATCH] feat(taiko-client): integrate new Raiko APIs (openAPI) (#17254) Co-authored-by: David --- .../prover/proof_producer/sgx_producer.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/taiko-client/prover/proof_producer/sgx_producer.go b/packages/taiko-client/prover/proof_producer/sgx_producer.go index bd1cbae1100..0e002547469 100644 --- a/packages/taiko-client/prover/proof_producer/sgx_producer.go +++ b/packages/taiko-client/prover/proof_producer/sgx_producer.go @@ -66,8 +66,12 @@ type RISC0RequestProofBodyParam struct { // RaikoRequestProofBodyResponse represents the JSON body of the response of the proof requests. type RaikoRequestProofBodyResponse struct { - Proof string `json:"proof"` //nolint:revive,stylecheck - ErrorMessage string `json:"message"` + Data *RaikoProofData `json:"data"` + ErrorMessage string `json:"message"` +} + +type RaikoProofData struct { + Proof string `json:"proof"` //nolint:revive,stylecheck } // RequestProof implements the ProofProducer interface. @@ -135,7 +139,14 @@ func (s *SGXProofProducer) callProverDaemon(ctx context.Context, opts *ProofRequ log.Debug("Proof generation output", "output", output) - proof = common.Hex2Bytes(output.Proof[2:]) + // Raiko returns "" as proof when proof type is native, + // so we just convert "" to bytes + if s.ProofType == ProofTypeCPU { + proof = common.Hex2Bytes(output.Data.Proof) + } else { + proof = common.Hex2Bytes(output.Data.Proof[2:]) + } + log.Info( "Proof generated", "height", opts.BlockID,