Add bundle v2 support for submit blind block (#15503)

* Add bundle v2 support for submit blind block

* add tests

---------

Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
Manu NALEPA
2025-07-17 09:51:28 +02:00
committed by GitHub
parent 9e014da0b9
commit 09485c2062
14 changed files with 945 additions and 336 deletions

View File

@@ -42,6 +42,7 @@ ssz_gen_marshal(
"ExecutionPayloadHeaderDeneb",
"ExecutionPayloadDeneb",
"ExecutionPayloadDenebAndBlobsBundle",
"ExecutionPayloadDenebAndBlobsBundleV2",
"BlindedBlobsBundle",
"BlobsBundle",
"BlobsBundleV2",

View File

@@ -1919,6 +1919,134 @@ func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (
return
}
// MarshalSSZ ssz marshals the ExecutionPayloadDenebAndBlobsBundleV2 object
func (e *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(e)
}
// MarshalSSZTo ssz marshals the ExecutionPayloadDenebAndBlobsBundleV2 object to a target array
func (e *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(8)
// Offset (0) 'Payload'
dst = ssz.WriteOffset(dst, offset)
if e.Payload == nil {
e.Payload = new(ExecutionPayloadDeneb)
}
offset += e.Payload.SizeSSZ()
// Offset (1) 'BlobsBundle'
dst = ssz.WriteOffset(dst, offset)
if e.BlobsBundle == nil {
e.BlobsBundle = new(BlobsBundleV2)
}
offset += e.BlobsBundle.SizeSSZ()
// Field (0) 'Payload'
if dst, err = e.Payload.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'BlobsBundle'
if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDenebAndBlobsBundleV2 object
func (e *ExecutionPayloadDenebAndBlobsBundleV2) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 8 {
return ssz.ErrSize
}
tail := buf
var o0, o1 uint64
// Offset (0) 'Payload'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 8 {
return ssz.ErrInvalidVariableOffset
}
// Offset (1) 'BlobsBundle'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
}
// Field (0) 'Payload'
{
buf = tail[o0:o1]
if e.Payload == nil {
e.Payload = new(ExecutionPayloadDeneb)
}
if err = e.Payload.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'BlobsBundle'
{
buf = tail[o1:]
if e.BlobsBundle == nil {
e.BlobsBundle = new(BlobsBundleV2)
}
if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDenebAndBlobsBundleV2 object
func (e *ExecutionPayloadDenebAndBlobsBundleV2) SizeSSZ() (size int) {
size = 8
// Field (0) 'Payload'
if e.Payload == nil {
e.Payload = new(ExecutionPayloadDeneb)
}
size += e.Payload.SizeSSZ()
// Field (1) 'BlobsBundle'
if e.BlobsBundle == nil {
e.BlobsBundle = new(BlobsBundleV2)
}
size += e.BlobsBundle.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the ExecutionPayloadDenebAndBlobsBundleV2 object
func (e *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(e)
}
// HashTreeRootWith ssz hashes the ExecutionPayloadDenebAndBlobsBundleV2 object with a hasher
func (e *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Payload'
if err = e.Payload.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'BlobsBundle'
if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil {
return
}
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the ExecutionPayloadHeader object
func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(e)

File diff suppressed because it is too large Load Diff

View File

@@ -102,6 +102,11 @@ message ExecutionPayloadDenebAndBlobsBundle {
BlobsBundle blobs_bundle = 2;
}
message ExecutionPayloadDenebAndBlobsBundleV2 {
ExecutionPayloadDeneb payload = 1;
BlobsBundleV2 blobs_bundle = 2;
}
message ExecutionPayloadDenebWithValueAndBlobsBundle {
ExecutionPayloadDeneb payload = 1;
bytes value = 2;

View File

@@ -610,6 +610,85 @@ func TestJsonMarshalUnmarshal(t *testing.T) {
t.Run("execution bundle electra with deneb payload, blob data, and execution requests", func(t *testing.T) {
// TODO #14351: update this test when geth updates
})
t.Run("ExecutionPayloadDenebAndBlobsBundleV2 SSZ marshaling", func(t *testing.T) {
payload := &enginev1.ExecutionPayloadDeneb{
ParentHash: make([]byte, 32),
FeeRecipient: make([]byte, 20),
StateRoot: make([]byte, 32),
ReceiptsRoot: make([]byte, 32),
LogsBloom: make([]byte, 256),
PrevRandao: make([]byte, 32),
BlockNumber: 123,
GasLimit: 456,
GasUsed: 789,
Timestamp: 1000,
ExtraData: []byte("extra"),
BaseFeePerGas: bytesutil.PadTo(big.NewInt(1000000000).Bytes(), 32),
BlockHash: make([]byte, 32),
Transactions: [][]byte{},
Withdrawals: []*enginev1.Withdrawal{},
BlobGasUsed: 1024,
ExcessBlobGas: 2048,
}
bundleV2 := &enginev1.BlobsBundleV2{
KzgCommitments: [][]byte{make([]byte, 48), make([]byte, 48)},
Proofs: [][]byte{make([]byte, 48), make([]byte, 48)},
Blobs: [][]byte{make([]byte, 131072), make([]byte, 131072)},
}
bundle := &enginev1.ExecutionPayloadDenebAndBlobsBundleV2{
Payload: payload,
BlobsBundle: bundleV2,
}
sszBytes, err := bundle.MarshalSSZ()
require.NoError(t, err)
unmarshaled := &enginev1.ExecutionPayloadDenebAndBlobsBundleV2{}
err = unmarshaled.UnmarshalSSZ(sszBytes)
require.NoError(t, err)
require.DeepEqual(t, bundle.Payload.BlockNumber, unmarshaled.Payload.BlockNumber)
require.DeepEqual(t, bundle.Payload.GasLimit, unmarshaled.Payload.GasLimit)
require.DeepEqual(t, bundle.BlobsBundle.KzgCommitments, unmarshaled.BlobsBundle.KzgCommitments)
require.DeepEqual(t, bundle.BlobsBundle.Proofs, unmarshaled.BlobsBundle.Proofs)
})
t.Run("BlobsBundleV2 SSZ marshaling", func(t *testing.T) {
bundle := &enginev1.BlobsBundleV2{
KzgCommitments: [][]byte{
make([]byte, 48),
make([]byte, 48),
make([]byte, 48),
},
Proofs: [][]byte{
make([]byte, 48),
make([]byte, 48),
make([]byte, 48),
},
Blobs: [][]byte{
make([]byte, 131072),
make([]byte, 131072),
make([]byte, 131072),
},
}
sszBytes, err := bundle.MarshalSSZ()
require.NoError(t, err)
unmarshaled := &enginev1.BlobsBundleV2{}
err = unmarshaled.UnmarshalSSZ(sszBytes)
require.NoError(t, err)
require.Equal(t, len(bundle.KzgCommitments), len(unmarshaled.KzgCommitments))
require.Equal(t, len(bundle.Proofs), len(unmarshaled.Proofs))
require.Equal(t, len(bundle.Blobs), len(unmarshaled.Blobs))
require.DeepEqual(t, bundle.KzgCommitments, unmarshaled.KzgCommitments)
require.DeepEqual(t, bundle.Proofs, unmarshaled.Proofs)
require.DeepEqual(t, bundle.Blobs, unmarshaled.Blobs)
})
}
func TestPayloadIDBytes_MarshalUnmarshalJSON(t *testing.T) {