Skip to content

Commit

Permalink
builder submission: on ssz decoding error, fallback to json (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris authored May 9, 2023
1 parent 3c45e90 commit 42dfeca
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1328,10 +1328,17 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
payload.Capella = new(builderCapella.SubmitBlockRequest)
if err = payload.Capella.UnmarshalSSZ(requestPayloadBytes); err != nil {
log.WithError(err).Warn("could not decode payload - SSZ")
api.RespondError(w, http.StatusBadRequest, err.Error())
return

// SSZ decoding failed. try JSON as fallback (some builders used octet-stream for json before)
if err2 := json.Unmarshal(requestPayloadBytes, payload); err2 != nil {
log.WithError(err).Warn("could not decode payload - SSZ or JSON")
api.RespondError(w, http.StatusBadRequest, err.Error())
return
}
log = log.WithField("reqContentType", "json")
} else {
log.Debug("received ssz-encoded payload")
}
log.Debug("received ssz-encoded payload")
} else {
log = log.WithField("reqContentType", "json")
if err := json.Unmarshal(requestPayloadBytes, payload); err != nil {
Expand Down

0 comments on commit 42dfeca

Please sign in to comment.