mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Capella beacon block (#11566)
* in progress * done, no tests yet * fix ToBlinded() * Revert "Auxiliary commit to revert individual files from 2e356b6f5b15d409ac15e825c744528591c13739" This reverts commit 081ab74e88fb7d0e3f6a81e00fe5e89483b41f90. * tests * fix tests * one more fix * and one more * review * fix proto_test * another fix * do not return error when nil object is wrapped * allow nil payload in body.Proto() * correctly assert error * nil checks in body.Execution() * simplify PR * Revert "Auxiliary commit to revert individual files from 5736c1f22f2d2f309b9303c13d0fb6b1679c6ecb" This reverts commit 1ff3a4c864923f5c180aa015aa087a2814498b42. * fix slice sizes in cloner tests * better payload tests * review Co-authored-by: terencechain <terence@prysmaticlabs.com>
This commit is contained in:
@@ -81,6 +81,113 @@ func TestWrapExecutionPayloadHeader_SSZ(t *testing.T) {
|
||||
assert.NoError(t, wsb.UnmarshalSSZ(encoded))
|
||||
}
|
||||
|
||||
func TestWrapExecutionPayloadCapella(t *testing.T) {
|
||||
data := &enginev1.ExecutionPayloadCapella{
|
||||
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{{
|
||||
WithdrawalIndex: 55,
|
||||
ValidatorIndex: 66,
|
||||
ExecutionAddress: []byte("executionaddress"),
|
||||
Amount: 77,
|
||||
}},
|
||||
}
|
||||
payload, err := blocks.WrappedExecutionPayloadCapella(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.DeepEqual(t, data, payload.Proto())
|
||||
}
|
||||
|
||||
func TestWrapExecutionPayloadHeaderCapella(t *testing.T) {
|
||||
data := &enginev1.ExecutionPayloadHeaderCapella{
|
||||
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"),
|
||||
}
|
||||
payload, err := blocks.WrappedExecutionPayloadHeaderCapella(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.DeepEqual(t, data, payload.Proto())
|
||||
}
|
||||
|
||||
func TestWrapExecutionPayloadCapella_IsNil(t *testing.T) {
|
||||
_, err := blocks.WrappedExecutionPayloadCapella(nil)
|
||||
require.Equal(t, blocks.ErrNilObjectWrapped, err)
|
||||
|
||||
data := &enginev1.ExecutionPayloadCapella{GasUsed: 54}
|
||||
payload, err := blocks.WrappedExecutionPayloadCapella(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, false, payload.IsNil())
|
||||
}
|
||||
|
||||
func TestWrapExecutionPayloadHeaderCapella_IsNil(t *testing.T) {
|
||||
_, err := blocks.WrappedExecutionPayloadHeaderCapella(nil)
|
||||
require.Equal(t, blocks.ErrNilObjectWrapped, err)
|
||||
|
||||
data := &enginev1.ExecutionPayloadHeaderCapella{GasUsed: 54}
|
||||
payload, err := blocks.WrappedExecutionPayloadHeaderCapella(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, false, payload.IsNil())
|
||||
}
|
||||
|
||||
func TestWrapExecutionPayloadCapella_SSZ(t *testing.T) {
|
||||
payload := createWrappedPayloadCapella(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 TestWrapExecutionPayloadHeaderCapella_SSZ(t *testing.T) {
|
||||
payload := createWrappedPayloadHeaderCapella(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),
|
||||
@@ -122,3 +229,47 @@ func createWrappedPayloadHeader(t testing.TB) interfaces.ExecutionData {
|
||||
require.NoError(t, err)
|
||||
return wsb
|
||||
}
|
||||
|
||||
func createWrappedPayloadCapella(t testing.TB) interfaces.ExecutionData {
|
||||
payload, err := blocks.WrappedExecutionPayloadCapella(&enginev1.ExecutionPayloadCapella{
|
||||
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),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
return payload
|
||||
}
|
||||
|
||||
func createWrappedPayloadHeaderCapella(t testing.TB) interfaces.ExecutionData {
|
||||
payload, err := blocks.WrappedExecutionPayloadHeaderCapella(&enginev1.ExecutionPayloadHeaderCapella{
|
||||
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),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
return payload
|
||||
}
|
||||
|
||||
@@ -47,6 +47,14 @@ func NewSignedBeaconBlock(i interface{}) (interfaces.SignedBeaconBlock, error) {
|
||||
return initBlindedSignedBlockFromProtoBellatrix(b.BlindedBellatrix)
|
||||
case *eth.SignedBlindedBeaconBlockBellatrix:
|
||||
return initBlindedSignedBlockFromProtoBellatrix(b)
|
||||
case *eth.GenericSignedBeaconBlock_Capella:
|
||||
return initSignedBlockFromProtoCapella(b.Capella)
|
||||
case *eth.SignedBeaconBlockCapella:
|
||||
return initSignedBlockFromProtoCapella(b)
|
||||
case *eth.GenericSignedBeaconBlock_BlindedCapella:
|
||||
return initBlindedSignedBlockFromProtoCapella(b.BlindedCapella)
|
||||
case *eth.SignedBlindedBeaconBlockCapella:
|
||||
return initBlindedSignedBlockFromProtoCapella(b)
|
||||
default:
|
||||
return nil, errors.Wrapf(ErrUnsupportedSignedBeaconBlock, "unable to create block from type %T", i)
|
||||
}
|
||||
@@ -73,6 +81,14 @@ func NewBeaconBlock(i interface{}) (interfaces.BeaconBlock, error) {
|
||||
return initBlindedBlockFromProtoBellatrix(b.BlindedBellatrix)
|
||||
case *eth.BlindedBeaconBlockBellatrix:
|
||||
return initBlindedBlockFromProtoBellatrix(b)
|
||||
case *eth.GenericBeaconBlock_Capella:
|
||||
return initBlockFromProtoCapella(b.Capella)
|
||||
case *eth.BeaconBlockCapella:
|
||||
return initBlockFromProtoCapella(b)
|
||||
case *eth.GenericBeaconBlock_BlindedCapella:
|
||||
return initBlindedBlockFromProtoCapella(b.BlindedCapella)
|
||||
case *eth.BlindedBeaconBlockCapella:
|
||||
return initBlindedBlockFromProtoCapella(b)
|
||||
default:
|
||||
return nil, errors.Wrapf(errUnsupportedBeaconBlock, "unable to create block from type %T", i)
|
||||
}
|
||||
@@ -91,6 +107,10 @@ func NewBeaconBlockBody(i interface{}) (interfaces.BeaconBlockBody, error) {
|
||||
return initBlockBodyFromProtoBellatrix(b)
|
||||
case *eth.BlindedBeaconBlockBodyBellatrix:
|
||||
return initBlindedBlockBodyFromProtoBellatrix(b)
|
||||
case *eth.BeaconBlockBodyCapella:
|
||||
return initBlockBodyFromProtoCapella(b)
|
||||
case *eth.BlindedBeaconBlockBodyCapella:
|
||||
return initBlindedBlockBodyFromProtoCapella(b)
|
||||
default:
|
||||
return nil, errors.Wrapf(errUnsupportedBeaconBlockBody, "unable to create block body from type %T", i)
|
||||
}
|
||||
@@ -131,6 +151,19 @@ func BuildSignedBeaconBlock(blk interfaces.BeaconBlock, signature []byte) (inter
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
return NewSignedBeaconBlock(ð.SignedBeaconBlockBellatrix{Block: pb, Signature: signature})
|
||||
case version.Capella:
|
||||
if blk.IsBlinded() {
|
||||
pb, ok := pb.(*eth.BlindedBeaconBlockCapella)
|
||||
if !ok {
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
return NewSignedBeaconBlock(ð.SignedBlindedBeaconBlockCapella{Block: pb, Signature: signature})
|
||||
}
|
||||
pb, ok := pb.(*eth.BeaconBlockCapella)
|
||||
if !ok {
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
return NewSignedBeaconBlock(ð.SignedBeaconBlockCapella{Block: pb, Signature: signature})
|
||||
default:
|
||||
return nil, errUnsupportedBeaconBlock
|
||||
}
|
||||
@@ -139,7 +172,7 @@ func BuildSignedBeaconBlock(blk interfaces.BeaconBlock, signature []byte) (inter
|
||||
// BuildSignedBeaconBlockFromExecutionPayload takes a signed, blinded beacon block and converts into
|
||||
// a full, signed beacon block by specifying an execution payload.
|
||||
func BuildSignedBeaconBlockFromExecutionPayload(
|
||||
blk interfaces.SignedBeaconBlock, payload *enginev1.ExecutionPayload,
|
||||
blk interfaces.SignedBeaconBlock, payload interface{},
|
||||
) (interfaces.SignedBeaconBlock, error) {
|
||||
if err := BeaconBlockIsNil(blk); err != nil {
|
||||
return nil, err
|
||||
@@ -153,16 +186,26 @@ func BuildSignedBeaconBlockFromExecutionPayload(
|
||||
return nil, errors.Wrap(err, "could not get execution payload header")
|
||||
default:
|
||||
}
|
||||
wrappedPayload, err := WrappedExecutionPayload(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
var wrappedPayload interfaces.ExecutionData
|
||||
var wrapErr error
|
||||
switch p := payload.(type) {
|
||||
case *enginev1.ExecutionPayload:
|
||||
wrappedPayload, wrapErr = WrappedExecutionPayload(p)
|
||||
case *enginev1.ExecutionPayloadCapella:
|
||||
wrappedPayload, wrapErr = WrappedExecutionPayloadCapella(p)
|
||||
default:
|
||||
return nil, fmt.Errorf("%T is not a type of execution payload", p)
|
||||
}
|
||||
if wrapErr != nil {
|
||||
return nil, wrapErr
|
||||
}
|
||||
empty, err := IsEmptyExecutionData(wrappedPayload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !empty {
|
||||
payloadRoot, err := payload.HashTreeRoot()
|
||||
payloadRoot, err := wrappedPayload.HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not hash tree root execution payload")
|
||||
}
|
||||
@@ -187,26 +230,61 @@ func BuildSignedBeaconBlockFromExecutionPayload(
|
||||
randaoReveal := b.Body().RandaoReveal()
|
||||
graffiti := b.Body().Graffiti()
|
||||
sig := blk.Signature()
|
||||
bellatrixFullBlock := ð.SignedBeaconBlockBellatrix{
|
||||
Block: ð.BeaconBlockBellatrix{
|
||||
Slot: b.Slot(),
|
||||
ProposerIndex: b.ProposerIndex(),
|
||||
ParentRoot: parentRoot[:],
|
||||
StateRoot: stateRoot[:],
|
||||
Body: ð.BeaconBlockBodyBellatrix{
|
||||
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: payload,
|
||||
|
||||
var fullBlock interface{}
|
||||
switch p := payload.(type) {
|
||||
case *enginev1.ExecutionPayload:
|
||||
fullBlock = ð.SignedBeaconBlockBellatrix{
|
||||
Block: ð.BeaconBlockBellatrix{
|
||||
Slot: b.Slot(),
|
||||
ProposerIndex: b.ProposerIndex(),
|
||||
ParentRoot: parentRoot[:],
|
||||
StateRoot: stateRoot[:],
|
||||
Body: ð.BeaconBlockBodyBellatrix{
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
Signature: sig[:],
|
||||
Signature: sig[:],
|
||||
}
|
||||
case *enginev1.ExecutionPayloadCapella:
|
||||
blsToExecutionChanges, err := b.Body().BLSToExecutionChanges()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fullBlock = ð.SignedBeaconBlockCapella{
|
||||
Block: ð.BeaconBlockCapella{
|
||||
Slot: b.Slot(),
|
||||
ProposerIndex: b.ProposerIndex(),
|
||||
ParentRoot: parentRoot[:],
|
||||
StateRoot: stateRoot[:],
|
||||
Body: ð.BeaconBlockBodyCapella{
|
||||
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,
|
||||
},
|
||||
},
|
||||
Signature: sig[:],
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("%T is not a type of execution payload", p)
|
||||
}
|
||||
return NewSignedBeaconBlock(bellatrixFullBlock)
|
||||
|
||||
return NewSignedBeaconBlock(fullBlock)
|
||||
}
|
||||
|
||||
@@ -85,6 +85,42 @@ func Test_NewSignedBeaconBlock(t *testing.T) {
|
||||
assert.Equal(t, version.Bellatrix, b.Version())
|
||||
assert.Equal(t, true, b.IsBlinded())
|
||||
})
|
||||
t.Run("GenericSignedBeaconBlock_Capella", func(t *testing.T) {
|
||||
pb := ð.GenericSignedBeaconBlock_Capella{
|
||||
Capella: ð.SignedBeaconBlockCapella{
|
||||
Block: ð.BeaconBlockCapella{
|
||||
Body: ð.BeaconBlockBodyCapella{}}}}
|
||||
b, err := NewSignedBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, b.Version())
|
||||
})
|
||||
t.Run("SignedBeaconBlockCapella", func(t *testing.T) {
|
||||
pb := ð.SignedBeaconBlockCapella{
|
||||
Block: ð.BeaconBlockCapella{
|
||||
Body: ð.BeaconBlockBodyCapella{}}}
|
||||
b, err := NewSignedBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, b.Version())
|
||||
})
|
||||
t.Run("GenericSignedBeaconBlock_BlindedCapella", func(t *testing.T) {
|
||||
pb := ð.GenericSignedBeaconBlock_BlindedCapella{
|
||||
BlindedCapella: ð.SignedBlindedBeaconBlockCapella{
|
||||
Block: ð.BlindedBeaconBlockCapella{
|
||||
Body: ð.BlindedBeaconBlockBodyCapella{}}}}
|
||||
b, err := NewSignedBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, b.Version())
|
||||
assert.Equal(t, true, b.IsBlinded())
|
||||
})
|
||||
t.Run("SignedBlindedBeaconBlockCapella", func(t *testing.T) {
|
||||
pb := ð.SignedBlindedBeaconBlockCapella{
|
||||
Block: ð.BlindedBeaconBlockCapella{
|
||||
Body: ð.BlindedBeaconBlockBodyCapella{}}}
|
||||
b, err := NewSignedBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, 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)
|
||||
@@ -146,6 +182,32 @@ func Test_NewBeaconBlock(t *testing.T) {
|
||||
assert.Equal(t, version.Bellatrix, b.Version())
|
||||
assert.Equal(t, true, b.IsBlinded())
|
||||
})
|
||||
t.Run("GenericBeaconBlock_Capella", func(t *testing.T) {
|
||||
pb := ð.GenericBeaconBlock_Capella{Capella: ð.BeaconBlockCapella{Body: ð.BeaconBlockBodyCapella{}}}
|
||||
b, err := NewBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, b.Version())
|
||||
})
|
||||
t.Run("BeaconBlockCapella", func(t *testing.T) {
|
||||
pb := ð.BeaconBlockCapella{Body: ð.BeaconBlockBodyCapella{}}
|
||||
b, err := NewBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, b.Version())
|
||||
})
|
||||
t.Run("GenericBeaconBlock_BlindedCapella", func(t *testing.T) {
|
||||
pb := ð.GenericBeaconBlock_BlindedCapella{BlindedCapella: ð.BlindedBeaconBlockCapella{Body: ð.BlindedBeaconBlockBodyCapella{}}}
|
||||
b, err := NewBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, b.Version())
|
||||
assert.Equal(t, true, b.IsBlinded())
|
||||
})
|
||||
t.Run("BlindedBeaconBlockCapella", func(t *testing.T) {
|
||||
pb := ð.BlindedBeaconBlockCapella{Body: ð.BlindedBeaconBlockBodyCapella{}}
|
||||
b, err := NewBeaconBlock(pb)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, version.Capella, 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)
|
||||
@@ -190,6 +252,23 @@ func Test_NewBeaconBlockBody(t *testing.T) {
|
||||
assert.Equal(t, version.Bellatrix, b.version)
|
||||
assert.Equal(t, true, b.isBlinded)
|
||||
})
|
||||
t.Run("BeaconBlockBodyCapella", func(t *testing.T) {
|
||||
pb := ð.BeaconBlockBodyCapella{}
|
||||
i, err := NewBeaconBlockBody(pb)
|
||||
require.NoError(t, err)
|
||||
b, ok := i.(*BeaconBlockBody)
|
||||
require.Equal(t, true, ok)
|
||||
assert.Equal(t, version.Capella, b.version)
|
||||
})
|
||||
t.Run("BlindedBeaconBlockBodyCapella", func(t *testing.T) {
|
||||
pb := ð.BlindedBeaconBlockBodyCapella{}
|
||||
i, err := NewBeaconBlockBody(pb)
|
||||
require.NoError(t, err)
|
||||
b, ok := i.(*BeaconBlockBody)
|
||||
require.Equal(t, true, ok)
|
||||
assert.Equal(t, version.Capella, 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)
|
||||
@@ -231,6 +310,21 @@ func Test_BuildSignedBeaconBlock(t *testing.T) {
|
||||
assert.Equal(t, version.Bellatrix, sb.Version())
|
||||
assert.Equal(t, true, sb.IsBlinded())
|
||||
})
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
b := &BeaconBlock{version: version.Capella, body: &BeaconBlockBody{version: version.Capella}}
|
||||
sb, err := BuildSignedBeaconBlock(b, sig[:])
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, sig, sb.Signature())
|
||||
assert.Equal(t, version.Capella, sb.Version())
|
||||
})
|
||||
t.Run("CapellaBlind", func(t *testing.T) {
|
||||
b := &BeaconBlock{version: version.Capella, body: &BeaconBlockBody{version: version.Capella, isBlinded: true}}
|
||||
sb, err := BuildSignedBeaconBlock(b, sig[:])
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, sig, sb.Signature())
|
||||
assert.Equal(t, version.Capella, sb.Version())
|
||||
assert.Equal(t, true, sb.IsBlinded())
|
||||
})
|
||||
}
|
||||
|
||||
func TestBuildSignedBeaconBlockFromExecutionPayload(t *testing.T) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package blocks
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
ssz "github.com/prysmaticlabs/fastssz"
|
||||
field_params "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/validator-client"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
@@ -60,6 +63,13 @@ func (b *SignedBeaconBlock) Copy() (interfaces.SignedBeaconBlock, error) {
|
||||
}
|
||||
cp := eth.CopySignedBeaconBlockBellatrix(pb.(*eth.SignedBeaconBlockBellatrix))
|
||||
return initSignedBlockFromProtoBellatrix(cp)
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
cp := eth.CopySignedBlindedBeaconBlockCapella(pb.(*eth.SignedBlindedBeaconBlockCapella))
|
||||
return initBlindedSignedBlockFromProtoCapella(cp)
|
||||
}
|
||||
cp := eth.CopySignedBeaconBlockCapella(pb.(*eth.SignedBeaconBlockCapella))
|
||||
return initSignedBlockFromProtoCapella(cp)
|
||||
default:
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -89,6 +99,15 @@ func (b *SignedBeaconBlock) PbGenericBlock() (*eth.GenericSignedBeaconBlock, err
|
||||
return ð.GenericSignedBeaconBlock{
|
||||
Block: ð.GenericSignedBeaconBlock_Bellatrix{Bellatrix: pb.(*eth.SignedBeaconBlockBellatrix)},
|
||||
}, nil
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return ð.GenericSignedBeaconBlock{
|
||||
Block: ð.GenericSignedBeaconBlock_BlindedCapella{BlindedCapella: pb.(*eth.SignedBlindedBeaconBlockCapella)},
|
||||
}, nil
|
||||
}
|
||||
return ð.GenericSignedBeaconBlock{
|
||||
Block: ð.GenericSignedBeaconBlock_Capella{Capella: pb.(*eth.SignedBeaconBlockCapella)},
|
||||
}, nil
|
||||
default:
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -143,9 +162,33 @@ func (b *SignedBeaconBlock) PbBlindedBellatrixBlock() (*eth.SignedBlindedBeaconB
|
||||
return pb.(*eth.SignedBlindedBeaconBlockBellatrix), nil
|
||||
}
|
||||
|
||||
// PbCapellaBlock returns the underlying protobuf object.
|
||||
func (b *SignedBeaconBlock) PbCapellaBlock() (*eth.SignedBeaconBlockCapella, error) {
|
||||
if b.version != version.Capella || b.IsBlinded() {
|
||||
return nil, errNotSupported("PbCapellaBlock", b.version)
|
||||
}
|
||||
pb, err := b.Proto()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockCapella), nil
|
||||
}
|
||||
|
||||
// PbBlindedCapellaBlock returns the underlying protobuf object.
|
||||
func (b *SignedBeaconBlock) PbBlindedCapellaBlock() (*eth.SignedBlindedBeaconBlockCapella, error) {
|
||||
if b.version != version.Capella || !b.IsBlinded() {
|
||||
return nil, errNotSupported("PbBlindedCapellaBlock", b.version)
|
||||
}
|
||||
pb, err := b.Proto()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pb.(*eth.SignedBlindedBeaconBlockCapella), nil
|
||||
}
|
||||
|
||||
// ToBlinded converts a non-blinded block to its blinded equivalent.
|
||||
func (b *SignedBeaconBlock) ToBlinded() (interfaces.SignedBeaconBlock, error) {
|
||||
if b.version != version.Bellatrix {
|
||||
if b.version < version.Bellatrix {
|
||||
return nil, ErrUnsupportedVersion
|
||||
}
|
||||
if b.IsBlinded() {
|
||||
@@ -158,32 +201,66 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.SignedBeaconBlock, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
header, err := PayloadToHeader(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return initBlindedSignedBlockFromProtoBellatrix(
|
||||
ð.SignedBlindedBeaconBlockBellatrix{
|
||||
Block: ð.BlindedBeaconBlockBellatrix{
|
||||
Slot: b.block.slot,
|
||||
ProposerIndex: b.block.proposerIndex,
|
||||
ParentRoot: b.block.parentRoot[:],
|
||||
StateRoot: b.block.stateRoot[:],
|
||||
Body: ð.BlindedBeaconBlockBodyBellatrix{
|
||||
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,
|
||||
|
||||
switch p := payload.Proto().(type) {
|
||||
case *enginev1.ExecutionPayload:
|
||||
header, err := PayloadToHeader(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return initBlindedSignedBlockFromProtoBellatrix(
|
||||
ð.SignedBlindedBeaconBlockBellatrix{
|
||||
Block: ð.BlindedBeaconBlockBellatrix{
|
||||
Slot: b.block.slot,
|
||||
ProposerIndex: b.block.proposerIndex,
|
||||
ParentRoot: b.block.parentRoot[:],
|
||||
StateRoot: b.block.stateRoot[:],
|
||||
Body: ð.BlindedBeaconBlockBodyBellatrix{
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
Signature: b.signature[:],
|
||||
})
|
||||
Signature: b.signature[:],
|
||||
})
|
||||
case *enginev1.ExecutionPayloadCapella:
|
||||
header, err := PayloadToHeaderCapella(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return initBlindedSignedBlockFromProtoCapella(
|
||||
ð.SignedBlindedBeaconBlockCapella{
|
||||
Block: ð.BlindedBeaconBlockCapella{
|
||||
Slot: b.block.slot,
|
||||
ProposerIndex: b.block.proposerIndex,
|
||||
ParentRoot: b.block.parentRoot[:],
|
||||
StateRoot: b.block.stateRoot[:],
|
||||
Body: ð.BlindedBeaconBlockBodyCapella{
|
||||
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,
|
||||
},
|
||||
},
|
||||
Signature: b.signature[:],
|
||||
})
|
||||
default:
|
||||
return nil, fmt.Errorf("%T is not an execution payload header", p)
|
||||
}
|
||||
}
|
||||
|
||||
// Version of the underlying protobuf object.
|
||||
@@ -233,6 +310,11 @@ func (b *SignedBeaconBlock) MarshalSSZ() ([]byte, error) {
|
||||
return pb.(*eth.SignedBlindedBeaconBlockBellatrix).MarshalSSZ()
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockBellatrix).MarshalSSZ()
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.SignedBlindedBeaconBlockCapella).MarshalSSZ()
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockCapella).MarshalSSZ()
|
||||
default:
|
||||
return []byte{}, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -255,6 +337,11 @@ func (b *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
return pb.(*eth.SignedBlindedBeaconBlockBellatrix).MarshalSSZTo(dst)
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockBellatrix).MarshalSSZTo(dst)
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.SignedBlindedBeaconBlockCapella).MarshalSSZTo(dst)
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockCapella).MarshalSSZTo(dst)
|
||||
default:
|
||||
return []byte{}, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -281,6 +368,11 @@ func (b *SignedBeaconBlock) SizeSSZ() int {
|
||||
return pb.(*eth.SignedBlindedBeaconBlockBellatrix).SizeSSZ()
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockBellatrix).SizeSSZ()
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.SignedBlindedBeaconBlockCapella).SizeSSZ()
|
||||
}
|
||||
return pb.(*eth.SignedBeaconBlockCapella).SizeSSZ()
|
||||
default:
|
||||
panic(incorrectBlockVersion)
|
||||
}
|
||||
@@ -332,6 +424,28 @@ func (b *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
pb := ð.SignedBlindedBeaconBlockCapella{}
|
||||
if err := pb.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
newBlock, err = initBlindedSignedBlockFromProtoCapella(pb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
pb := ð.SignedBeaconBlockCapella{}
|
||||
if err := pb.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
newBlock, err = initSignedBlockFromProtoCapella(pb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
default:
|
||||
return errIncorrectBlockVersion
|
||||
}
|
||||
@@ -395,6 +509,11 @@ func (b *BeaconBlock) HashTreeRoot() ([field_params.RootLength]byte, error) {
|
||||
return pb.(*eth.BlindedBeaconBlockBellatrix).HashTreeRoot()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBellatrix).HashTreeRoot()
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.BlindedBeaconBlockCapella).HashTreeRoot()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockCapella).HashTreeRoot()
|
||||
default:
|
||||
return [field_params.RootLength]byte{}, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -416,6 +535,11 @@ func (b *BeaconBlock) HashTreeRootWith(h *ssz.Hasher) error {
|
||||
return pb.(*eth.BlindedBeaconBlockBellatrix).HashTreeRootWith(h)
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBellatrix).HashTreeRootWith(h)
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.BlindedBeaconBlockCapella).HashTreeRootWith(h)
|
||||
}
|
||||
return pb.(*eth.BeaconBlockCapella).HashTreeRootWith(h)
|
||||
default:
|
||||
return errIncorrectBlockVersion
|
||||
}
|
||||
@@ -438,6 +562,11 @@ func (b *BeaconBlock) MarshalSSZ() ([]byte, error) {
|
||||
return pb.(*eth.BlindedBeaconBlockBellatrix).MarshalSSZ()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBellatrix).MarshalSSZ()
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.BlindedBeaconBlockCapella).MarshalSSZ()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockCapella).MarshalSSZ()
|
||||
default:
|
||||
return []byte{}, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -460,6 +589,11 @@ func (b *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
return pb.(*eth.BlindedBeaconBlockBellatrix).MarshalSSZTo(dst)
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBellatrix).MarshalSSZTo(dst)
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.BlindedBeaconBlockCapella).MarshalSSZTo(dst)
|
||||
}
|
||||
return pb.(*eth.BeaconBlockCapella).MarshalSSZTo(dst)
|
||||
default:
|
||||
return []byte{}, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -486,6 +620,11 @@ func (b *BeaconBlock) SizeSSZ() int {
|
||||
return pb.(*eth.BlindedBeaconBlockBellatrix).SizeSSZ()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBellatrix).SizeSSZ()
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return pb.(*eth.BlindedBeaconBlockCapella).SizeSSZ()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockCapella).SizeSSZ()
|
||||
default:
|
||||
panic(incorrectBodyVersion)
|
||||
}
|
||||
@@ -537,6 +676,28 @@ func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
pb := ð.BlindedBeaconBlockCapella{}
|
||||
if err := pb.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
newBlock, err = initBlindedBlockFromProtoCapella(pb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
pb := ð.BeaconBlockCapella{}
|
||||
if err := pb.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
newBlock, err = initBlockFromProtoCapella(pb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
default:
|
||||
return errIncorrectBlockVersion
|
||||
}
|
||||
@@ -560,6 +721,11 @@ func (b *BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, erro
|
||||
return &validatorpb.SignRequest_BlindedBlockBellatrix{BlindedBlockBellatrix: pb.(*eth.BlindedBeaconBlockBellatrix)}, nil
|
||||
}
|
||||
return &validatorpb.SignRequest_BlockBellatrix{BlockBellatrix: pb.(*eth.BeaconBlockBellatrix)}, nil
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
return &validatorpb.SignRequest_BlindedBlockCapella{BlindedBlockCapella: pb.(*eth.BlindedBeaconBlockCapella)}, nil
|
||||
}
|
||||
return &validatorpb.SignRequest_BlockCapella{BlockCapella: pb.(*eth.BeaconBlockCapella)}, nil
|
||||
default:
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
@@ -625,14 +791,58 @@ func (b *BeaconBlockBody) Execution() (interfaces.ExecutionData, error) {
|
||||
return nil, errNotSupported("Execution", b.version)
|
||||
case version.Bellatrix:
|
||||
if b.isBlinded {
|
||||
return WrappedExecutionPayloadHeader(b.executionPayloadHeader)
|
||||
var ph *enginev1.ExecutionPayloadHeader
|
||||
var ok bool
|
||||
if b.executionPayloadHeader != nil {
|
||||
ph, ok = b.executionPayloadHeader.Proto().(*enginev1.ExecutionPayloadHeader)
|
||||
if !ok {
|
||||
return nil, errPayloadHeaderWrongType
|
||||
}
|
||||
}
|
||||
return WrappedExecutionPayloadHeader(ph)
|
||||
}
|
||||
return WrappedExecutionPayload(b.executionPayload)
|
||||
var p *enginev1.ExecutionPayload
|
||||
var ok bool
|
||||
if b.executionPayload != nil {
|
||||
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayload)
|
||||
if !ok {
|
||||
return nil, errPayloadWrongType
|
||||
}
|
||||
}
|
||||
return WrappedExecutionPayload(p)
|
||||
case version.Capella:
|
||||
if b.isBlinded {
|
||||
var ph *enginev1.ExecutionPayloadHeaderCapella
|
||||
var ok bool
|
||||
if b.executionPayloadHeader != nil {
|
||||
ph, ok = b.executionPayloadHeader.Proto().(*enginev1.ExecutionPayloadHeaderCapella)
|
||||
if !ok {
|
||||
return nil, errPayloadHeaderWrongType
|
||||
}
|
||||
return WrappedExecutionPayloadHeaderCapella(ph)
|
||||
}
|
||||
}
|
||||
var p *enginev1.ExecutionPayloadCapella
|
||||
var ok bool
|
||||
if b.executionPayload != nil {
|
||||
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayloadCapella)
|
||||
if !ok {
|
||||
return nil, errPayloadWrongType
|
||||
}
|
||||
}
|
||||
return WrappedExecutionPayloadCapella(p)
|
||||
default:
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) BLSToExecutionChanges() ([]*eth.SignedBLSToExecutionChange, error) {
|
||||
if b.version < version.Capella {
|
||||
return nil, errNotSupported("BLSToExecutionChanges", b.version)
|
||||
}
|
||||
return b.blsToExecutionChanges, nil
|
||||
}
|
||||
|
||||
// HashTreeRoot returns the ssz root of the block body.
|
||||
func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error) {
|
||||
pb, err := b.Proto()
|
||||
@@ -649,6 +859,11 @@ func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error)
|
||||
return pb.(*eth.BlindedBeaconBlockBodyBellatrix).HashTreeRoot()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBodyBellatrix).HashTreeRoot()
|
||||
case version.Capella:
|
||||
if b.isBlinded {
|
||||
return pb.(*eth.BlindedBeaconBlockBodyCapella).HashTreeRoot()
|
||||
}
|
||||
return pb.(*eth.BeaconBlockBodyCapella).HashTreeRoot()
|
||||
default:
|
||||
return [field_params.RootLength]byte{}, errIncorrectBodyVersion
|
||||
}
|
||||
|
||||
@@ -309,6 +309,14 @@ func Test_BeaconBlockBody_SyncAggregate(t *testing.T) {
|
||||
assert.Equal(t, result, sa)
|
||||
}
|
||||
|
||||
func Test_BeaconBlockBody_BLSToExecutionChanges(t *testing.T) {
|
||||
changes := []*eth.SignedBLSToExecutionChange{{}}
|
||||
bb := &BeaconBlockBody{version: version.Capella, blsToExecutionChanges: changes}
|
||||
result, err := bb.BLSToExecutionChanges()
|
||||
require.NoError(t, err)
|
||||
assert.DeepSSZEqual(t, result, changes)
|
||||
}
|
||||
|
||||
func Test_BeaconBlockBody_HashTreeRoot(t *testing.T) {
|
||||
pb := hydrateBeaconBlockBody()
|
||||
expectedHTR, err := pb.HashTreeRoot()
|
||||
|
||||
@@ -3,6 +3,7 @@ package blocks
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -73,6 +74,33 @@ func (b *SignedBeaconBlock) Proto() (proto.Message, error) {
|
||||
Block: block,
|
||||
Signature: b.signature[:],
|
||||
}, nil
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
var block *eth.BlindedBeaconBlockCapella
|
||||
if blockMessage != nil {
|
||||
var ok bool
|
||||
block, ok = blockMessage.(*eth.BlindedBeaconBlockCapella)
|
||||
if !ok {
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
}
|
||||
return ð.SignedBlindedBeaconBlockCapella{
|
||||
Block: block,
|
||||
Signature: b.signature[:],
|
||||
}, nil
|
||||
}
|
||||
var block *eth.BeaconBlockCapella
|
||||
if blockMessage != nil {
|
||||
var ok bool
|
||||
block, ok = blockMessage.(*eth.BeaconBlockCapella)
|
||||
if !ok {
|
||||
return nil, errIncorrectBlockVersion
|
||||
}
|
||||
}
|
||||
return ð.SignedBeaconBlockCapella{
|
||||
Block: block,
|
||||
Signature: b.signature[:],
|
||||
}, nil
|
||||
default:
|
||||
return nil, errors.New("unsupported signed beacon block version")
|
||||
}
|
||||
@@ -155,6 +183,39 @@ func (b *BeaconBlock) Proto() (proto.Message, error) {
|
||||
StateRoot: b.stateRoot[:],
|
||||
Body: body,
|
||||
}, nil
|
||||
case version.Capella:
|
||||
if b.IsBlinded() {
|
||||
var body *eth.BlindedBeaconBlockBodyCapella
|
||||
if bodyMessage != nil {
|
||||
var ok bool
|
||||
body, ok = bodyMessage.(*eth.BlindedBeaconBlockBodyCapella)
|
||||
if !ok {
|
||||
return nil, errIncorrectBodyVersion
|
||||
}
|
||||
}
|
||||
return ð.BlindedBeaconBlockCapella{
|
||||
Slot: b.slot,
|
||||
ProposerIndex: b.proposerIndex,
|
||||
ParentRoot: b.parentRoot[:],
|
||||
StateRoot: b.stateRoot[:],
|
||||
Body: body,
|
||||
}, nil
|
||||
}
|
||||
var body *eth.BeaconBlockBodyCapella
|
||||
if bodyMessage != nil {
|
||||
var ok bool
|
||||
body, ok = bodyMessage.(*eth.BeaconBlockBodyCapella)
|
||||
if !ok {
|
||||
return nil, errIncorrectBodyVersion
|
||||
}
|
||||
}
|
||||
return ð.BeaconBlockCapella{
|
||||
Slot: b.slot,
|
||||
ProposerIndex: b.proposerIndex,
|
||||
ParentRoot: b.parentRoot[:],
|
||||
StateRoot: b.stateRoot[:],
|
||||
Body: body,
|
||||
}, nil
|
||||
default:
|
||||
return nil, errors.New("unsupported beacon block version")
|
||||
}
|
||||
@@ -192,6 +253,14 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
|
||||
}, nil
|
||||
case version.Bellatrix:
|
||||
if b.isBlinded {
|
||||
var ph *enginev1.ExecutionPayloadHeader
|
||||
var ok bool
|
||||
if b.executionPayloadHeader != nil {
|
||||
ph, ok = b.executionPayloadHeader.Proto().(*enginev1.ExecutionPayloadHeader)
|
||||
if !ok {
|
||||
return nil, errPayloadHeaderWrongType
|
||||
}
|
||||
}
|
||||
return ð.BlindedBeaconBlockBodyBellatrix{
|
||||
RandaoReveal: b.randaoReveal[:],
|
||||
Eth1Data: b.eth1Data,
|
||||
@@ -202,9 +271,17 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
|
||||
Deposits: b.deposits,
|
||||
VoluntaryExits: b.voluntaryExits,
|
||||
SyncAggregate: b.syncAggregate,
|
||||
ExecutionPayloadHeader: b.executionPayloadHeader,
|
||||
ExecutionPayloadHeader: ph,
|
||||
}, nil
|
||||
}
|
||||
var p *enginev1.ExecutionPayload
|
||||
var ok bool
|
||||
if b.executionPayload != nil {
|
||||
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayload)
|
||||
if !ok {
|
||||
return nil, errPayloadWrongType
|
||||
}
|
||||
}
|
||||
return ð.BeaconBlockBodyBellatrix{
|
||||
RandaoReveal: b.randaoReveal[:],
|
||||
Eth1Data: b.eth1Data,
|
||||
@@ -215,7 +292,52 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
|
||||
Deposits: b.deposits,
|
||||
VoluntaryExits: b.voluntaryExits,
|
||||
SyncAggregate: b.syncAggregate,
|
||||
ExecutionPayload: b.executionPayload,
|
||||
ExecutionPayload: p,
|
||||
}, nil
|
||||
case version.Capella:
|
||||
if b.isBlinded {
|
||||
var ph *enginev1.ExecutionPayloadHeaderCapella
|
||||
var ok bool
|
||||
if b.executionPayloadHeader != nil {
|
||||
ph, ok = b.executionPayloadHeader.Proto().(*enginev1.ExecutionPayloadHeaderCapella)
|
||||
if !ok {
|
||||
return nil, errPayloadHeaderWrongType
|
||||
}
|
||||
}
|
||||
return ð.BlindedBeaconBlockBodyCapella{
|
||||
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,
|
||||
}, nil
|
||||
}
|
||||
var p *enginev1.ExecutionPayloadCapella
|
||||
var ok bool
|
||||
if b.executionPayload != nil {
|
||||
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayloadCapella)
|
||||
if !ok {
|
||||
return nil, errPayloadWrongType
|
||||
}
|
||||
}
|
||||
return ð.BeaconBlockBodyCapella{
|
||||
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,
|
||||
}, nil
|
||||
default:
|
||||
return nil, errors.New("unsupported beacon block body version")
|
||||
@@ -273,6 +395,23 @@ func initSignedBlockFromProtoBellatrix(pb *eth.SignedBeaconBlockBellatrix) (*Sig
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initSignedBlockFromProtoCapella(pb *eth.SignedBeaconBlockCapella) (*SignedBeaconBlock, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlock
|
||||
}
|
||||
|
||||
block, err := initBlockFromProtoCapella(pb.Block)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := &SignedBeaconBlock{
|
||||
version: version.Capella,
|
||||
block: block,
|
||||
signature: bytesutil.ToBytes96(pb.Signature),
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initBlindedSignedBlockFromProtoBellatrix(pb *eth.SignedBlindedBeaconBlockBellatrix) (*SignedBeaconBlock, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlock
|
||||
@@ -290,6 +429,23 @@ func initBlindedSignedBlockFromProtoBellatrix(pb *eth.SignedBlindedBeaconBlockBe
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initBlindedSignedBlockFromProtoCapella(pb *eth.SignedBlindedBeaconBlockCapella) (*SignedBeaconBlock, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlock
|
||||
}
|
||||
|
||||
block, err := initBlindedBlockFromProtoCapella(pb.Block)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := &SignedBeaconBlock{
|
||||
version: version.Capella,
|
||||
block: block,
|
||||
signature: bytesutil.ToBytes96(pb.Signature),
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initBlockFromProtoPhase0(pb *eth.BeaconBlock) (*BeaconBlock, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlock
|
||||
@@ -370,6 +526,46 @@ func initBlindedBlockFromProtoBellatrix(pb *eth.BlindedBeaconBlockBellatrix) (*B
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initBlockFromProtoCapella(pb *eth.BeaconBlockCapella) (*BeaconBlock, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlock
|
||||
}
|
||||
|
||||
body, err := initBlockBodyFromProtoCapella(pb.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := &BeaconBlock{
|
||||
version: version.Capella,
|
||||
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
|
||||
}
|
||||
|
||||
body, err := initBlindedBlockBodyFromProtoCapella(pb.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := &BeaconBlock{
|
||||
version: version.Capella,
|
||||
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
|
||||
@@ -416,6 +612,11 @@ func initBlockBodyFromProtoBellatrix(pb *eth.BeaconBlockBodyBellatrix) (*BeaconB
|
||||
return nil, errNilBlockBody
|
||||
}
|
||||
|
||||
p, err := WrappedExecutionPayload(pb.ExecutionPayload)
|
||||
// We allow the payload to be nil
|
||||
if err != nil && err != ErrNilObjectWrapped {
|
||||
return nil, err
|
||||
}
|
||||
b := &BeaconBlockBody{
|
||||
version: version.Bellatrix,
|
||||
isBlinded: false,
|
||||
@@ -428,7 +629,7 @@ func initBlockBodyFromProtoBellatrix(pb *eth.BeaconBlockBodyBellatrix) (*BeaconB
|
||||
deposits: pb.Deposits,
|
||||
voluntaryExits: pb.VoluntaryExits,
|
||||
syncAggregate: pb.SyncAggregate,
|
||||
executionPayload: pb.ExecutionPayload,
|
||||
executionPayload: p,
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
@@ -438,6 +639,11 @@ func initBlindedBlockBodyFromProtoBellatrix(pb *eth.BlindedBeaconBlockBodyBellat
|
||||
return nil, errNilBlockBody
|
||||
}
|
||||
|
||||
ph, err := WrappedExecutionPayloadHeader(pb.ExecutionPayloadHeader)
|
||||
// We allow the payload to be nil
|
||||
if err != nil && err != ErrNilObjectWrapped {
|
||||
return nil, err
|
||||
}
|
||||
b := &BeaconBlockBody{
|
||||
version: version.Bellatrix,
|
||||
isBlinded: true,
|
||||
@@ -450,7 +656,63 @@ func initBlindedBlockBodyFromProtoBellatrix(pb *eth.BlindedBeaconBlockBodyBellat
|
||||
deposits: pb.Deposits,
|
||||
voluntaryExits: pb.VoluntaryExits,
|
||||
syncAggregate: pb.SyncAggregate,
|
||||
executionPayloadHeader: pb.ExecutionPayloadHeader,
|
||||
executionPayloadHeader: ph,
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initBlockBodyFromProtoCapella(pb *eth.BeaconBlockBodyCapella) (*BeaconBlockBody, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlockBody
|
||||
}
|
||||
|
||||
p, err := WrappedExecutionPayloadCapella(pb.ExecutionPayload)
|
||||
// We allow the payload to be nil
|
||||
if err != nil && err != ErrNilObjectWrapped {
|
||||
return nil, err
|
||||
}
|
||||
b := &BeaconBlockBody{
|
||||
version: version.Capella,
|
||||
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,
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func initBlindedBlockBodyFromProtoCapella(pb *eth.BlindedBeaconBlockBodyCapella) (*BeaconBlockBody, error) {
|
||||
if pb == nil {
|
||||
return nil, errNilBlockBody
|
||||
}
|
||||
|
||||
ph, err := WrappedExecutionPayloadHeaderCapella(pb.ExecutionPayloadHeader)
|
||||
// We allow the payload to be nil
|
||||
if err != nil && err != ErrNilObjectWrapped {
|
||||
return nil, err
|
||||
}
|
||||
b := &BeaconBlockBody{
|
||||
version: version.Capella,
|
||||
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,
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
@@ -12,16 +12,19 @@ import (
|
||||
)
|
||||
|
||||
type fields struct {
|
||||
root [32]byte
|
||||
sig [96]byte
|
||||
deposits []*eth.Deposit
|
||||
atts []*eth.Attestation
|
||||
proposerSlashings []*eth.ProposerSlashing
|
||||
attesterSlashings []*eth.AttesterSlashing
|
||||
voluntaryExits []*eth.SignedVoluntaryExit
|
||||
syncAggregate *eth.SyncAggregate
|
||||
execPayload *enginev1.ExecutionPayload
|
||||
execPayloadHeader *enginev1.ExecutionPayloadHeader
|
||||
root [32]byte
|
||||
sig [96]byte
|
||||
deposits []*eth.Deposit
|
||||
atts []*eth.Attestation
|
||||
proposerSlashings []*eth.ProposerSlashing
|
||||
attesterSlashings []*eth.AttesterSlashing
|
||||
voluntaryExits []*eth.SignedVoluntaryExit
|
||||
syncAggregate *eth.SyncAggregate
|
||||
execPayload *enginev1.ExecutionPayload
|
||||
execPayloadHeader *enginev1.ExecutionPayloadHeader
|
||||
execPayloadCapella *enginev1.ExecutionPayloadCapella
|
||||
execPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
|
||||
blsToExecutionChanges []*eth.SignedBLSToExecutionChange
|
||||
}
|
||||
|
||||
func Test_SignedBeaconBlock_Proto(t *testing.T) {
|
||||
@@ -114,7 +117,7 @@ func Test_SignedBeaconBlock_Proto(t *testing.T) {
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyBellatrix(),
|
||||
body: bodyBellatrix(t),
|
||||
},
|
||||
signature: f.sig,
|
||||
}
|
||||
@@ -148,7 +151,7 @@ func Test_SignedBeaconBlock_Proto(t *testing.T) {
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyBlindedBellatrix(),
|
||||
body: bodyBlindedBellatrix(t),
|
||||
},
|
||||
signature: f.sig,
|
||||
}
|
||||
@@ -163,6 +166,74 @@ func Test_SignedBeaconBlock_Proto(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedHTR, resultHTR)
|
||||
})
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
expectedBlock := ð.SignedBeaconBlockCapella{
|
||||
Block: ð.BeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbCapella(),
|
||||
},
|
||||
Signature: f.sig[:],
|
||||
}
|
||||
block := &SignedBeaconBlock{
|
||||
version: version.Capella,
|
||||
block: &BeaconBlock{
|
||||
version: version.Capella,
|
||||
slot: 128,
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyCapella(t),
|
||||
},
|
||||
signature: f.sig,
|
||||
}
|
||||
|
||||
result, err := block.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.SignedBeaconBlockCapella)
|
||||
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("CapellaBlind", func(t *testing.T) {
|
||||
expectedBlock := ð.SignedBlindedBeaconBlockCapella{
|
||||
Block: ð.BlindedBeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbBlindedCapella(),
|
||||
},
|
||||
Signature: f.sig[:],
|
||||
}
|
||||
block := &SignedBeaconBlock{
|
||||
version: version.Capella,
|
||||
block: &BeaconBlock{
|
||||
version: version.Capella,
|
||||
slot: 128,
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyBlindedCapella(t),
|
||||
},
|
||||
signature: f.sig,
|
||||
}
|
||||
|
||||
result, err := block.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.SignedBlindedBeaconBlockCapella)
|
||||
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) {
|
||||
@@ -236,7 +307,7 @@ func Test_BeaconBlock_Proto(t *testing.T) {
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyBellatrix(),
|
||||
body: bodyBellatrix(t),
|
||||
}
|
||||
|
||||
result, err := block.Proto()
|
||||
@@ -263,7 +334,7 @@ func Test_BeaconBlock_Proto(t *testing.T) {
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyBlindedBellatrix(),
|
||||
body: bodyBlindedBellatrix(t),
|
||||
}
|
||||
|
||||
result, err := block.Proto()
|
||||
@@ -276,6 +347,60 @@ func Test_BeaconBlock_Proto(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedHTR, resultHTR)
|
||||
})
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
expectedBlock := ð.BeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbCapella(),
|
||||
}
|
||||
block := &BeaconBlock{
|
||||
version: version.Capella,
|
||||
slot: 128,
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyCapella(t),
|
||||
}
|
||||
|
||||
result, err := block.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.BeaconBlockCapella)
|
||||
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("CapellaBlind", func(t *testing.T) {
|
||||
expectedBlock := ð.BlindedBeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbBlindedCapella(),
|
||||
}
|
||||
block := &BeaconBlock{
|
||||
version: version.Capella,
|
||||
slot: 128,
|
||||
proposerIndex: 128,
|
||||
parentRoot: f.root,
|
||||
stateRoot: f.root,
|
||||
body: bodyBlindedCapella(t),
|
||||
}
|
||||
|
||||
result, err := block.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.BlindedBeaconBlockCapella)
|
||||
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) {
|
||||
@@ -308,7 +433,7 @@ func Test_BeaconBlockBody_Proto(t *testing.T) {
|
||||
})
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
expectedBody := bodyPbBellatrix()
|
||||
body := bodyBellatrix()
|
||||
body := bodyBellatrix(t)
|
||||
result, err := body.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.BeaconBlockBodyBellatrix)
|
||||
@@ -321,7 +446,7 @@ func Test_BeaconBlockBody_Proto(t *testing.T) {
|
||||
})
|
||||
t.Run("BellatrixBlind", func(t *testing.T) {
|
||||
expectedBody := bodyPbBlindedBellatrix()
|
||||
body := bodyBlindedBellatrix()
|
||||
body := bodyBlindedBellatrix(t)
|
||||
result, err := body.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.BlindedBeaconBlockBodyBellatrix)
|
||||
@@ -332,6 +457,56 @@ func Test_BeaconBlockBody_Proto(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, expectedHTR, resultHTR)
|
||||
})
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
expectedBody := bodyPbCapella()
|
||||
body := bodyCapella(t)
|
||||
result, err := body.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.BeaconBlockBodyCapella)
|
||||
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("CapellaBlind", func(t *testing.T) {
|
||||
expectedBody := bodyPbBlindedCapella()
|
||||
body := bodyBlindedCapella(t)
|
||||
result, err := body.Proto()
|
||||
require.NoError(t, err)
|
||||
resultBlock, ok := result.(*eth.BlindedBeaconBlockBodyCapella)
|
||||
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{}
|
||||
_, err := body.Proto()
|
||||
require.ErrorIs(t, err, errPayloadWrongType)
|
||||
})
|
||||
t.Run("BellatrixBlind - wrong payload type", func(t *testing.T) {
|
||||
body := bodyBlindedBellatrix(t)
|
||||
body.executionPayloadHeader = &executionPayload{}
|
||||
_, err := body.Proto()
|
||||
require.ErrorIs(t, err, errPayloadHeaderWrongType)
|
||||
})
|
||||
t.Run("Capella - wrong payload type", func(t *testing.T) {
|
||||
body := bodyCapella(t)
|
||||
body.executionPayload = &executionPayloadHeaderCapella{}
|
||||
_, err := body.Proto()
|
||||
require.ErrorIs(t, err, errPayloadWrongType)
|
||||
})
|
||||
t.Run("CapellaBlind - wrong payload type", func(t *testing.T) {
|
||||
body := bodyBlindedCapella(t)
|
||||
body.executionPayloadHeader = &executionPayloadCapella{}
|
||||
_, err := body.Proto()
|
||||
require.ErrorIs(t, err, errPayloadHeaderWrongType)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_initSignedBlockFromProtoPhase0(t *testing.T) {
|
||||
@@ -422,6 +597,50 @@ func Test_initBlindedSignedBlockFromProtoBellatrix(t *testing.T) {
|
||||
assert.DeepEqual(t, expectedBlock.Signature, resultBlock.signature[:])
|
||||
}
|
||||
|
||||
func Test_initSignedBlockFromProtoCapella(t *testing.T) {
|
||||
f := getFields()
|
||||
expectedBlock := ð.SignedBeaconBlockCapella{
|
||||
Block: ð.BeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbCapella(),
|
||||
},
|
||||
Signature: f.sig[:],
|
||||
}
|
||||
resultBlock, err := initSignedBlockFromProtoCapella(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_initBlindedSignedBlockFromProtoCapella(t *testing.T) {
|
||||
f := getFields()
|
||||
expectedBlock := ð.SignedBlindedBeaconBlockCapella{
|
||||
Block: ð.BlindedBeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbBlindedCapella(),
|
||||
},
|
||||
Signature: f.sig[:],
|
||||
}
|
||||
resultBlock, err := initBlindedSignedBlockFromProtoCapella(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 := ð.BeaconBlock{
|
||||
@@ -494,6 +713,42 @@ func Test_initBlockFromProtoBlindedBellatrix(t *testing.T) {
|
||||
assert.DeepEqual(t, expectedHTR, resultHTR)
|
||||
}
|
||||
|
||||
func Test_initBlockFromProtoCapella(t *testing.T) {
|
||||
f := getFields()
|
||||
expectedBlock := ð.BeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbCapella(),
|
||||
}
|
||||
resultBlock, err := initBlockFromProtoCapella(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_initBlockFromProtoBlindedCapella(t *testing.T) {
|
||||
f := getFields()
|
||||
expectedBlock := ð.BlindedBeaconBlockCapella{
|
||||
Slot: 128,
|
||||
ProposerIndex: 128,
|
||||
ParentRoot: f.root[:],
|
||||
StateRoot: f.root[:],
|
||||
Body: bodyPbBlindedCapella(),
|
||||
}
|
||||
resultBlock, err := initBlindedBlockFromProtoCapella(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)
|
||||
@@ -538,6 +793,28 @@ func Test_initBlockBodyFromProtoBlindedBellatrix(t *testing.T) {
|
||||
assert.DeepEqual(t, expectedHTR, resultHTR)
|
||||
}
|
||||
|
||||
func Test_initBlockBodyFromProtoCapella(t *testing.T) {
|
||||
expectedBody := bodyPbCapella()
|
||||
resultBody, err := initBlockBodyFromProtoCapella(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_initBlockBodyFromProtoBlindedCapella(t *testing.T) {
|
||||
expectedBody := bodyPbBlindedCapella()
|
||||
resultBody, err := initBlindedBlockBodyFromProtoCapella(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 ð.BeaconBlockBody{
|
||||
@@ -615,6 +892,48 @@ func bodyPbBlindedBellatrix() *eth.BlindedBeaconBlockBodyBellatrix {
|
||||
}
|
||||
}
|
||||
|
||||
func bodyPbCapella() *eth.BeaconBlockBodyCapella {
|
||||
f := getFields()
|
||||
return ð.BeaconBlockBodyCapella{
|
||||
RandaoReveal: f.sig[:],
|
||||
Eth1Data: ð.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.execPayloadCapella,
|
||||
BlsToExecutionChanges: f.blsToExecutionChanges,
|
||||
}
|
||||
}
|
||||
|
||||
func bodyPbBlindedCapella() *eth.BlindedBeaconBlockBodyCapella {
|
||||
f := getFields()
|
||||
return ð.BlindedBeaconBlockBodyCapella{
|
||||
RandaoReveal: f.sig[:],
|
||||
Eth1Data: ð.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.execPayloadHeaderCapella,
|
||||
BlsToExecutionChanges: f.blsToExecutionChanges,
|
||||
}
|
||||
}
|
||||
|
||||
func bodyPhase0() *BeaconBlockBody {
|
||||
f := getFields()
|
||||
return &BeaconBlockBody{
|
||||
@@ -654,8 +973,10 @@ func bodyAltair() *BeaconBlockBody {
|
||||
}
|
||||
}
|
||||
|
||||
func bodyBellatrix() *BeaconBlockBody {
|
||||
func bodyBellatrix(t *testing.T) *BeaconBlockBody {
|
||||
f := getFields()
|
||||
p, err := WrappedExecutionPayload(f.execPayload)
|
||||
require.NoError(t, err)
|
||||
return &BeaconBlockBody{
|
||||
version: version.Bellatrix,
|
||||
randaoReveal: f.sig,
|
||||
@@ -671,12 +992,14 @@ func bodyBellatrix() *BeaconBlockBody {
|
||||
deposits: f.deposits,
|
||||
voluntaryExits: f.voluntaryExits,
|
||||
syncAggregate: f.syncAggregate,
|
||||
executionPayload: f.execPayload,
|
||||
executionPayload: p,
|
||||
}
|
||||
}
|
||||
|
||||
func bodyBlindedBellatrix() *BeaconBlockBody {
|
||||
func bodyBlindedBellatrix(t *testing.T) *BeaconBlockBody {
|
||||
f := getFields()
|
||||
ph, err := WrappedExecutionPayloadHeader(f.execPayloadHeader)
|
||||
require.NoError(t, err)
|
||||
return &BeaconBlockBody{
|
||||
version: version.Bellatrix,
|
||||
isBlinded: true,
|
||||
@@ -693,7 +1016,56 @@ func bodyBlindedBellatrix() *BeaconBlockBody {
|
||||
deposits: f.deposits,
|
||||
voluntaryExits: f.voluntaryExits,
|
||||
syncAggregate: f.syncAggregate,
|
||||
executionPayloadHeader: f.execPayloadHeader,
|
||||
executionPayloadHeader: ph,
|
||||
}
|
||||
}
|
||||
|
||||
func bodyCapella(t *testing.T) *BeaconBlockBody {
|
||||
f := getFields()
|
||||
p, err := WrappedExecutionPayloadCapella(f.execPayloadCapella)
|
||||
require.NoError(t, err)
|
||||
return &BeaconBlockBody{
|
||||
version: version.Capella,
|
||||
randaoReveal: f.sig,
|
||||
eth1Data: ð.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,
|
||||
}
|
||||
}
|
||||
|
||||
func bodyBlindedCapella(t *testing.T) *BeaconBlockBody {
|
||||
f := getFields()
|
||||
ph, err := WrappedExecutionPayloadHeaderCapella(f.execPayloadHeaderCapella)
|
||||
require.NoError(t, err)
|
||||
return &BeaconBlockBody{
|
||||
version: version.Capella,
|
||||
isBlinded: true,
|
||||
randaoReveal: f.sig,
|
||||
eth1Data: ð.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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,17 +1222,72 @@ func getFields() fields {
|
||||
BlockHash: root[:],
|
||||
TransactionsRoot: root[:],
|
||||
}
|
||||
execPayloadCapella := &enginev1.ExecutionPayloadCapella{
|
||||
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{
|
||||
{
|
||||
WithdrawalIndex: 128,
|
||||
ExecutionAddress: b20,
|
||||
Amount: 128,
|
||||
},
|
||||
},
|
||||
}
|
||||
execPayloadHeaderCapella := &enginev1.ExecutionPayloadHeaderCapella{
|
||||
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[:],
|
||||
}
|
||||
blsToExecutionChanges := []*eth.SignedBLSToExecutionChange{{
|
||||
Message: ð.BLSToExecutionChange{
|
||||
ValidatorIndex: 128,
|
||||
FromBlsPubkey: b48,
|
||||
ToExecutionAddress: b20,
|
||||
},
|
||||
Signature: sig[:],
|
||||
}}
|
||||
|
||||
return fields{
|
||||
root: root,
|
||||
sig: sig,
|
||||
deposits: deposits,
|
||||
atts: atts,
|
||||
proposerSlashings: []*eth.ProposerSlashing{proposerSlashing},
|
||||
attesterSlashings: []*eth.AttesterSlashing{attesterSlashing},
|
||||
voluntaryExits: []*eth.SignedVoluntaryExit{voluntaryExit},
|
||||
syncAggregate: syncAggregate,
|
||||
execPayload: execPayload,
|
||||
execPayloadHeader: execPayloadHeader,
|
||||
root: root,
|
||||
sig: sig,
|
||||
deposits: deposits,
|
||||
atts: atts,
|
||||
proposerSlashings: []*eth.ProposerSlashing{proposerSlashing},
|
||||
attesterSlashings: []*eth.AttesterSlashing{attesterSlashing},
|
||||
voluntaryExits: []*eth.SignedVoluntaryExit{voluntaryExit},
|
||||
syncAggregate: syncAggregate,
|
||||
execPayload: execPayload,
|
||||
execPayloadHeader: execPayloadHeader,
|
||||
execPayloadCapella: execPayloadCapella,
|
||||
execPayloadHeaderCapella: execPayloadHeaderCapella,
|
||||
blsToExecutionChanges: blsToExecutionChanges,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ func NewSignedBeaconBlockFromGeneric(gb *eth.GenericSignedBeaconBlock) (interfac
|
||||
return blocks.NewSignedBeaconBlock(bb.Bellatrix)
|
||||
case *eth.GenericSignedBeaconBlock_BlindedBellatrix:
|
||||
return blocks.NewSignedBeaconBlock(bb.BlindedBellatrix)
|
||||
case *eth.GenericSignedBeaconBlock_Capella:
|
||||
return blocks.NewSignedBeaconBlock(bb.Capella)
|
||||
case *eth.GenericSignedBeaconBlock_BlindedCapella:
|
||||
return blocks.NewSignedBeaconBlock(bb.BlindedCapella)
|
||||
default:
|
||||
return nil, errors.Wrapf(blocks.ErrUnsupportedSignedBeaconBlock, "unable to create block from type %T", gb)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type blockMutator struct {
|
||||
Phase0 func(beaconBlock *eth.SignedBeaconBlock)
|
||||
Altair func(beaconBlock *eth.SignedBeaconBlockAltair)
|
||||
Bellatrix func(beaconBlock *eth.SignedBeaconBlockBellatrix)
|
||||
Capella func(beaconBlock *eth.SignedBeaconBlockCapella)
|
||||
}
|
||||
|
||||
func (m blockMutator) apply(b interfaces.SignedBeaconBlock) (interfaces.SignedBeaconBlock, error) {
|
||||
@@ -37,6 +38,13 @@ func (m blockMutator) apply(b interfaces.SignedBeaconBlock) (interfaces.SignedBe
|
||||
}
|
||||
m.Bellatrix(bb)
|
||||
return blocks.NewSignedBeaconBlock(bb)
|
||||
case version.Capella:
|
||||
bb, err := b.PbCapellaBlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Capella(bb)
|
||||
return blocks.NewSignedBeaconBlock(bb)
|
||||
default:
|
||||
return nil, blocks.ErrUnsupportedSignedBeaconBlock
|
||||
}
|
||||
@@ -48,6 +56,7 @@ func SetBlockStateRoot(b interfaces.SignedBeaconBlock, sr [32]byte) (interfaces.
|
||||
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.StateRoot = sr[:] },
|
||||
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.StateRoot = sr[:] },
|
||||
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.StateRoot = sr[:] },
|
||||
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.StateRoot = sr[:] },
|
||||
}.apply(b)
|
||||
}
|
||||
|
||||
@@ -57,6 +66,7 @@ func SetBlockParentRoot(b interfaces.SignedBeaconBlock, pr [32]byte) (interfaces
|
||||
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.ParentRoot = pr[:] },
|
||||
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.ParentRoot = pr[:] },
|
||||
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.ParentRoot = pr[:] },
|
||||
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.ParentRoot = pr[:] },
|
||||
}.apply(b)
|
||||
}
|
||||
|
||||
@@ -66,6 +76,7 @@ func SetBlockSlot(b interfaces.SignedBeaconBlock, s types.Slot) (interfaces.Sign
|
||||
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.Slot = s },
|
||||
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.Slot = s },
|
||||
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.Slot = s },
|
||||
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.Slot = s },
|
||||
}.apply(b)
|
||||
}
|
||||
|
||||
@@ -75,5 +86,6 @@ func SetProposerIndex(b interfaces.SignedBeaconBlock, idx types.ValidatorIndex)
|
||||
Phase0: func(bb *eth.SignedBeaconBlock) { bb.Block.ProposerIndex = idx },
|
||||
Altair: func(bb *eth.SignedBeaconBlockAltair) { bb.Block.ProposerIndex = idx },
|
||||
Bellatrix: func(bb *eth.SignedBeaconBlockBellatrix) { bb.Block.ProposerIndex = idx },
|
||||
Capella: func(bb *eth.SignedBeaconBlockCapella) { bb.Block.ProposerIndex = idx },
|
||||
}.apply(b)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
field_params "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
engine "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
)
|
||||
@@ -18,6 +17,11 @@ var (
|
||||
_ = interfaces.BeaconBlockBody(&BeaconBlockBody{})
|
||||
)
|
||||
|
||||
var (
|
||||
errPayloadWrongType = errors.New("execution payload has wrong type")
|
||||
errPayloadHeaderWrongType = errors.New("execution payload header has wrong type")
|
||||
)
|
||||
|
||||
const (
|
||||
incorrectBlockVersion = "incorrect beacon block version"
|
||||
incorrectBodyVersion = "incorrect beacon block body version"
|
||||
@@ -49,8 +53,9 @@ type BeaconBlockBody struct {
|
||||
deposits []*eth.Deposit
|
||||
voluntaryExits []*eth.SignedVoluntaryExit
|
||||
syncAggregate *eth.SyncAggregate
|
||||
executionPayload *engine.ExecutionPayload
|
||||
executionPayloadHeader *engine.ExecutionPayloadHeader
|
||||
executionPayload interfaces.ExecutionData
|
||||
executionPayloadHeader interfaces.ExecutionData
|
||||
blsToExecutionChanges []*eth.SignedBLSToExecutionChange
|
||||
}
|
||||
|
||||
// BeaconBlock is the main beacon block structure. It can represent any block type.
|
||||
|
||||
@@ -24,6 +24,8 @@ type SignedBeaconBlock interface {
|
||||
ToBlinded() (SignedBeaconBlock, error)
|
||||
PbBellatrixBlock() (*ethpb.SignedBeaconBlockBellatrix, error)
|
||||
PbBlindedBellatrixBlock() (*ethpb.SignedBlindedBeaconBlockBellatrix, error)
|
||||
PbCapellaBlock() (*ethpb.SignedBeaconBlockCapella, error)
|
||||
PbBlindedCapellaBlock() (*ethpb.SignedBlindedBeaconBlockCapella, error)
|
||||
ssz.Marshaler
|
||||
ssz.Unmarshaler
|
||||
Version() int
|
||||
@@ -66,6 +68,7 @@ type BeaconBlockBody interface {
|
||||
HashTreeRoot() ([field_params.RootLength]byte, error)
|
||||
Proto() (proto.Message, error)
|
||||
Execution() (ExecutionData, error)
|
||||
BLSToExecutionChanges() ([]*ethpb.SignedBLSToExecutionChange, error)
|
||||
}
|
||||
|
||||
// ExecutionData represents execution layer information that is contained
|
||||
|
||||
@@ -54,6 +54,14 @@ func (SignedBeaconBlock) PbBlindedBellatrixBlock() (*eth.SignedBlindedBeaconBloc
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (SignedBeaconBlock) PbCapellaBlock() (*eth.SignedBeaconBlockCapella, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (SignedBeaconBlock) PbBlindedCapellaBlock() (*eth.SignedBlindedBeaconBlockCapella, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (SignedBeaconBlock) MarshalSSZTo(_ []byte) ([]byte, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
@@ -211,6 +219,10 @@ func (BeaconBlockBody) Execution() (interfaces.ExecutionData, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) BLSToExecutionChanges() ([]*eth.SignedBLSToExecutionChange, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
var _ interfaces.SignedBeaconBlock = &SignedBeaconBlock{}
|
||||
var _ interfaces.BeaconBlock = &BeaconBlock{}
|
||||
var _ interfaces.BeaconBlockBody = &BeaconBlockBody{}
|
||||
|
||||
@@ -422,7 +422,97 @@ func CopyBeaconBlockBodyBellatrix(body *BeaconBlockBodyBellatrix) *BeaconBlockBo
|
||||
}
|
||||
}
|
||||
|
||||
// CopyExecutionPayload copies the provided ApplicationPayload.
|
||||
// CopySignedBeaconBlockCapella copies the provided SignedBeaconBlockCapella.
|
||||
func CopySignedBeaconBlockCapella(sigBlock *SignedBeaconBlockCapella) *SignedBeaconBlockCapella {
|
||||
if sigBlock == nil {
|
||||
return nil
|
||||
}
|
||||
return &SignedBeaconBlockCapella{
|
||||
Block: CopyBeaconBlockCapella(sigBlock.Block),
|
||||
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyBeaconBlockCapella copies the provided BeaconBlockCapella.
|
||||
func CopyBeaconBlockCapella(block *BeaconBlockCapella) *BeaconBlockCapella {
|
||||
if block == nil {
|
||||
return nil
|
||||
}
|
||||
return &BeaconBlockCapella{
|
||||
Slot: block.Slot,
|
||||
ProposerIndex: block.ProposerIndex,
|
||||
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
|
||||
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
|
||||
Body: CopyBeaconBlockBodyCapella(block.Body),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyBeaconBlockBodyCapella copies the provided BeaconBlockBodyCapella.
|
||||
func CopyBeaconBlockBodyCapella(body *BeaconBlockBodyCapella) *BeaconBlockBodyCapella {
|
||||
if body == nil {
|
||||
return nil
|
||||
}
|
||||
return &BeaconBlockBodyCapella{
|
||||
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: CopyExecutionPayloadCapella(body.ExecutionPayload),
|
||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||
}
|
||||
}
|
||||
|
||||
// CopySignedBlindedBeaconBlockCapella copies the provided SignedBlindedBeaconBlockCapella.
|
||||
func CopySignedBlindedBeaconBlockCapella(sigBlock *SignedBlindedBeaconBlockCapella) *SignedBlindedBeaconBlockCapella {
|
||||
if sigBlock == nil {
|
||||
return nil
|
||||
}
|
||||
return &SignedBlindedBeaconBlockCapella{
|
||||
Block: CopyBlindedBeaconBlockCapella(sigBlock.Block),
|
||||
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyBlindedBeaconBlockCapella copies the provided BlindedBeaconBlockCapella.
|
||||
func CopyBlindedBeaconBlockCapella(block *BlindedBeaconBlockCapella) *BlindedBeaconBlockCapella {
|
||||
if block == nil {
|
||||
return nil
|
||||
}
|
||||
return &BlindedBeaconBlockCapella{
|
||||
Slot: block.Slot,
|
||||
ProposerIndex: block.ProposerIndex,
|
||||
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
|
||||
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
|
||||
Body: CopyBlindedBeaconBlockBodyCapella(block.Body),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyBlindedBeaconBlockBodyCapella copies the provided BlindedBeaconBlockBodyCapella.
|
||||
func CopyBlindedBeaconBlockBodyCapella(body *BlindedBeaconBlockBodyCapella) *BlindedBeaconBlockBodyCapella {
|
||||
if body == nil {
|
||||
return nil
|
||||
}
|
||||
return &BlindedBeaconBlockBodyCapella{
|
||||
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: CopyExecutionPayloadHeaderCapella(body.ExecutionPayloadHeader),
|
||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyExecutionPayload copies the provided execution payload.
|
||||
func CopyExecutionPayload(payload *enginev1.ExecutionPayload) *enginev1.ExecutionPayload {
|
||||
if payload == nil {
|
||||
return nil
|
||||
@@ -446,6 +536,31 @@ func CopyExecutionPayload(payload *enginev1.ExecutionPayload) *enginev1.Executio
|
||||
}
|
||||
}
|
||||
|
||||
// CopyExecutionPayloadCapella copies the provided execution payload.
|
||||
func CopyExecutionPayloadCapella(payload *enginev1.ExecutionPayloadCapella) *enginev1.ExecutionPayloadCapella {
|
||||
if payload == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &enginev1.ExecutionPayloadCapella{
|
||||
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),
|
||||
Transactions: bytesutil.SafeCopy2dBytes(payload.Transactions),
|
||||
Withdrawals: CopyWithdrawalSlice(payload.Withdrawals),
|
||||
}
|
||||
}
|
||||
|
||||
// CopyExecutionPayloadHeader copies the provided execution payload object.
|
||||
func CopyExecutionPayloadHeader(payload *enginev1.ExecutionPayloadHeader) *enginev1.ExecutionPayloadHeader {
|
||||
if payload == nil {
|
||||
@@ -563,3 +678,23 @@ func CopyWithdrawal(withdrawal *enginev1.Withdrawal) *enginev1.Withdrawal {
|
||||
Amount: withdrawal.Amount,
|
||||
}
|
||||
}
|
||||
|
||||
func CopyBLSToExecutionChanges(changes []*SignedBLSToExecutionChange) []*SignedBLSToExecutionChange {
|
||||
if changes == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
res := make([]*SignedBLSToExecutionChange, len(changes))
|
||||
for i := 0; i < len(changes); i++ {
|
||||
res[i] = &SignedBLSToExecutionChange{
|
||||
Message: &BLSToExecutionChange{
|
||||
ValidatorIndex: changes[i].Message.ValidatorIndex,
|
||||
FromBlsPubkey: bytesutil.SafeCopyBytes(changes[i].Message.FromBlsPubkey),
|
||||
ToExecutionAddress: bytesutil.SafeCopyBytes(changes[i].Message.ToExecutionAddress),
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(changes[i].Signature),
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -389,6 +389,66 @@ func TestCopyBlindedBeaconBlockBodyBellatrix(t *testing.T) {
|
||||
assert.NotEmpty(t, bb, "Copied blinded beacon block body Bellatrix has empty fields")
|
||||
}
|
||||
|
||||
func TestCopySignedBeaconBlockCapella(t *testing.T) {
|
||||
sbb := genSignedBeaconBlockCapella()
|
||||
|
||||
got := v1alpha1.CopySignedBeaconBlockCapella(sbb)
|
||||
if !reflect.DeepEqual(got, sbb) {
|
||||
t.Errorf("CopySignedBeaconBlockCapella() = %v, want %v", got, sbb)
|
||||
}
|
||||
assert.NotEmpty(t, sbb, "Copied signed beacon block Capella has empty fields")
|
||||
}
|
||||
|
||||
func TestCopyBeaconBlockCapella(t *testing.T) {
|
||||
b := genBeaconBlockCapella()
|
||||
|
||||
got := v1alpha1.CopyBeaconBlockCapella(b)
|
||||
if !reflect.DeepEqual(got, b) {
|
||||
t.Errorf("CopyBeaconBlockCapella() = %v, want %v", got, b)
|
||||
}
|
||||
assert.NotEmpty(t, b, "Copied beacon block Capella has empty fields")
|
||||
}
|
||||
|
||||
func TestCopyBeaconBlockBodyCapella(t *testing.T) {
|
||||
bb := genBeaconBlockBodyCapella()
|
||||
|
||||
got := v1alpha1.CopyBeaconBlockBodyCapella(bb)
|
||||
if !reflect.DeepEqual(got, bb) {
|
||||
t.Errorf("CopyBeaconBlockBodyCapella() = %v, want %v", got, bb)
|
||||
}
|
||||
assert.NotEmpty(t, bb, "Copied beacon block body Capella has empty fields")
|
||||
}
|
||||
|
||||
func TestCopySignedBlindedBeaconBlockCapella(t *testing.T) {
|
||||
sbb := genSignedBlindedBeaconBlockCapella()
|
||||
|
||||
got := v1alpha1.CopySignedBlindedBeaconBlockCapella(sbb)
|
||||
if !reflect.DeepEqual(got, sbb) {
|
||||
t.Errorf("CopySignedBlindedBeaconBlockCapella() = %v, want %v", got, sbb)
|
||||
}
|
||||
assert.NotEmpty(t, sbb, "Copied signed blinded beacon block Capella has empty fields")
|
||||
}
|
||||
|
||||
func TestCopyBlindedBeaconBlockCapella(t *testing.T) {
|
||||
b := genBlindedBeaconBlockCapella()
|
||||
|
||||
got := v1alpha1.CopyBlindedBeaconBlockCapella(b)
|
||||
if !reflect.DeepEqual(got, b) {
|
||||
t.Errorf("CopyBlindedBeaconBlockCapella() = %v, want %v", got, b)
|
||||
}
|
||||
assert.NotEmpty(t, b, "Copied blinded beacon block Capella has empty fields")
|
||||
}
|
||||
|
||||
func TestCopyBlindedBeaconBlockBodyCapella(t *testing.T) {
|
||||
bb := genBlindedBeaconBlockBodyCapella()
|
||||
|
||||
got := v1alpha1.CopyBlindedBeaconBlockBodyCapella(bb)
|
||||
if !reflect.DeepEqual(got, bb) {
|
||||
t.Errorf("CopyBlindedBeaconBlockBodyCapella() = %v, want %v", got, bb)
|
||||
}
|
||||
assert.NotEmpty(t, bb, "Copied blinded beacon block body Capella has empty fields")
|
||||
}
|
||||
|
||||
func bytes(length int) []byte {
|
||||
b := make([]byte, length)
|
||||
_, err := rand.Read(b)
|
||||
@@ -423,6 +483,15 @@ func TestCopyWithdrawal(t *testing.T) {
|
||||
assert.NotEmpty(t, got, "Copied withdrawal has empty fields")
|
||||
}
|
||||
|
||||
func TestCopyBLSToExecutionChanges(t *testing.T) {
|
||||
changes := genBLSToExecutionChanges(10)
|
||||
|
||||
got := v1alpha1.CopyBLSToExecutionChanges(changes)
|
||||
if !reflect.DeepEqual(got, changes) {
|
||||
t.Errorf("TestCopyBLSToExecutionChanges() = %v, want %v", got, changes)
|
||||
}
|
||||
}
|
||||
|
||||
func genAttestation() *v1alpha1.Attestation {
|
||||
return &v1alpha1.Attestation{
|
||||
AggregationBits: bytes(32),
|
||||
@@ -697,6 +766,72 @@ func genSignedBeaconBlockBellatrix() *v1alpha1.SignedBeaconBlockBellatrix {
|
||||
}
|
||||
}
|
||||
|
||||
func genBeaconBlockBodyCapella() *v1alpha1.BeaconBlockBodyCapella {
|
||||
return &v1alpha1.BeaconBlockBodyCapella{
|
||||
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: genPayloadCapella(),
|
||||
BlsToExecutionChanges: genBLSToExecutionChanges(10),
|
||||
}
|
||||
}
|
||||
|
||||
func genBeaconBlockCapella() *v1alpha1.BeaconBlockCapella {
|
||||
return &v1alpha1.BeaconBlockCapella{
|
||||
Slot: 123455,
|
||||
ProposerIndex: 55433,
|
||||
ParentRoot: bytes(32),
|
||||
StateRoot: bytes(32),
|
||||
Body: genBeaconBlockBodyCapella(),
|
||||
}
|
||||
}
|
||||
|
||||
func genSignedBeaconBlockCapella() *v1alpha1.SignedBeaconBlockCapella {
|
||||
return &v1alpha1.SignedBeaconBlockCapella{
|
||||
Block: genBeaconBlockCapella(),
|
||||
Signature: bytes(96),
|
||||
}
|
||||
}
|
||||
|
||||
func genBlindedBeaconBlockBodyCapella() *v1alpha1.BlindedBeaconBlockBodyCapella {
|
||||
return &v1alpha1.BlindedBeaconBlockBodyCapella{
|
||||
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: genPayloadHeaderCapella(),
|
||||
BlsToExecutionChanges: genBLSToExecutionChanges(10),
|
||||
}
|
||||
}
|
||||
|
||||
func genBlindedBeaconBlockCapella() *v1alpha1.BlindedBeaconBlockCapella {
|
||||
return &v1alpha1.BlindedBeaconBlockCapella{
|
||||
Slot: 123455,
|
||||
ProposerIndex: 55433,
|
||||
ParentRoot: bytes(32),
|
||||
StateRoot: bytes(32),
|
||||
Body: genBlindedBeaconBlockBodyCapella(),
|
||||
}
|
||||
}
|
||||
|
||||
func genSignedBlindedBeaconBlockCapella() *v1alpha1.SignedBlindedBeaconBlockCapella {
|
||||
return &v1alpha1.SignedBlindedBeaconBlockCapella{
|
||||
Block: genBlindedBeaconBlockCapella(),
|
||||
Signature: bytes(32),
|
||||
}
|
||||
}
|
||||
|
||||
func genSyncCommitteeMessage() *v1alpha1.SyncCommitteeMessage {
|
||||
return &v1alpha1.SyncCommitteeMessage{
|
||||
Slot: 424555,
|
||||
@@ -725,6 +860,39 @@ func genPayload() *enginev1.ExecutionPayload {
|
||||
}
|
||||
}
|
||||
|
||||
func genPayloadCapella() *enginev1.ExecutionPayloadCapella {
|
||||
return &enginev1.ExecutionPayloadCapella{
|
||||
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{
|
||||
{
|
||||
WithdrawalIndex: 123,
|
||||
ValidatorIndex: 123,
|
||||
ExecutionAddress: bytes(20),
|
||||
Amount: 123,
|
||||
},
|
||||
{
|
||||
WithdrawalIndex: 124,
|
||||
ValidatorIndex: 456,
|
||||
ExecutionAddress: bytes(20),
|
||||
Amount: 456,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func genPayloadHeader() *enginev1.ExecutionPayloadHeader {
|
||||
return &enginev1.ExecutionPayloadHeader{
|
||||
ParentHash: bytes(32),
|
||||
@@ -747,10 +915,10 @@ func genPayloadHeader() *enginev1.ExecutionPayloadHeader {
|
||||
func genPayloadHeaderCapella() *enginev1.ExecutionPayloadHeaderCapella {
|
||||
return &enginev1.ExecutionPayloadHeaderCapella{
|
||||
ParentHash: bytes(32),
|
||||
FeeRecipient: bytes(32),
|
||||
FeeRecipient: bytes(20),
|
||||
StateRoot: bytes(32),
|
||||
ReceiptsRoot: bytes(32),
|
||||
LogsBloom: bytes(32),
|
||||
LogsBloom: bytes(256),
|
||||
PrevRandao: bytes(32),
|
||||
BlockNumber: 1,
|
||||
GasLimit: 2,
|
||||
@@ -780,3 +948,22 @@ func genWithdrawal() *enginev1.Withdrawal {
|
||||
Amount: 55555,
|
||||
}
|
||||
}
|
||||
|
||||
func genBLSToExecutionChanges(num int) []*v1alpha1.SignedBLSToExecutionChange {
|
||||
changes := make([]*v1alpha1.SignedBLSToExecutionChange, num)
|
||||
for i := 0; i < num; i++ {
|
||||
changes[i] = genBLSToExecutionChange()
|
||||
}
|
||||
return changes
|
||||
}
|
||||
|
||||
func genBLSToExecutionChange() *v1alpha1.SignedBLSToExecutionChange {
|
||||
return &v1alpha1.SignedBLSToExecutionChange{
|
||||
Message: &v1alpha1.BLSToExecutionChange{
|
||||
ValidatorIndex: 123456,
|
||||
FromBlsPubkey: bytes(48),
|
||||
ToExecutionAddress: bytes(20),
|
||||
},
|
||||
Signature: bytes(96),
|
||||
}
|
||||
}
|
||||
|
||||
176
proto/prysm/v1alpha1/validator-client/keymanager.pb.go
generated
176
proto/prysm/v1alpha1/validator-client/keymanager.pb.go
generated
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.15.8
|
||||
// source: proto/prysm/v1alpha1/validator-client/keymanager.proto
|
||||
|
||||
@@ -151,6 +151,8 @@ type SignRequest struct {
|
||||
// *SignRequest_BlockBellatrix
|
||||
// *SignRequest_BlindedBlockBellatrix
|
||||
// *SignRequest_Registration
|
||||
// *SignRequest_BlockCapella
|
||||
// *SignRequest_BlindedBlockCapella
|
||||
Object isSignRequest_Object `protobuf_oneof:"object"`
|
||||
SigningSlot github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Slot `protobuf:"varint,6,opt,name=signing_slot,json=signingSlot,proto3" json:"signing_slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Slot"`
|
||||
}
|
||||
@@ -306,6 +308,20 @@ func (x *SignRequest) GetRegistration() *v1alpha1.ValidatorRegistrationV1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SignRequest) GetBlockCapella() *v1alpha1.BeaconBlockCapella {
|
||||
if x, ok := x.GetObject().(*SignRequest_BlockCapella); ok {
|
||||
return x.BlockCapella
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SignRequest) GetBlindedBlockCapella() *v1alpha1.BlindedBeaconBlockCapella {
|
||||
if x, ok := x.GetObject().(*SignRequest_BlindedBlockCapella); ok {
|
||||
return x.BlindedBlockCapella
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SignRequest) GetSigningSlot() github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.Slot {
|
||||
if x != nil {
|
||||
return x.SigningSlot
|
||||
@@ -369,6 +385,14 @@ type SignRequest_Registration struct {
|
||||
Registration *v1alpha1.ValidatorRegistrationV1 `protobuf:"bytes,113,opt,name=registration,proto3,oneof"`
|
||||
}
|
||||
|
||||
type SignRequest_BlockCapella struct {
|
||||
BlockCapella *v1alpha1.BeaconBlockCapella `protobuf:"bytes,114,opt,name=block_capella,json=blockCapella,proto3,oneof"`
|
||||
}
|
||||
|
||||
type SignRequest_BlindedBlockCapella struct {
|
||||
BlindedBlockCapella *v1alpha1.BlindedBeaconBlockCapella `protobuf:"bytes,115,opt,name=blinded_block_capella,json=blindedBlockCapella,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*SignRequest_Block) isSignRequest_Object() {}
|
||||
|
||||
func (*SignRequest_AttestationData) isSignRequest_Object() {}
|
||||
@@ -395,6 +419,10 @@ func (*SignRequest_BlindedBlockBellatrix) isSignRequest_Object() {}
|
||||
|
||||
func (*SignRequest_Registration) isSignRequest_Object() {}
|
||||
|
||||
func (*SignRequest_BlockCapella) isSignRequest_Object() {}
|
||||
|
||||
func (*SignRequest_BlindedBlockCapella) isSignRequest_Object() {}
|
||||
|
||||
type SignResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -479,7 +507,7 @@ var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDesc = []byte
|
||||
0x34, 0x0a, 0x16, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x75,
|
||||
0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52,
|
||||
0x14, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x75, 0x62, 0x6c, 0x69,
|
||||
0x63, 0x4b, 0x65, 0x79, 0x73, 0x22, 0x86, 0x0b, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65,
|
||||
0x63, 0x4b, 0x65, 0x79, 0x73, 0x22, 0xc0, 0x0c, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f,
|
||||
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69,
|
||||
0x63, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x5f,
|
||||
@@ -559,59 +587,71 @@ var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDesc = []byte
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72,
|
||||
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x48, 0x00,
|
||||
0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x68,
|
||||
0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x06,
|
||||
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, 0x33, 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, 0x0b, 0x73, 0x69, 0x67,
|
||||
0x6e, 0x69, 0x6e, 0x67, 0x53, 0x6c, 0x6f, 0x74, 0x42, 0x08, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0xb7,
|
||||
0x01, 0x0a, 0x0c, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x4b, 0x0a,
|
||||
0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||
0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53,
|
||||
0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x3c, 0x0a, 0x06, 0x53, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10,
|
||||
0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x55, 0x43, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x01,
|
||||
0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4e, 0x49, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06,
|
||||
0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x32, 0xa7, 0x02, 0x0a, 0x0c, 0x52, 0x65, 0x6d,
|
||||
0x6f, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x90, 0x01, 0x0a, 0x18, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x75, 0x62, 0x6c,
|
||||
0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x36,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c,
|
||||
0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x6d,
|
||||
0x6f, 0x74, 0x65, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x83, 0x01, 0x0a,
|
||||
0x04, 0x53, 0x69, 0x67, 0x6e, 0x12, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
|
||||
0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x22, 0x18, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x73, 0x69,
|
||||
0x67, 0x6e, 0x42, 0xce, 0x01, 0x0a, 0x22, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x50,
|
||||
0x0a, 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x63, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x18,
|
||||
0x72, 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, 0x65,
|
||||
0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61,
|
||||
0x48, 0x00, 0x52, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61,
|
||||
0x12, 0x66, 0x0a, 0x15, 0x62, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x5f, 0x63, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x18, 0x73, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x30, 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,
|
||||
0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c,
|
||||
0x61, 0x48, 0x00, 0x52, 0x13, 0x62, 0x6c, 0x69, 0x6e, 0x64, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x12, 0x68, 0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e,
|
||||
0x69, 0x6e, 0x67, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x06, 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, 0x33, 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, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x6c,
|
||||
0x6f, 0x74, 0x42, 0x08, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4a, 0x04, 0x08, 0x04,
|
||||
0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0xb7, 0x01, 0x0a, 0x0c, 0x53, 0x69, 0x67,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67,
|
||||
0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69,
|
||||
0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x4b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x22, 0x3c, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b,
|
||||
0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53,
|
||||
0x55, 0x43, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45,
|
||||
0x4e, 0x49, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44,
|
||||
0x10, 0x03, 0x32, 0xa7, 0x02, 0x0a, 0x0c, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x53, 0x69, 0x67,
|
||||
0x6e, 0x65, 0x72, 0x12, 0x90, 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73,
|
||||
0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x36, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0f, 0x4b, 0x65, 0x79, 0x6d, 0x61,
|
||||
0x6e, 0x61, 0x67, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 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, 0x33, 0x2f,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2d, 0x63,
|
||||
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70,
|
||||
0x62, 0xaa, 0x02, 0x1e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x56, 0x61, 0x6c,
|
||||
0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e,
|
||||
0x56, 0x32, 0xca, 0x02, 0x1e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x56, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
|
||||
0x5c, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75,
|
||||
0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x83, 0x01, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x6e, 0x12,
|
||||
0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64,
|
||||
0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
|
||||
0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69,
|
||||
0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93,
|
||||
0x02, 0x1a, 0x22, 0x18, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32,
|
||||
0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x42, 0xce, 0x01, 0x0a,
|
||||
0x22, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
|
||||
0x2e, 0x76, 0x32, 0x42, 0x0f, 0x4b, 0x65, 0x79, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 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, 0x33, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f,
|
||||
0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x76,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3b,
|
||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xaa, 0x02, 0x1e, 0x45, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72,
|
||||
0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x1e, 0x45,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
|
||||
0x72, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x32, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -643,7 +683,9 @@ var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_goTypes = []inte
|
||||
(*v1alpha1.BeaconBlockBellatrix)(nil), // 11: ethereum.eth.v1alpha1.BeaconBlockBellatrix
|
||||
(*v1alpha1.BlindedBeaconBlockBellatrix)(nil), // 12: ethereum.eth.v1alpha1.BlindedBeaconBlockBellatrix
|
||||
(*v1alpha1.ValidatorRegistrationV1)(nil), // 13: ethereum.eth.v1alpha1.ValidatorRegistrationV1
|
||||
(*empty.Empty)(nil), // 14: google.protobuf.Empty
|
||||
(*v1alpha1.BeaconBlockCapella)(nil), // 14: ethereum.eth.v1alpha1.BeaconBlockCapella
|
||||
(*v1alpha1.BlindedBeaconBlockCapella)(nil), // 15: ethereum.eth.v1alpha1.BlindedBeaconBlockCapella
|
||||
(*empty.Empty)(nil), // 16: google.protobuf.Empty
|
||||
}
|
||||
var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_depIdxs = []int32{
|
||||
4, // 0: ethereum.validator.accounts.v2.SignRequest.block:type_name -> ethereum.eth.v1alpha1.BeaconBlock
|
||||
@@ -656,16 +698,18 @@ var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_depIdxs = []int3
|
||||
11, // 7: ethereum.validator.accounts.v2.SignRequest.block_bellatrix:type_name -> ethereum.eth.v1alpha1.BeaconBlockBellatrix
|
||||
12, // 8: ethereum.validator.accounts.v2.SignRequest.blinded_block_bellatrix:type_name -> ethereum.eth.v1alpha1.BlindedBeaconBlockBellatrix
|
||||
13, // 9: ethereum.validator.accounts.v2.SignRequest.registration:type_name -> ethereum.eth.v1alpha1.ValidatorRegistrationV1
|
||||
0, // 10: ethereum.validator.accounts.v2.SignResponse.status:type_name -> ethereum.validator.accounts.v2.SignResponse.Status
|
||||
14, // 11: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:input_type -> google.protobuf.Empty
|
||||
2, // 12: ethereum.validator.accounts.v2.RemoteSigner.Sign:input_type -> ethereum.validator.accounts.v2.SignRequest
|
||||
1, // 13: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:output_type -> ethereum.validator.accounts.v2.ListPublicKeysResponse
|
||||
3, // 14: ethereum.validator.accounts.v2.RemoteSigner.Sign:output_type -> ethereum.validator.accounts.v2.SignResponse
|
||||
13, // [13:15] is the sub-list for method output_type
|
||||
11, // [11:13] is the sub-list for method input_type
|
||||
11, // [11:11] is the sub-list for extension type_name
|
||||
11, // [11:11] is the sub-list for extension extendee
|
||||
0, // [0:11] is the sub-list for field type_name
|
||||
14, // 10: ethereum.validator.accounts.v2.SignRequest.block_capella:type_name -> ethereum.eth.v1alpha1.BeaconBlockCapella
|
||||
15, // 11: ethereum.validator.accounts.v2.SignRequest.blinded_block_capella:type_name -> ethereum.eth.v1alpha1.BlindedBeaconBlockCapella
|
||||
0, // 12: ethereum.validator.accounts.v2.SignResponse.status:type_name -> ethereum.validator.accounts.v2.SignResponse.Status
|
||||
16, // 13: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:input_type -> google.protobuf.Empty
|
||||
2, // 14: ethereum.validator.accounts.v2.RemoteSigner.Sign:input_type -> ethereum.validator.accounts.v2.SignRequest
|
||||
1, // 15: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:output_type -> ethereum.validator.accounts.v2.ListPublicKeysResponse
|
||||
3, // 16: ethereum.validator.accounts.v2.RemoteSigner.Sign:output_type -> ethereum.validator.accounts.v2.SignResponse
|
||||
15, // [15:17] is the sub-list for method output_type
|
||||
13, // [13:15] is the sub-list for method input_type
|
||||
13, // [13:13] is the sub-list for extension type_name
|
||||
13, // [13:13] is the sub-list for extension extendee
|
||||
0, // [0:13] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_prysm_v1alpha1_validator_client_keymanager_proto_init() }
|
||||
@@ -725,6 +769,8 @@ func file_proto_prysm_v1alpha1_validator_client_keymanager_proto_init() {
|
||||
(*SignRequest_BlockBellatrix)(nil),
|
||||
(*SignRequest_BlindedBlockBellatrix)(nil),
|
||||
(*SignRequest_Registration)(nil),
|
||||
(*SignRequest_BlockCapella)(nil),
|
||||
(*SignRequest_BlindedBlockCapella)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
|
||||
@@ -81,6 +81,10 @@ message SignRequest {
|
||||
|
||||
// Builder objects.
|
||||
ethereum.eth.v1alpha1.ValidatorRegistrationV1 registration = 113;
|
||||
|
||||
// Capella objects.
|
||||
ethereum.eth.v1alpha1.BeaconBlockCapella block_capella = 114;
|
||||
ethereum.eth.v1alpha1.BlindedBeaconBlockCapella blinded_block_capella = 115;
|
||||
}
|
||||
reserved 4, 5; // Reserving old, deleted fields.
|
||||
uint64 signing_slot = 6 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Slot"];
|
||||
|
||||
Reference in New Issue
Block a user