Skip to content

Commit

Permalink
misc(mev-boost): address review
Browse files Browse the repository at this point in the history
  • Loading branch information
namn-grg committed Oct 8, 2024
1 parent dfbca19 commit e4e589e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions mev-boost/server/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ const (
pathGetPayload = "/eth/v1/builder/blinded_blocks"

// Constraints namespace paths
// Ref: https://docs.boltprotocol.xyz/api/builder#constraints
pathSubmitConstraint = "/constraints/v1/builder/constraints"
pathDelegate = "/constraints/v1/builder/delegate"
pathRevoke = "/constraints/v1/builder/revoke"
// Ref: https://docs.boltprotocol.xyz/api/builder#delegate
pathDelegate = "/constraints/v1/builder/delegate"
// Ref: https://docs.boltprotocol.xyz/api/builder#revoke
pathRevoke = "/constraints/v1/builder/revoke"

// // Relay Monitor paths
// pathAuctionTranscript = "/monitor/v1/transcript"
Expand Down
6 changes: 5 additions & 1 deletion mev-boost/server/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ConstraintsMessage struct {
Pubkey phase0.BLSPubKey `json:"pubkey"`
Slot uint64 `json:"slot"`
Top bool `json:"top"`
Transactions []Transaction // Custom marshal and unmarshal implemented below
Transactions []Transaction `json:"transactions"`
}

func (s *SignedConstraints) String() string {
Expand Down Expand Up @@ -105,21 +105,25 @@ func (c *ConstraintsCache) FindTransactionByHash(txHash gethCommon.Hash) (*Trans
return nil, false
}

// Ref: https://docs.boltprotocol.xyz/api/builder#delegate
type SignedDelegation struct {
Message Delegation `json:"message"`
Signature phase0.BLSSignature `json:"signature"`
}

// Ref: https://docs.boltprotocol.xyz/api/builder#delegate
type Delegation struct {
ValidatorPubkey phase0.BLSPubKey `json:"validator_pubkey"`
DelegateePubkey phase0.BLSPubKey `json:"delegatee_pubkey"`
}

// Ref: https://docs.boltprotocol.xyz/api/builder#revoke
type SignedRevocation struct {
Message Delegation `json:"message"`
Signature phase0.BLSSignature `json:"signature"`
}

// Ref: https://docs.boltprotocol.xyz/api/builder#revoke
type Revocation struct {
ValidatorPubkey phase0.BLSPubKey `json:"validator_pubkey"`
DelegateePubkey phase0.BLSPubKey `json:"delegatee_pubkey"`
Expand Down
8 changes: 5 additions & 3 deletions mev-boost/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (m *BoostService) handleRegisterValidator(w http.ResponseWriter, req *http.

func (m *BoostService) handleDelegate(w http.ResponseWriter, req *http.Request) {
log := m.log.WithField("method", "delegate")
log.Debug("delegate")
log.Debug("delegate:", req.Body)

payload := SignedDelegation{}
if err := DecodeJSON(req.Body, &payload); err != nil {
Expand All @@ -366,6 +366,7 @@ func (m *BoostService) handleDelegate(w http.ResponseWriter, req *http.Request)

ua := UserAgent(req.Header.Get("User-Agent"))
log = log.WithFields(logrus.Fields{
"validatorPubkey": payload.Message.ValidatorPubkey.String(),
"delegateePubkey": payload.Message.DelegateePubkey.String(),
"ua": ua,
})
Expand Down Expand Up @@ -399,7 +400,7 @@ func (m *BoostService) handleDelegate(w http.ResponseWriter, req *http.Request)

func (m *BoostService) handleRevoke(w http.ResponseWriter, req *http.Request) {
log := m.log.WithField("method", "revoke")
log.Debug("revoke")
log.Debug("revoke:", req.Body)

payload := SignedRevocation{}
if err := DecodeJSON(req.Body, &payload); err != nil {
Expand All @@ -409,6 +410,7 @@ func (m *BoostService) handleRevoke(w http.ResponseWriter, req *http.Request) {

ua := UserAgent(req.Header.Get("User-Agent"))
log = log.WithFields(logrus.Fields{
"validatorPubkey": payload.Message.ValidatorPubkey.String(),
"delegateePubkey": payload.Message.DelegateePubkey.String(),
"ua": ua,
})
Expand Down Expand Up @@ -901,7 +903,7 @@ func (m *BoostService) handleGetHeaderWithProofs(w http.ResponseWriter, req *htt
return
}

if responsePayload == nil {
if responsePayload.VersionedSignedBuilderBid == nil {
log.Warn("Bid in response is nil")
return
}
Expand Down

0 comments on commit e4e589e

Please sign in to comment.