From a3c18b99a47c8f7b29877ea76bbdac2a2511910a Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Thu, 29 Jun 2023 19:09:40 +0800 Subject: [PATCH] feat(roller): return concrete error for get traces error (#595) Co-authored-by: Lawliet-Chan <1576710154@qq.com> Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> --- roller/roller.go | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/roller/roller.go b/roller/roller.go index 7f3a6a591..eb69c8b8f 100644 --- a/roller/roller.go +++ b/roller/roller.go @@ -231,30 +231,38 @@ func (r *Roller) prove() error { var traces []*types.BlockTrace traces, err = r.getSortedTracesByHashes(task.Task.BlockHashes) - if err != nil { - return err - } - // If FFI panic during Prove, the roller will restart and re-enter prove() function, - // the proof will not be submitted. - var proof *message.AggProof - proof, err = r.prover.Prove(task.Task.ID, traces) if err != nil { proofMsg = &message.ProofDetail{ Status: message.StatusProofError, - Error: err.Error(), + Error: "get traces failed", ID: task.Task.ID, Type: task.Task.Type, - Proof: &message.AggProof{}, + Proof: nil, } - log.Error("prove block failed!", "task-id", task.Task.ID) + log.Error("get traces failed!", "task-id", task.Task.ID, "err", err) } else { - proofMsg = &message.ProofDetail{ - Status: message.StatusOk, - ID: task.Task.ID, - Type: task.Task.Type, - Proof: proof, + // If FFI panic during Prove, the roller will restart and re-enter prove() function, + // the proof will not be submitted. + var proof *message.AggProof + proof, err = r.prover.Prove(task.Task.ID, traces) + if err != nil { + proofMsg = &message.ProofDetail{ + Status: message.StatusProofError, + Error: err.Error(), + ID: task.Task.ID, + Type: task.Task.Type, + Proof: nil, + } + log.Error("prove block failed!", "task-id", task.Task.ID) + } else { + proofMsg = &message.ProofDetail{ + Status: message.StatusOk, + ID: task.Task.ID, + Type: task.Task.Type, + Proof: proof, + } + log.Info("prove block successfully!", "task-id", task.Task.ID) } - log.Info("prove block successfully!", "task-id", task.Task.ID) } } else { // when the roller has more than 3 times panic, @@ -264,7 +272,7 @@ func (r *Roller) prove() error { Error: "zk proving panic", ID: task.Task.ID, Type: task.Task.Type, - Proof: &message.AggProof{}, + Proof: nil, } }