Add deneb block to consensus types (#12368)

This commit is contained in:
terencechain
2023-05-08 16:47:46 -07:00
committed by Preston Van Loon
parent bd86c7c8f3
commit 8e91df9155
23 changed files with 3973 additions and 1106 deletions

View File

@@ -160,6 +160,11 @@ func (executionPayload) WithdrawalsRoot() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// ExcessDataGas --
func (e executionPayload) ExcessDataGas() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbBellatrix --
func (e executionPayload) PbBellatrix() (*enginev1.ExecutionPayload, error) {
return e.p, nil
@@ -321,7 +326,12 @@ func (executionPayloadHeader) WithdrawalsRoot() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbCapella --
// ExcessDataGas --
func (e executionPayloadHeader) ExcessDataGas() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbV2 --
func (executionPayloadHeader) PbCapella() (*enginev1.ExecutionPayloadCapella, error) {
return nil, consensus_types.ErrUnsupportedField
}
@@ -511,7 +521,12 @@ func (executionPayloadCapella) WithdrawalsRoot() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbCapella --
// ExcessDataGas returns error for executionPayloadCapella.
func (e executionPayloadCapella) ExcessDataGas() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbV2 --
func (e executionPayloadCapella) PbCapella() (*enginev1.ExecutionPayloadCapella, error) {
return e.p, nil
}
@@ -673,7 +688,12 @@ func (e executionPayloadHeaderCapella) WithdrawalsRoot() ([]byte, error) {
return e.p.WithdrawalsRoot, nil
}
// PbCapella --
// ExcessDataGas returns error for executionPayloadHeaderCapella.
func (e executionPayloadHeaderCapella) ExcessDataGas() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbV2 --
func (executionPayloadHeaderCapella) PbCapella() (*enginev1.ExecutionPayloadCapella, error) {
return nil, consensus_types.ErrUnsupportedField
}
@@ -726,6 +746,49 @@ func PayloadToHeaderCapella(payload interfaces.ExecutionData) (*enginev1.Executi
}, nil
}
// PayloadToHeaderDeneb converts `payload` into execution payload header format.
func PayloadToHeaderDeneb(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeaderDeneb, error) {
txs, err := payload.Transactions()
if err != nil {
return nil, err
}
txRoot, err := ssz.TransactionsRoot(txs)
if err != nil {
return nil, err
}
withdrawals, err := payload.Withdrawals()
if err != nil {
return nil, err
}
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload)
if err != nil {
return nil, err
}
excessDataGas, err := payload.ExcessDataGas()
if err != nil {
return nil, err
}
return &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash()),
FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient()),
StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot()),
ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot()),
LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom()),
PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao()),
BlockNumber: payload.BlockNumber(),
GasLimit: payload.GasLimit(),
GasUsed: payload.GasUsed(),
Timestamp: payload.Timestamp(),
ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData()),
BaseFeePerGas: bytesutil.SafeCopyBytes(payload.BaseFeePerGas()),
BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash()),
TransactionsRoot: txRoot[:],
WithdrawalsRoot: withdrawalsRoot[:],
ExcessDataGas: bytesutil.SafeCopyBytes(excessDataGas),
}, nil
}
// IsEmptyExecutionData checks if an execution data is empty underneath. If a single field has
// a non-zero value, this function will return false.
func IsEmptyExecutionData(data interfaces.ExecutionData) (bool, error) {
@@ -782,3 +845,333 @@ func IsEmptyExecutionData(data interfaces.ExecutionData) (bool, error) {
}
return true, nil
}
// executionPayloadHeaderDeneb is a convenience wrapper around a blinded beacon block body's execution header data structure.
// This wrapper allows us to conform to a common interface so that beacon
// blocks for future forks can also be applied across Prysm without issues.
type executionPayloadHeaderDeneb struct {
p *enginev1.ExecutionPayloadHeaderDeneb
value uint64
}
// WrappedExecutionPayloadHeaderDeneb is a constructor which wraps a protobuf execution header into an interface.
func WrappedExecutionPayloadHeaderDeneb(p *enginev1.ExecutionPayloadHeaderDeneb, value uint64) (interfaces.ExecutionData, error) {
w := executionPayloadHeaderDeneb{p: p, value: value}
if w.IsNil() {
return nil, consensus_types.ErrNilObjectWrapped
}
return w, nil
}
// IsNil checks if the underlying data is nil.
func (e executionPayloadHeaderDeneb) IsNil() bool {
return e.p == nil
}
// MarshalSSZ --
func (e executionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) {
return e.p.MarshalSSZ()
}
// MarshalSSZTo --
func (e executionPayloadHeaderDeneb) MarshalSSZTo(dst []byte) ([]byte, error) {
return e.p.MarshalSSZTo(dst)
}
// SizeSSZ --
func (e executionPayloadHeaderDeneb) SizeSSZ() int {
return e.p.SizeSSZ()
}
// UnmarshalSSZ --
func (e executionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error {
return e.p.UnmarshalSSZ(buf)
}
// HashTreeRoot --
func (e executionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) {
return e.p.HashTreeRoot()
}
// HashTreeRootWith --
func (e executionPayloadHeaderDeneb) HashTreeRootWith(hh *fastssz.Hasher) error {
return e.p.HashTreeRootWith(hh)
}
// Proto --
func (e executionPayloadHeaderDeneb) Proto() proto.Message {
return e.p
}
// ParentHash --
func (e executionPayloadHeaderDeneb) ParentHash() []byte {
return e.p.ParentHash
}
// FeeRecipient --
func (e executionPayloadHeaderDeneb) FeeRecipient() []byte {
return e.p.FeeRecipient
}
// StateRoot --
func (e executionPayloadHeaderDeneb) StateRoot() []byte {
return e.p.StateRoot
}
// ReceiptsRoot --
func (e executionPayloadHeaderDeneb) ReceiptsRoot() []byte {
return e.p.ReceiptsRoot
}
// LogsBloom --
func (e executionPayloadHeaderDeneb) LogsBloom() []byte {
return e.p.LogsBloom
}
// PrevRandao --
func (e executionPayloadHeaderDeneb) PrevRandao() []byte {
return e.p.PrevRandao
}
// BlockNumber --
func (e executionPayloadHeaderDeneb) BlockNumber() uint64 {
return e.p.BlockNumber
}
// GasLimit --
func (e executionPayloadHeaderDeneb) GasLimit() uint64 {
return e.p.GasLimit
}
// GasUsed --
func (e executionPayloadHeaderDeneb) GasUsed() uint64 {
return e.p.GasUsed
}
// Timestamp --
func (e executionPayloadHeaderDeneb) Timestamp() uint64 {
return e.p.Timestamp
}
// ExtraData --
func (e executionPayloadHeaderDeneb) ExtraData() []byte {
return e.p.ExtraData
}
// BaseFeePerGas --
func (e executionPayloadHeaderDeneb) BaseFeePerGas() []byte {
return e.p.BaseFeePerGas
}
// BlockHash --
func (e executionPayloadHeaderDeneb) BlockHash() []byte {
return e.p.BlockHash
}
// Transactions --
func (executionPayloadHeaderDeneb) Transactions() ([][]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// TransactionsRoot --
func (e executionPayloadHeaderDeneb) TransactionsRoot() ([]byte, error) {
return e.p.TransactionsRoot, nil
}
// Withdrawals --
func (e executionPayloadHeaderDeneb) Withdrawals() ([]*enginev1.Withdrawal, error) {
return nil, consensus_types.ErrUnsupportedField
}
// WitdrawalsRoot --
func (e executionPayloadHeaderDeneb) WithdrawalsRoot() ([]byte, error) {
return e.p.WithdrawalsRoot, nil
}
func (e executionPayloadHeaderDeneb) ExcessDataGas() ([]byte, error) {
return e.p.ExcessDataGas, nil
}
// PbBellatrix --
func (e executionPayloadHeaderDeneb) PbBellatrix() (*enginev1.ExecutionPayload, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbCapella --
func (e executionPayloadHeaderDeneb) PbCapella() (*enginev1.ExecutionPayloadCapella, error) {
return nil, consensus_types.ErrUnsupportedField
}
func (e executionPayloadHeaderDeneb) ValueInGwei() (uint64, error) {
return e.value, nil
}
// IsBlinded returns true if the underlying data is blinded.
func (e executionPayloadHeaderDeneb) IsBlinded() bool {
return true
}
// executionPayloadDeneb is a convenience wrapper around a beacon block body's execution payload data structure
// This wrapper allows us to conform to a common interface so that beacon
// blocks for future forks can also be applied across Prysm without issues.
type executionPayloadDeneb struct {
p *enginev1.ExecutionPayloadDeneb
value uint64
}
// WrappedExecutionPayloadDeneb is a constructor which wraps a protobuf execution payload into an interface.
func WrappedExecutionPayloadDeneb(p *enginev1.ExecutionPayloadDeneb, value uint64) (interfaces.ExecutionData, error) {
w := executionPayloadDeneb{p: p, value: value}
if w.IsNil() {
return nil, consensus_types.ErrNilObjectWrapped
}
return w, nil
}
// IsNil checks if the underlying data is nil.
func (e executionPayloadDeneb) IsNil() bool {
return e.p == nil
}
// MarshalSSZ --
func (e executionPayloadDeneb) MarshalSSZ() ([]byte, error) {
return e.p.MarshalSSZ()
}
// MarshalSSZTo --
func (e executionPayloadDeneb) MarshalSSZTo(dst []byte) ([]byte, error) {
return e.p.MarshalSSZTo(dst)
}
// SizeSSZ --
func (e executionPayloadDeneb) SizeSSZ() int {
return e.p.SizeSSZ()
}
// UnmarshalSSZ --
func (e executionPayloadDeneb) UnmarshalSSZ(buf []byte) error {
return e.p.UnmarshalSSZ(buf)
}
// HashTreeRoot --
func (e executionPayloadDeneb) HashTreeRoot() ([32]byte, error) {
return e.p.HashTreeRoot()
}
// HashTreeRootWith --
func (e executionPayloadDeneb) HashTreeRootWith(hh *fastssz.Hasher) error {
return e.p.HashTreeRootWith(hh)
}
// Proto --
func (e executionPayloadDeneb) Proto() proto.Message {
return e.p
}
// ParentHash --
func (e executionPayloadDeneb) ParentHash() []byte {
return e.p.ParentHash
}
// FeeRecipient --
func (e executionPayloadDeneb) FeeRecipient() []byte {
return e.p.FeeRecipient
}
// StateRoot --
func (e executionPayloadDeneb) StateRoot() []byte {
return e.p.StateRoot
}
// ReceiptsRoot --
func (e executionPayloadDeneb) ReceiptsRoot() []byte {
return e.p.ReceiptsRoot
}
// LogsBloom --
func (e executionPayloadDeneb) LogsBloom() []byte {
return e.p.LogsBloom
}
// PrevRandao --
func (e executionPayloadDeneb) PrevRandao() []byte {
return e.p.PrevRandao
}
// BlockNumber --
func (e executionPayloadDeneb) BlockNumber() uint64 {
return e.p.BlockNumber
}
// GasLimit --
func (e executionPayloadDeneb) GasLimit() uint64 {
return e.p.GasLimit
}
// GasUsed --
func (e executionPayloadDeneb) GasUsed() uint64 {
return e.p.GasUsed
}
// Timestamp --
func (e executionPayloadDeneb) Timestamp() uint64 {
return e.p.Timestamp
}
// ExtraData --
func (e executionPayloadDeneb) ExtraData() []byte {
return e.p.ExtraData
}
// BaseFeePerGas --
func (e executionPayloadDeneb) BaseFeePerGas() []byte {
return e.p.BaseFeePerGas
}
// BlockHash --
func (e executionPayloadDeneb) BlockHash() []byte {
return e.p.BlockHash
}
// Transactions --
func (e executionPayloadDeneb) Transactions() ([][]byte, error) {
return e.p.Transactions, nil
}
// TransactionsRoot --
func (e executionPayloadDeneb) TransactionsRoot() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
// Withdrawals --
func (e executionPayloadDeneb) Withdrawals() ([]*enginev1.Withdrawal, error) {
return e.p.Withdrawals, nil
}
// WithdrawalsRoot --
func (e executionPayloadDeneb) WithdrawalsRoot() ([]byte, error) {
return nil, consensus_types.ErrUnsupportedField
}
func (e executionPayloadDeneb) ExcessDataGas() ([]byte, error) {
return e.p.ExcessDataGas, nil
}
// PbBellatrix --
func (e executionPayloadDeneb) PbBellatrix() (*enginev1.ExecutionPayload, error) {
return nil, consensus_types.ErrUnsupportedField
}
// PbCapella --
func (e executionPayloadDeneb) PbCapella() (*enginev1.ExecutionPayloadCapella, error) {
return nil, consensus_types.ErrUnsupportedField
}
func (e executionPayloadDeneb) ValueInGwei() (uint64, error) {
return e.value, nil
}
// IsBlinded returns true if the underlying data is blinded.
func (e executionPayloadDeneb) IsBlinded() bool {
return false
}

View File

@@ -242,6 +242,104 @@ func Test_executionPayloadHeaderCapella_Pb(t *testing.T) {
require.ErrorIs(t, err, consensus_types.ErrUnsupportedField)
}
func TestWrapExecutionPayloadDeneb(t *testing.T) {
data := &enginev1.ExecutionPayloadDeneb{
ParentHash: []byte("parenthash"),
FeeRecipient: []byte("feerecipient"),
StateRoot: []byte("stateroot"),
ReceiptsRoot: []byte("receiptsroot"),
LogsBloom: []byte("logsbloom"),
PrevRandao: []byte("prevrandao"),
BlockNumber: 11,
GasLimit: 22,
GasUsed: 33,
Timestamp: 44,
ExtraData: []byte("extradata"),
BaseFeePerGas: []byte("basefeepergas"),
BlockHash: []byte("blockhash"),
Transactions: [][]byte{[]byte("transaction")},
Withdrawals: []*enginev1.Withdrawal{{
Index: 55,
ValidatorIndex: 66,
Address: []byte("executionaddress"),
Amount: 77,
}},
ExcessDataGas: []byte("excessdatagas"),
}
payload, err := blocks.WrappedExecutionPayloadDeneb(data, 420)
require.NoError(t, err)
v, err := payload.ValueInGwei()
require.NoError(t, err)
assert.Equal(t, uint64(420), v)
g, err := payload.ExcessDataGas()
require.NoError(t, err)
require.DeepEqual(t, []byte("excessdatagas"), g)
}
func TestWrapExecutionPayloadHeaderDeneb(t *testing.T) {
data := &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: []byte("parenthash"),
FeeRecipient: []byte("feerecipient"),
StateRoot: []byte("stateroot"),
ReceiptsRoot: []byte("receiptsroot"),
LogsBloom: []byte("logsbloom"),
PrevRandao: []byte("prevrandao"),
BlockNumber: 11,
GasLimit: 22,
GasUsed: 33,
Timestamp: 44,
ExtraData: []byte("extradata"),
BaseFeePerGas: []byte("basefeepergas"),
BlockHash: []byte("blockhash"),
TransactionsRoot: []byte("transactionsroot"),
WithdrawalsRoot: []byte("withdrawalsroot"),
ExcessDataGas: []byte("excessdatagas"),
}
payload, err := blocks.WrappedExecutionPayloadHeaderDeneb(data, 10)
require.NoError(t, err)
v, err := payload.ValueInGwei()
require.NoError(t, err)
assert.Equal(t, uint64(10), v)
g, err := payload.ExcessDataGas()
require.NoError(t, err)
require.DeepEqual(t, []byte("excessdatagas"), g)
}
func TestWrapExecutionPayloadDeneb_SSZ(t *testing.T) {
payload := createWrappedPayloadDeneb(t)
rt, err := payload.HashTreeRoot()
assert.NoError(t, err)
assert.NotEmpty(t, rt)
var b []byte
b, err = payload.MarshalSSZTo(b)
assert.NoError(t, err)
assert.NotEqual(t, 0, len(b))
encoded, err := payload.MarshalSSZ()
require.NoError(t, err)
assert.NotEqual(t, 0, payload.SizeSSZ())
assert.NoError(t, payload.UnmarshalSSZ(encoded))
}
func TestWrapExecutionPayloadHeaderDeneb_SSZ(t *testing.T) {
payload := createWrappedPayloadHeaderDeneb(t)
rt, err := payload.HashTreeRoot()
assert.NoError(t, err)
assert.NotEmpty(t, rt)
var b []byte
b, err = payload.MarshalSSZTo(b)
assert.NoError(t, err)
assert.NotEqual(t, 0, len(b))
encoded, err := payload.MarshalSSZ()
require.NoError(t, err)
assert.NotEqual(t, 0, payload.SizeSSZ())
assert.NoError(t, payload.UnmarshalSSZ(encoded))
}
func createWrappedPayload(t testing.TB) interfaces.ExecutionData {
wsb, err := blocks.WrappedExecutionPayload(&enginev1.ExecutionPayload{
ParentHash: make([]byte, fieldparams.RootLength),
@@ -327,3 +425,49 @@ func createWrappedPayloadHeaderCapella(t testing.TB) interfaces.ExecutionData {
require.NoError(t, err)
return payload
}
func createWrappedPayloadDeneb(t testing.TB) interfaces.ExecutionData {
payload, err := blocks.WrappedExecutionPayloadDeneb(&enginev1.ExecutionPayloadDeneb{
ParentHash: make([]byte, fieldparams.RootLength),
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
StateRoot: make([]byte, fieldparams.RootLength),
ReceiptsRoot: make([]byte, fieldparams.RootLength),
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
PrevRandao: make([]byte, fieldparams.RootLength),
BlockNumber: 0,
GasLimit: 0,
GasUsed: 0,
Timestamp: 0,
ExtraData: make([]byte, 0),
BaseFeePerGas: make([]byte, fieldparams.RootLength),
BlockHash: make([]byte, fieldparams.RootLength),
Transactions: make([][]byte, 0),
Withdrawals: make([]*enginev1.Withdrawal, 0),
ExcessDataGas: make([]byte, fieldparams.RootLength),
}, 0)
require.NoError(t, err)
return payload
}
func createWrappedPayloadHeaderDeneb(t testing.TB) interfaces.ExecutionData {
payload, err := blocks.WrappedExecutionPayloadHeaderDeneb(&enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: make([]byte, fieldparams.RootLength),
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
StateRoot: make([]byte, fieldparams.RootLength),
ReceiptsRoot: make([]byte, fieldparams.RootLength),
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
PrevRandao: make([]byte, fieldparams.RootLength),
BlockNumber: 0,
GasLimit: 0,
GasUsed: 0,
Timestamp: 0,
ExtraData: make([]byte, 0),
BaseFeePerGas: make([]byte, fieldparams.RootLength),
BlockHash: make([]byte, fieldparams.RootLength),
TransactionsRoot: make([]byte, fieldparams.RootLength),
WithdrawalsRoot: make([]byte, fieldparams.RootLength),
ExcessDataGas: make([]byte, fieldparams.RootLength),
}, 0)
require.NoError(t, err)
return payload
}

View File

@@ -56,6 +56,14 @@ func NewSignedBeaconBlock(i interface{}) (interfaces.SignedBeaconBlock, error) {
return initBlindedSignedBlockFromProtoCapella(b.BlindedCapella)
case *eth.SignedBlindedBeaconBlockCapella:
return initBlindedSignedBlockFromProtoCapella(b)
case *eth.GenericSignedBeaconBlock_Deneb:
return initSignedBlockFromProtoDeneb(b.Deneb.Block)
case *eth.SignedBeaconBlockDeneb:
return initSignedBlockFromProtoDeneb(b)
case *eth.SignedBlindedBeaconBlockDeneb:
return initBlindedSignedBlockFromProtoDeneb(b)
case *eth.GenericSignedBeaconBlock_Blinded_Deneb:
return initBlindedSignedBlockFromProtoDeneb(b.Blinded_Deneb.Block)
default:
return nil, errors.Wrapf(ErrUnsupportedSignedBeaconBlock, "unable to create block from type %T", i)
}
@@ -90,6 +98,14 @@ func NewBeaconBlock(i interface{}) (interfaces.ReadOnlyBeaconBlock, error) {
return initBlindedBlockFromProtoCapella(b.BlindedCapella)
case *eth.BlindedBeaconBlockCapella:
return initBlindedBlockFromProtoCapella(b)
case *eth.GenericBeaconBlock_Deneb:
return initBlockFromProtoDeneb(b.Deneb.Block)
case *eth.BeaconBlockDeneb:
return initBlockFromProtoDeneb(b)
case *eth.BlindedBeaconBlockDeneb:
return initBlindedBlockFromProtoDeneb(b)
case *eth.GenericBeaconBlock_Blinded_Deneb:
return initBlindedBlockFromProtoDeneb(b.Blinded_Deneb.Block)
default:
return nil, errors.Wrapf(errUnsupportedBeaconBlock, "unable to create block from type %T", i)
}
@@ -112,6 +128,10 @@ func NewBeaconBlockBody(i interface{}) (interfaces.ReadOnlyBeaconBlockBody, erro
return initBlockBodyFromProtoCapella(b)
case *eth.BlindedBeaconBlockBodyCapella:
return initBlindedBlockBodyFromProtoCapella(b)
case *eth.BeaconBlockBodyDeneb:
return initBlockBodyFromProtoDeneb(b)
case *eth.BlindedBeaconBlockBodyDeneb:
return initBlindedBlockBodyFromProtoDeneb(b)
default:
return nil, errors.Wrapf(errUnsupportedBeaconBlockBody, "unable to create block body from type %T", i)
}
@@ -165,6 +185,19 @@ func BuildSignedBeaconBlock(blk interfaces.ReadOnlyBeaconBlock, signature []byte
return nil, errIncorrectBlockVersion
}
return NewSignedBeaconBlock(&eth.SignedBeaconBlockCapella{Block: pb, Signature: signature})
case version.Deneb:
if blk.IsBlinded() {
pb, ok := pb.(*eth.BlindedBeaconBlockDeneb)
if !ok {
return nil, errIncorrectBlockVersion
}
return NewSignedBeaconBlock(&eth.SignedBlindedBeaconBlockDeneb{Block: pb, Signature: signature})
}
pb, ok := pb.(*eth.BeaconBlockDeneb)
if !ok {
return nil, errIncorrectBlockVersion
}
return NewSignedBeaconBlock(&eth.SignedBeaconBlockDeneb{Block: pb, Signature: signature})
default:
return nil, errUnsupportedBeaconBlock
}
@@ -194,6 +227,8 @@ func BuildSignedBeaconBlockFromExecutionPayload(
wrappedPayload, wrapErr = WrappedExecutionPayload(p)
case *enginev1.ExecutionPayloadCapella:
wrappedPayload, wrapErr = WrappedExecutionPayloadCapella(p, 0)
case *enginev1.ExecutionPayloadDeneb:
wrappedPayload, wrapErr = WrappedExecutionPayloadDeneb(p, 0)
default:
return nil, fmt.Errorf("%T is not a type of execution payload", p)
}
@@ -282,6 +317,38 @@ func BuildSignedBeaconBlockFromExecutionPayload(
},
Signature: sig[:],
}
case *enginev1.ExecutionPayloadDeneb:
blsToExecutionChanges, err := b.Body().BLSToExecutionChanges()
if err != nil {
return nil, err
}
commitments, err := b.Body().BlobKzgCommitments()
if err != nil {
return nil, err
}
fullBlock = &eth.SignedBeaconBlockDeneb{
Block: &eth.BeaconBlockDeneb{
Slot: b.Slot(),
ProposerIndex: b.ProposerIndex(),
ParentRoot: parentRoot[:],
StateRoot: stateRoot[:],
Body: &eth.BeaconBlockBodyDeneb{
RandaoReveal: randaoReveal[:],
Eth1Data: b.Body().Eth1Data(),
Graffiti: graffiti[:],
ProposerSlashings: b.Body().ProposerSlashings(),
AttesterSlashings: b.Body().AttesterSlashings(),
Attestations: b.Body().Attestations(),
Deposits: b.Body().Deposits(),
VoluntaryExits: b.Body().VoluntaryExits(),
SyncAggregate: syncAgg,
ExecutionPayload: p,
BlsToExecutionChanges: blsToExecutionChanges,
BlobKzgCommitments: commitments,
},
},
Signature: sig[:],
}
default:
return nil, fmt.Errorf("%T is not a type of execution payload", p)
}

View File

@@ -121,6 +121,46 @@ func Test_NewSignedBeaconBlock(t *testing.T) {
assert.Equal(t, version.Capella, b.Version())
assert.Equal(t, true, b.IsBlinded())
})
t.Run("GenericSignedBeaconBlock_Deneb", func(t *testing.T) {
pb := &eth.GenericSignedBeaconBlock_Deneb{
Deneb: &eth.SignedBeaconBlockAndBlobsDeneb{
Block: &eth.SignedBeaconBlockDeneb{
Block: &eth.BeaconBlockDeneb{
Body: &eth.BeaconBlockBodyDeneb{},
}}}}
b, err := NewSignedBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
})
t.Run("SignedBeaconBlockDeneb", func(t *testing.T) {
pb := &eth.SignedBeaconBlockDeneb{
Block: &eth.BeaconBlockDeneb{
Body: &eth.BeaconBlockBodyDeneb{}}}
b, err := NewSignedBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
})
t.Run("SignedBlindedBeaconBlockDeneb", func(t *testing.T) {
pb := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Body: &eth.BlindedBeaconBlockBodyDeneb{}}}
b, err := NewSignedBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
assert.Equal(t, true, b.IsBlinded())
})
t.Run("GenericSignedBeaconBlock_BlindedDeneb", func(t *testing.T) {
pb := &eth.GenericSignedBeaconBlock_Blinded_Deneb{
Blinded_Deneb: &eth.SignedBlindedBeaconBlockDenebAndBlobs{
Block: &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Body: &eth.BlindedBeaconBlockBodyDeneb{},
}}}}
b, err := NewSignedBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
assert.Equal(t, true, b.IsBlinded())
})
t.Run("nil", func(t *testing.T) {
_, err := NewSignedBeaconBlock(nil)
assert.ErrorContains(t, "received nil object", err)
@@ -208,6 +248,34 @@ func Test_NewBeaconBlock(t *testing.T) {
assert.Equal(t, version.Capella, b.Version())
assert.Equal(t, true, b.IsBlinded())
})
t.Run("GenericBeaconBlock_Deneb", func(t *testing.T) {
pb := &eth.GenericBeaconBlock_Deneb{Deneb: &eth.BeaconBlockDenebAndBlobs{Block: &eth.BeaconBlockDeneb{
Body: &eth.BeaconBlockBodyDeneb{},
}}}
b, err := NewBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
})
t.Run("BeaconBlockDeneb", func(t *testing.T) {
pb := &eth.BeaconBlockDeneb{Body: &eth.BeaconBlockBodyDeneb{}}
b, err := NewBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
})
t.Run("BlindedBeaconBlockDeneb", func(t *testing.T) {
pb := &eth.BlindedBeaconBlockDeneb{Body: &eth.BlindedBeaconBlockBodyDeneb{}}
b, err := NewBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
assert.Equal(t, true, b.IsBlinded())
})
t.Run("GenericBeaconBlock_BlindedDeneb", func(t *testing.T) {
pb := &eth.GenericBeaconBlock_Blinded_Deneb{Blinded_Deneb: &eth.BlindedBeaconBlockDenebAndBlobs{Block: &eth.BlindedBeaconBlockDeneb{Body: &eth.BlindedBeaconBlockBodyDeneb{}}}}
b, err := NewBeaconBlock(pb)
require.NoError(t, err)
assert.Equal(t, version.Deneb, b.Version())
assert.Equal(t, true, b.IsBlinded())
})
t.Run("nil", func(t *testing.T) {
_, err := NewBeaconBlock(nil)
assert.ErrorContains(t, "received nil object", err)
@@ -269,6 +337,23 @@ func Test_NewBeaconBlockBody(t *testing.T) {
assert.Equal(t, version.Capella, b.version)
assert.Equal(t, true, b.isBlinded)
})
t.Run("BeaconBlockBodyDeneb", func(t *testing.T) {
pb := &eth.BeaconBlockBodyDeneb{}
i, err := NewBeaconBlockBody(pb)
require.NoError(t, err)
b, ok := i.(*BeaconBlockBody)
require.Equal(t, true, ok)
assert.Equal(t, version.Deneb, b.version)
})
t.Run("BlindedBeaconBlockBodyDeneb", func(t *testing.T) {
pb := &eth.BlindedBeaconBlockBodyDeneb{}
i, err := NewBeaconBlockBody(pb)
require.NoError(t, err)
b, ok := i.(*BeaconBlockBody)
require.Equal(t, true, ok)
assert.Equal(t, version.Deneb, b.version)
assert.Equal(t, true, b.isBlinded)
})
t.Run("nil", func(t *testing.T) {
_, err := NewBeaconBlockBody(nil)
assert.ErrorContains(t, "received nil object", err)
@@ -325,6 +410,21 @@ func Test_BuildSignedBeaconBlock(t *testing.T) {
assert.Equal(t, version.Capella, sb.Version())
assert.Equal(t, true, sb.IsBlinded())
})
t.Run("Deneb", func(t *testing.T) {
b := &BeaconBlock{version: version.Deneb, body: &BeaconBlockBody{version: version.Deneb}}
sb, err := BuildSignedBeaconBlock(b, sig[:])
require.NoError(t, err)
assert.DeepEqual(t, sig, sb.Signature())
assert.Equal(t, version.Deneb, sb.Version())
})
t.Run("DenebBlind", func(t *testing.T) {
b := &BeaconBlock{version: version.Deneb, body: &BeaconBlockBody{version: version.Deneb, isBlinded: true}}
sb, err := BuildSignedBeaconBlock(b, sig[:])
require.NoError(t, err)
assert.DeepEqual(t, sig, sb.Signature())
assert.Equal(t, version.Deneb, sb.Version())
assert.Equal(t, true, sb.IsBlinded())
})
}
func TestBuildSignedBeaconBlockFromExecutionPayload(t *testing.T) {
@@ -401,4 +501,36 @@ func TestBuildSignedBeaconBlockFromExecutionPayload(t *testing.T) {
require.NoError(t, err)
require.DeepEqual(t, payload, got.Proto())
})
t.Run("deneb", func(t *testing.T) {
payload := &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),
ExcessDataGas: bytesutil.PadTo([]byte{123}, 32),
}
wrapped, err := WrappedExecutionPayloadDeneb(payload, 123)
require.NoError(t, err)
header, err := PayloadToHeaderDeneb(wrapped)
require.NoError(t, err)
blindedBlock := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Body: &eth.BlindedBeaconBlockBodyDeneb{}}}
blindedBlock.Block.Body.ExecutionPayloadHeader = header
blk, err := NewSignedBeaconBlock(blindedBlock)
require.NoError(t, err)
builtBlock, err := BuildSignedBeaconBlockFromExecutionPayload(blk, payload)
require.NoError(t, err)
got, err := builtBlock.Block().Body().Execution()
require.NoError(t, err)
require.DeepEqual(t, payload, got.Proto())
require.DeepEqual(t, bytesutil.PadTo([]byte{123}, 32), payload.ExcessDataGas)
})
}

View File

@@ -71,6 +71,13 @@ func (b *SignedBeaconBlock) Copy() (interfaces.ReadOnlySignedBeaconBlock, error)
}
cp := eth.CopySignedBeaconBlockCapella(pb.(*eth.SignedBeaconBlockCapella))
return initSignedBlockFromProtoCapella(cp)
case version.Deneb:
if b.IsBlinded() {
cp := eth.CopySignedBlindedBeaconBlockDeneb(pb.(*eth.SignedBlindedBeaconBlockDeneb))
return initBlindedSignedBlockFromProtoDeneb(cp)
}
cp := eth.CopySignedBeaconBlockDeneb(pb.(*eth.SignedBeaconBlockDeneb))
return initSignedBlockFromProtoDeneb(cp)
default:
return nil, errIncorrectBlockVersion
}
@@ -186,6 +193,30 @@ func (b *SignedBeaconBlock) PbBlindedCapellaBlock() (*eth.SignedBlindedBeaconBlo
return pb.(*eth.SignedBlindedBeaconBlockCapella), nil
}
// PbDenebBlock returns the underlying protobuf object.
func (b *SignedBeaconBlock) PbDenebBlock() (*eth.SignedBeaconBlockDeneb, error) {
if b.version != version.Deneb || b.IsBlinded() {
return nil, consensus_types.ErrNotSupported("PbDenebBlock", b.version)
}
pb, err := b.Proto()
if err != nil {
return nil, err
}
return pb.(*eth.SignedBeaconBlockDeneb), nil
}
// PbBlindedDenebBlock returns the underlying protobuf object.
func (b *SignedBeaconBlock) PbBlindedDenebBlock() (*eth.SignedBlindedBeaconBlockDeneb, error) {
if b.version != version.Deneb || !b.IsBlinded() {
return nil, consensus_types.ErrNotSupported("PbBlindedDenebBlock", b.version)
}
pb, err := b.Proto()
if err != nil {
return nil, err
}
return pb.(*eth.SignedBlindedBeaconBlockDeneb), nil
}
// ToBlinded converts a non-blinded block to its blinded equivalent.
func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, error) {
if b.version < version.Bellatrix {
@@ -258,6 +289,35 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
},
Signature: b.signature[:],
})
case *enginev1.ExecutionPayloadDeneb:
header, err := PayloadToHeaderDeneb(payload)
if err != nil {
return nil, err
}
return initBlindedSignedBlockFromProtoDeneb(
&eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Slot: b.block.slot,
ProposerIndex: b.block.proposerIndex,
ParentRoot: b.block.parentRoot[:],
StateRoot: b.block.stateRoot[:],
Body: &eth.BlindedBeaconBlockBodyDeneb{
RandaoReveal: b.block.body.randaoReveal[:],
Eth1Data: b.block.body.eth1Data,
Graffiti: b.block.body.graffiti[:],
ProposerSlashings: b.block.body.proposerSlashings,
AttesterSlashings: b.block.body.attesterSlashings,
Attestations: b.block.body.attestations,
Deposits: b.block.body.deposits,
VoluntaryExits: b.block.body.voluntaryExits,
SyncAggregate: b.block.body.syncAggregate,
ExecutionPayloadHeader: header,
BlsToExecutionChanges: b.block.body.blsToExecutionChanges,
BlobKzgCommitments: b.block.body.blobKzgCommitments,
},
},
Signature: b.signature[:],
})
default:
return nil, fmt.Errorf("%T is not an execution payload header", p)
}
@@ -315,6 +375,11 @@ func (b *SignedBeaconBlock) MarshalSSZ() ([]byte, error) {
return pb.(*eth.SignedBlindedBeaconBlockCapella).MarshalSSZ()
}
return pb.(*eth.SignedBeaconBlockCapella).MarshalSSZ()
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.SignedBlindedBeaconBlockDeneb).MarshalSSZ()
}
return pb.(*eth.SignedBeaconBlockDeneb).MarshalSSZ()
default:
return []byte{}, errIncorrectBlockVersion
}
@@ -342,6 +407,11 @@ func (b *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) {
return pb.(*eth.SignedBlindedBeaconBlockCapella).MarshalSSZTo(dst)
}
return pb.(*eth.SignedBeaconBlockCapella).MarshalSSZTo(dst)
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.SignedBlindedBeaconBlockDeneb).MarshalSSZTo(dst)
}
return pb.(*eth.SignedBeaconBlockDeneb).MarshalSSZTo(dst)
default:
return []byte{}, errIncorrectBlockVersion
}
@@ -373,6 +443,11 @@ func (b *SignedBeaconBlock) SizeSSZ() int {
return pb.(*eth.SignedBlindedBeaconBlockCapella).SizeSSZ()
}
return pb.(*eth.SignedBeaconBlockCapella).SizeSSZ()
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.SignedBlindedBeaconBlockDeneb).SizeSSZ()
}
return pb.(*eth.SignedBeaconBlockDeneb).SizeSSZ()
default:
panic(incorrectBlockVersion)
}
@@ -446,6 +521,28 @@ func (b *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error {
return err
}
}
case version.Deneb:
if b.IsBlinded() {
pb := &eth.SignedBlindedBeaconBlockDeneb{}
if err := pb.UnmarshalSSZ(buf); err != nil {
return err
}
var err error
newBlock, err = initBlindedSignedBlockFromProtoDeneb(pb)
if err != nil {
return err
}
} else {
pb := &eth.SignedBeaconBlockDeneb{}
if err := pb.UnmarshalSSZ(buf); err != nil {
return err
}
var err error
newBlock, err = initSignedBlockFromProtoDeneb(pb)
if err != nil {
return err
}
}
default:
return errIncorrectBlockVersion
}
@@ -514,6 +611,11 @@ func (b *BeaconBlock) HashTreeRoot() ([field_params.RootLength]byte, error) {
return pb.(*eth.BlindedBeaconBlockCapella).HashTreeRoot()
}
return pb.(*eth.BeaconBlockCapella).HashTreeRoot()
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockDeneb).HashTreeRoot()
}
return pb.(*eth.BeaconBlockDeneb).HashTreeRoot()
default:
return [field_params.RootLength]byte{}, errIncorrectBlockVersion
}
@@ -540,6 +642,11 @@ func (b *BeaconBlock) HashTreeRootWith(h *ssz.Hasher) error {
return pb.(*eth.BlindedBeaconBlockCapella).HashTreeRootWith(h)
}
return pb.(*eth.BeaconBlockCapella).HashTreeRootWith(h)
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockDeneb).HashTreeRootWith(h)
}
return pb.(*eth.BeaconBlockDeneb).HashTreeRootWith(h)
default:
return errIncorrectBlockVersion
}
@@ -567,6 +674,11 @@ func (b *BeaconBlock) MarshalSSZ() ([]byte, error) {
return pb.(*eth.BlindedBeaconBlockCapella).MarshalSSZ()
}
return pb.(*eth.BeaconBlockCapella).MarshalSSZ()
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockDeneb).MarshalSSZ()
}
return pb.(*eth.BeaconBlockDeneb).MarshalSSZ()
default:
return []byte{}, errIncorrectBlockVersion
}
@@ -594,6 +706,11 @@ func (b *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) {
return pb.(*eth.BlindedBeaconBlockCapella).MarshalSSZTo(dst)
}
return pb.(*eth.BeaconBlockCapella).MarshalSSZTo(dst)
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockDeneb).MarshalSSZTo(dst)
}
return pb.(*eth.BeaconBlockDeneb).MarshalSSZTo(dst)
default:
return []byte{}, errIncorrectBlockVersion
}
@@ -625,6 +742,11 @@ func (b *BeaconBlock) SizeSSZ() int {
return pb.(*eth.BlindedBeaconBlockCapella).SizeSSZ()
}
return pb.(*eth.BeaconBlockCapella).SizeSSZ()
case version.Deneb:
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockDeneb).SizeSSZ()
}
return pb.(*eth.BeaconBlockDeneb).SizeSSZ()
default:
panic(incorrectBodyVersion)
}
@@ -698,6 +820,28 @@ func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error {
return err
}
}
case version.Deneb:
if b.IsBlinded() {
pb := &eth.BlindedBeaconBlockDeneb{}
if err := pb.UnmarshalSSZ(buf); err != nil {
return err
}
var err error
newBlock, err = initBlindedBlockFromProtoDeneb(pb)
if err != nil {
return err
}
} else {
pb := &eth.BeaconBlockDeneb{}
if err := pb.UnmarshalSSZ(buf); err != nil {
return err
}
var err error
newBlock, err = initBlockFromProtoDeneb(pb)
if err != nil {
return err
}
}
default:
return errIncorrectBlockVersion
}
@@ -761,6 +905,13 @@ func (b *BeaconBlock) Copy() (interfaces.ReadOnlyBeaconBlock, error) {
}
cp := eth.CopyBeaconBlockCapella(pb.(*eth.BeaconBlockCapella))
return initBlockFromProtoCapella(cp)
case version.Deneb:
if b.IsBlinded() {
cp := eth.CopyBlindedBeaconBlockDeneb(pb.(*eth.BlindedBeaconBlockDeneb))
return initBlindedBlockFromProtoDeneb(cp)
}
cp := eth.CopyBeaconBlockDeneb(pb.(*eth.BeaconBlockDeneb))
return initBlockFromProtoDeneb(cp)
default:
return nil, errIncorrectBlockVersion
}
@@ -866,6 +1017,27 @@ func (b *BeaconBlockBody) Execution() (interfaces.ExecutionData, error) {
}
}
return WrappedExecutionPayloadCapella(p, 0)
case version.Deneb:
if b.isBlinded {
var ph *enginev1.ExecutionPayloadHeaderDeneb
var ok bool
if b.executionPayloadHeader != nil {
ph, ok = b.executionPayloadHeader.Proto().(*enginev1.ExecutionPayloadHeaderDeneb)
if !ok {
return nil, errPayloadHeaderWrongType
}
return WrappedExecutionPayloadHeaderDeneb(ph, 0)
}
}
var p *enginev1.ExecutionPayloadDeneb
var ok bool
if b.executionPayload != nil {
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayloadDeneb)
if !ok {
return nil, errPayloadWrongType
}
}
return WrappedExecutionPayloadDeneb(p, 0)
default:
return nil, errIncorrectBlockVersion
}
@@ -878,6 +1050,18 @@ func (b *BeaconBlockBody) BLSToExecutionChanges() ([]*eth.SignedBLSToExecutionCh
return b.blsToExecutionChanges, nil
}
// BlobKzgCommitments returns the blob kzg commitments in the block.
func (b *BeaconBlockBody) BlobKzgCommitments() ([][]byte, error) {
switch b.version {
case version.Phase0, version.Altair, version.Bellatrix, version.Capella:
return nil, consensus_types.ErrNotSupported("BlobKzgCommitments", b.version)
case version.Deneb:
return b.blobKzgCommitments, nil
default:
return nil, errIncorrectBlockVersion
}
}
// HashTreeRoot returns the ssz root of the block body.
func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error) {
pb, err := b.Proto()
@@ -899,6 +1083,11 @@ func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error)
return pb.(*eth.BlindedBeaconBlockBodyCapella).HashTreeRoot()
}
return pb.(*eth.BeaconBlockBodyCapella).HashTreeRoot()
case version.Deneb:
if b.isBlinded {
return pb.(*eth.BlindedBeaconBlockBodyDeneb).HashTreeRoot()
}
return pb.(*eth.BeaconBlockBodyDeneb).HashTreeRoot()
default:
return [field_params.RootLength]byte{}, errIncorrectBodyVersion
}

View File

@@ -212,6 +212,37 @@ func Test_BeaconBlock_Copy(t *testing.T) {
require.NoError(t, err)
assert.NotEqual(t, cp, b)
assert.NotEqual(t, cp.Body(), bb)
payload := &pb.ExecutionPayloadDeneb{ExcessDataGas: bytesutil.PadTo([]byte{123}, 32)}
header := &pb.ExecutionPayloadHeaderDeneb{ExcessDataGas: bytesutil.PadTo([]byte{223}, 32)}
payloadInterface, err := WrappedExecutionPayloadDeneb(payload, 123)
require.NoError(t, err)
headerInterface, err := WrappedExecutionPayloadHeaderDeneb(header, 123)
require.NoError(t, err)
bb = &BeaconBlockBody{executionPayload: payloadInterface, executionPayloadHeader: headerInterface, randaoReveal: bytesutil.ToBytes96([]byte{246}), graffiti: bytesutil.ToBytes32([]byte("graffiti"))}
b = &BeaconBlock{body: bb, slot: 123, proposerIndex: 456, parentRoot: bytesutil.ToBytes32([]byte("parentroot")), stateRoot: bytesutil.ToBytes32([]byte("stateroot"))}
b.version = version.Deneb
b.body.version = b.version
cp, err = b.Copy()
require.NoError(t, err)
assert.NotEqual(t, cp, b)
assert.NotEqual(t, cp.Body(), bb)
e, err := cp.Body().Execution()
require.NoError(t, err)
gas, err := e.ExcessDataGas()
require.NoError(t, err)
require.DeepEqual(t, gas, bytesutil.PadTo([]byte{123}, 32))
b.body.isBlinded = true
cp, err = b.Copy()
require.NoError(t, err)
assert.NotEqual(t, cp, b)
assert.NotEqual(t, cp.Body(), bb)
e, err = cp.Body().Execution()
require.NoError(t, err)
gas, err = e.ExcessDataGas()
require.NoError(t, err)
require.DeepEqual(t, gas, bytesutil.PadTo([]byte{223}, 32))
}
func Test_BeaconBlock_IsNil(t *testing.T) {
@@ -407,6 +438,30 @@ func Test_BeaconBlockBody_Execution(t *testing.T) {
result, err = bb.Block().Body().Execution()
require.NoError(t, err)
assert.DeepEqual(t, result, eCapellaHeader)
executionDeneb := &pb.ExecutionPayloadDeneb{BlockNumber: 1, ExcessDataGas: bytesutil.PadTo([]byte{123}, 32)}
eDeneb, err := WrappedExecutionPayloadDeneb(executionDeneb, 0)
require.NoError(t, err)
bb = &SignedBeaconBlock{version: version.Deneb, block: &BeaconBlock{body: &BeaconBlockBody{version: version.Deneb}}}
require.NoError(t, bb.SetExecution(eDeneb))
result, err = bb.Block().Body().Execution()
require.NoError(t, err)
assert.DeepEqual(t, result, eDeneb)
gas, err := eDeneb.ExcessDataGas()
require.NoError(t, err)
require.DeepEqual(t, gas, bytesutil.PadTo([]byte{123}, 32))
executionDenebHeader := &pb.ExecutionPayloadHeaderDeneb{BlockNumber: 1, ExcessDataGas: bytesutil.PadTo([]byte{223}, 32)}
eDenebHeader, err := WrappedExecutionPayloadHeaderDeneb(executionDenebHeader, 0)
require.NoError(t, err)
bb = &SignedBeaconBlock{version: version.Deneb, block: &BeaconBlock{version: version.Deneb, body: &BeaconBlockBody{version: version.Deneb, isBlinded: true}}}
require.NoError(t, bb.SetExecution(eDenebHeader))
result, err = bb.Block().Body().Execution()
require.NoError(t, err)
assert.DeepEqual(t, result, eDenebHeader)
gas, err = eDenebHeader.ExcessDataGas()
require.NoError(t, err)
require.DeepEqual(t, gas, bytesutil.PadTo([]byte{223}, 32))
}
func Test_BeaconBlockBody_HashTreeRoot(t *testing.T) {

View File

@@ -102,6 +102,33 @@ func (b *SignedBeaconBlock) Proto() (proto.Message, error) {
Block: block,
Signature: b.signature[:],
}, nil
case version.Deneb:
if b.IsBlinded() {
var block *eth.BlindedBeaconBlockDeneb
if blockMessage != nil {
var ok bool
block, ok = blockMessage.(*eth.BlindedBeaconBlockDeneb)
if !ok {
return nil, errIncorrectBlockVersion
}
}
return &eth.SignedBlindedBeaconBlockDeneb{
Block: block,
Signature: b.signature[:],
}, nil
}
var block *eth.BeaconBlockDeneb
if blockMessage != nil {
var ok bool
block, ok = blockMessage.(*eth.BeaconBlockDeneb)
if !ok {
return nil, errIncorrectBlockVersion
}
}
return &eth.SignedBeaconBlockDeneb{
Block: block,
Signature: b.signature[:],
}, nil
default:
return nil, errors.New("unsupported signed beacon block version")
}
@@ -217,6 +244,39 @@ func (b *BeaconBlock) Proto() (proto.Message, error) {
StateRoot: b.stateRoot[:],
Body: body,
}, nil
case version.Deneb:
if b.IsBlinded() {
var body *eth.BlindedBeaconBlockBodyDeneb
if bodyMessage != nil {
var ok bool
body, ok = bodyMessage.(*eth.BlindedBeaconBlockBodyDeneb)
if !ok {
return nil, errIncorrectBodyVersion
}
}
return &eth.BlindedBeaconBlockDeneb{
Slot: b.slot,
ProposerIndex: b.proposerIndex,
ParentRoot: b.parentRoot[:],
StateRoot: b.stateRoot[:],
Body: body,
}, nil
}
var body *eth.BeaconBlockBodyDeneb
if bodyMessage != nil {
var ok bool
body, ok = bodyMessage.(*eth.BeaconBlockBodyDeneb)
if !ok {
return nil, errIncorrectBodyVersion
}
}
return &eth.BeaconBlockDeneb{
Slot: b.slot,
ProposerIndex: b.proposerIndex,
ParentRoot: b.parentRoot[:],
StateRoot: b.stateRoot[:],
Body: body,
}, nil
default:
return nil, errors.New("unsupported beacon block version")
}
@@ -340,6 +400,53 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
ExecutionPayload: p,
BlsToExecutionChanges: b.blsToExecutionChanges,
}, nil
case version.Deneb:
if b.isBlinded {
var ph *enginev1.ExecutionPayloadHeaderDeneb
var ok bool
if b.executionPayloadHeader != nil {
ph, ok = b.executionPayloadHeader.Proto().(*enginev1.ExecutionPayloadHeaderDeneb)
if !ok {
return nil, errPayloadHeaderWrongType
}
}
return &eth.BlindedBeaconBlockBodyDeneb{
RandaoReveal: b.randaoReveal[:],
Eth1Data: b.eth1Data,
Graffiti: b.graffiti[:],
ProposerSlashings: b.proposerSlashings,
AttesterSlashings: b.attesterSlashings,
Attestations: b.attestations,
Deposits: b.deposits,
VoluntaryExits: b.voluntaryExits,
SyncAggregate: b.syncAggregate,
ExecutionPayloadHeader: ph,
BlsToExecutionChanges: b.blsToExecutionChanges,
BlobKzgCommitments: b.blobKzgCommitments,
}, nil
}
var p *enginev1.ExecutionPayloadDeneb
var ok bool
if b.executionPayload != nil {
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayloadDeneb)
if !ok {
return nil, errPayloadWrongType
}
}
return &eth.BeaconBlockBodyDeneb{
RandaoReveal: b.randaoReveal[:],
Eth1Data: b.eth1Data,
Graffiti: b.graffiti[:],
ProposerSlashings: b.proposerSlashings,
AttesterSlashings: b.attesterSlashings,
Attestations: b.attestations,
Deposits: b.deposits,
VoluntaryExits: b.voluntaryExits,
SyncAggregate: b.syncAggregate,
ExecutionPayload: p,
BlsToExecutionChanges: b.blsToExecutionChanges,
BlobKzgCommitments: b.blobKzgCommitments,
}, nil
default:
return nil, errors.New("unsupported beacon block body version")
}
@@ -413,6 +520,23 @@ func initSignedBlockFromProtoCapella(pb *eth.SignedBeaconBlockCapella) (*SignedB
return b, nil
}
func initSignedBlockFromProtoDeneb(pb *eth.SignedBeaconBlockDeneb) (*SignedBeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
}
block, err := initBlockFromProtoDeneb(pb.Block)
if err != nil {
return nil, err
}
b := &SignedBeaconBlock{
version: version.Deneb,
block: block,
signature: bytesutil.ToBytes96(pb.Signature),
}
return b, nil
}
func initBlindedSignedBlockFromProtoBellatrix(pb *eth.SignedBlindedBeaconBlockBellatrix) (*SignedBeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
@@ -447,6 +571,23 @@ func initBlindedSignedBlockFromProtoCapella(pb *eth.SignedBlindedBeaconBlockCape
return b, nil
}
func initBlindedSignedBlockFromProtoDeneb(pb *eth.SignedBlindedBeaconBlockDeneb) (*SignedBeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
}
block, err := initBlindedBlockFromProtoDeneb(pb.Block)
if err != nil {
return nil, err
}
b := &SignedBeaconBlock{
version: version.Deneb,
block: block,
signature: bytesutil.ToBytes96(pb.Signature),
}
return b, nil
}
func initBlockFromProtoPhase0(pb *eth.BeaconBlock) (*BeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
@@ -547,6 +688,26 @@ func initBlockFromProtoCapella(pb *eth.BeaconBlockCapella) (*BeaconBlock, error)
return b, nil
}
func initBlockFromProtoDeneb(pb *eth.BeaconBlockDeneb) (*BeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
}
body, err := initBlockBodyFromProtoDeneb(pb.Body)
if err != nil {
return nil, err
}
b := &BeaconBlock{
version: version.Deneb,
slot: pb.Slot,
proposerIndex: pb.ProposerIndex,
parentRoot: bytesutil.ToBytes32(pb.ParentRoot),
stateRoot: bytesutil.ToBytes32(pb.StateRoot),
body: body,
}
return b, nil
}
func initBlindedBlockFromProtoCapella(pb *eth.BlindedBeaconBlockCapella) (*BeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
@@ -567,6 +728,26 @@ func initBlindedBlockFromProtoCapella(pb *eth.BlindedBeaconBlockCapella) (*Beaco
return b, nil
}
func initBlindedBlockFromProtoDeneb(pb *eth.BlindedBeaconBlockDeneb) (*BeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
}
body, err := initBlindedBlockBodyFromProtoDeneb(pb.Body)
if err != nil {
return nil, err
}
b := &BeaconBlock{
version: version.Deneb,
slot: pb.Slot,
proposerIndex: pb.ProposerIndex,
parentRoot: bytesutil.ToBytes32(pb.ParentRoot),
stateRoot: bytesutil.ToBytes32(pb.StateRoot),
body: body,
}
return b, nil
}
func initBlockBodyFromProtoPhase0(pb *eth.BeaconBlockBody) (*BeaconBlockBody, error) {
if pb == nil {
return nil, errNilBlockBody
@@ -717,3 +898,61 @@ func initBlindedBlockBodyFromProtoCapella(pb *eth.BlindedBeaconBlockBodyCapella)
}
return b, nil
}
func initBlockBodyFromProtoDeneb(pb *eth.BeaconBlockBodyDeneb) (*BeaconBlockBody, error) {
if pb == nil {
return nil, errNilBlockBody
}
p, err := WrappedExecutionPayloadDeneb(pb.ExecutionPayload, 0)
// We allow the payload to be nil
if err != nil && err != consensus_types.ErrNilObjectWrapped {
return nil, err
}
b := &BeaconBlockBody{
version: version.Deneb,
isBlinded: false,
randaoReveal: bytesutil.ToBytes96(pb.RandaoReveal),
eth1Data: pb.Eth1Data,
graffiti: bytesutil.ToBytes32(pb.Graffiti),
proposerSlashings: pb.ProposerSlashings,
attesterSlashings: pb.AttesterSlashings,
attestations: pb.Attestations,
deposits: pb.Deposits,
voluntaryExits: pb.VoluntaryExits,
syncAggregate: pb.SyncAggregate,
executionPayload: p,
blsToExecutionChanges: pb.BlsToExecutionChanges,
blobKzgCommitments: pb.BlobKzgCommitments,
}
return b, nil
}
func initBlindedBlockBodyFromProtoDeneb(pb *eth.BlindedBeaconBlockBodyDeneb) (*BeaconBlockBody, error) {
if pb == nil {
return nil, errNilBlockBody
}
ph, err := WrappedExecutionPayloadHeaderDeneb(pb.ExecutionPayloadHeader, 0)
// We allow the payload to be nil
if err != nil && err != consensus_types.ErrNilObjectWrapped {
return nil, err
}
b := &BeaconBlockBody{
version: version.Deneb,
isBlinded: true,
randaoReveal: bytesutil.ToBytes96(pb.RandaoReveal),
eth1Data: pb.Eth1Data,
graffiti: bytesutil.ToBytes32(pb.Graffiti),
proposerSlashings: pb.ProposerSlashings,
attesterSlashings: pb.AttesterSlashings,
attestations: pb.Attestations,
deposits: pb.Deposits,
voluntaryExits: pb.VoluntaryExits,
syncAggregate: pb.SyncAggregate,
executionPayloadHeader: ph,
blsToExecutionChanges: pb.BlsToExecutionChanges,
blobKzgCommitments: pb.BlobKzgCommitments,
}
return b, nil
}

View File

@@ -4,6 +4,7 @@ import (
"testing"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/runtime/version"
@@ -24,7 +25,10 @@ type fields struct {
execPayloadHeader *enginev1.ExecutionPayloadHeader
execPayloadCapella *enginev1.ExecutionPayloadCapella
execPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
execPayloadDeneb *enginev1.ExecutionPayloadDeneb
execPayloadHeaderDeneb *enginev1.ExecutionPayloadHeaderDeneb
blsToExecutionChanges []*eth.SignedBLSToExecutionChange
kzgCommitments [][]byte
}
func Test_SignedBeaconBlock_Proto(t *testing.T) {
@@ -234,6 +238,74 @@ func Test_SignedBeaconBlock_Proto(t *testing.T) {
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("Deneb", func(t *testing.T) {
expectedBlock := &eth.SignedBeaconBlockDeneb{
Block: &eth.BeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbDeneb(),
},
Signature: f.sig[:],
}
block := &SignedBeaconBlock{
version: version.Deneb,
block: &BeaconBlock{
version: version.Deneb,
slot: 128,
proposerIndex: 128,
parentRoot: f.root,
stateRoot: f.root,
body: bodyDeneb(t),
},
signature: f.sig,
}
result, err := block.Proto()
require.NoError(t, err)
resultBlock, ok := result.(*eth.SignedBeaconBlockDeneb)
require.Equal(t, true, ok)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("DenebBlind", func(t *testing.T) {
expectedBlock := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbBlindedDeneb(),
},
Signature: f.sig[:],
}
block := &SignedBeaconBlock{
version: version.Deneb,
block: &BeaconBlock{
version: version.Deneb,
slot: 128,
proposerIndex: 128,
parentRoot: f.root,
stateRoot: f.root,
body: bodyBlindedDeneb(t),
},
signature: f.sig,
}
result, err := block.Proto()
require.NoError(t, err)
resultBlock, ok := result.(*eth.SignedBlindedBeaconBlockDeneb)
require.Equal(t, true, ok)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
}
func Test_BeaconBlock_Proto(t *testing.T) {
@@ -401,6 +473,60 @@ func Test_BeaconBlock_Proto(t *testing.T) {
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("Deneb", func(t *testing.T) {
expectedBlock := &eth.BeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbDeneb(),
}
block := &BeaconBlock{
version: version.Deneb,
slot: 128,
proposerIndex: 128,
parentRoot: f.root,
stateRoot: f.root,
body: bodyDeneb(t),
}
result, err := block.Proto()
require.NoError(t, err)
resultBlock, ok := result.(*eth.BeaconBlockDeneb)
require.Equal(t, true, ok)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("DenebBlind", func(t *testing.T) {
expectedBlock := &eth.BlindedBeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbBlindedDeneb(),
}
block := &BeaconBlock{
version: version.Deneb,
slot: 128,
proposerIndex: 128,
parentRoot: f.root,
stateRoot: f.root,
body: bodyBlindedDeneb(t),
}
result, err := block.Proto()
require.NoError(t, err)
resultBlock, ok := result.(*eth.BlindedBeaconBlockDeneb)
require.Equal(t, true, ok)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
}
func Test_BeaconBlockBody_Proto(t *testing.T) {
@@ -483,6 +609,32 @@ func Test_BeaconBlockBody_Proto(t *testing.T) {
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("Deneb", func(t *testing.T) {
expectedBody := bodyPbDeneb()
body := bodyDeneb(t)
result, err := body.Proto()
require.NoError(t, err)
resultBlock, ok := result.(*eth.BeaconBlockBodyDeneb)
require.Equal(t, true, ok)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBody.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("DenebBlind", func(t *testing.T) {
expectedBody := bodyPbBlindedDeneb()
body := bodyBlindedDeneb(t)
result, err := body.Proto()
require.NoError(t, err)
resultBlock, ok := result.(*eth.BlindedBeaconBlockBodyDeneb)
require.Equal(t, true, ok)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBody.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
})
t.Run("Bellatrix - wrong payload type", func(t *testing.T) {
body := bodyBellatrix(t)
body.executionPayload = &executionPayloadHeader{}
@@ -507,6 +659,18 @@ func Test_BeaconBlockBody_Proto(t *testing.T) {
_, err := body.Proto()
require.ErrorIs(t, err, errPayloadHeaderWrongType)
})
t.Run("Deneb - wrong payload type", func(t *testing.T) {
body := bodyDeneb(t)
body.executionPayload = &executionPayloadHeaderDeneb{}
_, err := body.Proto()
require.ErrorIs(t, err, errPayloadWrongType)
})
t.Run("DenebBlind - wrong payload type", func(t *testing.T) {
body := bodyBlindedDeneb(t)
body.executionPayloadHeader = &executionPayloadDeneb{}
_, err := body.Proto()
require.ErrorIs(t, err, errPayloadHeaderWrongType)
})
}
func Test_initSignedBlockFromProtoPhase0(t *testing.T) {
@@ -641,6 +805,50 @@ func Test_initBlindedSignedBlockFromProtoCapella(t *testing.T) {
assert.DeepEqual(t, expectedBlock.Signature, resultBlock.signature[:])
}
func Test_initSignedBlockFromProtoDeneb(t *testing.T) {
f := getFields()
expectedBlock := &eth.SignedBeaconBlockDeneb{
Block: &eth.BeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbDeneb(),
},
Signature: f.sig[:],
}
resultBlock, err := initSignedBlockFromProtoDeneb(expectedBlock)
require.NoError(t, err)
resultHTR, err := resultBlock.block.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
assert.DeepEqual(t, expectedBlock.Signature, resultBlock.signature[:])
}
func Test_initBlindedSignedBlockFromProtoDeneb(t *testing.T) {
f := getFields()
expectedBlock := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbBlindedDeneb(),
},
Signature: f.sig[:],
}
resultBlock, err := initBlindedSignedBlockFromProtoDeneb(expectedBlock)
require.NoError(t, err)
resultHTR, err := resultBlock.block.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.Block.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
assert.DeepEqual(t, expectedBlock.Signature, resultBlock.signature[:])
}
func Test_initBlockFromProtoPhase0(t *testing.T) {
f := getFields()
expectedBlock := &eth.BeaconBlock{
@@ -749,6 +957,42 @@ func Test_initBlockFromProtoBlindedCapella(t *testing.T) {
assert.DeepEqual(t, expectedHTR, resultHTR)
}
func Test_initBlockFromProtoDeneb(t *testing.T) {
f := getFields()
expectedBlock := &eth.BeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbDeneb(),
}
resultBlock, err := initBlockFromProtoDeneb(expectedBlock)
require.NoError(t, err)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
}
func Test_initBlockFromProtoBlindedDeneb(t *testing.T) {
f := getFields()
expectedBlock := &eth.BlindedBeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
StateRoot: f.root[:],
Body: bodyPbBlindedDeneb(),
}
resultBlock, err := initBlindedBlockFromProtoDeneb(expectedBlock)
require.NoError(t, err)
resultHTR, err := resultBlock.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
}
func Test_initBlockBodyFromProtoPhase0(t *testing.T) {
expectedBody := bodyPbPhase0()
resultBody, err := initBlockBodyFromProtoPhase0(expectedBody)
@@ -815,6 +1059,28 @@ func Test_initBlockBodyFromProtoBlindedCapella(t *testing.T) {
assert.DeepEqual(t, expectedHTR, resultHTR)
}
func Test_initBlockBodyFromProtoDeneb(t *testing.T) {
expectedBody := bodyPbDeneb()
resultBody, err := initBlockBodyFromProtoDeneb(expectedBody)
require.NoError(t, err)
resultHTR, err := resultBody.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBody.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
}
func Test_initBlockBodyFromProtoBlindedDeneb(t *testing.T) {
expectedBody := bodyPbBlindedDeneb()
resultBody, err := initBlindedBlockBodyFromProtoDeneb(expectedBody)
require.NoError(t, err)
resultHTR, err := resultBody.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBody.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
}
func bodyPbPhase0() *eth.BeaconBlockBody {
f := getFields()
return &eth.BeaconBlockBody{
@@ -934,6 +1200,50 @@ func bodyPbBlindedCapella() *eth.BlindedBeaconBlockBodyCapella {
}
}
func bodyPbDeneb() *eth.BeaconBlockBodyDeneb {
f := getFields()
return &eth.BeaconBlockBodyDeneb{
RandaoReveal: f.sig[:],
Eth1Data: &eth.Eth1Data{
DepositRoot: f.root[:],
DepositCount: 128,
BlockHash: f.root[:],
},
Graffiti: f.root[:],
ProposerSlashings: f.proposerSlashings,
AttesterSlashings: f.attesterSlashings,
Attestations: f.atts,
Deposits: f.deposits,
VoluntaryExits: f.voluntaryExits,
SyncAggregate: f.syncAggregate,
ExecutionPayload: f.execPayloadDeneb,
BlsToExecutionChanges: f.blsToExecutionChanges,
BlobKzgCommitments: f.kzgCommitments,
}
}
func bodyPbBlindedDeneb() *eth.BlindedBeaconBlockBodyDeneb {
f := getFields()
return &eth.BlindedBeaconBlockBodyDeneb{
RandaoReveal: f.sig[:],
Eth1Data: &eth.Eth1Data{
DepositRoot: f.root[:],
DepositCount: 128,
BlockHash: f.root[:],
},
Graffiti: f.root[:],
ProposerSlashings: f.proposerSlashings,
AttesterSlashings: f.attesterSlashings,
Attestations: f.atts,
Deposits: f.deposits,
VoluntaryExits: f.voluntaryExits,
SyncAggregate: f.syncAggregate,
ExecutionPayloadHeader: f.execPayloadHeaderDeneb,
BlsToExecutionChanges: f.blsToExecutionChanges,
BlobKzgCommitments: f.kzgCommitments,
}
}
func bodyPhase0() *BeaconBlockBody {
f := getFields()
return &BeaconBlockBody{
@@ -1069,6 +1379,57 @@ func bodyBlindedCapella(t *testing.T) *BeaconBlockBody {
}
}
func bodyDeneb(t *testing.T) *BeaconBlockBody {
f := getFields()
p, err := WrappedExecutionPayloadDeneb(f.execPayloadDeneb, 0)
require.NoError(t, err)
return &BeaconBlockBody{
version: version.Deneb,
randaoReveal: f.sig,
eth1Data: &eth.Eth1Data{
DepositRoot: f.root[:],
DepositCount: 128,
BlockHash: f.root[:],
},
graffiti: f.root,
proposerSlashings: f.proposerSlashings,
attesterSlashings: f.attesterSlashings,
attestations: f.atts,
deposits: f.deposits,
voluntaryExits: f.voluntaryExits,
syncAggregate: f.syncAggregate,
executionPayload: p,
blsToExecutionChanges: f.blsToExecutionChanges,
blobKzgCommitments: f.kzgCommitments,
}
}
func bodyBlindedDeneb(t *testing.T) *BeaconBlockBody {
f := getFields()
ph, err := WrappedExecutionPayloadHeaderDeneb(f.execPayloadHeaderDeneb, 0)
require.NoError(t, err)
return &BeaconBlockBody{
version: version.Deneb,
isBlinded: true,
randaoReveal: f.sig,
eth1Data: &eth.Eth1Data{
DepositRoot: f.root[:],
DepositCount: 128,
BlockHash: f.root[:],
},
graffiti: f.root,
proposerSlashings: f.proposerSlashings,
attesterSlashings: f.attesterSlashings,
attestations: f.atts,
deposits: f.deposits,
voluntaryExits: f.voluntaryExits,
syncAggregate: f.syncAggregate,
executionPayloadHeader: ph,
blsToExecutionChanges: f.blsToExecutionChanges,
blobKzgCommitments: f.kzgCommitments,
}
}
func getFields() fields {
b20 := make([]byte, 20)
b48 := make([]byte, 48)
@@ -1275,6 +1636,60 @@ func getFields() fields {
Signature: sig[:],
}}
execPayloadDeneb := &enginev1.ExecutionPayloadDeneb{
ParentHash: root[:],
FeeRecipient: b20,
StateRoot: root[:],
ReceiptsRoot: root[:],
LogsBloom: b256,
PrevRandao: root[:],
BlockNumber: 128,
GasLimit: 128,
GasUsed: 128,
Timestamp: 128,
ExtraData: root[:],
BaseFeePerGas: root[:],
BlockHash: root[:],
Transactions: [][]byte{
[]byte("transaction1"),
[]byte("transaction2"),
[]byte("transaction8"),
},
Withdrawals: []*enginev1.Withdrawal{
{
Index: 128,
Address: b20,
Amount: 128,
},
},
ExcessDataGas: root[:],
}
execPayloadHeaderDeneb := &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: root[:],
FeeRecipient: b20,
StateRoot: root[:],
ReceiptsRoot: root[:],
LogsBloom: b256,
PrevRandao: root[:],
BlockNumber: 128,
GasLimit: 128,
GasUsed: 128,
Timestamp: 128,
ExtraData: root[:],
BaseFeePerGas: root[:],
BlockHash: root[:],
TransactionsRoot: root[:],
WithdrawalsRoot: root[:],
ExcessDataGas: root[:],
}
kzgCommitments := [][]byte{
bytesutil.PadTo([]byte{123}, 48),
bytesutil.PadTo([]byte{223}, 48),
bytesutil.PadTo([]byte{183}, 48),
bytesutil.PadTo([]byte{143}, 48),
}
return fields{
root: root,
sig: sig,
@@ -1288,6 +1703,9 @@ func getFields() fields {
execPayloadHeader: execPayloadHeader,
execPayloadCapella: execPayloadCapella,
execPayloadHeaderCapella: execPayloadHeaderCapella,
execPayloadDeneb: execPayloadDeneb,
execPayloadHeaderDeneb: execPayloadHeaderDeneb,
blsToExecutionChanges: blsToExecutionChanges,
kzgCommitments: kzgCommitments,
}
}

View File

@@ -125,3 +125,16 @@ func (b *SignedBeaconBlock) SetBLSToExecutionChanges(blsToExecutionChanges []*et
b.block.body.blsToExecutionChanges = blsToExecutionChanges
return nil
}
// SetBlobKzgCommitments sets the blob kzg commitments in the block.
func (b *SignedBeaconBlock) SetBlobKzgCommitments(c [][]byte) error {
switch b.version {
case version.Phase0, version.Altair, version.Bellatrix, version.Capella:
return consensus_types.ErrNotSupported("SetBlobKzgCommitments", b.version)
case version.Deneb:
b.block.body.blobKzgCommitments = c
return nil
default:
return errIncorrectBlockVersion
}
}

View File

@@ -49,6 +49,7 @@ type BeaconBlockBody struct {
executionPayload interfaces.ExecutionData
executionPayloadHeader interfaces.ExecutionData
blsToExecutionChanges []*eth.SignedBLSToExecutionChange
blobKzgCommitments [][]byte
}
// BeaconBlock is the main beacon block structure. It can represent any block type.

View File

@@ -25,7 +25,9 @@ type ReadOnlySignedBeaconBlock interface {
PbBellatrixBlock() (*ethpb.SignedBeaconBlockBellatrix, error)
PbBlindedBellatrixBlock() (*ethpb.SignedBlindedBeaconBlockBellatrix, error)
PbCapellaBlock() (*ethpb.SignedBeaconBlockCapella, error)
PbDenebBlock() (*ethpb.SignedBeaconBlockDeneb, error)
PbBlindedCapellaBlock() (*ethpb.SignedBlindedBeaconBlockCapella, error)
PbBlindedDenebBlock() (*ethpb.SignedBlindedBeaconBlockDeneb, error)
ssz.Marshaler
ssz.Unmarshaler
Version() int
@@ -70,12 +72,14 @@ type ReadOnlyBeaconBlockBody interface {
Proto() (proto.Message, error)
Execution() (ExecutionData, error)
BLSToExecutionChanges() ([]*ethpb.SignedBLSToExecutionChange, error)
BlobKzgCommitments() ([][]byte, error)
}
type SignedBeaconBlock interface {
ReadOnlySignedBeaconBlock
SetExecution(ExecutionData) error
SetBLSToExecutionChanges([]*ethpb.SignedBLSToExecutionChange) error
SetBlobKzgCommitments(c [][]byte) error
SetSyncAggregate(*ethpb.SyncAggregate) error
SetVoluntaryExits([]*ethpb.SignedVoluntaryExit)
SetDeposits([]*ethpb.Deposit)
@@ -114,6 +118,7 @@ type ExecutionData interface {
Timestamp() uint64
ExtraData() []byte
BaseFeePerGas() []byte
ExcessDataGas() ([]byte, error)
BlockHash() []byte
Transactions() ([][]byte, error)
TransactionsRoot() ([]byte, error)

View File

@@ -66,6 +66,14 @@ func (SignedBeaconBlock) PbBlindedCapellaBlock() (*eth.SignedBlindedBeaconBlockC
panic("implement me")
}
func (SignedBeaconBlock) PbDenebBlock() (*eth.SignedBeaconBlockDeneb, error) {
panic("implement me")
}
func (SignedBeaconBlock) PbBlindedDenebBlock() (*eth.SignedBlindedBeaconBlockDeneb, error) {
panic("implement me")
}
func (SignedBeaconBlock) MarshalSSZTo(_ []byte) ([]byte, error) {
panic("implement me")
}
@@ -215,10 +223,6 @@ func (BeaconBlockBody) AttesterSlashings() []*eth.AttesterSlashing {
panic("implement me")
}
func (BeaconBlockBody) Attestations() []*eth.Attestation {
panic("implement me")
}
func (BeaconBlockBody) Deposits() []*eth.Deposit {
panic("implement me")
}
@@ -299,6 +303,15 @@ func (b *BeaconBlockBody) SetBLSToExecutionChanges([]*eth.SignedBLSToExecutionCh
panic("implement me")
}
// BlobKzgCommitments returns the blob kzg commitments in the block.
func (b *BeaconBlockBody) BlobKzgCommitments() ([][]byte, error) {
panic("implement me")
}
func (b *BeaconBlockBody) Attestations() []*eth.Attestation {
panic("implement me")
}
var _ interfaces.ReadOnlySignedBeaconBlock = &SignedBeaconBlock{}
var _ interfaces.ReadOnlyBeaconBlock = &BeaconBlock{}
var _ interfaces.ReadOnlyBeaconBlockBody = &BeaconBlockBody{}

View File

@@ -18,7 +18,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
github_com_prysmaticlabs_prysm_v4_consensus_types_primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
v1 "github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
"github.com/prysmaticlabs/prysm/v4/proto/eth/v2"
"google.golang.org/grpc"

View File

@@ -18,7 +18,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
github_com_prysmaticlabs_prysm_v4_consensus_types_primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
v1 "github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
"github.com/prysmaticlabs/prysm/v4/proto/eth/v2"
"google.golang.org/grpc"

View File

@@ -18,7 +18,6 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
github_com_prysmaticlabs_prysm_v4_consensus_types_primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
v1 "github.com/prysmaticlabs/prysm/v4/proto/eth/v1"
"github.com/prysmaticlabs/prysm/v4/proto/eth/v2"
"google.golang.org/grpc"

315
proto/eth/v2/blobs.pb.go generated Executable file
View File

@@ -0,0 +1,315 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc v3.15.8
// source: proto/eth/v2/blobs.proto
package eth
import (
reflect "reflect"
sync "sync"
github_com_prysmaticlabs_prysm_v4_consensus_types_primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
_ "github.com/prysmaticlabs/prysm/v4/proto/eth/ext"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type SignedBlindedBlobSidecar struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Message *BlindedBlobSidecar `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty" ssz-max:"4"`
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"`
}
func (x *SignedBlindedBlobSidecar) Reset() {
*x = SignedBlindedBlobSidecar{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v2_blobs_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SignedBlindedBlobSidecar) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SignedBlindedBlobSidecar) ProtoMessage() {}
func (x *SignedBlindedBlobSidecar) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v2_blobs_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SignedBlindedBlobSidecar.ProtoReflect.Descriptor instead.
func (*SignedBlindedBlobSidecar) Descriptor() ([]byte, []int) {
return file_proto_eth_v2_blobs_proto_rawDescGZIP(), []int{0}
}
func (x *SignedBlindedBlobSidecar) GetMessage() *BlindedBlobSidecar {
if x != nil {
return x.Message
}
return nil
}
func (x *SignedBlindedBlobSidecar) GetSignature() []byte {
if x != nil {
return x.Signature
}
return nil
}
type BlindedBlobSidecar struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
BlockRoot []byte `protobuf:"bytes,1,opt,name=block_root,json=blockRoot,proto3" json:"block_root,omitempty" ssz-size:"32"`
Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
Slot github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot"`
BlockParentRoot []byte `protobuf:"bytes,4,opt,name=block_parent_root,json=blockParentRoot,proto3" json:"block_parent_root,omitempty" ssz-size:"32"`
ProposerIndex github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.ValidatorIndex `protobuf:"varint,5,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.ValidatorIndex"`
BlobRoot []byte `protobuf:"bytes,6,opt,name=blob_root,json=blobRoot,proto3" json:"blob_root,omitempty" ssz-size:"32"`
KzgCommitment []byte `protobuf:"bytes,7,opt,name=kzg_commitment,json=kzgCommitment,proto3" json:"kzg_commitment,omitempty" ssz-size:"48"`
KzgProof []byte `protobuf:"bytes,8,opt,name=kzg_proof,json=kzgProof,proto3" json:"kzg_proof,omitempty" ssz-size:"48"`
}
func (x *BlindedBlobSidecar) Reset() {
*x = BlindedBlobSidecar{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_eth_v2_blobs_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BlindedBlobSidecar) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BlindedBlobSidecar) ProtoMessage() {}
func (x *BlindedBlobSidecar) ProtoReflect() protoreflect.Message {
mi := &file_proto_eth_v2_blobs_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BlindedBlobSidecar.ProtoReflect.Descriptor instead.
func (*BlindedBlobSidecar) Descriptor() ([]byte, []int) {
return file_proto_eth_v2_blobs_proto_rawDescGZIP(), []int{1}
}
func (x *BlindedBlobSidecar) GetBlockRoot() []byte {
if x != nil {
return x.BlockRoot
}
return nil
}
func (x *BlindedBlobSidecar) GetIndex() uint64 {
if x != nil {
return x.Index
}
return 0
}
func (x *BlindedBlobSidecar) GetSlot() github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot {
if x != nil {
return x.Slot
}
return github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot(0)
}
func (x *BlindedBlobSidecar) GetBlockParentRoot() []byte {
if x != nil {
return x.BlockParentRoot
}
return nil
}
func (x *BlindedBlobSidecar) GetProposerIndex() github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.ValidatorIndex {
if x != nil {
return x.ProposerIndex
}
return github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.ValidatorIndex(0)
}
func (x *BlindedBlobSidecar) GetBlobRoot() []byte {
if x != nil {
return x.BlobRoot
}
return nil
}
func (x *BlindedBlobSidecar) GetKzgCommitment() []byte {
if x != nil {
return x.KzgCommitment
}
return nil
}
func (x *BlindedBlobSidecar) GetKzgProof() []byte {
if x != nil {
return x.KzgProof
}
return nil
}
var File_proto_eth_v2_blobs_proto protoreflect.FileDescriptor
var file_proto_eth_v2_blobs_proto_rawDesc = []byte{
0x0a, 0x18, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x62,
0x6c, 0x6f, 0x62, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x65, 0x74, 0x68, 0x65,
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x1a, 0x1b, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x86, 0x01, 0x0a, 0x18, 0x53, 0x69, 0x67,
0x6e, 0x65, 0x64, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69,
0x64, 0x65, 0x63, 0x61, 0x72, 0x12, 0x44, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 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, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x73,
0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72,
0x65, 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, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x12,
0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05,
0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20,
0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62,
0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65,
0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69,
0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74,
0x12, 0x32, 0x0a, 0x11, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74,
0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18,
0x02, 0x33, 0x32, 0x52, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74,
0x52, 0x6f, 0x6f, 0x74, 0x12, 0x76, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5,
0x18, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79,
0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
0x2f, 0x76, 0x34, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79,
0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56,
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0d, 0x70,
0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x23, 0x0a, 0x09,
0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42,
0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x08, 0x62, 0x6c, 0x6f, 0x62, 0x52, 0x6f, 0x6f,
0x74, 0x12, 0x2d, 0x0a, 0x0e, 0x6b, 0x7a, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d,
0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x34,
0x38, 0x52, 0x0d, 0x6b, 0x7a, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74,
0x12, 0x23, 0x0a, 0x09, 0x6b, 0x7a, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x08, 0x20,
0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x34, 0x38, 0x52, 0x08, 0x6b, 0x7a, 0x67,
0x50, 0x72, 0x6f, 0x6f, 0x66, 0x42, 0x7b, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68,
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x42, 0x6c,
0x6f, 0x62, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63,
0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02,
0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32,
0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c,
0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_eth_v2_blobs_proto_rawDescOnce sync.Once
file_proto_eth_v2_blobs_proto_rawDescData = file_proto_eth_v2_blobs_proto_rawDesc
)
func file_proto_eth_v2_blobs_proto_rawDescGZIP() []byte {
file_proto_eth_v2_blobs_proto_rawDescOnce.Do(func() {
file_proto_eth_v2_blobs_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_eth_v2_blobs_proto_rawDescData)
})
return file_proto_eth_v2_blobs_proto_rawDescData
}
var file_proto_eth_v2_blobs_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_proto_eth_v2_blobs_proto_goTypes = []interface{}{
(*SignedBlindedBlobSidecar)(nil), // 0: ethereum.eth.v2.SignedBlindedBlobSidecar
(*BlindedBlobSidecar)(nil), // 1: ethereum.eth.v2.BlindedBlobSidecar
}
var file_proto_eth_v2_blobs_proto_depIdxs = []int32{
1, // 0: ethereum.eth.v2.SignedBlindedBlobSidecar.message:type_name -> ethereum.eth.v2.BlindedBlobSidecar
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_proto_eth_v2_blobs_proto_init() }
func file_proto_eth_v2_blobs_proto_init() {
if File_proto_eth_v2_blobs_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_eth_v2_blobs_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SignedBlindedBlobSidecar); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_eth_v2_blobs_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BlindedBlobSidecar); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_eth_v2_blobs_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_proto_eth_v2_blobs_proto_goTypes,
DependencyIndexes: file_proto_eth_v2_blobs_proto_depIdxs,
MessageInfos: file_proto_eth_v2_blobs_proto_msgTypes,
}.Build()
File_proto_eth_v2_blobs_proto = out.File
file_proto_eth_v2_blobs_proto_rawDesc = nil
file_proto_eth_v2_blobs_proto_goTypes = nil
file_proto_eth_v2_blobs_proto_depIdxs = nil
}

4
proto/eth/v2/blobs.pb.gw.go Executable file
View File

@@ -0,0 +1,4 @@
//go:build ignore
// +build ignore
package ignore

File diff suppressed because it is too large Load Diff

View File

@@ -49,6 +49,8 @@ message GenericSignedBeaconBlock {
SignedBlindedBeaconBlockCapella blinded_capella = 6;
SignedBeaconBlockAndBlobsDeneb Deneb = 7;
SignedBlindedBeaconBlockDenebAndBlobs blinded_Deneb = 8;
}
}
@@ -73,6 +75,8 @@ message GenericBeaconBlock {
BlindedBeaconBlockCapella blinded_capella = 6;
BeaconBlockDenebAndBlobs Deneb = 7;
BlindedBeaconBlockDenebAndBlobs blinded_Deneb = 8;
}
}
@@ -641,6 +645,17 @@ message BlindedBeaconBlockBodyCapella {
// At most MAX_BLS_TO_EXECUTION_CHANGES. New in Capella network upgrade.
repeated SignedBLSToExecutionChange bls_to_execution_changes = 11 [(ethereum.eth.ext.ssz_max) = "16"];
}
message SignedBlindedBeaconBlockDenebAndBlobs {
SignedBlindedBeaconBlockDeneb block = 1;
repeated SignedBlindedBlobSidecar blobs = 2 [(ethereum.eth.ext.ssz_max) = "4"];
}
message BlindedBeaconBlockDenebAndBlobs {
BlindedBeaconBlockDeneb block = 1;
repeated BlindedBlobSidecar blobs = 2 [(ethereum.eth.ext.ssz_max) = "4"];
}
message SignedBlindedBeaconBlockDeneb {
// The unsigned blinded beacon block itself.
BlindedBeaconBlockDeneb block = 1;

View File

@@ -228,6 +228,211 @@ func (x *SignedBlobSidecar) GetSignature() []byte {
return nil
}
type BlindedBlobSidecars struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Sidecars []*BlindedBlobSidecar `protobuf:"bytes,1,rep,name=sidecars,proto3" json:"sidecars,omitempty" ssz-max:"4"`
}
func (x *BlindedBlobSidecars) Reset() {
*x = BlindedBlobSidecars{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BlindedBlobSidecars) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BlindedBlobSidecars) ProtoMessage() {}
func (x *BlindedBlobSidecars) ProtoReflect() protoreflect.Message {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BlindedBlobSidecars.ProtoReflect.Descriptor instead.
func (*BlindedBlobSidecars) Descriptor() ([]byte, []int) {
return file_proto_prysm_v1alpha1_blobs_proto_rawDescGZIP(), []int{3}
}
func (x *BlindedBlobSidecars) GetSidecars() []*BlindedBlobSidecar {
if x != nil {
return x.Sidecars
}
return nil
}
type BlindedBlobSidecar struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
BlockRoot []byte `protobuf:"bytes,1,opt,name=block_root,json=blockRoot,proto3" json:"block_root,omitempty" ssz-size:"32"`
Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
Slot github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot"`
BlockParentRoot []byte `protobuf:"bytes,4,opt,name=block_parent_root,json=blockParentRoot,proto3" json:"block_parent_root,omitempty" ssz-size:"32"`
ProposerIndex github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.ValidatorIndex `protobuf:"varint,5,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.ValidatorIndex"`
BlobRoot []byte `protobuf:"bytes,6,opt,name=blob_root,json=blobRoot,proto3" json:"blob_root,omitempty" ssz-size:"32"`
KzgCommitment []byte `protobuf:"bytes,7,opt,name=kzg_commitment,json=kzgCommitment,proto3" json:"kzg_commitment,omitempty" ssz-size:"48"`
KzgProof []byte `protobuf:"bytes,8,opt,name=kzg_proof,json=kzgProof,proto3" json:"kzg_proof,omitempty" ssz-size:"48"`
}
func (x *BlindedBlobSidecar) Reset() {
*x = BlindedBlobSidecar{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BlindedBlobSidecar) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BlindedBlobSidecar) ProtoMessage() {}
func (x *BlindedBlobSidecar) ProtoReflect() protoreflect.Message {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BlindedBlobSidecar.ProtoReflect.Descriptor instead.
func (*BlindedBlobSidecar) Descriptor() ([]byte, []int) {
return file_proto_prysm_v1alpha1_blobs_proto_rawDescGZIP(), []int{4}
}
func (x *BlindedBlobSidecar) GetBlockRoot() []byte {
if x != nil {
return x.BlockRoot
}
return nil
}
func (x *BlindedBlobSidecar) GetIndex() uint64 {
if x != nil {
return x.Index
}
return 0
}
func (x *BlindedBlobSidecar) GetSlot() github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot {
if x != nil {
return x.Slot
}
return github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.Slot(0)
}
func (x *BlindedBlobSidecar) GetBlockParentRoot() []byte {
if x != nil {
return x.BlockParentRoot
}
return nil
}
func (x *BlindedBlobSidecar) GetProposerIndex() github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.ValidatorIndex {
if x != nil {
return x.ProposerIndex
}
return github_com_prysmaticlabs_prysm_v4_consensus_types_primitives.ValidatorIndex(0)
}
func (x *BlindedBlobSidecar) GetBlobRoot() []byte {
if x != nil {
return x.BlobRoot
}
return nil
}
func (x *BlindedBlobSidecar) GetKzgCommitment() []byte {
if x != nil {
return x.KzgCommitment
}
return nil
}
func (x *BlindedBlobSidecar) GetKzgProof() []byte {
if x != nil {
return x.KzgProof
}
return nil
}
type SignedBlindedBlobSidecar struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Message *BlindedBlobSidecar `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty" ssz-size:"96"`
}
func (x *SignedBlindedBlobSidecar) Reset() {
*x = SignedBlindedBlobSidecar{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SignedBlindedBlobSidecar) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SignedBlindedBlobSidecar) ProtoMessage() {}
func (x *SignedBlindedBlobSidecar) ProtoReflect() protoreflect.Message {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SignedBlindedBlobSidecar.ProtoReflect.Descriptor instead.
func (*SignedBlindedBlobSidecar) Descriptor() ([]byte, []int) {
return file_proto_prysm_v1alpha1_blobs_proto_rawDescGZIP(), []int{5}
}
func (x *SignedBlindedBlobSidecar) GetMessage() *BlindedBlobSidecar {
if x != nil {
return x.Message
}
return nil
}
func (x *SignedBlindedBlobSidecar) GetSignature() []byte {
if x != nil {
return x.Signature
}
return nil
}
type BlobIdentifier struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -240,7 +445,7 @@ type BlobIdentifier struct {
func (x *BlobIdentifier) Reset() {
*x = BlobIdentifier{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[3]
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -253,7 +458,7 @@ func (x *BlobIdentifier) String() string {
func (*BlobIdentifier) ProtoMessage() {}
func (x *BlobIdentifier) ProtoReflect() protoreflect.Message {
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[3]
mi := &file_proto_prysm_v1alpha1_blobs_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -266,7 +471,7 @@ func (x *BlobIdentifier) ProtoReflect() protoreflect.Message {
// Deprecated: Use BlobIdentifier.ProtoReflect.Descriptor instead.
func (*BlobIdentifier) Descriptor() ([]byte, []int) {
return file_proto_prysm_v1alpha1_blobs_proto_rawDescGZIP(), []int{3}
return file_proto_prysm_v1alpha1_blobs_proto_rawDescGZIP(), []int{6}
}
func (x *BlobIdentifier) GetBlockRoot() []byte {
@@ -332,22 +537,66 @@ var file_proto_prysm_v1alpha1_blobs_proto_rawDesc = []byte{
0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x12, 0x24, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52, 0x09, 0x73, 0x69,
0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x4d, 0x0a, 0x0e, 0x42, 0x6c, 0x6f, 0x62, 0x49,
0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 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, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74,
0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x42, 0x95, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x65,
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c,
0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f,
0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70,
0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x63, 0x0a, 0x13, 0x42, 0x6c, 0x69, 0x6e, 0x64,
0x65, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x73, 0x12, 0x4c,
0x0a, 0x08, 0x73, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x73, 0x18, 0x01, 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, 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,
0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e,
0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78,
0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45,
0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70,
0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79,
0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73,
0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02,
0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x76, 0x31,
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d,
0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73,
0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x32, 0x0a, 0x11, 0x62,
0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f,
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12,
0x76, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65,
0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5, 0x18, 0x4b, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69,
0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x63,
0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70,
0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61,
0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73,
0x65, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x23, 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x62, 0x5f,
0x72, 0x6f, 0x6f, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02,
0x33, 0x32, 0x52, 0x08, 0x62, 0x6c, 0x6f, 0x62, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2d, 0x0a, 0x0e,
0x6b, 0x7a, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x07,
0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x34, 0x38, 0x52, 0x0d, 0x6b, 0x7a,
0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x09, 0x6b,
0x7a, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
0x8a, 0xb5, 0x18, 0x02, 0x34, 0x38, 0x52, 0x08, 0x6b, 0x7a, 0x67, 0x50, 0x72, 0x6f, 0x6f, 0x66,
0x22, 0x85, 0x01, 0x0a, 0x18, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x42, 0x6c, 0x69, 0x6e, 0x64,
0x65, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x53, 0x69, 0x64, 0x65, 0x63, 0x61, 0x72, 0x12, 0x43, 0x0a,
0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 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, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x12, 0x24, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x39, 0x36, 0x52, 0x09, 0x73,
0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x4d, 0x0a, 0x0e, 0x42, 0x6c, 0x6f, 0x62,
0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 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, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f,
0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04,
0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x42, 0x95, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e,
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61,
0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72,
0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79,
0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x74, 0x68, 0xaa,
0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x76,
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65,
0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -362,21 +611,26 @@ func file_proto_prysm_v1alpha1_blobs_proto_rawDescGZIP() []byte {
return file_proto_prysm_v1alpha1_blobs_proto_rawDescData
}
var file_proto_prysm_v1alpha1_blobs_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_proto_prysm_v1alpha1_blobs_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_proto_prysm_v1alpha1_blobs_proto_goTypes = []interface{}{
(*BlobSidecars)(nil), // 0: ethereum.eth.v1alpha1.BlobSidecars
(*BlobSidecar)(nil), // 1: ethereum.eth.v1alpha1.BlobSidecar
(*SignedBlobSidecar)(nil), // 2: ethereum.eth.v1alpha1.SignedBlobSidecar
(*BlobIdentifier)(nil), // 3: ethereum.eth.v1alpha1.BlobIdentifier
(*BlobSidecars)(nil), // 0: ethereum.eth.v1alpha1.BlobSidecars
(*BlobSidecar)(nil), // 1: ethereum.eth.v1alpha1.BlobSidecar
(*SignedBlobSidecar)(nil), // 2: ethereum.eth.v1alpha1.SignedBlobSidecar
(*BlindedBlobSidecars)(nil), // 3: ethereum.eth.v1alpha1.BlindedBlobSidecars
(*BlindedBlobSidecar)(nil), // 4: ethereum.eth.v1alpha1.BlindedBlobSidecar
(*SignedBlindedBlobSidecar)(nil), // 5: ethereum.eth.v1alpha1.SignedBlindedBlobSidecar
(*BlobIdentifier)(nil), // 6: ethereum.eth.v1alpha1.BlobIdentifier
}
var file_proto_prysm_v1alpha1_blobs_proto_depIdxs = []int32{
1, // 0: ethereum.eth.v1alpha1.BlobSidecars.sidecars:type_name -> ethereum.eth.v1alpha1.BlobSidecar
1, // 1: ethereum.eth.v1alpha1.SignedBlobSidecar.message:type_name -> ethereum.eth.v1alpha1.BlobSidecar
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
4, // 2: ethereum.eth.v1alpha1.BlindedBlobSidecars.sidecars:type_name -> ethereum.eth.v1alpha1.BlindedBlobSidecar
4, // 3: ethereum.eth.v1alpha1.SignedBlindedBlobSidecar.message:type_name -> ethereum.eth.v1alpha1.BlindedBlobSidecar
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_proto_prysm_v1alpha1_blobs_proto_init() }
@@ -422,6 +676,42 @@ func file_proto_prysm_v1alpha1_blobs_proto_init() {
}
}
file_proto_prysm_v1alpha1_blobs_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BlindedBlobSidecars); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_prysm_v1alpha1_blobs_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BlindedBlobSidecar); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_prysm_v1alpha1_blobs_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SignedBlindedBlobSidecar); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_prysm_v1alpha1_blobs_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BlobIdentifier); i {
case 0:
return &v.state
@@ -440,7 +730,7 @@ func file_proto_prysm_v1alpha1_blobs_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_prysm_v1alpha1_blobs_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 7,
NumExtensions: 0,
NumServices: 0,
},

View File

@@ -44,6 +44,26 @@ message SignedBlobSidecar {
bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"];
}
message BlindedBlobSidecars {
repeated BlindedBlobSidecar sidecars = 1 [(ethereum.eth.ext.ssz_max) = "4"];
}
message BlindedBlobSidecar {
bytes block_root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 index = 2;
uint64 slot = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.Slot"];
bytes block_parent_root = 4 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 proposer_index = 5 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives.ValidatorIndex"];
bytes blob_root = 6 [(ethereum.eth.ext.ssz_size) = "32"];
bytes kzg_commitment = 7 [(ethereum.eth.ext.ssz_size) = "48"];
bytes kzg_proof = 8 [(ethereum.eth.ext.ssz_size) = "48"];
}
message SignedBlindedBlobSidecar {
BlindedBlobSidecar message = 1;
bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"];
}
message BlobIdentifier {
bytes block_root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
uint64 index = 2;

View File

@@ -512,6 +512,52 @@ func CopyBlindedBeaconBlockBodyCapella(body *BlindedBeaconBlockBodyCapella) *Bli
}
}
// CopySignedBlindedBeaconBlockDeneb copies the provided SignedBlindedBeaconBlockDeneb.
func CopySignedBlindedBeaconBlockDeneb(sigBlock *SignedBlindedBeaconBlockDeneb) *SignedBlindedBeaconBlockDeneb {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockDeneb{
Block: CopyBlindedBeaconBlockDeneb(sigBlock.Block),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// CopyBlindedBeaconBlockDeneb copies the provided BlindedBeaconBlockDeneb.
func CopyBlindedBeaconBlockDeneb(block *BlindedBeaconBlockDeneb) *BlindedBeaconBlockDeneb {
if block == nil {
return nil
}
return &BlindedBeaconBlockDeneb{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: CopyBlindedBeaconBlockBodyDeneb(block.Body),
}
}
// CopyBlindedBeaconBlockBodyDeneb copies the provided BlindedBeaconBlockBodyDeneb.
func CopyBlindedBeaconBlockBodyDeneb(body *BlindedBeaconBlockBodyDeneb) *BlindedBeaconBlockBodyDeneb {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyDeneb{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: CopyETH1Data(body.Eth1Data),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopyProposerSlashings(body.ProposerSlashings),
AttesterSlashings: CopyAttesterSlashings(body.AttesterSlashings),
Attestations: CopyAttestations(body.Attestations),
Deposits: CopyDeposits(body.Deposits),
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
ExecutionPayloadHeader: CopyExecutionPayloadHeaderDeneb(body.ExecutionPayloadHeader),
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
}
}
// CopyExecutionPayload copies the provided execution payload.
func CopyExecutionPayload(payload *enginev1.ExecutionPayload) *enginev1.ExecutionPayload {
if payload == nil {
@@ -699,6 +745,107 @@ func CopyBLSToExecutionChanges(changes []*SignedBLSToExecutionChange) []*SignedB
return res
}
// CopyBlobKZGs copies the provided blob kzgs object.
func CopyBlobKZGs(b [][]byte) [][]byte {
return bytesutil.SafeCopy2dBytes(b)
}
// CopySignedBeaconBlockDeneb copies the provided SignedBeaconBlockDeneb.
func CopySignedBeaconBlockDeneb(sigBlock *SignedBeaconBlockDeneb) *SignedBeaconBlockDeneb {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockDeneb{
Block: CopyBeaconBlockDeneb(sigBlock.Block),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// CopyBeaconBlockDeneb copies the provided BeaconBlockDeneb.
func CopyBeaconBlockDeneb(block *BeaconBlockDeneb) *BeaconBlockDeneb {
if block == nil {
return nil
}
return &BeaconBlockDeneb{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: CopyBeaconBlockBodyDeneb(block.Body),
}
}
// CopyBeaconBlockBodyDeneb copies the provided BeaconBlockBodyDeneb.
func CopyBeaconBlockBodyDeneb(body *BeaconBlockBodyDeneb) *BeaconBlockBodyDeneb {
if body == nil {
return nil
}
return &BeaconBlockBodyDeneb{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: CopyETH1Data(body.Eth1Data),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopyProposerSlashings(body.ProposerSlashings),
AttesterSlashings: CopyAttesterSlashings(body.AttesterSlashings),
Attestations: CopyAttestations(body.Attestations),
Deposits: CopyDeposits(body.Deposits),
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
ExecutionPayload: CopyExecutionPayloadDeneb(body.ExecutionPayload),
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
}
}
// CopyExecutionPayloadHeaderDeneb copies the provided execution payload object.
func CopyExecutionPayloadHeaderDeneb(payload *enginev1.ExecutionPayloadHeaderDeneb) *enginev1.ExecutionPayloadHeaderDeneb {
if payload == nil {
return nil
}
return &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash),
FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient),
StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot),
ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot),
LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom),
PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao),
BlockNumber: payload.BlockNumber,
GasLimit: payload.GasLimit,
GasUsed: payload.GasUsed,
Timestamp: payload.Timestamp,
ExcessDataGas: bytesutil.SafeCopyBytes(payload.ExcessDataGas),
BaseFeePerGas: bytesutil.SafeCopyBytes(payload.BaseFeePerGas),
ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData),
BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash),
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
}
}
// CopyExecutionPayloadDeneb copies the provided execution payload.
func CopyExecutionPayloadDeneb(payload *enginev1.ExecutionPayloadDeneb) *enginev1.ExecutionPayloadDeneb {
if payload == nil {
return nil
}
return &enginev1.ExecutionPayloadDeneb{
ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash),
FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient),
StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot),
ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot),
LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom),
PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao),
BlockNumber: payload.BlockNumber,
GasLimit: payload.GasLimit,
GasUsed: payload.GasUsed,
Timestamp: payload.Timestamp,
ExcessDataGas: bytesutil.SafeCopyBytes(payload.ExcessDataGas),
ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData),
BaseFeePerGas: bytesutil.SafeCopyBytes(payload.BaseFeePerGas),
BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash),
Transactions: bytesutil.SafeCopy2dBytes(payload.Transactions),
Withdrawals: CopyWithdrawalSlice(payload.Withdrawals),
}
}
// CopyHistoricalSummaries copies the historical summaries.
func CopyHistoricalSummaries(summaries []*HistoricalSummary) []*HistoricalSummary {
if summaries == nil {

View File

@@ -329,6 +329,16 @@ func TestCopyPayloadHeaderCapella(t *testing.T) {
assert.NotEmpty(t, got, "Copied execution payload header has empty fields")
}
func TestCopyPayloadHeaderDeneb(t *testing.T) {
p := genPayloadHeaderDeneb()
got := v1alpha1.CopyExecutionPayloadHeaderDeneb(p)
if !reflect.DeepEqual(got, p) {
t.Errorf("TestCopyPayloadHeaderDeneb() = %v, want %v", got, p)
}
assert.NotEmpty(t, got, "Copied execution payload header has empty fields")
}
func TestCopySignedBeaconBlockBellatrix(t *testing.T) {
sbb := genSignedBeaconBlockBellatrix()
@@ -449,6 +459,66 @@ func TestCopyBlindedBeaconBlockBodyCapella(t *testing.T) {
assert.NotEmpty(t, bb, "Copied blinded beacon block body Capella has empty fields")
}
func TestCopySignedBeaconBlockDeneb(t *testing.T) {
sbb := genSignedBeaconBlockDeneb()
got := v1alpha1.CopySignedBeaconBlockDeneb(sbb)
if !reflect.DeepEqual(got, sbb) {
t.Errorf("CopySignedBeaconBlockDeneb() = %v, want %v", got, sbb)
}
assert.NotEmpty(t, sbb, "Copied signed beacon block Deneb has empty fields")
}
func TestCopyBeaconBlockDeneb(t *testing.T) {
b := genBeaconBlockDeneb()
got := v1alpha1.CopyBeaconBlockDeneb(b)
if !reflect.DeepEqual(got, b) {
t.Errorf("CopyBeaconBlockDeneb() = %v, want %v", got, b)
}
assert.NotEmpty(t, b, "Copied beacon block Deneb has empty fields")
}
func TestCopyBeaconBlockBodyDeneb(t *testing.T) {
bb := genBeaconBlockBodyDeneb()
got := v1alpha1.CopyBeaconBlockBodyDeneb(bb)
if !reflect.DeepEqual(got, bb) {
t.Errorf("CopyBeaconBlockBodyDeneb() = %v, want %v", got, bb)
}
assert.NotEmpty(t, bb, "Copied beacon block body Deneb has empty fields")
}
func TestCopySignedBlindedBeaconBlockDeneb(t *testing.T) {
sbb := genSignedBlindedBeaconBlockDeneb()
got := v1alpha1.CopySignedBlindedBeaconBlockDeneb(sbb)
if !reflect.DeepEqual(got, sbb) {
t.Errorf("CopySignedBlindedBeaconBlockDeneb() = %v, want %v", got, sbb)
}
assert.NotEmpty(t, sbb, "Copied signed blinded beacon block Deneb has empty fields")
}
func TestCopyBlindedBeaconBlockDeneb(t *testing.T) {
b := genBlindedBeaconBlockDeneb()
got := v1alpha1.CopyBlindedBeaconBlockDeneb(b)
if !reflect.DeepEqual(got, b) {
t.Errorf("CopyBlindedBeaconBlockDeneb() = %v, want %v", got, b)
}
assert.NotEmpty(t, b, "Copied blinded beacon block Deneb has empty fields")
}
func TestCopyBlindedBeaconBlockBodyDeneb(t *testing.T) {
bb := genBlindedBeaconBlockBodyDeneb()
got := v1alpha1.CopyBlindedBeaconBlockBodyDeneb(bb)
if !reflect.DeepEqual(got, bb) {
t.Errorf("CopyBlindedBeaconBlockBodyDeneb() = %v, want %v", got, bb)
}
assert.NotEmpty(t, bb, "Copied blinded beacon block body Deneb has empty fields")
}
func bytes(length int) []byte {
b := make([]byte, length)
for i := 0; i < length; i++ {
@@ -838,6 +908,82 @@ func genSignedBlindedBeaconBlockCapella() *v1alpha1.SignedBlindedBeaconBlockCape
}
}
func genBeaconBlockBodyDeneb() *v1alpha1.BeaconBlockBodyDeneb {
return &v1alpha1.BeaconBlockBodyDeneb{
RandaoReveal: bytes(96),
Eth1Data: genEth1Data(),
Graffiti: bytes(32),
ProposerSlashings: genProposerSlashings(5),
AttesterSlashings: genAttesterSlashings(5),
Attestations: genAttestations(10),
Deposits: genDeposits(5),
VoluntaryExits: genSignedVoluntaryExits(12),
SyncAggregate: genSyncAggregate(),
ExecutionPayload: genPayloadDeneb(),
BlsToExecutionChanges: genBLSToExecutionChanges(10),
BlobKzgCommitments: getKZGCommitments(4),
}
}
func genBeaconBlockDeneb() *v1alpha1.BeaconBlockDeneb {
return &v1alpha1.BeaconBlockDeneb{
Slot: 123455,
ProposerIndex: 55433,
ParentRoot: bytes(32),
StateRoot: bytes(32),
Body: genBeaconBlockBodyDeneb(),
}
}
func genSignedBeaconBlockDeneb() *v1alpha1.SignedBeaconBlockDeneb {
return &v1alpha1.SignedBeaconBlockDeneb{
Block: genBeaconBlockDeneb(),
Signature: bytes(96),
}
}
func genBlindedBeaconBlockBodyDeneb() *v1alpha1.BlindedBeaconBlockBodyDeneb {
return &v1alpha1.BlindedBeaconBlockBodyDeneb{
RandaoReveal: bytes(96),
Eth1Data: genEth1Data(),
Graffiti: bytes(32),
ProposerSlashings: genProposerSlashings(5),
AttesterSlashings: genAttesterSlashings(5),
Attestations: genAttestations(10),
Deposits: genDeposits(5),
VoluntaryExits: genSignedVoluntaryExits(12),
SyncAggregate: genSyncAggregate(),
ExecutionPayloadHeader: genPayloadHeaderDeneb(),
BlsToExecutionChanges: genBLSToExecutionChanges(10),
BlobKzgCommitments: getKZGCommitments(4),
}
}
func getKZGCommitments(n int) [][]byte {
kzgs := make([][]byte, n)
for i := 0; i < n; i++ {
kzgs[i] = bytes(48)
}
return kzgs
}
func genBlindedBeaconBlockDeneb() *v1alpha1.BlindedBeaconBlockDeneb {
return &v1alpha1.BlindedBeaconBlockDeneb{
Slot: 123455,
ProposerIndex: 55433,
ParentRoot: bytes(32),
StateRoot: bytes(32),
Body: genBlindedBeaconBlockBodyDeneb(),
}
}
func genSignedBlindedBeaconBlockDeneb() *v1alpha1.SignedBlindedBeaconBlockDeneb {
return &v1alpha1.SignedBlindedBeaconBlockDeneb{
Block: genBlindedBeaconBlockDeneb(),
Signature: bytes(32),
}
}
func genSyncCommitteeMessage() *v1alpha1.SyncCommitteeMessage {
return &v1alpha1.SyncCommitteeMessage{
Slot: 424555,
@@ -899,6 +1045,40 @@ func genPayloadCapella() *enginev1.ExecutionPayloadCapella {
}
}
func genPayloadDeneb() *enginev1.ExecutionPayloadDeneb {
return &enginev1.ExecutionPayloadDeneb{
ParentHash: bytes(32),
FeeRecipient: bytes(20),
StateRoot: bytes(32),
ReceiptsRoot: bytes(32),
LogsBloom: bytes(256),
PrevRandao: bytes(32),
BlockNumber: 1,
GasLimit: 2,
GasUsed: 3,
Timestamp: 4,
ExtraData: bytes(32),
BaseFeePerGas: bytes(32),
BlockHash: bytes(32),
Transactions: [][]byte{{'a'}, {'b'}, {'c'}},
Withdrawals: []*enginev1.Withdrawal{
{
Index: 123,
ValidatorIndex: 123,
Address: bytes(20),
Amount: 123,
},
{
Index: 124,
ValidatorIndex: 456,
Address: bytes(20),
Amount: 456,
},
},
ExcessDataGas: bytes(32),
}
}
func genPayloadHeader() *enginev1.ExecutionPayloadHeader {
return &enginev1.ExecutionPayloadHeader{
ParentHash: bytes(32),
@@ -938,6 +1118,27 @@ func genPayloadHeaderCapella() *enginev1.ExecutionPayloadHeaderCapella {
}
}
func genPayloadHeaderDeneb() *enginev1.ExecutionPayloadHeaderDeneb {
return &enginev1.ExecutionPayloadHeaderDeneb{
ParentHash: bytes(32),
FeeRecipient: bytes(20),
StateRoot: bytes(32),
ReceiptsRoot: bytes(32),
LogsBloom: bytes(256),
PrevRandao: bytes(32),
BlockNumber: 1,
GasLimit: 2,
GasUsed: 3,
Timestamp: 4,
ExtraData: bytes(32),
BaseFeePerGas: bytes(32),
BlockHash: bytes(32),
TransactionsRoot: bytes(32),
WithdrawalsRoot: bytes(32),
ExcessDataGas: bytes(32),
}
}
func genWithdrawals(num int) []*enginev1.Withdrawal {
ws := make([]*enginev1.Withdrawal, num)
for i := 0; i < num; i++ {