mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
feat: fix bug
This commit is contained in:
@@ -165,7 +165,7 @@ func (c *CoordinatorClient) GetTask(ctx context.Context, req *GetTaskRequest) (*
|
||||
}
|
||||
|
||||
// SubmitProof sends a request to the coordinator to submit proof.
|
||||
func (c *CoordinatorClient) SubmitProof(ctx context.Context, req *SubmitProofRequest) error {
|
||||
func (c *CoordinatorClient) SubmitProof(ctx context.Context, req *SubmitProofRequest) (needDelete bool, err error) {
|
||||
var result SubmitProofResponse
|
||||
|
||||
resp, err := c.client.R().
|
||||
@@ -175,24 +175,24 @@ func (c *CoordinatorClient) SubmitProof(ctx context.Context, req *SubmitProofReq
|
||||
Post("/coordinator/v1/submit_proof")
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("submit proof request failed: %v", err)
|
||||
return false, fmt.Errorf("submit proof request failed: %v", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode() != 200 {
|
||||
return fmt.Errorf("failed to submit proof, status code: %v", resp.StatusCode())
|
||||
return false, fmt.Errorf("failed to submit proof, status code: %v", resp.StatusCode())
|
||||
}
|
||||
|
||||
if result.ErrCode == types.ErrJWTTokenExpired {
|
||||
log.Info("JWT expired, attempting to re-login")
|
||||
if err := c.Login(ctx); err != nil {
|
||||
return fmt.Errorf("JWT expired, re-login failed: %v", err)
|
||||
return false, fmt.Errorf("JWT expired, re-login failed: %v", err)
|
||||
}
|
||||
log.Info("re-login success")
|
||||
return c.SubmitProof(ctx, req)
|
||||
}
|
||||
if result.ErrCode != types.Success {
|
||||
return fmt.Errorf("error code: %v, error message: %v", result.ErrCode, result.ErrMsg)
|
||||
return true, fmt.Errorf("error code: %v, error message: %v", result.ErrCode, result.ErrMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -321,14 +321,19 @@ func (r *Prover) submitProof(msg *message.ProofDetail) error {
|
||||
}
|
||||
|
||||
// send the submit request
|
||||
if err := r.coordinatorClient.SubmitProof(r.ctx, req); err != nil {
|
||||
needDeleteTask, err := r.coordinatorClient.SubmitProof(r.ctx, req)
|
||||
if needDeleteTask {
|
||||
if err := r.stack.Delete(msg.ID); err != nil {
|
||||
log.Error("prover stack pop failed", "task_type", msg.Type, "task_id", msg.ID, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error submitting proof: %v", err)
|
||||
}
|
||||
|
||||
log.Info("proof submitted successfully", "task-id", msg.ID, "task-type", msg.Type, "task-status", msg.Status, "err", msg.Error)
|
||||
if err := r.stack.Delete(msg.ID); err != nil {
|
||||
log.Error("prover stack pop failed", "task_type", msg.Type, "task_id", msg.ID, "err", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -344,16 +349,20 @@ func (r *Prover) submitErr(task *store.ProvingTask, proofFailureType message.Pro
|
||||
}
|
||||
|
||||
// send the submit request
|
||||
if submitErr := r.coordinatorClient.SubmitProof(r.ctx, req); submitErr != nil {
|
||||
needDeleteTask, submitErr := r.coordinatorClient.SubmitProof(r.ctx, req)
|
||||
if needDeleteTask {
|
||||
if err = r.stack.Delete(task.Task.ID); err != nil {
|
||||
log.Error("prover stack pop failed", "task_type", task.Task.Type, "task_id", task.Task.ID, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
if submitErr != nil {
|
||||
return fmt.Errorf("error submitting proof: %v", submitErr)
|
||||
}
|
||||
|
||||
log.Info("proof submitted report failure successfully",
|
||||
"task-id", task.Task.ID, "task-type", task.Task.Type,
|
||||
"task-status", message.StatusProofError, "err", err)
|
||||
if err = r.stack.Delete(task.Task.ID); err != nil {
|
||||
log.Error("prover stack pop failed", "task_type", task.Task.Type, "task_id", task.Task.ID, "err", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user