Skip to content

Commit

Permalink
Merge pull request #298 from chainbound/nico/chore/mev-boost-delegations
Browse files Browse the repository at this point in the history
feat(mev-boost): delegations/revocations update
  • Loading branch information
thedevbirb authored Oct 17, 2024
2 parents a5daabb + 6456ec3 commit 50806b7
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions mev-boost/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,22 @@ func (m *BoostService) handleDelegate(w http.ResponseWriter, req *http.Request)
log := m.log.WithField("method", "delegate")
log.Debug("delegate:", req.Body)

payload := SignedDelegation{}
payload := make([]SignedDelegation, 0)
if err := DecodeJSON(req.Body, &payload); err != nil {
m.respondError(w, http.StatusBadRequest, err.Error())
return
}
if payload.Message.Action != 0 {
m.respondError(w, http.StatusBadRequest, "invalid action, expected 0 for delegate")
return

for _, signedDelegation := range payload {
if signedDelegation.Message.Action != 0 {
m.respondError(w, http.StatusBadRequest, "invalid action, expected 0 for delegate")
return
}
}

ua := UserAgent(req.Header.Get("User-Agent"))
log = log.WithFields(logrus.Fields{
"validatorPubkey": payload.Message.ValidatorPubkey.String(),
"delegateePubkey": payload.Message.DelegateePubkey.String(),
"ua": ua,
"ua": ua,
})

relayRespCh := make(chan error, len(m.relays))
Expand Down Expand Up @@ -406,20 +407,21 @@ func (m *BoostService) handleRevoke(w http.ResponseWriter, req *http.Request) {
log := m.log.WithField("method", "revoke")
log.Debug("revoke:", req.Body)

payload := SignedRevocation{}
payload := make([]SignedRevocation, 0)
if err := DecodeJSON(req.Body, &payload); err != nil {
m.respondError(w, http.StatusBadRequest, err.Error())
return
}
if payload.Message.Action != 1 {
m.respondError(w, http.StatusBadRequest, "invalid action, expected 1 for revoke")

for _, signedRevocation := range payload {
if signedRevocation.Message.Action != 1 {
m.respondError(w, http.StatusBadRequest, "invalid action, expected 1 for revoke")
}
}

ua := UserAgent(req.Header.Get("User-Agent"))
log = log.WithFields(logrus.Fields{
"validatorPubkey": payload.Message.ValidatorPubkey.String(),
"delegateePubkey": payload.Message.DelegateePubkey.String(),
"ua": ua,
"ua": ua,
})

relayRespCh := make(chan error, len(m.relays))
Expand Down

0 comments on commit 50806b7

Please sign in to comment.