Skip to content

Commit

Permalink
persist validation errors in database (#413)
Browse files Browse the repository at this point in the history
save validation error
  • Loading branch information
metachris authored May 17, 2023
1 parent 74750e4 commit 557d03e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,23 +1822,23 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
go api.processOptimisticBlock(opts)
} else {
// Simulate block (synchronously)
reqErr, simErr := api.simulateBlock(req.Context(), opts) // success/error logging happens inside
requestErr, validationErr = 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
if os.IsTimeout(reqErr) {
if requestErr != nil { // Request error
if os.IsTimeout(requestErr) {
api.RespondError(w, http.StatusGatewayTimeout, "validation request timeout")
} else {
api.RespondError(w, http.StatusBadRequest, reqErr.Error())
api.RespondError(w, http.StatusBadRequest, requestErr.Error())
}
return
} else {
wasSimulated = true
if simErr != nil {
api.RespondError(w, http.StatusBadRequest, simErr.Error())
if validationErr != nil {
api.RespondError(w, http.StatusBadRequest, validationErr.Error())
return
}
}
Expand Down

0 comments on commit 557d03e

Please sign in to comment.