Skip to content

Commit

Permalink
Update & reverse payload decoding order
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia committed Oct 14, 2024
1 parent 1adf26a commit 097756d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
8 changes: 1 addition & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
github.com/ethereum/go-ethereum v1.14.9
github.com/flashbots/go-boost-utils v1.8.2-0.20240925223941-58709124077d
github.com/flashbots/go-boost-utils v1.8.2-0.20241014201857-55b15840e530
github.com/flashbots/go-utils v0.5.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
Expand Down Expand Up @@ -90,9 +90,3 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// Remove this when Jim merges pk910's PR.
replace github.com/attestantio/go-eth2-client => github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca

// Remove this when Jim merge's jtraglia's PR.
replace github.com/attestantio/go-builder-client => github.com/jtraglia/go-builder-client v0.4.6-0.20240925183257-4d86495441b5
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/attestantio/go-builder-client v0.5.1-0.20240925223414-5da8987dd6f3 h1:Ccyc8R6CJbnb5oTwjuYSa2XaYWFSN8R43Gh9V1zN3Dg=
github.com/attestantio/go-builder-client v0.5.1-0.20240925223414-5da8987dd6f3/go.mod h1:qM91NvVG+fepPBN2/MDLpWJ9I/zZtpZAkXa8T9GFOvM=
github.com/attestantio/go-eth2-client v0.21.12-0.20241006200801-8fa702e3a895 h1:3uu4l7TK5PPVBvVUpwxftDpKFddEE3g196BYJbKYq4g=
github.com/attestantio/go-eth2-client v0.21.12-0.20241006200801-8fa702e3a895/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -70,8 +74,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/ferranbt/fastssz v0.1.3 h1:ZI+z3JH05h4kgmFXdHuR1aWYsgrg7o+Fw7/NCzM16Mo=
github.com/ferranbt/fastssz v0.1.3/go.mod h1:0Y9TEd/9XuFlh7mskMPfXiI2Dkw4Ddg9EyXt1W7MRvE=
github.com/flashbots/go-boost-utils v1.8.2-0.20240925223941-58709124077d h1:O4iDEwTCD7MaDyccFzmV5yYXfDD99Y2KH284Z4ZR4q0=
github.com/flashbots/go-boost-utils v1.8.2-0.20240925223941-58709124077d/go.mod h1:kU1G5Xk2OBBnYag2RGRuaPuMuuhH2yZx+xHeX91E9Po=
github.com/flashbots/go-boost-utils v1.8.2-0.20241014201857-55b15840e530 h1:8G61JquNZ2f1CXo7jOODKy50zEmR9wC8hi4Za9AFUdA=
github.com/flashbots/go-boost-utils v1.8.2-0.20241014201857-55b15840e530/go.mod h1:CAi7WSr+y5yQhYtluoj/7JlX1yysXPKXJlnH+0DH3V4=
github.com/flashbots/go-utils v0.5.0 h1:ldjWta9B9//DJU2QcwRbErez3+1aKhSn6EoFc6d5kPY=
github.com/flashbots/go-utils v0.5.0/go.mod h1:LauDwifaRdSK0mS5X34GR59pJtUu1T/lOFNdff1BqtI=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down Expand Up @@ -130,8 +134,6 @@ github.com/huandu/go-clone/generic v1.6.0/go.mod h1:xgd9ZebcMsBWWcBx5mVMCoqMX24g
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/jtraglia/go-builder-client v0.4.6-0.20240925183257-4d86495441b5 h1:1W/Cz544b7FmjTn/5dB8obNDAFuRdRsywWJgOmxz5mU=
github.com/jtraglia/go-builder-client v0.4.6-0.20240925183257-4d86495441b5/go.mod h1:lPd6wgiraLD0umFeiCjYaqoMLeU2b3dMATOJ9B/jnIA=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
Expand Down Expand Up @@ -182,8 +184,6 @@ github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca h1:rc6VVR79GdE58Wx1Arh9QNo+0qmXOfYjWQhrbkSeoI0=
github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
27 changes: 21 additions & 6 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
builderSpec "github.com/attestantio/go-builder-client/spec"
eth2ApiV1Deneb "github.com/attestantio/go-eth2-client/api/v1/deneb"
eth2ApiV1Electra "github.com/attestantio/go-eth2-client/api/v1/electra"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/flashbots/go-boost-utils/ssz"
"github.com/flashbots/go-utils/httplogger"
Expand Down Expand Up @@ -569,6 +570,12 @@ func (m *BoostService) processDenebPayload(w http.ResponseWriter, req *http.Requ
return
}

if responsePayload.Version != spec.DataVersionDeneb {
log.WithFields(logrus.Fields{
"version": responsePayload.Version,
}).Error("response version was not deneb")
return
}
if getPayloadResponseIsEmpty(responsePayload) {
log.Error("response with empty data!")
return
Expand Down Expand Up @@ -704,6 +711,12 @@ func (m *BoostService) processElectraPayload(w http.ResponseWriter, req *http.Re
return
}

if responsePayload.Version != spec.DataVersionElectra {
log.WithFields(logrus.Fields{
"version": responsePayload.Version,
}).Error("response version was not electra")
return
}
if getPayloadResponseIsEmpty(responsePayload) {
log.Error("response with empty data!")
return
Expand Down Expand Up @@ -785,19 +798,21 @@ func (m *BoostService) handleGetPayload(w http.ResponseWriter, req *http.Request
}

// Decode the body now
payload := new(eth2ApiV1Electra.SignedBlindedBeaconBlock)
payload := new(eth2ApiV1Deneb.SignedBlindedBeaconBlock)
log.Debug("attempting to decode body into Deneb payload")
if err := DecodeJSON(bytes.NewReader(body), payload); err != nil {
log.Debug("could not decode Electra request payload, attempting to decode body into Deneb payload")
payload := new(eth2ApiV1Deneb.SignedBlindedBeaconBlock)
log.Debug("could not decode Deneb request payload, attempting to decode body into Electra payload")
payload := new(eth2ApiV1Electra.SignedBlindedBeaconBlock)
if err := DecodeJSON(bytes.NewReader(body), payload); err != nil {
log.Debug("could not decode Deneb request payload, attempting to decode body into Capella payload")
log.Debug("could not decode Electra request payload")
log.WithError(err).WithField("body", string(body)).Error("could not decode request payload from the beacon-node (signed blinded beacon block)")
m.respondError(w, http.StatusBadRequest, err.Error())
return
}
m.processDenebPayload(w, req, log, payload)
m.processElectraPayload(w, req, log, payload)
return
}
m.processElectraPayload(w, req, log, payload)
m.processDenebPayload(w, req, log, payload)
}

// CheckRelays sends a request to each one of the relays previously registered to get their status
Expand Down

0 comments on commit 097756d

Please sign in to comment.