From 3db63d947f5e4066b3a1e19dfa70f30d41438aa4 Mon Sep 17 00:00:00 2001 From: Keyao Shen Date: Mon, 1 Dec 2025 21:06:04 -0800 Subject: [PATCH 1/2] Update error handling --- op-batcher/batcher/espresso.go | 41 +++++++++++----------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/op-batcher/batcher/espresso.go b/op-batcher/batcher/espresso.go index a4affc8f372..8939b6a01b3 100644 --- a/op-batcher/batcher/espresso.go +++ b/op-batcher/batcher/espresso.go @@ -1,8 +1,8 @@ package batcher import ( + "errors" "fmt" - "strings" "time" "context" @@ -210,16 +210,13 @@ const ( Skip ) -// TODO (Keyao) Update the espresso-network-go repo for better error handling. -// -// // Evaluate the submission job. // // # Returns // // * If there is no error: Handle. // -// * If there is an issue on our side: Skip. +// * If there is a permanent issue that won't be fixed by a retry: Skip. // // * Otherwise: RetrySubmission. func evaluateSubmission(jobResp espressoSubmitTransactionJobResponse) JobEvaluation { @@ -230,25 +227,13 @@ func evaluateSubmission(jobResp espressoSubmitTransactionJobResponse) JobEvaluat return Handle } - msg := err.Error() - - // If the transaction is invalid due to a JSON error, skip the submission. - if strings.Contains(msg, "json: unsupported type:") || - strings.Contains(msg, "json: unsupported value:") || - strings.Contains(msg, "json: error calling") || - strings.Contains(msg, "json: invalid UTF-8 in string") || - strings.Contains(msg, "json: invalid number literal") || - strings.Contains(msg, "json: encoding error for type") { - log.Warn("json.Marshal fails, skipping", "msg", msg) + if errors.Is(err, espressoClient.ErrPermanent) { return Skip } - // If the request is invalid (likely due to API change), skip the submission. - if strings.Contains(msg, "net/http: nil Context") || - strings.Contains(msg, "net/http: invalid method") || - strings.HasPrefix(msg, "parse ") { - log.Warn("NewRequestWithContext fails, skipping", "msg", msg) - return Skip + if !errors.Is(err, espressoClient.ErrEphemeral) { + // Log the warning for a potentially missed error handling, but stil retry it. + log.Warn("error not explicitly marked as retryable or not", "err", err) } // Otherwise, retry the submission. @@ -319,16 +304,13 @@ const VERIFY_RECEIPT_TIMEOUT = 4 * time.Second // retrying a job that failed to verify the receipt. const VERIFY_RECEIPT_RETRY_DELAY = 100 * time.Millisecond -// TODO (Keyao) Update the espresso-network-go repo for better error handling. -// -// // Evaluate the verification job. // // # Returns // // * If there is no error: Handle. // -// * If there is an issue on our side: Skip. +// * If there is a permanent issue that won't be fixed by a retry: Skip. // // * If the verification times out: RetrySubmission. // @@ -341,12 +323,15 @@ func evaluateVerification(jobResp espressoVerifyReceiptJobResponse) JobEvaluatio return Handle } - // If the hash is invalid, skip the verification. - if strings.Contains(err.Error(), "hash is nil") { - log.Warn("Hash is nil, skipping") + if errors.Is(err, espressoClient.ErrPermanent) { return Skip } + if !errors.Is(err, espressoClient.ErrEphemeral) { + // Log the warning for a potentially missed error handling, but still retry it. + log.Warn("error not explicitly marked as retryable or not", "err", err) + } + // If the verification times out, degrade to the submission phase and try again. if have := time.Now(); have.Sub(jobResp.job.start) > VERIFY_RECEIPT_TIMEOUT { return RetrySubmission From d709a1422964adc6e9735d76c8778691712c0923 Mon Sep 17 00:00:00 2001 From: Keyao Shen Date: Thu, 4 Dec 2025 15:36:45 -0800 Subject: [PATCH 2/2] Fix typo Co-authored-by: Phil --- op-batcher/batcher/espresso.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op-batcher/batcher/espresso.go b/op-batcher/batcher/espresso.go index 8939b6a01b3..b4ba62af4f8 100644 --- a/op-batcher/batcher/espresso.go +++ b/op-batcher/batcher/espresso.go @@ -232,7 +232,7 @@ func evaluateSubmission(jobResp espressoSubmitTransactionJobResponse) JobEvaluat } if !errors.Is(err, espressoClient.ErrEphemeral) { - // Log the warning for a potentially missed error handling, but stil retry it. + // Log the warning for a potentially missed error handling, but still retry it. log.Warn("error not explicitly marked as retryable or not", "err", err) }