@@ -13,6 +13,7 @@ import (
13
13
"github.com/prysmaticlabs/prysm/v5/api/server"
14
14
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
15
15
"github.com/prysmaticlabs/prysm/v5/config/params"
16
+ "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
16
17
consensusblocks "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
17
18
types "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
18
19
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
@@ -574,7 +575,9 @@ func (r *ExecutionPayloadResponse) ParsePayload() (ParsedPayload, error) {
574
575
if err != nil {
575
576
return nil , errors .Wrap (err , fmt .Sprintf ("unsupported version %s" , strings .ToLower (r .Version )))
576
577
}
577
- if v >= version .Deneb {
578
+ if v >= version .Fulu {
579
+ toProto = & ExecutionPayloadFuluAndBlobsBundle {}
580
+ } else if v >= version .Deneb {
578
581
toProto = & ExecutionPayloadDenebAndBlobsBundle {}
579
582
} else if v >= version .Capella {
580
583
toProto = & ExecutionPayloadCapella {}
@@ -666,6 +669,11 @@ type SignedBlindedBeaconBlockBellatrix struct {
666
669
* eth.SignedBlindedBeaconBlockBellatrix
667
670
}
668
671
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
+
669
677
// ProposerSlashing is a field in BlindedBeaconBlockBodyCapella.
670
678
type ProposerSlashing struct {
671
679
* eth.ProposerSlashing
@@ -1178,18 +1186,18 @@ func (b BlobsBundle) ToProto() (*v1.BlobsBundle, error) {
1178
1186
1179
1187
// FromBundleProto converts the proto bundle type to the builder
1180
1188
// 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 ])
1185
1193
}
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 ])
1189
1197
}
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 ])
1193
1201
}
1194
1202
return & BlobsBundle {
1195
1203
Commitments : commitments ,
@@ -1330,6 +1338,131 @@ func (bb *BuilderBidElectra) ToProto() (*eth.BuilderBidElectra, error) {
1330
1338
}, nil
1331
1339
}
1332
1340
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
+
1333
1466
// ExecutionRequestsV1 is a wrapper for different execution requests
1334
1467
type ExecutionRequestsV1 struct {
1335
1468
Deposits []* DepositRequestV1 `json:"deposits"`
0 commit comments