Remove Fulu block and state. (#14905)

* Remove Fulu block and state.

* Add missing tests.

* Alias `ProtobufBeaconStateFulu` to `ProtobufBeaconStateElectra`
This commit is contained in:
Manu NALEPA
2025-02-14 11:48:24 +01:00
committed by GitHub
parent e39f44b529
commit 215fbcb2e4
38 changed files with 1485 additions and 5763 deletions

View File

@@ -134,8 +134,6 @@ func NewBeaconBlock(i interface{}) (interfaces.ReadOnlyBeaconBlock, error) {
return initBlindedBlockFromProtoElectra(b.BlindedElectra)
case *eth.GenericBeaconBlock_Fulu:
return initBlockFromProtoFulu(b.Fulu.Block)
case *eth.BeaconBlockFulu:
return initBlockFromProtoFulu(b)
case *eth.BlindedBeaconBlockFulu:
return initBlindedBlockFromProtoFulu(b)
case *eth.GenericBeaconBlock_BlindedFulu:
@@ -170,10 +168,6 @@ func NewBeaconBlockBody(i interface{}) (interfaces.ReadOnlyBeaconBlockBody, erro
return initBlockBodyFromProtoElectra(b)
case *eth.BlindedBeaconBlockBodyElectra:
return initBlindedBlockBodyFromProtoElectra(b)
case *eth.BeaconBlockBodyFulu:
return initBlockBodyFromProtoFulu(b)
case *eth.BlindedBeaconBlockBodyFulu:
return initBlindedBlockBodyFromProtoFulu(b)
default:
return nil, errors.Wrapf(errUnsupportedBeaconBlockBody, "unable to create block body from type %T", i)
}
@@ -261,7 +255,7 @@ func BuildSignedBeaconBlock(blk interfaces.ReadOnlyBeaconBlock, signature []byte
}
return NewSignedBeaconBlock(&eth.SignedBlindedBeaconBlockFulu{Message: pb, Signature: signature})
}
pb, ok := pb.(*eth.BeaconBlockFulu)
pb, ok := pb.(*eth.BeaconBlockElectra)
if !ok {
return nil, errIncorrectBlockVersion
}
@@ -612,12 +606,12 @@ func BuildSignedBeaconBlockFromExecutionPayload(blk interfaces.ReadOnlySignedBea
}
fullBlock = &eth.SignedBeaconBlockFulu{
Block: &eth.BeaconBlockFulu{
Block: &eth.BeaconBlockElectra{
Slot: b.Slot(),
ProposerIndex: b.ProposerIndex(),
ParentRoot: parentRoot[:],
StateRoot: stateRoot[:],
Body: &eth.BeaconBlockBodyFulu{
Body: &eth.BeaconBlockBodyElectra{
RandaoReveal: randaoReveal[:],
Eth1Data: b.Body().Eth1Data(),
Graffiti: graffiti[:],

View File

@@ -195,7 +195,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
ProposerIndex: b.block.proposerIndex,
ParentRoot: b.block.parentRoot[:],
StateRoot: b.block.stateRoot[:],
Body: &eth.BlindedBeaconBlockBodyFulu{
Body: &eth.BlindedBeaconBlockBodyElectra{
RandaoReveal: b.block.body.randaoReveal[:],
Eth1Data: b.block.body.eth1Data,
Graffiti: b.block.body.graffiti[:],
@@ -747,7 +747,7 @@ func (b *BeaconBlock) HashTreeRoot() ([field_params.RootLength]byte, error) {
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockFulu).HashTreeRoot()
}
return pb.(*eth.BeaconBlockFulu).HashTreeRoot()
return pb.(*eth.BeaconBlockElectra).HashTreeRoot()
default:
return [field_params.RootLength]byte{}, errIncorrectBlockVersion
}
@@ -788,7 +788,7 @@ func (b *BeaconBlock) HashTreeRootWith(h *ssz.Hasher) error {
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockFulu).HashTreeRootWith(h)
}
return pb.(*eth.BeaconBlockFulu).HashTreeRootWith(h)
return pb.(*eth.BeaconBlockElectra).HashTreeRootWith(h)
default:
return errIncorrectBlockVersion
}
@@ -830,7 +830,7 @@ func (b *BeaconBlock) MarshalSSZ() ([]byte, error) {
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockFulu).MarshalSSZ()
}
return pb.(*eth.BeaconBlockFulu).MarshalSSZ()
return pb.(*eth.BeaconBlockElectra).MarshalSSZ()
default:
return []byte{}, errIncorrectBlockVersion
}
@@ -872,7 +872,7 @@ func (b *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) {
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockFulu).MarshalSSZTo(dst)
}
return pb.(*eth.BeaconBlockFulu).MarshalSSZTo(dst)
return pb.(*eth.BeaconBlockElectra).MarshalSSZTo(dst)
default:
return []byte{}, errIncorrectBlockVersion
}
@@ -918,7 +918,7 @@ func (b *BeaconBlock) SizeSSZ() int {
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockFulu).SizeSSZ()
}
return pb.(*eth.BeaconBlockFulu).SizeSSZ()
return pb.(*eth.BeaconBlockElectra).SizeSSZ()
default:
panic(incorrectBodyVersion)
}
@@ -1049,7 +1049,7 @@ func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error {
return err
}
} else {
pb := &eth.BeaconBlockFulu{}
pb := &eth.BeaconBlockElectra{}
if err := pb.UnmarshalSSZ(buf); err != nil {
return err
}
@@ -1101,7 +1101,7 @@ func (b *BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, erro
if b.IsBlinded() {
return &validatorpb.SignRequest_BlindedBlockFulu{BlindedBlockFulu: pb.(*eth.BlindedBeaconBlockFulu)}, nil
}
return &validatorpb.SignRequest_BlockFulu{BlockFulu: pb.(*eth.BeaconBlockFulu)}, nil
return &validatorpb.SignRequest_BlockFulu{BlockFulu: pb.(*eth.BeaconBlockElectra)}, nil
default:
return nil, errIncorrectBlockVersion
}
@@ -1275,9 +1275,9 @@ func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error)
return pb.(*eth.BeaconBlockBodyElectra).HashTreeRoot()
case version.Fulu:
if b.IsBlinded() {
return pb.(*eth.BlindedBeaconBlockBodyFulu).HashTreeRoot()
return pb.(*eth.BlindedBeaconBlockBodyElectra).HashTreeRoot()
}
return pb.(*eth.BeaconBlockBodyFulu).HashTreeRoot()
return pb.(*eth.BeaconBlockBodyElectra).HashTreeRoot()
default:
return [field_params.RootLength]byte{}, errIncorrectBodyVersion
}

View File

@@ -171,10 +171,10 @@ func (b *SignedBeaconBlock) Proto() (proto.Message, error) { // nolint:gocognit
Signature: b.signature[:],
}, nil
}
var block *eth.BeaconBlockFulu
var block *eth.BeaconBlockElectra
if blockMessage != nil {
var ok bool
block, ok = blockMessage.(*eth.BeaconBlockFulu)
block, ok = blockMessage.(*eth.BeaconBlockElectra)
if !ok {
return nil, errIncorrectBlockVersion
}
@@ -366,10 +366,10 @@ func (b *BeaconBlock) Proto() (proto.Message, error) { // nolint:gocognit
}, nil
case version.Fulu:
if b.IsBlinded() {
var body *eth.BlindedBeaconBlockBodyFulu
var body *eth.BlindedBeaconBlockBodyElectra
if bodyMessage != nil {
var ok bool
body, ok = bodyMessage.(*eth.BlindedBeaconBlockBodyFulu)
body, ok = bodyMessage.(*eth.BlindedBeaconBlockBodyElectra)
if !ok {
return nil, errIncorrectBodyVersion
}
@@ -382,22 +382,21 @@ func (b *BeaconBlock) Proto() (proto.Message, error) { // nolint:gocognit
Body: body,
}, nil
}
var body *eth.BeaconBlockBodyFulu
var body *eth.BeaconBlockBodyElectra
if bodyMessage != nil {
var ok bool
body, ok = bodyMessage.(*eth.BeaconBlockBodyFulu)
body, ok = bodyMessage.(*eth.BeaconBlockBodyElectra)
if !ok {
return nil, errIncorrectBodyVersion
}
}
return &eth.BeaconBlockFulu{
return &eth.BeaconBlockElectra{
Slot: b.slot,
ProposerIndex: b.proposerIndex,
ParentRoot: b.parentRoot[:],
StateRoot: b.stateRoot[:],
Body: body,
}, nil
default:
return nil, errors.New("unsupported beacon block version")
}
@@ -628,7 +627,7 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
return nil, errPayloadHeaderWrongType
}
}
return &eth.BlindedBeaconBlockBodyFulu{
return &eth.BlindedBeaconBlockBodyElectra{
RandaoReveal: b.randaoReveal[:],
Eth1Data: b.eth1Data,
Graffiti: b.graffiti[:],
@@ -652,7 +651,7 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
return nil, errPayloadWrongType
}
}
return &eth.BeaconBlockBodyFulu{
return &eth.BeaconBlockBodyElectra{
RandaoReveal: b.randaoReveal[:],
Eth1Data: b.eth1Data,
Graffiti: b.graffiti[:],
@@ -667,7 +666,6 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
BlobKzgCommitments: b.blobKzgCommitments,
ExecutionRequests: b.executionRequests,
}, nil
default:
return nil, errors.New("unsupported beacon block body version")
}
@@ -1372,7 +1370,7 @@ func initBlindedSignedBlockFromProtoFulu(pb *eth.SignedBlindedBeaconBlockFulu) (
return b, nil
}
func initBlockFromProtoFulu(pb *eth.BeaconBlockFulu) (*BeaconBlock, error) {
func initBlockFromProtoFulu(pb *eth.BeaconBlockElectra) (*BeaconBlock, error) {
if pb == nil {
return nil, errNilBlock
}
@@ -1412,7 +1410,7 @@ func initBlindedBlockFromProtoFulu(pb *eth.BlindedBeaconBlockFulu) (*BeaconBlock
return b, nil
}
func initBlockBodyFromProtoFulu(pb *eth.BeaconBlockBodyFulu) (*BeaconBlockBody, error) {
func initBlockBodyFromProtoFulu(pb *eth.BeaconBlockBodyElectra) (*BeaconBlockBody, error) {
if pb == nil {
return nil, errNilBlockBody
}
@@ -1445,7 +1443,7 @@ func initBlockBodyFromProtoFulu(pb *eth.BeaconBlockBodyFulu) (*BeaconBlockBody,
return b, nil
}
func initBlindedBlockBodyFromProtoFulu(pb *eth.BlindedBeaconBlockBodyFulu) (*BeaconBlockBody, error) {
func initBlindedBlockBodyFromProtoFulu(pb *eth.BlindedBeaconBlockBodyElectra) (*BeaconBlockBody, error) {
if pb == nil {
return nil, errNilBlockBody
}