Skip to content

Commit

Permalink
block validation: log failure only once (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris authored May 15, 2023
1 parent 51ab2f2 commit d2df40a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1810,16 +1810,14 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
optimisticSubmission = true
go api.processOptimisticBlock(opts)
} else {
// Simulate block (synchronously).
reqErr, simErr := api.simulateBlock(req.Context(), opts)
// Simulate block (synchronously)
reqErr, simErr := api.simulateBlock(req.Context(), opts) // success/error logging happens inside
validationDurationMs := time.Since(timeBeforeValidation).Milliseconds()
log = log.WithFields(logrus.Fields{
"timestampAfterValidation": time.Now().UTC().UnixMilli(),
"validationDurationMs": validationDurationMs,
})
if reqErr != nil {
// Request error -- log and return error
log.WithField("requestErr", reqErr.Error()).Info("block validation failed - request error")
if reqErr != nil { // Request error
if os.IsTimeout(reqErr) {
api.RespondError(w, http.StatusGatewayTimeout, "validation request timeout")
} else {
Expand All @@ -1829,7 +1827,6 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
} else {
wasSimulated = true
if simErr != nil {
log.WithField("validationErr", simErr.Error()).Info("block validation failed - validation error")
api.RespondError(w, http.StatusBadRequest, simErr.Error())
return
}
Expand Down

0 comments on commit d2df40a

Please sign in to comment.