2020-10-15 18:00:49 +00:00
|
|
|
package migration
|
|
|
|
|
|
|
|
import (
|
2024-02-15 05:46:47 +00:00
|
|
|
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
|
|
|
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
2020-10-15 18:00:49 +00:00
|
|
|
)
|
|
|
|
|
2021-02-24 15:29:25 +00:00
|
|
|
// V1Alpha1SignedHeaderToV1 converts a v1alpha1 signed beacon block header to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1SignedHeaderToV1(v1alpha1Hdr *ethpbalpha.SignedBeaconBlockHeader) *ethpbv1.SignedBeaconBlockHeader {
|
2021-02-24 15:29:25 +00:00
|
|
|
if v1alpha1Hdr == nil || v1alpha1Hdr.Header == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.SignedBeaconBlockHeader{}
|
2021-02-24 15:29:25 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.SignedBeaconBlockHeader{
|
2023-11-21 12:26:39 +00:00
|
|
|
Message: V1Alpha1HeaderToV1(v1alpha1Hdr.Header),
|
2021-02-24 15:29:25 +00:00
|
|
|
Signature: v1alpha1Hdr.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-21 12:26:39 +00:00
|
|
|
// V1Alpha1HeaderToV1 converts a v1alpha1 beacon block header to v1.
|
|
|
|
func V1Alpha1HeaderToV1(v1alpha1Hdr *ethpbalpha.BeaconBlockHeader) *ethpbv1.BeaconBlockHeader {
|
|
|
|
if v1alpha1Hdr == nil {
|
|
|
|
return ðpbv1.BeaconBlockHeader{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ðpbv1.BeaconBlockHeader{
|
|
|
|
Slot: v1alpha1Hdr.Slot,
|
|
|
|
ProposerIndex: v1alpha1Hdr.ProposerIndex,
|
|
|
|
ParentRoot: v1alpha1Hdr.ParentRoot,
|
|
|
|
StateRoot: v1alpha1Hdr.StateRoot,
|
|
|
|
BodyRoot: v1alpha1Hdr.BodyRoot,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// V1HeaderToV1Alpha1 converts a v1 beacon block header to v1alpha1.
|
|
|
|
func V1HeaderToV1Alpha1(v1Header *ethpbv1.BeaconBlockHeader) *ethpbalpha.BeaconBlockHeader {
|
|
|
|
if v1Header == nil {
|
|
|
|
return ðpbalpha.BeaconBlockHeader{}
|
|
|
|
}
|
|
|
|
return ðpbalpha.BeaconBlockHeader{
|
|
|
|
Slot: v1Header.Slot,
|
|
|
|
ProposerIndex: v1Header.ProposerIndex,
|
|
|
|
ParentRoot: v1Header.ParentRoot,
|
|
|
|
StateRoot: v1Header.StateRoot,
|
|
|
|
BodyRoot: v1Header.BodyRoot,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 07:23:52 +00:00
|
|
|
// V1ValidatorToV1Alpha1 converts a v1 validator to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1ValidatorToV1Alpha1(v1Validator *ethpbv1.Validator) *ethpbalpha.Validator {
|
2021-08-05 07:23:52 +00:00
|
|
|
if v1Validator == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.Validator{}
|
2021-08-05 07:23:52 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.Validator{
|
2021-08-05 07:23:52 +00:00
|
|
|
PublicKey: v1Validator.Pubkey,
|
2021-05-20 07:41:39 +00:00
|
|
|
WithdrawalCredentials: v1Validator.WithdrawalCredentials,
|
|
|
|
EffectiveBalance: v1Validator.EffectiveBalance,
|
|
|
|
Slashed: v1Validator.Slashed,
|
|
|
|
ActivationEligibilityEpoch: v1Validator.ActivationEligibilityEpoch,
|
|
|
|
ActivationEpoch: v1Validator.ActivationEpoch,
|
|
|
|
ExitEpoch: v1Validator.ExitEpoch,
|
|
|
|
WithdrawableEpoch: v1Validator.WithdrawableEpoch,
|
|
|
|
}
|
|
|
|
}
|