diff --git a/mev-boost/server/constraints.go b/mev-boost/server/constraints.go index d6c2f6597..817ab1692 100644 --- a/mev-boost/server/constraints.go +++ b/mev-boost/server/constraints.go @@ -105,26 +105,34 @@ func (c *ConstraintsCache) FindTransactionByHash(txHash gethCommon.Hash) (*Trans return nil, false } -// Ref: https://docs.boltprotocol.xyz/api/builder#delegate +// SignedDelegation represents the delegation signed by the proposer pubkey to +// authorize the delegatee pubkey to submit constraints on their behalf. +// +// Specs: 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 +// Delegation as from Specs: https://docs.boltprotocol.xyz/api/builder#delegate type Delegation struct { + Action uint8 `json:"action"` ValidatorPubkey phase0.BLSPubKey `json:"validator_pubkey"` DelegateePubkey phase0.BLSPubKey `json:"delegatee_pubkey"` } -// Ref: https://docs.boltprotocol.xyz/api/builder#revoke +// SignedRevocation represents the revocation signed by the proposer pubkey to +// revoke the delegatee pubkey's ability to submit constraints on their behalf. +// +// Specs: https://docs.boltprotocol.xyz/api/builder#revoke type SignedRevocation struct { Message Revocation `json:"message"` Signature phase0.BLSSignature `json:"signature"` } -// Ref: https://docs.boltprotocol.xyz/api/builder#revoke +// Revocation as from Specs: https://docs.boltprotocol.xyz/api/builder#revoke type Revocation struct { + Action uint8 `json:"action"` ValidatorPubkey phase0.BLSPubKey `json:"validator_pubkey"` DelegateePubkey phase0.BLSPubKey `json:"delegatee_pubkey"` } diff --git a/mev-boost/server/service.go b/mev-boost/server/service.go index d0d88b6d1..746566c54 100644 --- a/mev-boost/server/service.go +++ b/mev-boost/server/service.go @@ -363,6 +363,10 @@ func (m *BoostService) handleDelegate(w http.ResponseWriter, req *http.Request) 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 + } ua := UserAgent(req.Header.Get("User-Agent")) log = log.WithFields(logrus.Fields{ @@ -407,6 +411,9 @@ func (m *BoostService) handleRevoke(w http.ResponseWriter, req *http.Request) { m.respondError(w, http.StatusBadRequest, err.Error()) return } + if payload.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{ diff --git a/mev-boost/server/service_test.go b/mev-boost/server/service_test.go index 6efb23972..c4212951d 100644 --- a/mev-boost/server/service_test.go +++ b/mev-boost/server/service_test.go @@ -315,6 +315,7 @@ func TestDelegate(t *testing.T) { path := pathDelegate delegate := SignedDelegation{ Message: Delegation{ + Action: 0, ValidatorPubkey: _HexToPubkey("0xa695ad325dfc7e1191fbc9f186f58eff42a634029731b18380ff89bf42c464a42cb8ca55b200f051f57f1e1893c68759"), DelegateePubkey: _HexToPubkey("0xb8ba260170b9cda2ad54c321d9a8d77e4ca34517106f587eb5ec184bf78f8a0ce4fb55658301b0dc6b129d10adf62391"), }, @@ -334,6 +335,7 @@ func TestRevoke(t *testing.T) { path := pathRevoke revoke := SignedRevocation{ Message: Revocation{ + Action: 1, ValidatorPubkey: _HexToPubkey("0xa695ad325dfc7e1191fbc9f186f58eff42a634029731b18380ff89bf42c464a42cb8ca55b200f051f57f1e1893c68759"), DelegateePubkey: _HexToPubkey("0xb8ba260170b9cda2ad54c321d9a8d77e4ca34517106f587eb5ec184bf78f8a0ce4fb55658301b0dc6b129d10adf62391"), },