2020-10-15 18:00:49 +00:00
|
|
|
package migration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
2021-09-22 17:59:06 +00:00
|
|
|
statev1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
2021-09-02 19:28:55 +00:00
|
|
|
statev2 "github.com/prysmaticlabs/prysm/beacon-chain/state/v2"
|
2021-09-23 15:23:37 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
2021-08-26 15:22:06 +00:00
|
|
|
ethpbv1 "github.com/prysmaticlabs/prysm/proto/eth/v1"
|
|
|
|
ethpbv2 "github.com/prysmaticlabs/prysm/proto/eth/v2"
|
|
|
|
ethpbalpha "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-07-28 21:23:44 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
|
2021-05-17 18:32:04 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
2020-10-15 18:00:49 +00:00
|
|
|
)
|
|
|
|
|
2021-06-14 16:58:08 +00:00
|
|
|
// BlockIfaceToV1BlockHeader converts a signed beacon block interface into a signed beacon block header.
|
2021-08-26 15:22:06 +00:00
|
|
|
func BlockIfaceToV1BlockHeader(block block.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlockHeader, error) {
|
2021-06-14 16:58:08 +00:00
|
|
|
bodyRoot, err := block.Block().Body().HashTreeRoot()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "failed to get body root of block")
|
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.SignedBeaconBlockHeader{
|
|
|
|
Message: ðpbv1.BeaconBlockHeader{
|
2021-06-14 16:58:08 +00:00
|
|
|
Slot: block.Block().Slot(),
|
|
|
|
ProposerIndex: block.Block().ProposerIndex(),
|
|
|
|
ParentRoot: block.Block().ParentRoot(),
|
|
|
|
StateRoot: block.Block().StateRoot(),
|
|
|
|
BodyRoot: bodyRoot[:],
|
|
|
|
},
|
|
|
|
Signature: block.Signature(),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-07-23 14:29:38 +00:00
|
|
|
// V1Alpha1ToV1SignedBlock converts a v1alpha1 SignedBeaconBlock proto to a v1 proto.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1ToV1SignedBlock(alphaBlk *ethpbalpha.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
|
2021-05-17 18:32:04 +00:00
|
|
|
marshaledBlk, err := proto.Marshal(alphaBlk)
|
2020-10-15 18:00:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not marshal block")
|
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
v1Block := ðpbv1.SignedBeaconBlock{}
|
2020-10-15 18:00:49 +00:00
|
|
|
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not unmarshal block")
|
|
|
|
}
|
|
|
|
return v1Block, nil
|
|
|
|
}
|
|
|
|
|
2021-07-23 14:29:38 +00:00
|
|
|
// V1ToV1Alpha1SignedBlock converts a v1 SignedBeaconBlock proto to a v1alpha1 proto.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1ToV1Alpha1SignedBlock(alphaBlk *ethpbv1.SignedBeaconBlock) (*ethpbalpha.SignedBeaconBlock, error) {
|
2021-05-17 18:32:04 +00:00
|
|
|
marshaledBlk, err := proto.Marshal(alphaBlk)
|
2020-10-15 18:00:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not marshal block")
|
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
v1alpha1Block := ðpbalpha.SignedBeaconBlock{}
|
2020-10-15 18:00:49 +00:00
|
|
|
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not unmarshal block")
|
|
|
|
}
|
|
|
|
return v1alpha1Block, nil
|
|
|
|
}
|
2021-02-23 15:17:07 +00:00
|
|
|
|
2021-07-23 14:29:38 +00:00
|
|
|
// V1Alpha1ToV1Block converts a v1alpha1 BeaconBlock proto to a v1 proto.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1ToV1Block(alphaBlk *ethpbalpha.BeaconBlock) (*ethpbv1.BeaconBlock, error) {
|
2021-07-23 14:29:38 +00:00
|
|
|
marshaledBlk, err := proto.Marshal(alphaBlk)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not marshal block")
|
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
v1Block := ðpbv1.BeaconBlock{}
|
2021-07-23 14:29:38 +00:00
|
|
|
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not unmarshal block")
|
|
|
|
}
|
|
|
|
return v1Block, nil
|
|
|
|
}
|
|
|
|
|
2021-06-14 16:58:08 +00:00
|
|
|
// V1Alpha1AggregateAttAndProofToV1 converts a v1alpha1 aggregate attestation and proof to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1AggregateAttAndProofToV1(v1alpha1Att *ethpbalpha.AggregateAttestationAndProof) *ethpbv1.AggregateAttestationAndProof {
|
2021-06-14 16:58:08 +00:00
|
|
|
if v1alpha1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.AggregateAttestationAndProof{}
|
2021-06-14 16:58:08 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.AggregateAttestationAndProof{
|
2021-06-14 16:58:08 +00:00
|
|
|
AggregatorIndex: v1alpha1Att.AggregatorIndex,
|
|
|
|
Aggregate: V1Alpha1AttestationToV1(v1alpha1Att.Aggregate),
|
|
|
|
SelectionProof: v1alpha1Att.SelectionProof,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-04 09:01:38 +00:00
|
|
|
// V1SignedAggregateAttAndProofToV1Alpha1 converts a v1 signed aggregate attestation and proof to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1SignedAggregateAttAndProofToV1Alpha1(v1Att *ethpbv1.SignedAggregateAttestationAndProof) *ethpbalpha.SignedAggregateAttestationAndProof {
|
2021-08-04 09:01:38 +00:00
|
|
|
if v1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.SignedAggregateAttestationAndProof{}
|
2021-08-04 09:01:38 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.SignedAggregateAttestationAndProof{
|
|
|
|
Message: ðpbalpha.AggregateAttestationAndProof{
|
2021-08-04 09:01:38 +00:00
|
|
|
AggregatorIndex: v1Att.Message.AggregatorIndex,
|
|
|
|
Aggregate: V1AttestationToV1Alpha1(v1Att.Message.Aggregate),
|
|
|
|
SelectionProof: v1Att.Message.SelectionProof,
|
|
|
|
},
|
|
|
|
Signature: v1Att.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-23 15:17:07 +00:00
|
|
|
// V1Alpha1IndexedAttToV1 converts a v1alpha1 indexed attestation to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1IndexedAttToV1(v1alpha1Att *ethpbalpha.IndexedAttestation) *ethpbv1.IndexedAttestation {
|
2021-02-23 15:17:07 +00:00
|
|
|
if v1alpha1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.IndexedAttestation{}
|
2021-02-23 15:17:07 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.IndexedAttestation{
|
2021-02-23 15:17:07 +00:00
|
|
|
AttestingIndices: v1alpha1Att.AttestingIndices,
|
|
|
|
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
|
|
|
|
Signature: v1alpha1Att.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 14:55:24 +00:00
|
|
|
// V1Alpha1AttestationToV1 converts a v1alpha1 attestation to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1AttestationToV1(v1alpha1Att *ethpbalpha.Attestation) *ethpbv1.Attestation {
|
2021-05-19 14:55:24 +00:00
|
|
|
if v1alpha1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.Attestation{}
|
2021-05-19 14:55:24 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.Attestation{
|
2021-05-19 14:55:24 +00:00
|
|
|
AggregationBits: v1alpha1Att.AggregationBits,
|
|
|
|
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
|
|
|
|
Signature: v1alpha1Att.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-04 09:01:38 +00:00
|
|
|
// V1AttestationToV1Alpha1 converts a v1 attestation to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1AttestationToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
|
2021-08-04 09:01:38 +00:00
|
|
|
if v1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.Attestation{}
|
2021-08-04 09:01:38 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.Attestation{
|
2021-08-04 09:01:38 +00:00
|
|
|
AggregationBits: v1Att.AggregationBits,
|
|
|
|
Data: V1AttDataToV1Alpha1(v1Att.Data),
|
|
|
|
Signature: v1Att.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-23 15:17:07 +00:00
|
|
|
// V1Alpha1AttDataToV1 converts a v1alpha1 attestation data to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1AttDataToV1(v1alpha1AttData *ethpbalpha.AttestationData) *ethpbv1.AttestationData {
|
2021-02-23 15:17:07 +00:00
|
|
|
if v1alpha1AttData == nil || v1alpha1AttData.Source == nil || v1alpha1AttData.Target == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.AttestationData{}
|
2021-02-23 15:17:07 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.AttestationData{
|
2021-02-23 15:17:07 +00:00
|
|
|
Slot: v1alpha1AttData.Slot,
|
2021-05-25 01:02:01 +00:00
|
|
|
Index: v1alpha1AttData.CommitteeIndex,
|
2021-02-23 15:17:07 +00:00
|
|
|
BeaconBlockRoot: v1alpha1AttData.BeaconBlockRoot,
|
2021-08-26 15:22:06 +00:00
|
|
|
Source: ðpbv1.Checkpoint{
|
2021-02-23 15:17:07 +00:00
|
|
|
Root: v1alpha1AttData.Source.Root,
|
|
|
|
Epoch: v1alpha1AttData.Source.Epoch,
|
|
|
|
},
|
2021-08-26 15:22:06 +00:00
|
|
|
Target: ðpbv1.Checkpoint{
|
2021-02-23 15:17:07 +00:00
|
|
|
Root: v1alpha1AttData.Target.Root,
|
|
|
|
Epoch: v1alpha1AttData.Target.Epoch,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// V1Alpha1AttSlashingToV1 converts a v1alpha1 attester slashing to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1AttSlashingToV1(v1alpha1Slashing *ethpbalpha.AttesterSlashing) *ethpbv1.AttesterSlashing {
|
2021-02-23 15:17:07 +00:00
|
|
|
if v1alpha1Slashing == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.AttesterSlashing{}
|
2021-02-23 15:17:07 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.AttesterSlashing{
|
2021-02-23 15:17:07 +00:00
|
|
|
Attestation_1: V1Alpha1IndexedAttToV1(v1alpha1Slashing.Attestation_1),
|
|
|
|
Attestation_2: V1Alpha1IndexedAttToV1(v1alpha1Slashing.Attestation_2),
|
|
|
|
}
|
|
|
|
}
|
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{
|
|
|
|
Message: ðpbv1.BeaconBlockHeader{
|
2021-02-24 15:29:25 +00:00
|
|
|
Slot: v1alpha1Hdr.Header.Slot,
|
|
|
|
ProposerIndex: v1alpha1Hdr.Header.ProposerIndex,
|
|
|
|
ParentRoot: v1alpha1Hdr.Header.ParentRoot,
|
|
|
|
StateRoot: v1alpha1Hdr.Header.StateRoot,
|
|
|
|
BodyRoot: v1alpha1Hdr.Header.BodyRoot,
|
|
|
|
},
|
|
|
|
Signature: v1alpha1Hdr.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-01 16:08:39 +00:00
|
|
|
// V1SignedHeaderToV1Alpha1 converts a v1 signed beacon block header to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1SignedHeaderToV1Alpha1(v1Header *ethpbv1.SignedBeaconBlockHeader) *ethpbalpha.SignedBeaconBlockHeader {
|
2021-05-25 01:02:01 +00:00
|
|
|
if v1Header == nil || v1Header.Message == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.SignedBeaconBlockHeader{}
|
2021-03-01 16:08:39 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.SignedBeaconBlockHeader{
|
|
|
|
Header: ðpbalpha.BeaconBlockHeader{
|
2021-05-25 01:02:01 +00:00
|
|
|
Slot: v1Header.Message.Slot,
|
|
|
|
ProposerIndex: v1Header.Message.ProposerIndex,
|
|
|
|
ParentRoot: v1Header.Message.ParentRoot,
|
|
|
|
StateRoot: v1Header.Message.StateRoot,
|
|
|
|
BodyRoot: v1Header.Message.BodyRoot,
|
2021-03-01 16:08:39 +00:00
|
|
|
},
|
|
|
|
Signature: v1Header.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-24 15:29:25 +00:00
|
|
|
// V1Alpha1ProposerSlashingToV1 converts a v1alpha1 proposer slashing to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1ProposerSlashingToV1(v1alpha1Slashing *ethpbalpha.ProposerSlashing) *ethpbv1.ProposerSlashing {
|
2021-02-24 15:29:25 +00:00
|
|
|
if v1alpha1Slashing == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.ProposerSlashing{}
|
2021-02-24 15:29:25 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.ProposerSlashing{
|
2021-05-25 01:02:01 +00:00
|
|
|
SignedHeader_1: V1Alpha1SignedHeaderToV1(v1alpha1Slashing.Header_1),
|
|
|
|
SignedHeader_2: V1Alpha1SignedHeaderToV1(v1alpha1Slashing.Header_2),
|
2021-02-24 15:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// V1Alpha1ExitToV1 converts a v1alpha1 SignedVoluntaryExit to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1ExitToV1(v1alpha1Exit *ethpbalpha.SignedVoluntaryExit) *ethpbv1.SignedVoluntaryExit {
|
2021-02-24 15:29:25 +00:00
|
|
|
if v1alpha1Exit == nil || v1alpha1Exit.Exit == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.SignedVoluntaryExit{}
|
2021-02-24 15:29:25 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.SignedVoluntaryExit{
|
|
|
|
Message: ðpbv1.VoluntaryExit{
|
2021-02-24 15:29:25 +00:00
|
|
|
Epoch: v1alpha1Exit.Exit.Epoch,
|
|
|
|
ValidatorIndex: v1alpha1Exit.Exit.ValidatorIndex,
|
|
|
|
},
|
|
|
|
Signature: v1alpha1Exit.Signature,
|
|
|
|
}
|
|
|
|
}
|
2021-02-25 17:14:04 +00:00
|
|
|
|
2021-03-01 16:08:39 +00:00
|
|
|
// V1ExitToV1Alpha1 converts a v1 SignedVoluntaryExit to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1ExitToV1Alpha1(v1Exit *ethpbv1.SignedVoluntaryExit) *ethpbalpha.SignedVoluntaryExit {
|
2021-05-25 01:02:01 +00:00
|
|
|
if v1Exit == nil || v1Exit.Message == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.SignedVoluntaryExit{}
|
2021-03-01 16:08:39 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.SignedVoluntaryExit{
|
|
|
|
Exit: ðpbalpha.VoluntaryExit{
|
2021-05-25 01:02:01 +00:00
|
|
|
Epoch: v1Exit.Message.Epoch,
|
|
|
|
ValidatorIndex: v1Exit.Message.ValidatorIndex,
|
2021-03-01 16:08:39 +00:00
|
|
|
},
|
|
|
|
Signature: v1Exit.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-08 14:42:05 +00:00
|
|
|
// V1AttToV1Alpha1 converts a v1 attestation to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1AttToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
|
2021-03-08 14:42:05 +00:00
|
|
|
if v1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.Attestation{}
|
2021-03-08 14:42:05 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.Attestation{
|
2021-03-08 14:42:05 +00:00
|
|
|
AggregationBits: v1Att.AggregationBits,
|
|
|
|
Data: V1AttDataToV1Alpha1(v1Att.Data),
|
|
|
|
Signature: v1Att.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-25 17:14:04 +00:00
|
|
|
// V1IndexedAttToV1Alpha1 converts a v1 indexed attestation to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1IndexedAttToV1Alpha1(v1Att *ethpbv1.IndexedAttestation) *ethpbalpha.IndexedAttestation {
|
2021-02-25 17:14:04 +00:00
|
|
|
if v1Att == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.IndexedAttestation{}
|
2021-02-25 17:14:04 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.IndexedAttestation{
|
2021-02-25 17:14:04 +00:00
|
|
|
AttestingIndices: v1Att.AttestingIndices,
|
|
|
|
Data: V1AttDataToV1Alpha1(v1Att.Data),
|
|
|
|
Signature: v1Att.Signature,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// V1AttDataToV1Alpha1 converts a v1 attestation data to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1AttDataToV1Alpha1(v1AttData *ethpbv1.AttestationData) *ethpbalpha.AttestationData {
|
2021-02-25 17:14:04 +00:00
|
|
|
if v1AttData == nil || v1AttData.Source == nil || v1AttData.Target == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.AttestationData{}
|
2021-02-25 17:14:04 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.AttestationData{
|
2021-02-25 17:14:04 +00:00
|
|
|
Slot: v1AttData.Slot,
|
2021-05-25 01:02:01 +00:00
|
|
|
CommitteeIndex: v1AttData.Index,
|
2021-02-25 17:14:04 +00:00
|
|
|
BeaconBlockRoot: v1AttData.BeaconBlockRoot,
|
2021-08-26 15:22:06 +00:00
|
|
|
Source: ðpbalpha.Checkpoint{
|
2021-02-25 17:14:04 +00:00
|
|
|
Root: v1AttData.Source.Root,
|
|
|
|
Epoch: v1AttData.Source.Epoch,
|
|
|
|
},
|
2021-08-26 15:22:06 +00:00
|
|
|
Target: ðpbalpha.Checkpoint{
|
2021-02-25 17:14:04 +00:00
|
|
|
Root: v1AttData.Target.Root,
|
|
|
|
Epoch: v1AttData.Target.Epoch,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// V1AttSlashingToV1Alpha1 converts a v1 attester slashing to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1AttSlashingToV1Alpha1(v1Slashing *ethpbv1.AttesterSlashing) *ethpbalpha.AttesterSlashing {
|
2021-02-25 17:14:04 +00:00
|
|
|
if v1Slashing == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.AttesterSlashing{}
|
2021-02-25 17:14:04 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.AttesterSlashing{
|
2021-02-25 17:14:04 +00:00
|
|
|
Attestation_1: V1IndexedAttToV1Alpha1(v1Slashing.Attestation_1),
|
|
|
|
Attestation_2: V1IndexedAttToV1Alpha1(v1Slashing.Attestation_2),
|
|
|
|
}
|
|
|
|
}
|
2021-03-01 16:08:39 +00:00
|
|
|
|
|
|
|
// V1ProposerSlashingToV1Alpha1 converts a v1 proposer slashing to v1alpha1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1ProposerSlashingToV1Alpha1(v1Slashing *ethpbv1.ProposerSlashing) *ethpbalpha.ProposerSlashing {
|
2021-03-01 16:08:39 +00:00
|
|
|
if v1Slashing == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.ProposerSlashing{}
|
2021-03-01 16:08:39 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbalpha.ProposerSlashing{
|
2021-05-25 01:02:01 +00:00
|
|
|
Header_1: V1SignedHeaderToV1Alpha1(v1Slashing.SignedHeader_1),
|
|
|
|
Header_2: V1SignedHeaderToV1Alpha1(v1Slashing.SignedHeader_2),
|
2021-03-01 16:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-20 07:41:39 +00:00
|
|
|
|
2021-08-05 07:23:52 +00:00
|
|
|
// V1Alpha1ValidatorToV1 converts a v1alpha1 validator to v1.
|
2021-08-26 15:22:06 +00:00
|
|
|
func V1Alpha1ValidatorToV1(v1Alpha1Validator *ethpbalpha.Validator) *ethpbv1.Validator {
|
2021-08-05 07:23:52 +00:00
|
|
|
if v1Alpha1Validator == nil {
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.Validator{}
|
2021-05-20 07:41:39 +00:00
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
return ðpbv1.Validator{
|
2021-08-05 07:23:52 +00:00
|
|
|
Pubkey: v1Alpha1Validator.PublicKey,
|
|
|
|
WithdrawalCredentials: v1Alpha1Validator.WithdrawalCredentials,
|
|
|
|
EffectiveBalance: v1Alpha1Validator.EffectiveBalance,
|
|
|
|
Slashed: v1Alpha1Validator.Slashed,
|
|
|
|
ActivationEligibilityEpoch: v1Alpha1Validator.ActivationEligibilityEpoch,
|
|
|
|
ActivationEpoch: v1Alpha1Validator.ActivationEpoch,
|
|
|
|
ExitEpoch: v1Alpha1Validator.ExitEpoch,
|
|
|
|
WithdrawableEpoch: v1Alpha1Validator.WithdrawableEpoch,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
}
|
2021-06-15 15:28:49 +00:00
|
|
|
|
|
|
|
// SignedBeaconBlock converts a signed beacon block interface to a v1alpha1 block.
|
2021-08-26 15:22:06 +00:00
|
|
|
func SignedBeaconBlock(block block.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
|
2021-06-15 15:28:49 +00:00
|
|
|
if block == nil || block.IsNil() {
|
|
|
|
return nil, errors.New("could not find requested block")
|
|
|
|
}
|
|
|
|
blk, err := block.PbPhase0Block()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrapf(err, "could not get raw block")
|
|
|
|
}
|
|
|
|
|
2021-07-23 14:29:38 +00:00
|
|
|
v1Block, err := V1Alpha1ToV1SignedBlock(blk)
|
2021-06-15 15:28:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.New("could not convert block to v1 block")
|
|
|
|
}
|
|
|
|
|
|
|
|
return v1Block, nil
|
|
|
|
}
|
2021-08-26 15:22:06 +00:00
|
|
|
|
|
|
|
// V1Alpha1BeaconBlockAltairToV2 converts a v1alpha1 Altair beacon block to a v2 Altair block.
|
|
|
|
func V1Alpha1BeaconBlockAltairToV2(v1alpha1Block *ethpbalpha.BeaconBlockAltair) (*ethpbv2.BeaconBlockAltair, error) {
|
|
|
|
marshaledBlk, err := proto.Marshal(v1alpha1Block)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not marshal block")
|
|
|
|
}
|
|
|
|
v2Block := ðpbv2.BeaconBlockAltair{}
|
|
|
|
if err := proto.Unmarshal(marshaledBlk, v2Block); err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not unmarshal block")
|
|
|
|
}
|
|
|
|
return v2Block, nil
|
|
|
|
}
|
2021-09-02 19:28:55 +00:00
|
|
|
|
2021-09-22 17:59:06 +00:00
|
|
|
func BeaconStateToV1(state *statev1.BeaconState) (*ethpbv1.BeaconState, error) {
|
|
|
|
sourceFork := state.Fork()
|
|
|
|
sourceLatestBlockHeader := state.LatestBlockHeader()
|
|
|
|
sourceEth1Data := state.Eth1Data()
|
|
|
|
sourceEth1DataVotes := state.Eth1DataVotes()
|
|
|
|
sourceValidators := state.Validators()
|
|
|
|
sourcePrevEpochAtts, err := state.PreviousEpochAttestations()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrapf(err, "could not get previous epoch attestations from state")
|
|
|
|
}
|
|
|
|
sourceCurrEpochAtts, err := state.CurrentEpochAttestations()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrapf(err, "could not get current epoch attestations from state")
|
|
|
|
}
|
|
|
|
sourcePrevJustifiedCheckpoint := state.PreviousJustifiedCheckpoint()
|
|
|
|
sourceCurrJustifiedCheckpoint := state.CurrentJustifiedCheckpoint()
|
|
|
|
sourceFinalizedCheckpoint := state.FinalizedCheckpoint()
|
|
|
|
|
|
|
|
resultEth1DataVotes := make([]*ethpbv1.Eth1Data, len(sourceEth1DataVotes))
|
|
|
|
for i, vote := range sourceEth1DataVotes {
|
|
|
|
resultEth1DataVotes[i] = ðpbv1.Eth1Data{
|
|
|
|
DepositRoot: bytesutil.SafeCopyBytes(vote.DepositRoot),
|
|
|
|
DepositCount: vote.DepositCount,
|
|
|
|
BlockHash: bytesutil.SafeCopyBytes(vote.BlockHash),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resultValidators := make([]*ethpbv1.Validator, len(sourceValidators))
|
|
|
|
for i, validator := range sourceValidators {
|
|
|
|
resultValidators[i] = ðpbv1.Validator{
|
|
|
|
Pubkey: bytesutil.SafeCopyBytes(validator.PublicKey),
|
|
|
|
WithdrawalCredentials: bytesutil.SafeCopyBytes(validator.WithdrawalCredentials),
|
|
|
|
EffectiveBalance: validator.EffectiveBalance,
|
|
|
|
Slashed: validator.Slashed,
|
|
|
|
ActivationEligibilityEpoch: validator.ActivationEligibilityEpoch,
|
|
|
|
ActivationEpoch: validator.ActivationEpoch,
|
|
|
|
ExitEpoch: validator.ExitEpoch,
|
|
|
|
WithdrawableEpoch: validator.WithdrawableEpoch,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resultPrevEpochAtts := make([]*ethpbv1.PendingAttestation, len(sourcePrevEpochAtts))
|
|
|
|
for i, att := range sourcePrevEpochAtts {
|
|
|
|
data := att.Data
|
|
|
|
resultPrevEpochAtts[i] = ðpbv1.PendingAttestation{
|
|
|
|
AggregationBits: att.AggregationBits,
|
|
|
|
Data: ðpbv1.AttestationData{
|
|
|
|
Slot: data.Slot,
|
|
|
|
Index: data.CommitteeIndex,
|
|
|
|
BeaconBlockRoot: data.BeaconBlockRoot,
|
|
|
|
Source: ðpbv1.Checkpoint{
|
|
|
|
Epoch: data.Source.Epoch,
|
|
|
|
Root: data.Source.Root,
|
|
|
|
},
|
|
|
|
Target: ðpbv1.Checkpoint{
|
|
|
|
Epoch: data.Target.Epoch,
|
|
|
|
Root: data.Target.Root,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
InclusionDelay: att.InclusionDelay,
|
|
|
|
ProposerIndex: att.ProposerIndex,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resultCurrEpochAtts := make([]*ethpbv1.PendingAttestation, len(sourceCurrEpochAtts))
|
|
|
|
for i, att := range sourceCurrEpochAtts {
|
|
|
|
data := att.Data
|
|
|
|
resultCurrEpochAtts[i] = ðpbv1.PendingAttestation{
|
|
|
|
AggregationBits: att.AggregationBits,
|
|
|
|
Data: ðpbv1.AttestationData{
|
|
|
|
Slot: data.Slot,
|
|
|
|
Index: data.CommitteeIndex,
|
|
|
|
BeaconBlockRoot: data.BeaconBlockRoot,
|
|
|
|
Source: ðpbv1.Checkpoint{
|
|
|
|
Epoch: data.Source.Epoch,
|
|
|
|
Root: data.Source.Root,
|
|
|
|
},
|
|
|
|
Target: ðpbv1.Checkpoint{
|
|
|
|
Epoch: data.Target.Epoch,
|
|
|
|
Root: data.Target.Root,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
InclusionDelay: att.InclusionDelay,
|
|
|
|
ProposerIndex: att.ProposerIndex,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result := ðpbv1.BeaconState{
|
|
|
|
GenesisTime: state.GenesisTime(),
|
|
|
|
GenesisValidatorsRoot: bytesutil.SafeCopyBytes(state.GenesisValidatorRoot()),
|
|
|
|
Slot: state.Slot(),
|
|
|
|
Fork: ðpbv1.Fork{
|
|
|
|
PreviousVersion: bytesutil.SafeCopyBytes(sourceFork.PreviousVersion),
|
|
|
|
CurrentVersion: bytesutil.SafeCopyBytes(sourceFork.CurrentVersion),
|
|
|
|
Epoch: sourceFork.Epoch,
|
|
|
|
},
|
|
|
|
LatestBlockHeader: ðpbv1.BeaconBlockHeader{
|
|
|
|
Slot: sourceLatestBlockHeader.Slot,
|
|
|
|
ProposerIndex: sourceLatestBlockHeader.ProposerIndex,
|
|
|
|
ParentRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.ParentRoot),
|
|
|
|
StateRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.StateRoot),
|
|
|
|
BodyRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.BodyRoot),
|
|
|
|
},
|
|
|
|
BlockRoots: bytesutil.SafeCopy2dBytes(state.BlockRoots()),
|
|
|
|
StateRoots: bytesutil.SafeCopy2dBytes(state.StateRoots()),
|
|
|
|
HistoricalRoots: bytesutil.SafeCopy2dBytes(state.HistoricalRoots()),
|
|
|
|
Eth1Data: ðpbv1.Eth1Data{
|
|
|
|
DepositRoot: bytesutil.SafeCopyBytes(sourceEth1Data.DepositRoot),
|
|
|
|
DepositCount: sourceEth1Data.DepositCount,
|
|
|
|
BlockHash: bytesutil.SafeCopyBytes(sourceEth1Data.BlockHash),
|
|
|
|
},
|
|
|
|
Eth1DataVotes: resultEth1DataVotes,
|
|
|
|
Eth1DepositIndex: state.Eth1DepositIndex(),
|
|
|
|
Validators: resultValidators,
|
|
|
|
Balances: state.Balances(),
|
|
|
|
RandaoMixes: bytesutil.SafeCopy2dBytes(state.RandaoMixes()),
|
|
|
|
Slashings: state.Slashings(),
|
|
|
|
PreviousEpochAttestations: resultPrevEpochAtts,
|
|
|
|
CurrentEpochAttestations: resultCurrEpochAtts,
|
|
|
|
JustificationBits: bytesutil.SafeCopyBytes(state.JustificationBits()),
|
|
|
|
PreviousJustifiedCheckpoint: ðpbv1.Checkpoint{
|
|
|
|
Epoch: sourcePrevJustifiedCheckpoint.Epoch,
|
|
|
|
Root: bytesutil.SafeCopyBytes(sourcePrevJustifiedCheckpoint.Root),
|
|
|
|
},
|
|
|
|
CurrentJustifiedCheckpoint: ðpbv1.Checkpoint{
|
|
|
|
Epoch: sourceCurrJustifiedCheckpoint.Epoch,
|
|
|
|
Root: bytesutil.SafeCopyBytes(sourceCurrJustifiedCheckpoint.Root),
|
|
|
|
},
|
|
|
|
FinalizedCheckpoint: ðpbv1.Checkpoint{
|
|
|
|
Epoch: sourceFinalizedCheckpoint.Epoch,
|
|
|
|
Root: bytesutil.SafeCopyBytes(sourceFinalizedCheckpoint.Root),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2021-09-02 19:28:55 +00:00
|
|
|
func BeaconStateAltairToV2(altairState *statev2.BeaconState) (*ethpbv2.BeaconStateV2, error) {
|
|
|
|
sourceFork := altairState.Fork()
|
|
|
|
sourceLatestBlockHeader := altairState.LatestBlockHeader()
|
|
|
|
sourceEth1Data := altairState.Eth1Data()
|
|
|
|
sourceEth1DataVotes := altairState.Eth1DataVotes()
|
|
|
|
sourceValidators := altairState.Validators()
|
|
|
|
sourcePrevJustifiedCheckpoint := altairState.PreviousJustifiedCheckpoint()
|
|
|
|
sourceCurrJustifiedCheckpoint := altairState.CurrentJustifiedCheckpoint()
|
|
|
|
sourceFinalizedCheckpoint := altairState.FinalizedCheckpoint()
|
|
|
|
|
|
|
|
resultEth1DataVotes := make([]*ethpbv1.Eth1Data, len(sourceEth1DataVotes))
|
|
|
|
for i, vote := range sourceEth1DataVotes {
|
|
|
|
resultEth1DataVotes[i] = ðpbv1.Eth1Data{
|
|
|
|
DepositRoot: bytesutil.SafeCopyBytes(vote.DepositRoot),
|
|
|
|
DepositCount: vote.DepositCount,
|
|
|
|
BlockHash: bytesutil.SafeCopyBytes(vote.BlockHash),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resultValidators := make([]*ethpbv1.Validator, len(sourceValidators))
|
|
|
|
for i, validator := range sourceValidators {
|
|
|
|
resultValidators[i] = ðpbv1.Validator{
|
|
|
|
Pubkey: bytesutil.SafeCopyBytes(validator.PublicKey),
|
|
|
|
WithdrawalCredentials: bytesutil.SafeCopyBytes(validator.WithdrawalCredentials),
|
|
|
|
EffectiveBalance: validator.EffectiveBalance,
|
|
|
|
Slashed: validator.Slashed,
|
|
|
|
ActivationEligibilityEpoch: validator.ActivationEligibilityEpoch,
|
|
|
|
ActivationEpoch: validator.ActivationEpoch,
|
|
|
|
ExitEpoch: validator.ExitEpoch,
|
|
|
|
WithdrawableEpoch: validator.WithdrawableEpoch,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sourcePrevEpochParticipation, err := altairState.PreviousEpochParticipation()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not get previous epoch participation")
|
|
|
|
}
|
|
|
|
sourceCurrEpochParticipation, err := altairState.CurrentEpochParticipation()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not get current epoch participation")
|
|
|
|
}
|
|
|
|
sourceInactivityScores, err := altairState.InactivityScores()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not get inactivity scores")
|
|
|
|
}
|
|
|
|
sourceCurrSyncCommittee, err := altairState.CurrentSyncCommittee()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not get current sync committee")
|
|
|
|
}
|
|
|
|
sourceNextSyncCommittee, err := altairState.NextSyncCommittee()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "could not get next sync committee")
|
|
|
|
}
|
|
|
|
|
|
|
|
result := ðpbv2.BeaconStateV2{
|
|
|
|
GenesisTime: altairState.GenesisTime(),
|
|
|
|
GenesisValidatorsRoot: bytesutil.SafeCopyBytes(altairState.GenesisValidatorRoot()),
|
|
|
|
Slot: altairState.Slot(),
|
|
|
|
Fork: ðpbv1.Fork{
|
|
|
|
PreviousVersion: bytesutil.SafeCopyBytes(sourceFork.PreviousVersion),
|
|
|
|
CurrentVersion: bytesutil.SafeCopyBytes(sourceFork.CurrentVersion),
|
|
|
|
Epoch: sourceFork.Epoch,
|
|
|
|
},
|
|
|
|
LatestBlockHeader: ðpbv1.BeaconBlockHeader{
|
|
|
|
Slot: sourceLatestBlockHeader.Slot,
|
|
|
|
ProposerIndex: sourceLatestBlockHeader.ProposerIndex,
|
|
|
|
ParentRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.ParentRoot),
|
|
|
|
StateRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.StateRoot),
|
|
|
|
BodyRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.BodyRoot),
|
|
|
|
},
|
|
|
|
BlockRoots: bytesutil.SafeCopy2dBytes(altairState.BlockRoots()),
|
|
|
|
StateRoots: bytesutil.SafeCopy2dBytes(altairState.StateRoots()),
|
|
|
|
HistoricalRoots: bytesutil.SafeCopy2dBytes(altairState.HistoricalRoots()),
|
|
|
|
Eth1Data: ðpbv1.Eth1Data{
|
|
|
|
DepositRoot: bytesutil.SafeCopyBytes(sourceEth1Data.DepositRoot),
|
|
|
|
DepositCount: sourceEth1Data.DepositCount,
|
|
|
|
BlockHash: bytesutil.SafeCopyBytes(sourceEth1Data.BlockHash),
|
|
|
|
},
|
|
|
|
Eth1DataVotes: resultEth1DataVotes,
|
|
|
|
Eth1DepositIndex: altairState.Eth1DepositIndex(),
|
|
|
|
Validators: resultValidators,
|
|
|
|
Balances: altairState.Balances(),
|
|
|
|
RandaoMixes: bytesutil.SafeCopy2dBytes(altairState.RandaoMixes()),
|
|
|
|
Slashings: altairState.Slashings(),
|
|
|
|
PreviousEpochParticipation: bytesutil.SafeCopyBytes(sourcePrevEpochParticipation),
|
|
|
|
CurrentEpochParticipation: bytesutil.SafeCopyBytes(sourceCurrEpochParticipation),
|
|
|
|
JustificationBits: bytesutil.SafeCopyBytes(altairState.JustificationBits()),
|
|
|
|
PreviousJustifiedCheckpoint: ðpbv1.Checkpoint{
|
|
|
|
Epoch: sourcePrevJustifiedCheckpoint.Epoch,
|
|
|
|
Root: bytesutil.SafeCopyBytes(sourcePrevJustifiedCheckpoint.Root),
|
|
|
|
},
|
|
|
|
CurrentJustifiedCheckpoint: ðpbv1.Checkpoint{
|
|
|
|
Epoch: sourceCurrJustifiedCheckpoint.Epoch,
|
|
|
|
Root: bytesutil.SafeCopyBytes(sourceCurrJustifiedCheckpoint.Root),
|
|
|
|
},
|
|
|
|
FinalizedCheckpoint: ðpbv1.Checkpoint{
|
|
|
|
Epoch: sourceFinalizedCheckpoint.Epoch,
|
|
|
|
Root: bytesutil.SafeCopyBytes(sourceFinalizedCheckpoint.Root),
|
|
|
|
},
|
|
|
|
InactivityScores: sourceInactivityScores,
|
|
|
|
CurrentSyncCommittee: ðpbv2.SyncCommittee{
|
|
|
|
Pubkeys: bytesutil.SafeCopy2dBytes(sourceCurrSyncCommittee.Pubkeys),
|
|
|
|
AggregatePubkey: bytesutil.SafeCopyBytes(sourceCurrSyncCommittee.AggregatePubkey),
|
|
|
|
},
|
|
|
|
NextSyncCommittee: ðpbv2.SyncCommittee{
|
|
|
|
Pubkeys: bytesutil.SafeCopy2dBytes(sourceNextSyncCommittee.Pubkeys),
|
|
|
|
AggregatePubkey: bytesutil.SafeCopyBytes(sourceNextSyncCommittee.AggregatePubkey),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|