Skip to content

Commit 72fab1a

Browse files
avalonchejtragliametachris
authored
Deneb Support (#564)
* Remove bellatrix from wrapper types (#475) * Remove bellatrix from wrapper types * remove test logs * Remove get header wrapper types (#477) * Remove signed blinded beacon block wrapper (#482) * remove signed blinded beacon block wrapper type * linting * remove signed beacon block wrapper types (#483) * Remove submit block request wrapper (#485) * remove submit block request wrapper types * fix tests * fix lint * Upgrade go-boost-utils (#488) * Upgrade go-boost-utils * pr comments * remove commented out code * Add custom json marshalling for versioned structs (#493) * Add deneb signature checking for block contents * Add deneb support for type conversions * Add redis and database tests to store deneb payloads * Block submission to v3 validation endpoint * Update signed block conversions * Replace some expectCont with expectOk (#509) * Allow fork epochs to be 0 * Make attestantio import names consistent (#510) * Make attestantio import names consistent * Fix linter errors & two comments * Fix mistake in redis prefix name (#517) * Fix mistake in redis prefix for deneb * Fix typo in prefix * rebase conflicts from main * update submit block request * bug fixes * fix blob sidecar signature * ssz encode request to publish block * use v2 publish endpoint by default * go mod tidy * update relay to latest builder-specs * update go mod * fix lint and tests * switch to json encoding instead of ssz for block publishing v2 * add blob logging * address pr comments * Handle no deneb fork schedule from beacon client (#572) * backwards compatibility if no deneb schedule * Update services/api/service.go Co-authored-by: Chris Hager <[email protected]> --------- Co-authored-by: Chris Hager <[email protected]> * change specific error log to info because it's expected nowadays (#574) * Add json and ssz marshalling tests (#573) * add test vectors * linting --------- Co-authored-by: Justin Traglia <[email protected]> Co-authored-by: Chris Hager <[email protected]>
1 parent 930f084 commit 72fab1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3223
-2228
lines changed

.golangci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ linters:
33
enable-all: true
44
disable:
55
- cyclop
6+
- depguard
67
- forbidigo
78
- funlen
89
- gochecknoglobals
@@ -69,6 +70,7 @@ linters-settings:
6970

7071
gomoddirectives:
7172
replace-allow-list:
73+
- github.com/attestantio/go-builder-client
7274
- github.com/attestantio/go-eth2-client
7375

7476
maintidx:
@@ -88,6 +90,12 @@ linters-settings:
8890
# Because it's easier to read without the other fields.
8991
#
9092
- 'GetPayloadsFilters'
93+
#
94+
# Easier to read with only one of the versioned payloads.
95+
#
96+
- 'VersionedSubmitBlindedBlockResponse'
97+
- 'VersionedExecutionPayload'
98+
- 'VersionedSignedBuilderBid'
9199

92100
#
93101
# Structures outside our control that have a ton of settings. It doesn't

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ redis-cli DEL boost-relay/sepolia:validators-registration boost-relay/sepolia:va
152152
* `DISABLE_LOWPRIO_BUILDERS` - reject block submissions by low-prio builders
153153
* `FORCE_GET_HEADER_204` - force 204 as getHeader response
154154
* `ENABLE_IGNORABLE_VALIDATION_ERRORS` - enable ignorable validation errors
155-
* `USE_V2_PUBLISH_BLOCK_ENDPOINT` - uses the v2 publish block endpoint on the beacon node
155+
* `USE_V1_PUBLISH_BLOCK_ENDPOINT` - uses the v1 publish block endpoint on the beacon node
156156

157157
#### Development Environment Variables
158158

beaconclient/beacon_client_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/flashbots/go-boost-utils/types"
1110
"github.com/flashbots/mev-boost-relay/common"
1211
"github.com/gorilla/mux"
1312
"github.com/stretchr/testify/require"
@@ -194,11 +193,10 @@ func TestFetchValidators(t *testing.T) {
194193

195194
// only beacon 2 should have a validator, and should be used by default
196195
backend.beaconInstances[0].MockFetchValidatorsErr = nil
197-
backend.beaconInstances[1].SetValidators(make(map[types.PubkeyHex]ValidatorResponseEntry))
196+
backend.beaconInstances[1].SetValidators(make(map[common.PubkeyHex]ValidatorResponseEntry))
198197
backend.beaconInstances[2].MockFetchValidatorsErr = nil
199198
backend.beaconInstances[2].AddValidator(entry)
200199

201-
// t.Log("beacon0/1/2 validators:", backend.beaconInstances[0].NumValidators(), backend.beaconInstances[1].NumValidators(), backend.beaconInstances[2].NumValidators())
202200
validators, err = backend.beaconClient.GetStateValidators("1")
203201
require.NoError(t, err)
204202
require.Equal(t, 1, len(validators.Data))

beaconclient/mock_beacon_instance.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import (
44
"sync"
55
"time"
66

7-
"github.com/flashbots/go-boost-utils/types"
87
"github.com/flashbots/mev-boost-relay/common"
98
)
109

1110
type MockBeaconInstance struct {
1211
mu sync.RWMutex
13-
validatorSet map[types.PubkeyHex]ValidatorResponseEntry
12+
validatorSet map[common.PubkeyHex]ValidatorResponseEntry
1413

1514
MockSyncStatus *SyncStatusPayloadData
1615
MockSyncStatusErr error
@@ -23,7 +22,7 @@ type MockBeaconInstance struct {
2322

2423
func NewMockBeaconInstance() *MockBeaconInstance {
2524
return &MockBeaconInstance{
26-
validatorSet: make(map[types.PubkeyHex]ValidatorResponseEntry),
25+
validatorSet: make(map[common.PubkeyHex]ValidatorResponseEntry),
2726

2827
MockSyncStatus: &SyncStatusPayloadData{
2928
HeadSlot: 1,
@@ -44,17 +43,17 @@ func NewMockBeaconInstance() *MockBeaconInstance {
4443

4544
func (c *MockBeaconInstance) AddValidator(entry ValidatorResponseEntry) {
4645
c.mu.Lock()
47-
c.validatorSet[types.NewPubkeyHex(entry.Validator.Pubkey)] = entry
46+
c.validatorSet[common.NewPubkeyHex(entry.Validator.Pubkey)] = entry
4847
c.mu.Unlock()
4948
}
5049

51-
func (c *MockBeaconInstance) SetValidators(validatorSet map[types.PubkeyHex]ValidatorResponseEntry) {
50+
func (c *MockBeaconInstance) SetValidators(validatorSet map[common.PubkeyHex]ValidatorResponseEntry) {
5251
c.mu.Lock()
5352
c.validatorSet = validatorSet
5453
c.mu.Unlock()
5554
}
5655

57-
func (c *MockBeaconInstance) IsValidator(pubkey types.PubkeyHex) bool {
56+
func (c *MockBeaconInstance) IsValidator(pubkey common.PubkeyHex) bool {
5857
c.mu.RLock()
5958
_, found := c.validatorSet[pubkey]
6059
c.mu.RUnlock()
@@ -107,18 +106,14 @@ func (c *MockBeaconInstance) addDelay() {
107106
}
108107
}
109108

110-
func (c *MockBeaconInstance) PublishBlock(block *common.SignedBeaconBlock, broadcaseMode BroadcastMode) (code int, err error) {
109+
func (c *MockBeaconInstance) PublishBlock(block *common.VersionedSignedProposal, broadcaseMode BroadcastMode) (code int, err error) {
111110
return 0, nil
112111
}
113112

114113
func (c *MockBeaconInstance) GetGenesis() (*GetGenesisResponse, error) {
115114
return nil, nil
116115
}
117116

118-
func (c *MockBeaconInstance) GetBlock(blockID string) (block *GetBlockResponse, err error) {
119-
return nil, nil
120-
}
121-
122117
func (c *MockBeaconInstance) GetSpec() (spec *GetSpecResponse, err error) {
123118
return nil, nil
124119
}

beaconclient/mock_multi_beacon_client.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ func (*MockMultiBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData) {}
2020
func (*MockMultiBeaconClient) SubscribeToPayloadAttributesEvents(payloadAttrC chan PayloadAttributesEvent) {
2121
}
2222

23-
// func (*MockMultiBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error) {
24-
// return nil, nil
25-
// }
26-
2723
func (*MockMultiBeaconClient) GetStateValidators(stateID string) (*GetStateValidatorsResponse, error) {
2824
return nil, nil
2925
}
@@ -32,7 +28,7 @@ func (*MockMultiBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesRe
3228
return nil, nil
3329
}
3430

35-
func (*MockMultiBeaconClient) PublishBlock(block *common.SignedBeaconBlock) (code int, err error) {
31+
func (*MockMultiBeaconClient) PublishBlock(block *common.VersionedSignedProposal) (code int, err error) {
3632
return 0, nil
3733
}
3834

@@ -62,10 +58,6 @@ func (*MockMultiBeaconClient) GetForkSchedule() (spec *GetForkScheduleResponse,
6258
return resp, nil
6359
}
6460

65-
func (*MockMultiBeaconClient) GetBlock(blockID string) (block *GetBlockResponse, err error) {
66-
return nil, nil
67-
}
68-
6961
func (*MockMultiBeaconClient) GetRandao(slot uint64) (spec *GetRandaoResponse, err error) {
7062
return nil, nil
7163
}

beaconclient/multi_beacon_client.go

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@ var (
2020
ErrBeaconBlock202 = errors.New("beacon block failed validation but was still broadcast (202)")
2121
)
2222

23-
type BroadcastMode int
23+
type BroadcastMode string
2424

2525
const (
26-
Gossip BroadcastMode = iota // lightweight gossip checks only
27-
Consensus // full consensus checks, including validation of all signatures and blocks fields
28-
ConsensusAndEquivocation // the same as `consensus`, with an extra equivocation check
26+
Gossip BroadcastMode = "gossip" // lightweight gossip checks only
27+
Consensus BroadcastMode = "consensus" // full consensus checks, including validation of all signatures and blocks fields
28+
ConsensusAndEquivocation BroadcastMode = "consensus_and_equivocation" // the same as `consensus`, with an extra equivocation check
2929
)
3030

31-
func (b BroadcastMode) String() string {
32-
return [...]string{"gossip", "consensus", "consensus_and_equivocation"}[b]
33-
}
34-
3531
// IMultiBeaconClient is the interface for the MultiBeaconClient, which can manage several beacon client instances under the hood
3632
type IMultiBeaconClient interface {
3733
BestSyncStatus() (*SyncStatusPayloadData, error)
@@ -42,11 +38,10 @@ type IMultiBeaconClient interface {
4238
// GetStateValidators returns all active and pending validators from the beacon node
4339
GetStateValidators(stateID string) (*GetStateValidatorsResponse, error)
4440
GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
45-
PublishBlock(block *common.SignedBeaconBlock) (code int, err error)
41+
PublishBlock(block *common.VersionedSignedProposal) (code int, err error)
4642
GetGenesis() (*GetGenesisResponse, error)
4743
GetSpec() (spec *GetSpecResponse, err error)
4844
GetForkSchedule() (spec *GetForkScheduleResponse, err error)
49-
GetBlock(blockID string) (block *GetBlockResponse, err error)
5045
GetRandao(slot uint64) (spec *GetRandaoResponse, err error)
5146
GetWithdrawals(slot uint64) (spec *GetWithdrawalsResponse, err error)
5247
}
@@ -60,11 +55,10 @@ type IBeaconInstance interface {
6055
GetStateValidators(stateID string) (*GetStateValidatorsResponse, error)
6156
GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
6257
GetURI() string
63-
PublishBlock(block *common.SignedBeaconBlock, broadcastMode BroadcastMode) (code int, err error)
58+
PublishBlock(block *common.VersionedSignedProposal, broadcastMode BroadcastMode) (code int, err error)
6459
GetGenesis() (*GetGenesisResponse, error)
6560
GetSpec() (spec *GetSpecResponse, err error)
6661
GetForkSchedule() (spec *GetForkScheduleResponse, err error)
67-
GetBlock(blockID string) (*GetBlockResponse, error)
6862
GetRandao(slot uint64) (spec *GetRandaoResponse, err error)
6963
GetWithdrawals(slot uint64) (spec *GetWithdrawalsResponse, err error)
7064
}
@@ -99,10 +93,10 @@ func NewMultiBeaconClient(log *logrus.Entry, beaconInstances []IBeaconInstance)
9993
if broadcastModeStr != "" {
10094
broadcastMode, ok := parseBroadcastModeString(broadcastModeStr)
10195
if !ok {
102-
msg := fmt.Sprintf("env: BROADCAST_MODE: invalid value %s, leaving to default value %s", broadcastModeStr, client.broadcastMode.String())
96+
msg := fmt.Sprintf("env: BROADCAST_MODE: invalid value %s, leaving to default value %s", broadcastModeStr, client.broadcastMode)
10397
client.log.Warn(msg)
10498
} else {
105-
client.log.Info(fmt.Sprintf("env: BROADCAST_MODE: setting mode to %s", broadcastMode.String()))
99+
client.log.Info(fmt.Sprintf("env: BROADCAST_MODE: setting mode to %s", broadcastMode))
106100
client.broadcastMode = broadcastMode
107101
}
108102
}
@@ -255,10 +249,20 @@ type publishResp struct {
255249
}
256250

257251
// PublishBlock publishes the signed beacon block via https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/publishBlock
258-
func (c *MultiBeaconClient) PublishBlock(block *common.SignedBeaconBlock) (code int, err error) {
252+
func (c *MultiBeaconClient) PublishBlock(block *common.VersionedSignedProposal) (code int, err error) {
253+
slot, err := block.Slot()
254+
if err != nil {
255+
c.log.WithError(err).Warn("failed to publish block as block slot is missing")
256+
return 0, err
257+
}
258+
blockHash, err := block.ExecutionBlockHash()
259+
if err != nil {
260+
c.log.WithError(err).Warn("failed to publish block as block hash is missing")
261+
return 0, err
262+
}
259263
log := c.log.WithFields(logrus.Fields{
260-
"slot": block.Slot(),
261-
"blockHash": block.BlockHash(),
264+
"slot": slot,
265+
"blockHash": blockHash.String(),
262266
})
263267

264268
clients := c.beaconInstancesByLastResponse()
@@ -360,23 +364,6 @@ func (c *MultiBeaconClient) GetForkSchedule() (spec *GetForkScheduleResponse, er
360364
return nil, err
361365
}
362366

363-
// GetBlock returns a block - https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2
364-
func (c *MultiBeaconClient) GetBlock(blockID string) (block *GetBlockResponse, err error) {
365-
clients := c.beaconInstancesByLastResponse()
366-
for _, client := range clients {
367-
log := c.log.WithField("uri", client.GetURI())
368-
if block, err = client.GetBlock(blockID); err != nil {
369-
log.WithField("blockID", blockID).WithError(err).Warn("failed to get block")
370-
continue
371-
}
372-
373-
return block, nil
374-
}
375-
376-
c.log.WithField("blockID", blockID).WithError(err).Error("failed to get block from any CL node")
377-
return nil, err
378-
}
379-
380367
// GetRandao - 3500/eth/v1/beacon/states/<slot>/randao
381368
func (c *MultiBeaconClient) GetRandao(slot uint64) (randaoResp *GetRandaoResponse, err error) {
382369
clients := c.beaconInstancesByLastResponse()

0 commit comments

Comments
 (0)