From 98a98fd4636e3cd5f3ec019493a72880e141f494 Mon Sep 17 00:00:00 2001 From: Gavin Yu Date: Wed, 25 Dec 2024 09:14:12 +0800 Subject: [PATCH] feat(taiko-client): catch raiko deserialization errors (#18644) --- packages/taiko-client/prover/proof_producer/sgx_producer.go | 6 +++++- .../taiko-client/prover/proof_producer/zkvm_producer.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/taiko-client/prover/proof_producer/sgx_producer.go b/packages/taiko-client/prover/proof_producer/sgx_producer.go index 3f4861fd933..91ca16064f3 100644 --- a/packages/taiko-client/prover/proof_producer/sgx_producer.go +++ b/packages/taiko-client/prover/proof_producer/sgx_producer.go @@ -308,6 +308,9 @@ func (s *SGXProofProducer) requestBatchProof( return nil, fmt.Errorf("failed to get batch proof, msg: %s", output.ErrorMessage) } + if output.Data == nil { + return nil, fmt.Errorf("unexpected structure error, response: %s", string(resBytes)) + } if output.Data.Status == ErrProofInProgress.Error() { return nil, ErrProofInProgress } @@ -315,7 +318,8 @@ func (s *SGXProofProducer) requestBatchProof( return nil, ErrRetry } - if len(output.Data.Proof.Proof) == 0 { + if output.Data.Proof == nil || + len(output.Data.Proof.Proof) == 0 { return nil, errEmptyProof } proof = common.Hex2Bytes(output.Data.Proof.Proof[2:]) diff --git a/packages/taiko-client/prover/proof_producer/zkvm_producer.go b/packages/taiko-client/prover/proof_producer/zkvm_producer.go index 3e2711a1962..98f8529acc5 100644 --- a/packages/taiko-client/prover/proof_producer/zkvm_producer.go +++ b/packages/taiko-client/prover/proof_producer/zkvm_producer.go @@ -479,6 +479,10 @@ func (s *ZKvmProofProducer) requestBatchProof( if len(output.ErrorMessage) > 0 || len(output.Error) > 0 { return nil, fmt.Errorf("failed to get batch proof, msg: %s", output.ErrorMessage) } + if output.Data == nil { + return nil, fmt.Errorf("unexpected structure error, response: %s", string(resBytes)) + } + if output.Data.Status == ErrProofInProgress.Error() { return nil, ErrProofInProgress } @@ -486,7 +490,7 @@ func (s *ZKvmProofProducer) requestBatchProof( return nil, ErrRetry } - if len(output.Data.Proof.Proof) == 0 { + if output.Data.Proof == nil || len(output.Data.Proof.Proof) == 0 { return nil, errEmptyProof } proof = common.Hex2Bytes(output.Data.Proof.Proof[2:])