Fix builder blind block namings (#12910)

* Fix builder blind block namings

* Fix

* Fix tests

---------

Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
This commit is contained in:
terencechain
2023-09-18 08:32:10 -07:00
committed by GitHub
parent 398f44bb53
commit 998a493ee2
30 changed files with 343 additions and 338 deletions

View File

@@ -63,7 +63,7 @@ func NewSignedBeaconBlock(i interface{}) (interfaces.SignedBeaconBlock, error) {
case *eth.SignedBlindedBeaconBlockDeneb:
return initBlindedSignedBlockFromProtoDeneb(b)
case *eth.GenericSignedBeaconBlock_BlindedDeneb:
return initBlindedSignedBlockFromProtoDeneb(b.BlindedDeneb.Block)
return initBlindedSignedBlockFromProtoDeneb(b.BlindedDeneb.SignedBlindedBlock)
default:
return nil, errors.Wrapf(ErrUnsupportedSignedBeaconBlock, "unable to create block from type %T", i)
}
@@ -191,7 +191,7 @@ func BuildSignedBeaconBlock(blk interfaces.ReadOnlyBeaconBlock, signature []byte
if !ok {
return nil, errIncorrectBlockVersion
}
return NewSignedBeaconBlock(&eth.SignedBlindedBeaconBlockDeneb{Block: pb, Signature: signature})
return NewSignedBeaconBlock(&eth.SignedBlindedBeaconBlockDeneb{Message: pb, Signature: signature})
}
pb, ok := pb.(*eth.BeaconBlockDeneb)
if !ok {

View File

@@ -142,7 +142,7 @@ func Test_NewSignedBeaconBlock(t *testing.T) {
})
t.Run("SignedBlindedBeaconBlockDeneb", func(t *testing.T) {
pb := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Message: &eth.BlindedBeaconBlockDeneb{
Body: &eth.BlindedBeaconBlockBodyDeneb{}}}
b, err := NewSignedBeaconBlock(pb)
require.NoError(t, err)
@@ -152,8 +152,8 @@ func Test_NewSignedBeaconBlock(t *testing.T) {
t.Run("GenericSignedBeaconBlock_BlindedDeneb", func(t *testing.T) {
pb := &eth.GenericSignedBeaconBlock_BlindedDeneb{
BlindedDeneb: &eth.SignedBlindedBeaconBlockAndBlobsDeneb{
Block: &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
SignedBlindedBlock: &eth.SignedBlindedBeaconBlockDeneb{
Message: &eth.BlindedBeaconBlockDeneb{
Body: &eth.BlindedBeaconBlockBodyDeneb{},
}}}}
b, err := NewSignedBeaconBlock(pb)
@@ -520,9 +520,9 @@ func TestBuildSignedBeaconBlockFromExecutionPayload(t *testing.T) {
header, err := PayloadToHeaderDeneb(wrapped)
require.NoError(t, err)
blindedBlock := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Message: &eth.BlindedBeaconBlockDeneb{
Body: &eth.BlindedBeaconBlockBodyDeneb{}}}
blindedBlock.Block.Body.ExecutionPayloadHeader = header
blindedBlock.Message.Body.ExecutionPayloadHeader = header
blk, err := NewSignedBeaconBlock(blindedBlock)
require.NoError(t, err)

View File

@@ -121,7 +121,7 @@ func (b *SignedBeaconBlock) PbGenericBlock() (*eth.GenericSignedBeaconBlock, err
if b.IsBlinded() {
return &eth.GenericSignedBeaconBlock{
Block: &eth.GenericSignedBeaconBlock_BlindedDeneb{BlindedDeneb: &eth.SignedBlindedBeaconBlockAndBlobsDeneb{
Block: pb.(*eth.SignedBlindedBeaconBlockDeneb),
SignedBlindedBlock: pb.(*eth.SignedBlindedBeaconBlockDeneb),
}},
}, nil
}
@@ -310,7 +310,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
}
return initBlindedSignedBlockFromProtoDeneb(
&eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Message: &eth.BlindedBeaconBlockDeneb{
Slot: b.block.slot,
ProposerIndex: b.block.proposerIndex,
ParentRoot: b.block.parentRoot[:],

View File

@@ -113,7 +113,7 @@ func (b *SignedBeaconBlock) Proto() (proto.Message, error) {
}
}
return &eth.SignedBlindedBeaconBlockDeneb{
Block: block,
Message: block,
Signature: b.signature[:],
}, nil
}
@@ -576,7 +576,7 @@ func initBlindedSignedBlockFromProtoDeneb(pb *eth.SignedBlindedBeaconBlockDeneb)
return nil, errNilBlock
}
block, err := initBlindedBlockFromProtoDeneb(pb.Block)
block, err := initBlindedBlockFromProtoDeneb(pb.Message)
if err != nil {
return nil, err
}

View File

@@ -274,7 +274,7 @@ func Test_SignedBeaconBlock_Proto(t *testing.T) {
})
t.Run("DenebBlind", func(t *testing.T) {
expectedBlock := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Message: &eth.BlindedBeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
@@ -830,7 +830,7 @@ func Test_initSignedBlockFromProtoDeneb(t *testing.T) {
func Test_initBlindedSignedBlockFromProtoDeneb(t *testing.T) {
f := getFields()
expectedBlock := &eth.SignedBlindedBeaconBlockDeneb{
Block: &eth.BlindedBeaconBlockDeneb{
Message: &eth.BlindedBeaconBlockDeneb{
Slot: 128,
ProposerIndex: 128,
ParentRoot: f.root[:],
@@ -843,7 +843,7 @@ func Test_initBlindedSignedBlockFromProtoDeneb(t *testing.T) {
require.NoError(t, err)
resultHTR, err := resultBlock.block.HashTreeRoot()
require.NoError(t, err)
expectedHTR, err := expectedBlock.Block.HashTreeRoot()
expectedHTR, err := expectedBlock.Message.HashTreeRoot()
require.NoError(t, err)
assert.DeepEqual(t, expectedHTR, resultHTR)
assert.DeepEqual(t, expectedBlock.Signature, resultBlock.signature[:])

View File

@@ -29,7 +29,7 @@ func NewSignedBeaconBlockFromGeneric(gb *eth.GenericSignedBeaconBlock) (interfac
case *eth.GenericSignedBeaconBlock_Deneb:
return blocks.NewSignedBeaconBlock(bb.Deneb.Block)
case *eth.GenericSignedBeaconBlock_BlindedDeneb:
return blocks.NewSignedBeaconBlock(bb.BlindedDeneb.Block)
return blocks.NewSignedBeaconBlock(bb.BlindedDeneb.SignedBlindedBlock)
// Generic Signed Beacon Block Deneb can't be used here as it is not a block, but block content with blobs
default:
return nil, errors.Wrapf(blocks.ErrUnsupportedSignedBeaconBlock, "unable to create block from type %T", gb)