Skip to content

Commit 972a381

Browse files
committed
Execution api: add and use blobs_bundle_v2
1 parent 2d46d6f commit 972a381

File tree

18 files changed

+349
-85
lines changed

18 files changed

+349
-85
lines changed

api/client/builder/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type BuilderClient interface {
8888
NodeURL() string
8989
GetHeader(ctx context.Context, slot primitives.Slot, parentHash [32]byte, pubkey [48]byte) (SignedBid, error)
9090
RegisterValidator(ctx context.Context, svr []*ethpb.SignedValidatorRegistrationV1) error
91-
SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error)
91+
SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, v1.BlobsBundler, error)
9292
Status(ctx context.Context) error
9393
}
9494

@@ -310,7 +310,7 @@ var errResponseVersionMismatch = errors.New("builder API response uses a differe
310310

311311
// SubmitBlindedBlock calls the builder API endpoint that binds the validator to the builder and submits the block.
312312
// The response is the full execution payload used to create the blinded block.
313-
func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error) {
313+
func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, v1.BlobsBundler, error) {
314314
if !sb.IsBlinded() {
315315
return nil, nil, errNotBlinded
316316
}

api/client/builder/testing/mock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (m MockClient) RegisterValidator(_ context.Context, svr []*ethpb.SignedVali
4141
}
4242

4343
// SubmitBlindedBlock --
44-
func (MockClient) SubmitBlindedBlock(_ context.Context, _ interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error) {
44+
func (MockClient) SubmitBlindedBlock(_ context.Context, _ interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, v1.BlobsBundler, error) {
4545
return nil, nil, nil
4646
}
4747

api/client/builder/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,9 @@ type ParsedPayload interface {
558558
PayloadProto() (proto.Message, error)
559559
}
560560

561-
// BlobBundler can retrieve the underlying blob bundle protobuf message for the given execution payload response.
561+
// BlobBundler can retrieve the underlying blob bundler interface for the given execution payload response.
562562
type BlobBundler interface {
563-
BundleProto() (*v1.BlobsBundle, error)
563+
BundleProto() (v1.BlobsBundler, error)
564564
}
565565

566566
// ParsedExecutionRequests can retrieve the underlying execution requests for the given execution payload response.

beacon-chain/builder/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var ErrNoBuilder = errors.New("builder endpoint not configured")
2525

2626
// BlockBuilder defines the interface for interacting with the block builder
2727
type BlockBuilder interface {
28-
SubmitBlindedBlock(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error)
28+
SubmitBlindedBlock(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, v1.BlobsBundler, error)
2929
GetHeader(ctx context.Context, slot primitives.Slot, parentHash [32]byte, pubKey [48]byte) (builder.SignedBid, error)
3030
RegisterValidator(ctx context.Context, reg []*ethpb.SignedValidatorRegistrationV1) error
3131
RegistrationByValidatorID(ctx context.Context, id primitives.ValidatorIndex) (*ethpb.ValidatorRegistrationV1, error)
@@ -88,7 +88,7 @@ func (s *Service) Stop() error {
8888
}
8989

9090
// SubmitBlindedBlock submits a blinded block to the builder relay network.
91-
func (s *Service) SubmitBlindedBlock(ctx context.Context, b interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error) {
91+
func (s *Service) SubmitBlindedBlock(ctx context.Context, b interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, v1.BlobsBundler, error) {
9292
ctx, span := trace.StartSpan(ctx, "builder.SubmitBlindedBlock")
9393
defer span.End()
9494
start := time.Now()

beacon-chain/builder/testing/mock.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ type MockBuilderService struct {
2828
Payload *v1.ExecutionPayload
2929
PayloadCapella *v1.ExecutionPayloadCapella
3030
PayloadDeneb *v1.ExecutionPayloadDeneb
31-
BlobBundle *v1.BlobsBundle
31+
BlobBundleV1 *v1.BlobsBundle
32+
BlobBundleV2 *v1.BlobsBundleV2
3233
ErrSubmitBlindedBlock error
3334
Bid *ethpb.SignedBuilderBid
3435
BidCapella *ethpb.SignedBuilderBidCapella
@@ -46,7 +47,7 @@ func (s *MockBuilderService) Configured() bool {
4647
}
4748

4849
// SubmitBlindedBlock for mocking.
49-
func (s *MockBuilderService) SubmitBlindedBlock(_ context.Context, b interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error) {
50+
func (s *MockBuilderService) SubmitBlindedBlock(_ context.Context, b interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, v1.BlobsBundler, error) {
5051
switch b.Version() {
5152
case version.Bellatrix:
5253
w, err := blocks.WrappedExecutionPayload(s.Payload)
@@ -65,7 +66,13 @@ func (s *MockBuilderService) SubmitBlindedBlock(_ context.Context, b interfaces.
6566
if err != nil {
6667
return nil, nil, errors.Wrap(err, "could not wrap deneb payload")
6768
}
68-
return w, s.BlobBundle, s.ErrSubmitBlindedBlock
69+
return w, s.BlobBundleV1, s.ErrSubmitBlindedBlock
70+
case version.Fulu:
71+
w, err := blocks.WrappedExecutionPayloadDeneb(s.PayloadDeneb)
72+
if err != nil {
73+
return nil, nil, errors.Wrap(err, "could not wrap deneb payload")
74+
}
75+
return w, s.BlobBundleV2, s.ErrSubmitBlindedBlock
6976
default:
7077
return nil, nil, errors.New("unknown block version for mocking")
7178
}

beacon-chain/execution/engine_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func (s *Service) ForkchoiceUpdated(
275275
func getPayloadMethodAndMessage(slot primitives.Slot) (string, proto.Message) {
276276
pe := slots.ToEpoch(slot)
277277
if pe >= params.BeaconConfig().FuluForkEpoch {
278-
return GetPayloadMethodV5, &pb.ExecutionBundleElectra{}
278+
return GetPayloadMethodV5, &pb.ExecutionBundleFulu{}
279279
}
280280
if pe >= params.BeaconConfig().ElectraForkEpoch {
281281
return GetPayloadMethodV4, &pb.ExecutionBundleElectra{}

beacon-chain/rpc/prysm/v1alpha1/validator/construct_generic_block.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package validator
33
import (
44
"fmt"
55

6+
"github.com/pkg/errors"
67
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
78
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
89
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
@@ -12,9 +13,13 @@ import (
1213
)
1314

1415
// constructGenericBeaconBlock constructs a `GenericBeaconBlock` based on the block version and other parameters.
15-
func (vs *Server) constructGenericBeaconBlock(sBlk interfaces.SignedBeaconBlock, blobsBundle *enginev1.BlobsBundle, winningBid primitives.Wei) (*ethpb.GenericBeaconBlock, error) {
16+
func (vs *Server) constructGenericBeaconBlock(
17+
sBlk interfaces.SignedBeaconBlock,
18+
blobsBundle enginev1.BlobsBundler,
19+
winningBid primitives.Wei,
20+
) (*ethpb.GenericBeaconBlock, error) {
1621
if sBlk == nil || sBlk.Block() == nil {
17-
return nil, fmt.Errorf("block cannot be nil")
22+
return nil, errors.New("block cannot be nil")
1823
}
1924

2025
blockProto, err := sBlk.Block().Proto()
@@ -34,12 +39,21 @@ func (vs *Server) constructGenericBeaconBlock(sBlk interfaces.SignedBeaconBlock,
3439
return vs.constructBellatrixBlock(blockProto, isBlinded, bidStr), nil
3540
case version.Capella:
3641
return vs.constructCapellaBlock(blockProto, isBlinded, bidStr), nil
37-
case version.Deneb:
38-
return vs.constructDenebBlock(blockProto, isBlinded, bidStr, blobsBundle), nil
39-
case version.Electra:
40-
return vs.constructElectraBlock(blockProto, isBlinded, bidStr, blobsBundle), nil
42+
case version.Deneb, version.Electra:
43+
bundle, ok := blobsBundle.(*enginev1.BlobsBundle)
44+
if blobsBundle != nil && !ok {
45+
return nil, fmt.Errorf("expected *BlobsBundle, got %T", blobsBundle)
46+
}
47+
if sBlk.Version() == version.Deneb {
48+
return vs.constructDenebBlock(blockProto, isBlinded, bidStr, bundle), nil
49+
}
50+
return vs.constructElectraBlock(blockProto, isBlinded, bidStr, bundle), nil
4151
case version.Fulu:
42-
return vs.constructFuluBlock(blockProto, isBlinded, bidStr, blobsBundle), nil
52+
bundle, ok := blobsBundle.(*enginev1.BlobsBundleV2)
53+
if blobsBundle != nil && !ok {
54+
return nil, fmt.Errorf("expected *BlobsBundleV2, got %T", blobsBundle)
55+
}
56+
return vs.constructFuluBlock(blockProto, isBlinded, bidStr, bundle), nil
4357
default:
4458
return nil, fmt.Errorf("unknown block version: %d", sBlk.Version())
4559
}
@@ -92,7 +106,7 @@ func (vs *Server) constructElectraBlock(blockProto proto.Message, isBlinded bool
92106
return &ethpb.GenericBeaconBlock{Block: &ethpb.GenericBeaconBlock_Electra{Electra: electraContents}, IsBlinded: false, PayloadValue: payloadValue}
93107
}
94108

95-
func (vs *Server) constructFuluBlock(blockProto proto.Message, isBlinded bool, payloadValue string, bundle *enginev1.BlobsBundle) *ethpb.GenericBeaconBlock {
109+
func (vs *Server) constructFuluBlock(blockProto proto.Message, isBlinded bool, payloadValue string, bundle *enginev1.BlobsBundleV2) *ethpb.GenericBeaconBlock {
96110
if isBlinded {
97111
return &ethpb.GenericBeaconBlock{Block: &ethpb.GenericBeaconBlock_BlindedFulu{BlindedFulu: blockProto.(*ethpb.BlindedBeaconBlockFulu)}, IsBlinded: true, PayloadValue: payloadValue}
98112
}

beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func (vs *Server) BuildBlockParallel(ctx context.Context, sBlk interfaces.Signed
238238
}()
239239

240240
winningBid := primitives.ZeroWei()
241-
var bundle *enginev1.BlobsBundle
241+
var bundle enginev1.BlobsBundler
242242
if sBlk.Version() >= version.Bellatrix {
243243
local, err := vs.getLocalPayload(ctx, sBlk.Block(), head)
244244
if err != nil {
@@ -369,7 +369,7 @@ func (vs *Server) handleBlindedBlock(ctx context.Context, block interfaces.Signe
369369
}
370370

371371
if isPeerDASEnabled {
372-
dataColumnSideCars, err := peerdas.ConstructDataColumnSidecars(block, bundle.Blobs, bundle.Proofs)
372+
dataColumnSideCars, err := peerdas.ConstructDataColumnSidecars(block, bundle.GetBlobs(), bundle.GetProofs())
373373
if err != nil {
374374
return nil, nil, nil, errors.Wrap(err, "construct data column sidecars")
375375
}

beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const blockBuilderTimeout = 1 * time.Second
5454
const gasLimitAdjustmentFactor = 1024
5555

5656
// Sets the execution data for the block. Execution data can come from local EL client or remote builder depends on validator registration and circuit breaker conditions.
57-
func setExecutionData(ctx context.Context, blk interfaces.SignedBeaconBlock, local *blocks.GetPayloadResponse, bid builder.Bid, builderBoostFactor primitives.Gwei) (primitives.Wei, *enginev1.BlobsBundle, error) {
57+
func setExecutionData(ctx context.Context, blk interfaces.SignedBeaconBlock, local *blocks.GetPayloadResponse, bid builder.Bid, builderBoostFactor primitives.Gwei) (primitives.Wei, enginev1.BlobsBundler, error) {
5858
_, span := trace.StartSpan(ctx, "ProposerServer.setExecutionData")
5959
defer span.End()
6060

@@ -376,7 +376,7 @@ func matchingWithdrawalsRoot(local, builder interfaces.ExecutionData) (bool, err
376376
func setLocalExecution(blk interfaces.SignedBeaconBlock, local *blocks.GetPayloadResponse) error {
377377
var kzgCommitments [][]byte
378378
if local.BlobsBundle != nil {
379-
kzgCommitments = local.BlobsBundle.KzgCommitments
379+
kzgCommitments = local.BlobsBundle.GetKzgCommitments()
380380
}
381381
if local.ExecutionRequests != nil {
382382
if err := blk.SetExecutionRequests(local.ExecutionRequests); err != nil {

beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ func TestProposer_ProposeBlock_OK(t *testing.T) {
11161116
BlockNotifier: c.BlockNotifier(),
11171117
P2P: mockp2p.NewTestP2P(t),
11181118
BlockBuilder: &builderTest.MockBuilderService{HasConfigured: tt.useBuilder, PayloadCapella: emptyPayloadCapella(), PayloadDeneb: emptyPayloadDeneb(),
1119-
BlobBundle: &enginev1.BlobsBundle{KzgCommitments: [][]byte{bytesutil.PadTo([]byte{0x01}, 48)}, Proofs: [][]byte{{0x02}}, Blobs: [][]byte{{0x03}}}},
1119+
BlobBundleV1: &enginev1.BlobsBundle{KzgCommitments: [][]byte{bytesutil.PadTo([]byte{0x01}, 48)}, Proofs: [][]byte{{0x02}}, Blobs: [][]byte{{0x03}}}},
11201120
BeaconDB: db,
11211121
BlobReceiver: c,
11221122
OperationNotifier: c.OperationNotifier(),

0 commit comments

Comments
 (0)