Skip to content

Commit 652c285

Browse files
committed
Update all builder related code
1 parent 5092bde commit 652c285

File tree

9 files changed

+283
-25
lines changed

9 files changed

+283
-25
lines changed

api/client/builder/client.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
2222
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing"
2323
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
24-
v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
2524
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
2625
"github.com/prysmaticlabs/prysm/v5/runtime/version"
2726
log "github.com/sirupsen/logrus"
@@ -88,7 +87,7 @@ type BuilderClient interface {
8887
NodeURL() string
8988
GetHeader(ctx context.Context, slot primitives.Slot, parentHash [32]byte, pubkey [48]byte) (SignedBid, error)
9089
RegisterValidator(ctx context.Context, svr []*ethpb.SignedValidatorRegistrationV1) error
91-
SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, *v1.BlobsBundle, error)
90+
SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, blocks.BlobsBundle, error)
9291
Status(ctx context.Context) error
9392
}
9493

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

311310
// SubmitBlindedBlock calls the builder API endpoint that binds the validator to the builder and submits the block.
312311
// 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) {
312+
func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, blocks.BlobsBundle, error) {
314313
if !sb.IsBlinded() {
315314
return nil, nil, errNotBlinded
316315
}

api/client/builder/testing/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ go_library(
77
visibility = ["//visibility:public"],
88
deps = [
99
"//api/client/builder:go_default_library",
10+
"//consensus-types/blocks:go_default_library",
1011
"//consensus-types/interfaces:go_default_library",
1112
"//consensus-types/primitives:go_default_library",
1213
"//encoding/bytesutil:go_default_library",
13-
"//proto/engine/v1:go_default_library",
1414
"//proto/prysm/v1alpha1:go_default_library",
1515
],
1616
)

api/client/builder/testing/mock.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"context"
55

66
"github.com/prysmaticlabs/prysm/v5/api/client/builder"
7+
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
78
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
89
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
910
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
10-
v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
1111
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
1212
)
1313

@@ -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, blocks.BlobsBundle, error) {
4545
return nil, nil, nil
4646
}
4747

api/client/builder/types.go

+144-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/prysmaticlabs/prysm/v5/api/server"
1414
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
1515
"github.com/prysmaticlabs/prysm/v5/config/params"
16+
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
1617
consensusblocks "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
1718
types "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
1819
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
@@ -574,7 +575,9 @@ func (r *ExecutionPayloadResponse) ParsePayload() (ParsedPayload, error) {
574575
if err != nil {
575576
return nil, errors.Wrap(err, fmt.Sprintf("unsupported version %s", strings.ToLower(r.Version)))
576577
}
577-
if v >= version.Deneb {
578+
if v >= version.Fulu {
579+
toProto = &ExecutionPayloadFuluAndBlobsBundle{}
580+
} else if v >= version.Deneb {
578581
toProto = &ExecutionPayloadDenebAndBlobsBundle{}
579582
} else if v >= version.Capella {
580583
toProto = &ExecutionPayloadCapella{}
@@ -666,6 +669,11 @@ type SignedBlindedBeaconBlockBellatrix struct {
666669
*eth.SignedBlindedBeaconBlockBellatrix
667670
}
668671

672+
// SignedBlindedBeaconBlockFulu is the request object for builder API /eth/v1/builder/blinded_blocks after Fulu.
673+
type SignedBlindedBeaconBlockFulu struct {
674+
*eth.SignedBlindedBeaconBlockFulu
675+
}
676+
669677
// ProposerSlashing is a field in BlindedBeaconBlockBodyCapella.
670678
type ProposerSlashing struct {
671679
*eth.ProposerSlashing
@@ -1178,18 +1186,18 @@ func (b BlobsBundle) ToProto() (*v1.BlobsBundle, error) {
11781186

11791187
// FromBundleProto converts the proto bundle type to the builder
11801188
// type.
1181-
func FromBundleProto(bundle *v1.BlobsBundle) *BlobsBundle {
1182-
commitments := make([]hexutil.Bytes, len(bundle.KzgCommitments))
1183-
for i := range bundle.KzgCommitments {
1184-
commitments[i] = bytesutil.SafeCopyBytes(bundle.KzgCommitments[i])
1189+
func FromBundleProto(bundle blocks.BlobsBundle) *BlobsBundle {
1190+
commitments := make([]hexutil.Bytes, len(bundle.GetKzgCommitments()))
1191+
for i := range bundle.GetKzgCommitments() {
1192+
commitments[i] = bytesutil.SafeCopyBytes(bundle.GetKzgCommitments()[i])
11851193
}
1186-
proofs := make([]hexutil.Bytes, len(bundle.Proofs))
1187-
for i := range bundle.Proofs {
1188-
proofs[i] = bytesutil.SafeCopyBytes(bundle.Proofs[i])
1194+
proofs := make([]hexutil.Bytes, len(bundle.GetProofs()))
1195+
for i := range bundle.GetProofs() {
1196+
proofs[i] = bytesutil.SafeCopyBytes(bundle.GetProofs()[i])
11891197
}
1190-
blobs := make([]hexutil.Bytes, len(bundle.Blobs))
1191-
for i := range bundle.Blobs {
1192-
blobs[i] = bytesutil.SafeCopyBytes(bundle.Blobs[i])
1198+
blobs := make([]hexutil.Bytes, len(bundle.GetBlobs()))
1199+
for i := range bundle.GetBlobs() {
1200+
blobs[i] = bytesutil.SafeCopyBytes(bundle.GetBlobs()[i])
11931201
}
11941202
return &BlobsBundle{
11951203
Commitments: commitments,
@@ -1330,6 +1338,131 @@ func (bb *BuilderBidElectra) ToProto() (*eth.BuilderBidElectra, error) {
13301338
}, nil
13311339
}
13321340

1341+
// ExecutionPayloadFuluAndBlobsBundle is a field of ExecPayloadResponseFulu.
1342+
type ExecutionPayloadFuluAndBlobsBundle struct {
1343+
ExecutionPayload *ExecutionPayloadFulu `json:"execution_payload"`
1344+
BlobsBundle *BlobsBundle `json:"blobs_bundle"`
1345+
}
1346+
1347+
func (r *ExecutionPayloadFuluAndBlobsBundle) PayloadProto() (proto.Message, error) {
1348+
if r.ExecutionPayload == nil {
1349+
return nil, errors.Wrap(consensusblocks.ErrNilObject, "nil execution payload in combined fulu payload")
1350+
}
1351+
pb, err := r.ExecutionPayload.ToProto()
1352+
return pb, err
1353+
}
1354+
1355+
func (r *ExecutionPayloadFuluAndBlobsBundle) BundleProto() (proto.Message, error) {
1356+
if r.BlobsBundle == nil {
1357+
return nil, errors.Wrap(consensusblocks.ErrNilObject, "nil blobs bundle")
1358+
}
1359+
return r.BlobsBundle.ToProto()
1360+
}
1361+
1362+
// ExecutionPayloadFulu is a field of ExecutionPayloadFuluAndBlobsBundle
1363+
type ExecutionPayloadFulu struct {
1364+
ParentHash hexutil.Bytes `json:"parent_hash"`
1365+
FeeRecipient hexutil.Bytes `json:"fee_recipient"`
1366+
StateRoot hexutil.Bytes `json:"state_root"`
1367+
ReceiptsRoot hexutil.Bytes `json:"receipts_root"`
1368+
LogsBloom hexutil.Bytes `json:"logs_bloom"`
1369+
PrevRandao hexutil.Bytes `json:"prev_randao"`
1370+
BlockNumber Uint64String `json:"block_number"`
1371+
GasLimit Uint64String `json:"gas_limit"`
1372+
GasUsed Uint64String `json:"gas_used"`
1373+
Timestamp Uint64String `json:"timestamp"`
1374+
ExtraData hexutil.Bytes `json:"extra_data"`
1375+
BaseFeePerGas Uint256 `json:"base_fee_per_gas"`
1376+
BlockHash hexutil.Bytes `json:"block_hash"`
1377+
Transactions []hexutil.Bytes `json:"transactions"`
1378+
Withdrawals []Withdrawal `json:"withdrawals"`
1379+
BlobGasUsed Uint64String `json:"blob_gas_used"` // new in deneb
1380+
ExcessBlobGas Uint64String `json:"excess_blob_gas"` // new in deneb
1381+
ProofVersion hexutil.Bytes `json:"proof_version"` // new in fulu
1382+
}
1383+
1384+
// ToProto returns the ExecutionPayloadFulu Proto.
1385+
func (p *ExecutionPayloadFulu) ToProto() (*v1.ExecutionPayloadFulu, error) {
1386+
if p == nil {
1387+
return nil, errors.Wrap(consensusblocks.ErrNilObject, "nil execution payload")
1388+
}
1389+
1390+
txs := make([][]byte, len(p.Transactions))
1391+
for i := range p.Transactions {
1392+
txs[i] = bytesutil.SafeCopyBytes(p.Transactions[i])
1393+
}
1394+
withdrawals := make([]*v1.Withdrawal, len(p.Withdrawals))
1395+
for i, w := range p.Withdrawals {
1396+
withdrawals[i] = &v1.Withdrawal{
1397+
Index: w.Index.Uint64(),
1398+
ValidatorIndex: types.ValidatorIndex(w.ValidatorIndex.Uint64()),
1399+
Address: bytesutil.SafeCopyBytes(w.Address),
1400+
Amount: w.Amount.Uint64(),
1401+
}
1402+
}
1403+
1404+
return &v1.ExecutionPayloadFulu{
1405+
ParentHash: bytesutil.SafeCopyBytes(p.ParentHash),
1406+
FeeRecipient: bytesutil.SafeCopyBytes(p.FeeRecipient),
1407+
StateRoot: bytesutil.SafeCopyBytes(p.StateRoot),
1408+
ReceiptsRoot: bytesutil.SafeCopyBytes(p.ReceiptsRoot),
1409+
LogsBloom: bytesutil.SafeCopyBytes(p.LogsBloom),
1410+
PrevRandao: bytesutil.SafeCopyBytes(p.PrevRandao),
1411+
BlockNumber: uint64(p.BlockNumber),
1412+
GasLimit: uint64(p.GasLimit),
1413+
GasUsed: uint64(p.GasUsed),
1414+
Timestamp: uint64(p.Timestamp),
1415+
ExtraData: bytesutil.SafeCopyBytes(p.ExtraData),
1416+
BaseFeePerGas: bytesutil.SafeCopyBytes(p.BaseFeePerGas.SSZBytes()),
1417+
BlockHash: bytesutil.SafeCopyBytes(p.BlockHash),
1418+
Transactions: txs,
1419+
Withdrawals: withdrawals,
1420+
BlobGasUsed: uint64(p.BlobGasUsed),
1421+
ExcessBlobGas: uint64(p.ExcessBlobGas),
1422+
ProofVersion: bytesutil.SafeCopyBytes(p.ProofVersion),
1423+
}, nil
1424+
}
1425+
1426+
func FromProtoFulu(payload *v1.ExecutionPayloadFulu) (ExecutionPayloadFulu, error) {
1427+
bFee, err := sszBytesToUint256(payload.BaseFeePerGas)
1428+
if err != nil {
1429+
return ExecutionPayloadFulu{}, err
1430+
}
1431+
txs := make([]hexutil.Bytes, len(payload.Transactions))
1432+
for i := range payload.Transactions {
1433+
txs[i] = bytesutil.SafeCopyBytes(payload.Transactions[i])
1434+
}
1435+
withdrawals := make([]Withdrawal, len(payload.Withdrawals))
1436+
for i, w := range payload.Withdrawals {
1437+
withdrawals[i] = Withdrawal{
1438+
Index: Uint256{Int: big.NewInt(0).SetUint64(w.Index)},
1439+
ValidatorIndex: Uint256{Int: big.NewInt(0).SetUint64(uint64(w.ValidatorIndex))},
1440+
Address: bytesutil.SafeCopyBytes(w.Address),
1441+
Amount: Uint256{Int: big.NewInt(0).SetUint64(w.Amount)},
1442+
}
1443+
}
1444+
return ExecutionPayloadFulu{
1445+
ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash),
1446+
FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient),
1447+
StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot),
1448+
ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot),
1449+
LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom),
1450+
PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao),
1451+
BlockNumber: Uint64String(payload.BlockNumber),
1452+
GasLimit: Uint64String(payload.GasLimit),
1453+
GasUsed: Uint64String(payload.GasUsed),
1454+
Timestamp: Uint64String(payload.Timestamp),
1455+
ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData),
1456+
BaseFeePerGas: bFee,
1457+
BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash),
1458+
Transactions: txs,
1459+
Withdrawals: withdrawals,
1460+
BlobGasUsed: Uint64String(payload.BlobGasUsed),
1461+
ExcessBlobGas: Uint64String(payload.ExcessBlobGas),
1462+
ProofVersion: bytesutil.SafeCopyBytes(payload.ProofVersion),
1463+
}, nil
1464+
}
1465+
13331466
// ExecutionRequestsV1 is a wrapper for different execution requests
13341467
type ExecutionRequestsV1 struct {
13351468
Deposits []*DepositRequestV1 `json:"deposits"`

beacon-chain/builder/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ go_library(
1515
"//beacon-chain/cache:go_default_library",
1616
"//beacon-chain/db:go_default_library",
1717
"//cmd/beacon-chain/flags:go_default_library",
18+
"//consensus-types/blocks:go_default_library",
1819
"//consensus-types/interfaces:go_default_library",
1920
"//consensus-types/primitives:go_default_library",
2021
"//encoding/bytesutil:go_default_library",
2122
"//monitoring/tracing:go_default_library",
2223
"//monitoring/tracing/trace:go_default_library",
23-
"//proto/engine/v1:go_default_library",
2424
"//proto/prysm/v1alpha1:go_default_library",
2525
"@com_github_pkg_errors//:go_default_library",
2626
"@com_github_prometheus_client_golang//prometheus:go_default_library",

beacon-chain/builder/service.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
1111
"github.com/prysmaticlabs/prysm/v5/beacon-chain/cache"
1212
"github.com/prysmaticlabs/prysm/v5/beacon-chain/db"
13+
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
1314
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
1415
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
1516
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
1617
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing"
1718
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
18-
v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
1919
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
2020
log "github.com/sirupsen/logrus"
2121
)
@@ -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, blocks.BlobsBundle, 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, blocks.BlobsBundle, error) {
9292
ctx, span := trace.StartSpan(ctx, "builder.SubmitBlindedBlock")
9393
defer span.End()
9494
start := time.Now()

beacon-chain/builder/testing/mock.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type MockBuilderService struct {
2828
Payload *v1.ExecutionPayload
2929
PayloadCapella *v1.ExecutionPayloadCapella
3030
PayloadDeneb *v1.ExecutionPayloadDeneb
31+
PayloadFulu *v1.ExecutionPayloadFulu
3132
BlobBundle *v1.BlobsBundle
3233
ErrSubmitBlindedBlock error
3334
Bid *ethpb.SignedBuilderBid
@@ -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, blocks.BlobsBundle, error) {
5051
switch b.Version() {
5152
case version.Bellatrix:
5253
w, err := blocks.WrappedExecutionPayload(s.Payload)

beacon-chain/verification/data_column_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func GenerateTestDataColumns(t *testing.T, parent [fieldparams.RootLength]byte,
2929
blobs = append(blobs, kzg.Blob(roBlobs[i].Blob))
3030
}
3131

32-
dataColumnSidecars, err := peerdas.DataColumnSidecars(roBlock, blobs)
32+
cellsAndProofs := util.GenerateCellsAndProofs(t, blobs)
33+
dataColumnSidecars, err := peerdas.DataColumnSidecars(roBlock, cellsAndProofs)
3334
require.NoError(t, err)
3435

3536
roDataColumns := make([]blocks.RODataColumn, 0, len(dataColumnSidecars))

0 commit comments

Comments
 (0)