mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
ToBlinded: Use Fulu. (#14797)
* `ToBlinded`: Use Fulu. * Fix Sammy's comment. * `unmarshalState`: Use `hasFuluKey`.
This commit is contained in:
@@ -517,6 +517,19 @@ func (s *Store) unmarshalState(_ context.Context, enc []byte, validatorEntries [
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
case hasFuluKey(enc):
|
||||||
|
protoState := ðpb.BeaconStateFulu{}
|
||||||
|
if err := protoState.UnmarshalSSZ(enc[len(fuluKey):]); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to unmarshal encoding for Electra")
|
||||||
|
}
|
||||||
|
ok, err := s.isStateValidatorMigrationOver()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
protoState.Validators = validatorEntries
|
||||||
|
}
|
||||||
|
return statenative.InitializeFromProtoUnsafeFulu(protoState)
|
||||||
case hasElectraKey(enc):
|
case hasElectraKey(enc):
|
||||||
protoState := ðpb.BeaconStateElectra{}
|
protoState := ðpb.BeaconStateElectra{}
|
||||||
if err := protoState.UnmarshalSSZ(enc[len(electraKey):]); err != nil {
|
if err := protoState.UnmarshalSSZ(enc[len(electraKey):]); err != nil {
|
||||||
|
|||||||
3
changelog/manu_fulu_to_blinded.md
Normal file
3
changelog/manu_fulu_to_blinded.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `ToBlinded`: Use Fulu struct for Fulu (instead of Electra)
|
||||||
@@ -366,5 +366,5 @@ func FillTestVersions(c *BeaconChainConfig, b byte) {
|
|||||||
c.CapellaForkVersion[0] = 3
|
c.CapellaForkVersion[0] = 3
|
||||||
c.DenebForkVersion[0] = 4
|
c.DenebForkVersion[0] = 4
|
||||||
c.ElectraForkVersion[0] = 5
|
c.ElectraForkVersion[0] = 5
|
||||||
c.FuluForkVersion[0] = 5
|
c.FuluForkVersion[0] = 6
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -784,7 +784,10 @@ func PayloadToHeaderDeneb(payload interfaces.ExecutionData) (*enginev1.Execution
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var PayloadToHeaderElectra = PayloadToHeaderDeneb
|
var (
|
||||||
|
PayloadToHeaderElectra = PayloadToHeaderDeneb
|
||||||
|
PayloadToHeaderFulu = PayloadToHeaderDeneb
|
||||||
|
)
|
||||||
|
|
||||||
// IsEmptyExecutionData checks if an execution data is empty underneath. If a single field has
|
// IsEmptyExecutionData checks if an execution data is empty underneath. If a single field has
|
||||||
// a non-zero value, this function will return false.
|
// a non-zero value, this function will return false.
|
||||||
|
|||||||
@@ -166,6 +166,43 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if b.version >= version.Fulu {
|
||||||
|
p, ok := payload.Proto().(*enginev1.ExecutionPayloadDeneb)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("%T is not an execution payload header of Deneb version", p)
|
||||||
|
}
|
||||||
|
header, err := PayloadToHeaderFulu(payload)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "payload to header fulu")
|
||||||
|
}
|
||||||
|
|
||||||
|
return initBlindedSignedBlockFromProtoFulu(
|
||||||
|
ð.SignedBlindedBeaconBlockFulu{
|
||||||
|
Message: ð.BlindedBeaconBlockFulu{
|
||||||
|
Slot: b.block.slot,
|
||||||
|
ProposerIndex: b.block.proposerIndex,
|
||||||
|
ParentRoot: b.block.parentRoot[:],
|
||||||
|
StateRoot: b.block.stateRoot[:],
|
||||||
|
Body: ð.BlindedBeaconBlockBodyFulu{
|
||||||
|
RandaoReveal: b.block.body.randaoReveal[:],
|
||||||
|
Eth1Data: b.block.body.eth1Data,
|
||||||
|
Graffiti: b.block.body.graffiti[:],
|
||||||
|
ProposerSlashings: b.block.body.proposerSlashings,
|
||||||
|
AttesterSlashings: b.block.body.attesterSlashingsElectra,
|
||||||
|
Attestations: b.block.body.attestationsElectra,
|
||||||
|
Deposits: b.block.body.deposits,
|
||||||
|
VoluntaryExits: b.block.body.voluntaryExits,
|
||||||
|
SyncAggregate: b.block.body.syncAggregate,
|
||||||
|
ExecutionPayloadHeader: header,
|
||||||
|
BlsToExecutionChanges: b.block.body.blsToExecutionChanges,
|
||||||
|
BlobKzgCommitments: b.block.body.blobKzgCommitments,
|
||||||
|
ExecutionRequests: b.block.body.executionRequests,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Signature: b.signature[:],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if b.version >= version.Electra {
|
if b.version >= version.Electra {
|
||||||
p, ok := payload.Proto().(*enginev1.ExecutionPayloadDeneb)
|
p, ok := payload.Proto().(*enginev1.ExecutionPayloadDeneb)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -173,7 +210,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
|
|||||||
}
|
}
|
||||||
header, err := PayloadToHeaderElectra(payload)
|
header, err := PayloadToHeaderElectra(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrap(err, "payload to header electra")
|
||||||
}
|
}
|
||||||
return initBlindedSignedBlockFromProtoElectra(
|
return initBlindedSignedBlockFromProtoElectra(
|
||||||
ð.SignedBlindedBeaconBlockElectra{
|
ð.SignedBlindedBeaconBlockElectra{
|
||||||
@@ -206,7 +243,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
|
|||||||
case *enginev1.ExecutionPayload:
|
case *enginev1.ExecutionPayload:
|
||||||
header, err := PayloadToHeader(payload)
|
header, err := PayloadToHeader(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrap(err, "payload to header")
|
||||||
}
|
}
|
||||||
return initBlindedSignedBlockFromProtoBellatrix(
|
return initBlindedSignedBlockFromProtoBellatrix(
|
||||||
ð.SignedBlindedBeaconBlockBellatrix{
|
ð.SignedBlindedBeaconBlockBellatrix{
|
||||||
@@ -261,7 +298,7 @@ func (b *SignedBeaconBlock) ToBlinded() (interfaces.ReadOnlySignedBeaconBlock, e
|
|||||||
case *enginev1.ExecutionPayloadDeneb:
|
case *enginev1.ExecutionPayloadDeneb:
|
||||||
header, err := PayloadToHeaderDeneb(payload)
|
header, err := PayloadToHeaderDeneb(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errors.Wrap(err, "payload to header deneb")
|
||||||
}
|
}
|
||||||
return initBlindedSignedBlockFromProtoDeneb(
|
return initBlindedSignedBlockFromProtoDeneb(
|
||||||
ð.SignedBlindedBeaconBlockDeneb{
|
ð.SignedBlindedBeaconBlockDeneb{
|
||||||
|
|||||||
Reference in New Issue
Block a user