Skip to content

Commit

Permalink
Merge branch 'alan/pre-fork' into alan/pre-fork-spec-tests-alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Jul 25, 2024
2 parents b7776b6 + b171973 commit db6c137
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions protocol/genesis/types/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import (
// TODO: (Alan) write tests with all fields and equality checks
func ConvertToGenesisShare(share *spectypes.Share, operator *spectypes.CommitteeMember) *genesisspectypes.Share {
q, pc := ComputeQuorumAndPartialQuorum(len(share.Committee))

key := make([]byte, len(share.ValidatorPubKey))
copy(key, share.ValidatorPubKey[:])

genesisShare := &genesisspectypes.Share{
OperatorID: operator.OperatorID,
ValidatorPubKey: share.ValidatorPubKey[:], // Ensure this is necessary; remove if ValidatorPubKey is already a slice.
SharePubKey: share.SharePubKey,
ValidatorPubKey: key,
Committee: make([]*genesisspectypes.Operator, 0, len(share.Committee)),
Quorum: q,
PartialQuorum: pc,
Expand All @@ -35,10 +39,13 @@ func ConvertToGenesisShare(share *spectypes.Share, operator *spectypes.Committee
func ConvertToAlanShare(alanShare *typesv2.SSVShare, operator *spectypes.CommitteeMember) *SSVShare {
q, pc := ComputeQuorumAndPartialQuorum(len(alanShare.Committee))

key := make([]byte, len(alanShare.ValidatorPubKey))
copy(key, alanShare.ValidatorPubKey[:])

share := &SSVShare{
Share: genesisspectypes.Share{
OperatorID: operator.OperatorID,
ValidatorPubKey: genesisspectypes.ValidatorPK(alanShare.ValidatorPubKey[:]), // Ensure this is necessary; remove if ValidatorPubKey is already a slice.
ValidatorPubKey: key, // Ensure this is necessary; remove if ValidatorPubKey is already a slice.
SharePubKey: alanShare.SharePubKey,
Committee: make([]*genesisspectypes.Operator, 0, len(alanShare.Committee)),
Quorum: q,
Expand Down

0 comments on commit db6c137

Please sign in to comment.