adding ssz capabilities for deneb publish block v1 (#12622)

This commit is contained in:
james-prysm 2023-07-17 11:28:20 -05:00 committed by Preston Van Loon
parent b8fb602fc4
commit 5a62aa4c07
18 changed files with 1826 additions and 1139 deletions

View File

@ -123,6 +123,7 @@ go_test(
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/state-native:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",

View File

@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/v1alpha1/validator"
"github.com/prysmaticlabs/prysm/v4/config/params"
consensus_types "github.com/prysmaticlabs/prysm/v4/consensus-types"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/encoding/ssz/detect"
@ -238,13 +239,46 @@ func (bs *Server) SubmitBlindedBlockSSZ(ctx context.Context, req *ethpbv2.SSZCon
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not create unmarshaler: %v", err)
}
block, err := unmarshaler.UnmarshalBlindedBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
switch forkVer {
case bytesutil.ToBytes4(params.BeaconConfig().DenebForkVersion):
blkContent := &ethpbv2.SignedBlindedBeaconBlockContentsDeneb{}
if err := blkContent.UnmarshalSSZ(req.Data); err != nil {
return &emptypb.Empty{}, status.Errorf(codes.InvalidArgument, "Could not unmarshal ssz signed blinded block contents: %v", err)
}
blindedBlock, err := migration.BlindedDenebToV1Alpha1SignedBlock(blkContent.SignedBlindedBlock)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "Could not convert signed blinded block to v1alpha1: %v", err)
}
block, err := blocks.NewSignedBeaconBlock(blindedBlock)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not init block: %v", err)
}
b, err := block.PbBlindedDenebBlock()
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not get proto block: %v", err)
}
_, err = bs.V1Alpha1ValidatorServer.ProposeBeaconBlock(ctx, &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_BlindedDeneb{
BlindedDeneb: &eth.SignedBlindedBeaconBlockAndBlobsDeneb{
Block: b,
Blobs: migration.SignedBlindedBlobsToV1Alpha1SignedBlindedBlobs(blkContent.SignedBlindedBlobSidecars),
},
},
})
if err != nil {
if strings.Contains(err.Error(), validator.CouldNotDecodeBlock) {
return &emptypb.Empty{}, status.Error(codes.InvalidArgument, err.Error())
}
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not propose block: %v", err)
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().CapellaForkVersion):
block, err := unmarshaler.UnmarshalBlindedBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
if !block.IsBlinded() {
return nil, status.Error(codes.InvalidArgument, "Submitted block is not blinded")
}
@ -265,6 +299,10 @@ func (bs *Server) SubmitBlindedBlockSSZ(ctx context.Context, req *ethpbv2.SSZCon
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().BellatrixForkVersion):
block, err := unmarshaler.UnmarshalBlindedBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
if !block.IsBlinded() {
return nil, status.Error(codes.InvalidArgument, "Submitted block is not blinded")
}
@ -285,6 +323,10 @@ func (bs *Server) SubmitBlindedBlockSSZ(ctx context.Context, req *ethpbv2.SSZCon
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion):
block, err := unmarshaler.UnmarshalBlindedBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
b, err := block.PbAltairBlock()
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not get proto block: %v", err)
@ -302,6 +344,10 @@ func (bs *Server) SubmitBlindedBlockSSZ(ctx context.Context, req *ethpbv2.SSZCon
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().GenesisForkVersion):
block, err := unmarshaler.UnmarshalBlindedBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
b, err := block.PbPhase0Block()
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not get proto block: %v", err)

View File

@ -10,6 +10,7 @@ import (
mock "github.com/prysmaticlabs/prysm/v4/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil"
mockSync "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
ethpbv1 "github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
@ -470,6 +471,49 @@ func TestServer_SubmitBlindedBlockSSZ(t *testing.T) {
_, err = server.SubmitBlindedBlockSSZ(sszCtx, blockReq)
assert.NotNil(t, err)
})
t.Run("Deneb", func(t *testing.T) {
v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl)
v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), gomock.Any())
server := &Server{
V1Alpha1ValidatorServer: v1alpha1Server,
SyncChecker: &mockSync.Sync{IsSyncing: false},
}
b, err := util.NewBlindedBeaconBlockContentsDeneb(fieldparams.MaxBlobsPerBlock)
require.NoError(t, err)
// TODO: replace when deneb fork epoch is known
b.SignedBlindedBlock.Message.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().CapellaForkEpoch))
ssz, err := b.MarshalSSZ()
require.NoError(t, err)
blockReq := &ethpbv2.SSZContainer{
Data: ssz,
}
md := metadata.MD{}
md.Set(api.VersionHeader, "deneb")
sszCtx := metadata.NewIncomingContext(ctx, md)
_, err = server.SubmitBlindedBlockSSZ(sszCtx, blockReq)
assert.NoError(t, err)
})
t.Run("Deneb full", func(t *testing.T) {
server := &Server{
SyncChecker: &mockSync.Sync{IsSyncing: false},
}
b, err := util.NewBeaconBlockContentsDeneb(fieldparams.MaxBlobsPerBlock)
require.NoError(t, err)
// TODO: replace when deneb fork epoch is known
b.SignedBlock.Message.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().CapellaForkEpoch))
ssz, err := b.MarshalSSZ()
require.NoError(t, err)
blockReq := &ethpbv2.SSZContainer{
Data: ssz,
}
md := metadata.MD{}
md.Set(api.VersionHeader, "deneb")
sszCtx := metadata.NewIncomingContext(ctx, md)
_, err = server.SubmitBlindedBlockSSZ(sszCtx, blockReq)
assert.NotNil(t, err)
})
t.Run("sync not ready", func(t *testing.T) {
chainService := &mock.ChainService{}
v1Server := &Server{

View File

@ -271,13 +271,45 @@ func (bs *Server) SubmitBlockSSZ(ctx context.Context, req *ethpbv2.SSZContainer)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not create unmarshaler: %v", err)
}
block, err := unmarshaler.UnmarshalBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
switch forkVer {
case bytesutil.ToBytes4(params.BeaconConfig().DenebForkVersion):
blkContent := &ethpbv2.SignedBeaconBlockContentsDeneb{}
if err := blkContent.UnmarshalSSZ(req.Data); err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal ssz block contents: %v", err)
}
v1block, err := migration.DenebToV1Alpha1SignedBlock(blkContent.SignedBlock)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "Submitted block is not valid: %v", err)
}
block, err := blocks.NewSignedBeaconBlock(v1block)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not init block: %v", err)
}
b, err := block.PbDenebBlock()
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not get proto block: %v", err)
}
_, err = bs.V1Alpha1ValidatorServer.ProposeBeaconBlock(ctx, &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_Deneb{
Deneb: &eth.SignedBeaconBlockAndBlobsDeneb{
Block: b,
Blobs: migration.SignedBlobsToV1Alpha1SignedBlobs(blkContent.SignedBlobSidecars),
},
},
})
if err != nil {
if strings.Contains(err.Error(), validator.CouldNotDecodeBlock) {
return &emptypb.Empty{}, status.Error(codes.InvalidArgument, err.Error())
}
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not propose block: %v", err)
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().CapellaForkVersion):
block, err := unmarshaler.UnmarshalBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
if block.IsBlinded() {
return nil, status.Error(codes.InvalidArgument, "Submitted block is blinded")
}
@ -298,6 +330,10 @@ func (bs *Server) SubmitBlockSSZ(ctx context.Context, req *ethpbv2.SSZContainer)
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().BellatrixForkVersion):
block, err := unmarshaler.UnmarshalBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
if block.IsBlinded() {
return nil, status.Error(codes.InvalidArgument, "Submitted block is blinded")
}
@ -318,6 +354,10 @@ func (bs *Server) SubmitBlockSSZ(ctx context.Context, req *ethpbv2.SSZContainer)
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion):
block, err := unmarshaler.UnmarshalBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
b, err := block.PbAltairBlock()
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not get proto block: %v", err)
@ -335,6 +375,10 @@ func (bs *Server) SubmitBlockSSZ(ctx context.Context, req *ethpbv2.SSZContainer)
}
return &emptypb.Empty{}, nil
case bytesutil.ToBytes4(params.BeaconConfig().GenesisForkVersion):
block, err := unmarshaler.UnmarshalBeaconBlock(req.Data)
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not unmarshal request data into block: %v", err)
}
b, err := block.PbPhase0Block()
if err != nil {
return &emptypb.Empty{}, status.Errorf(codes.Internal, "Could not get proto block: %v", err)

View File

@ -13,6 +13,7 @@ import (
dbTest "github.com/prysmaticlabs/prysm/v4/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil"
mockSync "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/config/params"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces"
@ -411,6 +412,25 @@ func TestServer_SubmitBlock(t *testing.T) {
_, err := server.SubmitBlock(context.Background(), blockReq)
assert.NoError(t, err)
})
t.Run("Deneb", func(t *testing.T) {
v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl)
v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), gomock.Any())
server := &Server{
V1Alpha1ValidatorServer: v1alpha1Server,
SyncChecker: &mockSync.Sync{IsSyncing: false},
}
blockReq := &ethpbv2.SignedBeaconBlockContentsContainer{
Message: &ethpbv2.SignedBeaconBlockContentsContainer_DenebContents{
DenebContents: &ethpbv2.SignedBeaconBlockContentsDeneb{
SignedBlock: &ethpbv2.SignedBeaconBlockDeneb{},
SignedBlobSidecars: []*ethpbv2.SignedBlobSidecar{},
},
},
}
_, err := server.SubmitBlock(context.Background(), blockReq)
assert.NoError(t, err)
})
t.Run("sync not ready", func(t *testing.T) {
chainService := &mock.ChainService{}
v1Server := &Server{
@ -547,6 +567,49 @@ func TestServer_SubmitBlockSSZ(t *testing.T) {
_, err = server.SubmitBlockSSZ(sszCtx, blockReq)
assert.NotNil(t, err)
})
t.Run("Deneb", func(t *testing.T) {
v1alpha1Server := mock2.NewMockBeaconNodeValidatorServer(ctrl)
v1alpha1Server.EXPECT().ProposeBeaconBlock(gomock.Any(), gomock.Any())
server := &Server{
V1Alpha1ValidatorServer: v1alpha1Server,
SyncChecker: &mockSync.Sync{IsSyncing: false},
}
b, err := util.NewBeaconBlockContentsDeneb(fieldparams.MaxBlobsPerBlock)
require.NoError(t, err)
// TODO: update to deneb fork epoch
b.SignedBlock.Message.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().CapellaForkEpoch))
ssz, err := b.MarshalSSZ()
require.NoError(t, err)
blockReq := &ethpbv2.SSZContainer{
Data: ssz,
}
md := metadata.MD{}
md.Set(api.VersionHeader, "deneb")
sszCtx := metadata.NewIncomingContext(ctx, md)
_, err = server.SubmitBlockSSZ(sszCtx, blockReq)
assert.NoError(t, err)
})
t.Run("Deneb blinded", func(t *testing.T) {
server := &Server{
SyncChecker: &mockSync.Sync{IsSyncing: false},
}
b, err := util.NewBlindedBeaconBlockContentsDeneb(fieldparams.MaxBlobsPerBlock)
require.NoError(t, err)
// TODO: update to deneb fork epoch
b.SignedBlindedBlock.Message.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().CapellaForkEpoch))
ssz, err := b.MarshalSSZ()
require.NoError(t, err)
blockReq := &ethpbv2.SSZContainer{
Data: ssz,
}
md := metadata.MD{}
md.Set(api.VersionHeader, "deneb")
sszCtx := metadata.NewIncomingContext(ctx, md)
_, err = server.SubmitBlockSSZ(sszCtx, blockReq)
assert.NotNil(t, err)
})
t.Run("sync not ready", func(t *testing.T) {
chainService := &mock.ChainService{}
v1Server := &Server{

View File

@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: 401cdb3ad7380c513dbcec6cecea7854113a0c2d862d35445b2b319aaf3cbecd
// Hash: be585637bf02ff296cc47c64aa4c161246d51305b2c95ae51cac2687892b3617
package v1
import (

View File

@ -52,6 +52,8 @@ ssz_gen_marshal(
"BlindedBlobSidecar",
"BlobSidecar",
"BlobSidecars",
"SignedBeaconBlockContentsDeneb",
"SignedBlindedBeaconBlockContentsDeneb",
],
)

File diff suppressed because it is too large Load Diff

View File

@ -60,11 +60,6 @@ message BeaconBlockContainerV2 {
}
}
message BeaconBlockAndBlobsDeneb {
BeaconBlockDeneb block = 1;
repeated BlobSidecar blobs = 2 [(ethereum.eth.ext.ssz_max) = "4"];
}
message SignedBeaconBlockContainer {
oneof message {
v1.BeaconBlock phase0_block = 1;

View File

@ -28,7 +28,7 @@ type BlobSidecars struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Sidecars []*BlobSidecar `protobuf:"bytes,1,rep,name=sidecars,proto3" json:"sidecars,omitempty" ssz-max:"4"`
Sidecars []*BlobSidecar `protobuf:"bytes,1,rep,name=sidecars,proto3" json:"sidecars,omitempty" ssz-max:"6"`
}
func (x *BlobSidecars) Reset() {
@ -452,7 +452,7 @@ var file_proto_eth_v2_blobs_proto_rawDesc = []byte{
0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x73, 0x12, 0x3f, 0x0a, 0x08, 0x73, 0x69, 0x64, 0x65,
0x63, 0x61, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x74, 0x68,
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x6c, 0x6f,
0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52,
0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x36, 0x52,
0x08, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x73, 0x22, 0xc5, 0x03, 0x0a, 0x0b, 0x42, 0x6c,
0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a,

View File

@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: 10fbf3bf6d33b9bb3b31379c65cd6cc3bd9bc0a86e6a2395340138fe26041af0
// Hash: 3787b840268295a82b8e651531b47ac585b6c853e77f8baf886b0b5fde45abf0
package eth
import (
@ -5788,6 +5788,314 @@ func (b *BeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
// MarshalSSZ ssz marshals the SignedBeaconBlockContentsDeneb object
func (s *SignedBeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsDeneb object to a target array
func (s *SignedBeaconBlockContentsDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(8)
// Offset (0) 'SignedBlock'
dst = ssz.WriteOffset(dst, offset)
if s.SignedBlock == nil {
s.SignedBlock = new(SignedBeaconBlockDeneb)
}
offset += s.SignedBlock.SizeSSZ()
// Offset (1) 'SignedBlobSidecars'
dst = ssz.WriteOffset(dst, offset)
offset += len(s.SignedBlobSidecars) * 131352
// Field (0) 'SignedBlock'
if dst, err = s.SignedBlock.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'SignedBlobSidecars'
if size := len(s.SignedBlobSidecars); size > 6 {
err = ssz.ErrListTooBigFn("--.SignedBlobSidecars", size, 6)
return
}
for ii := 0; ii < len(s.SignedBlobSidecars); ii++ {
if dst, err = s.SignedBlobSidecars[ii].MarshalSSZTo(dst); err != nil {
return
}
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsDeneb object
func (s *SignedBeaconBlockContentsDeneb) 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) 'SignedBlock'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 < 8 {
return ssz.ErrInvalidVariableOffset
}
// Offset (1) 'SignedBlobSidecars'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
}
// Field (0) 'SignedBlock'
{
buf = tail[o0:o1]
if s.SignedBlock == nil {
s.SignedBlock = new(SignedBeaconBlockDeneb)
}
if err = s.SignedBlock.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'SignedBlobSidecars'
{
buf = tail[o1:]
num, err := ssz.DivideInt2(len(buf), 131352, 6)
if err != nil {
return err
}
s.SignedBlobSidecars = make([]*SignedBlobSidecar, num)
for ii := 0; ii < num; ii++ {
if s.SignedBlobSidecars[ii] == nil {
s.SignedBlobSidecars[ii] = new(SignedBlobSidecar)
}
if err = s.SignedBlobSidecars[ii].UnmarshalSSZ(buf[ii*131352 : (ii+1)*131352]); err != nil {
return err
}
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsDeneb object
func (s *SignedBeaconBlockContentsDeneb) SizeSSZ() (size int) {
size = 8
// Field (0) 'SignedBlock'
if s.SignedBlock == nil {
s.SignedBlock = new(SignedBeaconBlockDeneb)
}
size += s.SignedBlock.SizeSSZ()
// Field (1) 'SignedBlobSidecars'
size += len(s.SignedBlobSidecars) * 131352
return
}
// HashTreeRoot ssz hashes the SignedBeaconBlockContentsDeneb object
func (s *SignedBeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsDeneb object with a hasher
func (s *SignedBeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'SignedBlock'
if err = s.SignedBlock.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'SignedBlobSidecars'
{
subIndx := hh.Index()
num := uint64(len(s.SignedBlobSidecars))
if num > 6 {
err = ssz.ErrIncorrectListSize
return
}
for _, elem := range s.SignedBlobSidecars {
if err = elem.HashTreeRootWith(hh); err != nil {
return
}
}
if ssz.EnableVectorizedHTR {
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 6)
} else {
hh.MerkleizeWithMixin(subIndx, num, 6)
}
}
if ssz.EnableVectorizedHTR {
hh.MerkleizeVectorizedHTR(indx)
} else {
hh.Merkleize(indx)
}
return
}
// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockContentsDeneb object
func (s *SignedBlindedBeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockContentsDeneb object to a target array
func (s *SignedBlindedBeaconBlockContentsDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(8)
// Offset (0) 'SignedBlindedBlock'
dst = ssz.WriteOffset(dst, offset)
if s.SignedBlindedBlock == nil {
s.SignedBlindedBlock = new(SignedBlindedBeaconBlockDeneb)
}
offset += s.SignedBlindedBlock.SizeSSZ()
// Offset (1) 'SignedBlindedBlobSidecars'
dst = ssz.WriteOffset(dst, offset)
offset += len(s.SignedBlindedBlobSidecars) * 312
// Field (0) 'SignedBlindedBlock'
if dst, err = s.SignedBlindedBlock.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'SignedBlindedBlobSidecars'
if size := len(s.SignedBlindedBlobSidecars); size > 6 {
err = ssz.ErrListTooBigFn("--.SignedBlindedBlobSidecars", size, 6)
return
}
for ii := 0; ii < len(s.SignedBlindedBlobSidecars); ii++ {
if dst, err = s.SignedBlindedBlobSidecars[ii].MarshalSSZTo(dst); err != nil {
return
}
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockContentsDeneb object
func (s *SignedBlindedBeaconBlockContentsDeneb) 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) 'SignedBlindedBlock'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 < 8 {
return ssz.ErrInvalidVariableOffset
}
// Offset (1) 'SignedBlindedBlobSidecars'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
}
// Field (0) 'SignedBlindedBlock'
{
buf = tail[o0:o1]
if s.SignedBlindedBlock == nil {
s.SignedBlindedBlock = new(SignedBlindedBeaconBlockDeneb)
}
if err = s.SignedBlindedBlock.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'SignedBlindedBlobSidecars'
{
buf = tail[o1:]
num, err := ssz.DivideInt2(len(buf), 312, 6)
if err != nil {
return err
}
s.SignedBlindedBlobSidecars = make([]*SignedBlindedBlobSidecar, num)
for ii := 0; ii < num; ii++ {
if s.SignedBlindedBlobSidecars[ii] == nil {
s.SignedBlindedBlobSidecars[ii] = new(SignedBlindedBlobSidecar)
}
if err = s.SignedBlindedBlobSidecars[ii].UnmarshalSSZ(buf[ii*312 : (ii+1)*312]); err != nil {
return err
}
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockContentsDeneb object
func (s *SignedBlindedBeaconBlockContentsDeneb) SizeSSZ() (size int) {
size = 8
// Field (0) 'SignedBlindedBlock'
if s.SignedBlindedBlock == nil {
s.SignedBlindedBlock = new(SignedBlindedBeaconBlockDeneb)
}
size += s.SignedBlindedBlock.SizeSSZ()
// Field (1) 'SignedBlindedBlobSidecars'
size += len(s.SignedBlindedBlobSidecars) * 312
return
}
// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockContentsDeneb object
func (s *SignedBlindedBeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockContentsDeneb object with a hasher
func (s *SignedBlindedBeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'SignedBlindedBlock'
if err = s.SignedBlindedBlock.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'SignedBlindedBlobSidecars'
{
subIndx := hh.Index()
num := uint64(len(s.SignedBlindedBlobSidecars))
if num > 6 {
err = ssz.ErrIncorrectListSize
return
}
for _, elem := range s.SignedBlindedBlobSidecars {
if err = elem.HashTreeRootWith(hh); err != nil {
return
}
}
if ssz.EnableVectorizedHTR {
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 6)
} else {
hh.MerkleizeWithMixin(subIndx, num, 6)
}
}
if ssz.EnableVectorizedHTR {
hh.MerkleizeVectorizedHTR(indx)
} else {
hh.Merkleize(indx)
}
return
}
// MarshalSSZ ssz marshals the BlobSidecars object
func (b *BlobSidecars) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)
@ -5803,8 +6111,8 @@ func (b *BlobSidecars) MarshalSSZTo(buf []byte) (dst []byte, err error) {
offset += len(b.Sidecars) * 131256
// Field (0) 'Sidecars'
if size := len(b.Sidecars); size > 4 {
err = ssz.ErrListTooBigFn("--.Sidecars", size, 4)
if size := len(b.Sidecars); size > 6 {
err = ssz.ErrListTooBigFn("--.Sidecars", size, 6)
return
}
for ii := 0; ii < len(b.Sidecars); ii++ {
@ -5839,7 +6147,7 @@ func (b *BlobSidecars) UnmarshalSSZ(buf []byte) error {
// Field (0) 'Sidecars'
{
buf = tail[o0:]
num, err := ssz.DivideInt2(len(buf), 131256, 4)
num, err := ssz.DivideInt2(len(buf), 131256, 6)
if err != nil {
return err
}
@ -5879,7 +6187,7 @@ func (b *BlobSidecars) HashTreeRootWith(hh *ssz.Hasher) (err error) {
{
subIndx := hh.Index()
num := uint64(len(b.Sidecars))
if num > 4 {
if num > 6 {
err = ssz.ErrIncorrectListSize
return
}
@ -5889,9 +6197,9 @@ func (b *BlobSidecars) HashTreeRootWith(hh *ssz.Hasher) (err error) {
}
}
if ssz.EnableVectorizedHTR {
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 4)
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 6)
} else {
hh.MerkleizeWithMixin(subIndx, num, 4)
hh.MerkleizeWithMixin(subIndx, num, 6)
}
}
@ -6076,6 +6384,93 @@ func (b *BlobSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
// MarshalSSZ ssz marshals the SignedBlobSidecar object
func (s *SignedBlobSidecar) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBlobSidecar object to a target array
func (s *SignedBlobSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BlobSidecar)
}
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
dst = append(dst, s.Signature...)
return
}
// UnmarshalSSZ ssz unmarshals the SignedBlobSidecar object
func (s *SignedBlobSidecar) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 131352 {
return ssz.ErrSize
}
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BlobSidecar)
}
if err = s.Message.UnmarshalSSZ(buf[0:131256]); err != nil {
return err
}
// Field (1) 'Signature'
if cap(s.Signature) == 0 {
s.Signature = make([]byte, 0, len(buf[131256:131352]))
}
s.Signature = append(s.Signature, buf[131256:131352]...)
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBlobSidecar object
func (s *SignedBlobSidecar) SizeSSZ() (size int) {
size = 131352
return
}
// HashTreeRoot ssz hashes the SignedBlobSidecar object
func (s *SignedBlobSidecar) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBlobSidecar object with a hasher
func (s *SignedBlobSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
hh.PutBytes(s.Signature)
if ssz.EnableVectorizedHTR {
hh.MerkleizeVectorizedHTR(indx)
} else {
hh.Merkleize(indx)
}
return
}
// MarshalSSZ ssz marshals the SignedBlindedBlobSidecar object
func (s *SignedBlindedBlobSidecar) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)

View File

@ -172,6 +172,20 @@ func V1Alpha1BeaconBlockDenebToV2(v1alpha1Block *ethpbalpha.BeaconBlockDeneb) (*
return v2Block, nil
}
// V2BeaconBlockDenebToV1Alpha1 converts a v2 Deneb beacon block to a v1alpha1
// Deneb block.
func V2BeaconBlockDenebToV1Alpha1(v2block *ethpbv2.BeaconBlockDeneb) (*ethpbalpha.BeaconBlockDeneb, error) {
marshaledBlk, err := proto.Marshal(v2block)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
}
v1alpha1block := &ethpbalpha.BeaconBlockDeneb{}
if err := proto.Unmarshal(marshaledBlk, v1alpha1block); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
}
return v1alpha1block, nil
}
// V1Alpha1BlobSidecarsToV2 converts an array of v1alpha1 blinded blob sidecars to its v2 equivalent.
func V1Alpha1BlobSidecarsToV2(v1alpha1Blobs []*ethpbalpha.BlobSidecar) ([]*ethpbv2.BlobSidecar, error) {
v2Blobs := make([]*ethpbv2.BlobSidecar, len(v1alpha1Blobs))
@ -208,16 +222,16 @@ func V1Alpha1BlindedBlobSidecarsToV2(v1alpha1Blobs []*ethpbalpha.BlindedBlobSide
// V1Alpha1BeaconBlockDenebAndBlobsToV2 converts a v1alpha1 Deneb beacon block and blobs to a v2
// Deneb block.
func V1Alpha1BeaconBlockDenebAndBlobsToV2(v1alpha1Block *ethpbalpha.BeaconBlockAndBlobsDeneb) (*ethpbv2.BeaconBlockAndBlobsDeneb, error) {
marshaledBlkandBlobs, err := proto.Marshal(v1alpha1Block)
func V1Alpha1BeaconBlockDenebAndBlobsToV2(v1alpha1Block *ethpbalpha.BeaconBlockAndBlobsDeneb) (*ethpbv2.BeaconBlockContentsDeneb, error) {
v2Block, err := V1Alpha1BeaconBlockDenebToV2(v1alpha1Block.Block)
if err != nil {
return nil, errors.Wrap(err, "could not marshal block")
return nil, errors.Wrap(err, "could not convert block")
}
v2BlocknBlobs := &ethpbv2.BeaconBlockAndBlobsDeneb{}
if err := proto.Unmarshal(marshaledBlkandBlobs, v2BlocknBlobs); err != nil {
return nil, errors.Wrap(err, "could not unmarshal block")
v2Blobs, err := V1Alpha1BlobSidecarsToV2(v1alpha1Block.Blobs)
if err != nil {
return nil, errors.Wrap(err, "could not convert blobs")
}
return v2BlocknBlobs, nil
return &ethpbv2.BeaconBlockContentsDeneb{Block: v2Block, BlobSidecars: v2Blobs}, nil
}
// V1Alpha1BlindedBlockAndBlobsDenebToV2Blinded converts a v1alpha1 Deneb blinded beacon block and blobs to v2 blinded block contents.

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc v3.15.8
// protoc v4.23.3
// source: proto/prysm/v1alpha1/beacon_block.proto
package eth
@ -1939,7 +1939,7 @@ type SignedBeaconBlockAndBlobsDeneb struct {
unknownFields protoimpl.UnknownFields
Block *SignedBeaconBlockDeneb `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"`
Blobs []*SignedBlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"4"`
Blobs []*SignedBlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"6"`
}
func (x *SignedBeaconBlockAndBlobsDeneb) Reset() {
@ -2049,7 +2049,7 @@ type BeaconBlockAndBlobsDeneb struct {
unknownFields protoimpl.UnknownFields
Block *BeaconBlockDeneb `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"`
Blobs []*BlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"4"`
Blobs []*BlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"6"`
}
func (x *BeaconBlockAndBlobsDeneb) Reset() {
@ -2840,7 +2840,7 @@ type SignedBlindedBeaconBlockAndBlobsDeneb struct {
unknownFields protoimpl.UnknownFields
Block *SignedBlindedBeaconBlockDeneb `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"`
Blobs []*SignedBlindedBlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"4"`
Blobs []*SignedBlindedBlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"6"`
}
func (x *SignedBlindedBeaconBlockAndBlobsDeneb) Reset() {
@ -2895,7 +2895,7 @@ type BlindedBeaconBlockAndBlobsDeneb struct {
unknownFields protoimpl.UnknownFields
Block *BlindedBeaconBlockDeneb `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"`
Blobs []*BlindedBlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"4"`
Blobs []*BlindedBlobSidecar `protobuf:"bytes,2,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"6"`
}
func (x *BlindedBeaconBlockAndBlobsDeneb) Reset() {
@ -4364,7 +4364,7 @@ var file_proto_prysm_v1alpha1_beacon_block_proto_rawDesc = []byte{
0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65,
0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42, 0x05, 0x92, 0xb5,
0x18, 0x01, 0x34, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22, 0x7d, 0x0a, 0x16, 0x53, 0x69,
0x18, 0x01, 0x36, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22, 0x7d, 0x0a, 0x16, 0x53, 0x69,
0x67, 0x6e, 0x65, 0x64, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x44,
0x65, 0x6e, 0x65, 0x62, 0x12, 0x3d, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
@ -4381,7 +4381,7 @@ var file_proto_prysm_v1alpha1_beacon_block_proto_rawDesc = []byte{
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x3f, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x18, 0x02,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x6c, 0x6f,
0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52,
0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x36, 0x52,
0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22, 0xf6, 0x02, 0x0a, 0x10, 0x42, 0x65, 0x61, 0x63, 0x6f,
0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, 0x59, 0x0a, 0x04, 0x73,
0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67,
@ -4655,7 +4655,7 @@ var file_proto_prysm_v1alpha1_beacon_block_proto_rawDesc = []byte{
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x42, 0x6c, 0x69,
0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42,
0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22, 0xaf, 0x01,
0x05, 0x92, 0xb5, 0x18, 0x01, 0x36, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22, 0xaf, 0x01,
0x0a, 0x1f, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42,
0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x44, 0x65, 0x6e, 0x65,
0x62, 0x12, 0x44, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
@ -4666,7 +4666,7 @@ var file_proto_prysm_v1alpha1_beacon_block_proto_rawDesc = []byte{
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42,
0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61,
0x72, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22,
0x72, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x36, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22,
0x8b, 0x01, 0x0a, 0x1d, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65,
0x64, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x44, 0x65, 0x6e, 0x65,
0x62, 0x12, 0x44, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc v3.15.8
// protoc v4.23.3
// source: proto/prysm/v1alpha1/blobs.proto
package eth
@ -233,7 +233,7 @@ type BlindedBlobSidecars struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Sidecars []*BlindedBlobSidecar `protobuf:"bytes,1,rep,name=sidecars,proto3" json:"sidecars,omitempty" ssz-max:"4"`
Sidecars []*BlindedBlobSidecar `protobuf:"bytes,1,rep,name=sidecars,proto3" json:"sidecars,omitempty" ssz-max:"6"`
}
func (x *BlindedBlobSidecars) Reset() {
@ -543,7 +543,7 @@ var file_proto_prysm_v1alpha1_blobs_proto_rawDesc = []byte{
0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64,
0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x42, 0x05, 0x92, 0xb5, 0x18,
0x01, 0x34, 0x52, 0x08, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x73, 0x22, 0xd1, 0x03, 0x0a,
0x01, 0x36, 0x52, 0x08, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x73, 0x22, 0xd1, 0x03, 0x0a,
0x12, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65,
0x63, 0x61, 0x72, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52,

View File

@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: 7728b6c4c0ae56589deb9c9ca87c8c58d6c1120d4d2d399f8da0c811b8c6c7cc
// Hash: de1a69d9126e429c6eb2c5d50c30bc7c3f9dfe5e2c08243da4fb23768c1f582f
package eth
import (

View File

@ -24,7 +24,7 @@ mainnet = {
"blob.size": "131072",
"logs_bloom.size": "256",
"extra_data.size": "32",
"max_blobs_per_block.size": "4",
"max_blobs_per_block.size": "6",
"max_blob_commitments.size":"4096",
}
@ -45,7 +45,7 @@ minimal = {
"blob.size": "128",
"logs_bloom.size": "256",
"extra_data.size": "32",
"max_blobs_per_block.size": "4",
"max_blobs_per_block.size": "6",
"max_blob_commitments.size":"16",
}

View File

@ -1139,6 +1139,16 @@ func HydrateSignedBeaconBlockDeneb(b *ethpb.SignedBeaconBlockDeneb) *ethpb.Signe
return b
}
// HydrateV2SignedBeaconBlockDeneb hydrates a v2 signed beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateV2SignedBeaconBlockDeneb(b *v2.SignedBeaconBlockDeneb) *v2.SignedBeaconBlockDeneb {
if b.Signature == nil {
b.Signature = make([]byte, fieldparams.BLSSignatureLength)
}
b.Message = HydrateV2BeaconBlockDeneb(b.Message)
return b
}
// HydrateBeaconBlockDeneb hydrates a beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconBlockDeneb(b *ethpb.BeaconBlockDeneb) *ethpb.BeaconBlockDeneb {
@ -1155,6 +1165,22 @@ func HydrateBeaconBlockDeneb(b *ethpb.BeaconBlockDeneb) *ethpb.BeaconBlockDeneb
return b
}
// HydrateV2BeaconBlockDeneb hydrates a v2 beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateV2BeaconBlockDeneb(b *v2.BeaconBlockDeneb) *v2.BeaconBlockDeneb {
if b == nil {
b = &v2.BeaconBlockDeneb{}
}
if b.ParentRoot == nil {
b.ParentRoot = make([]byte, fieldparams.RootLength)
}
if b.StateRoot == nil {
b.StateRoot = make([]byte, fieldparams.RootLength)
}
b.Body = HydrateV2BeaconBlockBodyDeneb(b.Body)
return b
}
// HydrateBeaconBlockBodyDeneb hydrates a beacon block body with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateBeaconBlockBodyDeneb(b *ethpb.BeaconBlockBodyDeneb) *ethpb.BeaconBlockBodyDeneb {
@ -1196,6 +1222,47 @@ func HydrateBeaconBlockBodyDeneb(b *ethpb.BeaconBlockBodyDeneb) *ethpb.BeaconBlo
return b
}
// HydrateV2BeaconBlockBodyDeneb hydrates a v2 beacon block body with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateV2BeaconBlockBodyDeneb(b *v2.BeaconBlockBodyDeneb) *v2.BeaconBlockBodyDeneb {
if b == nil {
b = &v2.BeaconBlockBodyDeneb{}
}
if b.RandaoReveal == nil {
b.RandaoReveal = make([]byte, fieldparams.BLSSignatureLength)
}
if b.Graffiti == nil {
b.Graffiti = make([]byte, fieldparams.RootLength)
}
if b.Eth1Data == nil {
b.Eth1Data = &v1.Eth1Data{
DepositRoot: make([]byte, fieldparams.RootLength),
BlockHash: make([]byte, fieldparams.RootLength),
}
}
if b.SyncAggregate == nil {
b.SyncAggregate = &v1.SyncAggregate{
SyncCommitteeBits: make([]byte, fieldparams.SyncAggregateSyncCommitteeBytesLength),
SyncCommitteeSignature: make([]byte, fieldparams.BLSSignatureLength),
}
}
if b.ExecutionPayload == nil {
b.ExecutionPayload = &enginev1.ExecutionPayloadDeneb{
ParentHash: make([]byte, fieldparams.RootLength),
FeeRecipient: make([]byte, 20),
StateRoot: make([]byte, fieldparams.RootLength),
ReceiptsRoot: make([]byte, fieldparams.RootLength),
LogsBloom: make([]byte, 256),
PrevRandao: make([]byte, fieldparams.RootLength),
BaseFeePerGas: make([]byte, fieldparams.RootLength),
BlockHash: make([]byte, fieldparams.RootLength),
Transactions: make([][]byte, 0),
ExtraData: make([]byte, 0),
}
}
return b
}
// HydrateSignedBlindedBeaconBlockDeneb hydrates a signed blinded beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateSignedBlindedBeaconBlockDeneb(b *ethpb.SignedBlindedBeaconBlockDeneb) *ethpb.SignedBlindedBeaconBlockDeneb {
@ -1206,6 +1273,16 @@ func HydrateSignedBlindedBeaconBlockDeneb(b *ethpb.SignedBlindedBeaconBlockDeneb
return b
}
// HydrateV2SignedBlindedBeaconBlockDeneb hydrates a signed v2 blinded beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateV2SignedBlindedBeaconBlockDeneb(b *v2.SignedBlindedBeaconBlockDeneb) *v2.SignedBlindedBeaconBlockDeneb {
if b.Signature == nil {
b.Signature = make([]byte, fieldparams.BLSSignatureLength)
}
b.Message = HydrateV2BlindedBeaconBlockDeneb(b.Message)
return b
}
// HydrateBlindedBeaconBlockDeneb hydrates a blinded beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateBlindedBeaconBlockDeneb(b *ethpb.BlindedBeaconBlockDeneb) *ethpb.BlindedBeaconBlockDeneb {
@ -1222,6 +1299,22 @@ func HydrateBlindedBeaconBlockDeneb(b *ethpb.BlindedBeaconBlockDeneb) *ethpb.Bli
return b
}
// HydrateV2BlindedBeaconBlockDeneb hydrates a v2 blinded beacon block with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateV2BlindedBeaconBlockDeneb(b *v2.BlindedBeaconBlockDeneb) *v2.BlindedBeaconBlockDeneb {
if b == nil {
b = &v2.BlindedBeaconBlockDeneb{}
}
if b.ParentRoot == nil {
b.ParentRoot = make([]byte, fieldparams.RootLength)
}
if b.StateRoot == nil {
b.StateRoot = make([]byte, fieldparams.RootLength)
}
b.Body = HydrateV2BlindedBeaconBlockBodyDeneb(b.Body)
return b
}
// HydrateBlindedBeaconBlockBodyDeneb hydrates a blinded beacon block body with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateBlindedBeaconBlockBodyDeneb(b *ethpb.BlindedBeaconBlockBodyDeneb) *ethpb.BlindedBeaconBlockBodyDeneb {
@ -1263,3 +1356,45 @@ func HydrateBlindedBeaconBlockBodyDeneb(b *ethpb.BlindedBeaconBlockBodyDeneb) *e
}
return b
}
// HydrateV2BlindedBeaconBlockBodyDeneb hydrates a blinded v2 beacon block body with correct field length sizes
// to comply with fssz marshalling and unmarshalling rules.
func HydrateV2BlindedBeaconBlockBodyDeneb(b *v2.BlindedBeaconBlockBodyDeneb) *v2.BlindedBeaconBlockBodyDeneb {
if b == nil {
b = &v2.BlindedBeaconBlockBodyDeneb{}
}
if b.RandaoReveal == nil {
b.RandaoReveal = make([]byte, fieldparams.BLSSignatureLength)
}
if b.Graffiti == nil {
b.Graffiti = make([]byte, 32)
}
if b.Eth1Data == nil {
b.Eth1Data = &v1.Eth1Data{
DepositRoot: make([]byte, fieldparams.RootLength),
BlockHash: make([]byte, 32),
}
}
if b.SyncAggregate == nil {
b.SyncAggregate = &v1.SyncAggregate{
SyncCommitteeBits: make([]byte, fieldparams.SyncAggregateSyncCommitteeBytesLength),
SyncCommitteeSignature: make([]byte, fieldparams.BLSSignatureLength),
}
}
if b.ExecutionPayloadHeader == nil {
b.ExecutionPayloadHeader = &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: make([]byte, 32),
FeeRecipient: make([]byte, 20),
StateRoot: make([]byte, fieldparams.RootLength),
ReceiptsRoot: make([]byte, fieldparams.RootLength),
LogsBloom: make([]byte, 256),
PrevRandao: make([]byte, 32),
BaseFeePerGas: make([]byte, 32),
BlockHash: make([]byte, 32),
TransactionsRoot: make([]byte, fieldparams.RootLength),
ExtraData: make([]byte, 0),
WithdrawalsRoot: make([]byte, fieldparams.RootLength),
}
}
return b
}

View File

@ -53,29 +53,56 @@ func NewBlindedBeaconBlockCapellaV2() *v2.SignedBlindedBeaconBlockCapella {
return HydrateV2SignedBlindedBeaconBlockCapella(&v2.SignedBlindedBeaconBlockCapella{})
}
// NewBeaconBlockAndBlobsDeneb creates a beacon block content including blobs with minimum marshalable fields.
func NewBeaconBlockAndBlobsDeneb(numOfBlobs uint64) (*ethpb.SignedBeaconBlockAndBlobsDeneb, error) {
// NewBeaconBlockContentsDeneb creates a beacon block content including blobs with minimum marshalable fields.
func NewBeaconBlockContentsDeneb(numOfBlobs uint64) (*v2.SignedBeaconBlockContentsDeneb, error) {
if numOfBlobs > fieldparams.MaxBlobsPerBlock {
return nil, fmt.Errorf("declared too many blobs: %v", numOfBlobs)
}
blobs := make([]*ethpb.SignedBlobSidecar, numOfBlobs)
blobs := make([]*v2.SignedBlobSidecar, numOfBlobs)
for i := range blobs {
blobs[i] = &ethpb.SignedBlobSidecar{
Message: &ethpb.BlobSidecar{
blobs[i] = &v2.SignedBlobSidecar{
Message: &v2.BlobSidecar{
BlockRoot: make([]byte, fieldparams.RootLength),
Index: 0,
Slot: 0,
BlockParentRoot: make([]byte, fieldparams.RootLength),
ProposerIndex: 0,
Blob: make([]byte, fieldparams.BlobLength),
KzgCommitment: make([]byte, 48),
KzgProof: make([]byte, 48),
KzgCommitment: make([]byte, fieldparams.BLSPubkeyLength),
KzgProof: make([]byte, fieldparams.BLSPubkeyLength),
},
Signature: make([]byte, fieldparams.BLSSignatureLength),
}
}
return &ethpb.SignedBeaconBlockAndBlobsDeneb{
Block: HydrateSignedBeaconBlockDeneb(&ethpb.SignedBeaconBlockDeneb{}),
Blobs: blobs,
return &v2.SignedBeaconBlockContentsDeneb{
SignedBlock: HydrateV2SignedBeaconBlockDeneb(&v2.SignedBeaconBlockDeneb{}),
SignedBlobSidecars: blobs,
}, nil
}
// NewBlindedBeaconBlockContentsDeneb creates a blinded beacon block content including blobs with minimum marshalable fields.
func NewBlindedBeaconBlockContentsDeneb(numOfBlobs uint64) (*v2.SignedBlindedBeaconBlockContentsDeneb, error) {
if numOfBlobs > fieldparams.MaxBlobsPerBlock {
return nil, fmt.Errorf("declared too many blobs: %v", numOfBlobs)
}
blobs := make([]*v2.SignedBlindedBlobSidecar, numOfBlobs)
for i := range blobs {
blobs[i] = &v2.SignedBlindedBlobSidecar{
Message: &v2.BlindedBlobSidecar{
BlockRoot: make([]byte, fieldparams.RootLength),
Index: 0,
Slot: 0,
BlockParentRoot: make([]byte, fieldparams.RootLength),
ProposerIndex: 0,
BlobRoot: make([]byte, fieldparams.RootLength),
KzgCommitment: make([]byte, fieldparams.BLSPubkeyLength),
KzgProof: make([]byte, fieldparams.BLSPubkeyLength),
},
Signature: make([]byte, fieldparams.BLSSignatureLength),
}
}
return &v2.SignedBlindedBeaconBlockContentsDeneb{
SignedBlindedBlock: HydrateV2SignedBlindedBeaconBlockDeneb(&v2.SignedBlindedBeaconBlockDeneb{}),
SignedBlindedBlobSidecars: blobs,
}, nil
}