diff --git a/migrations/migration_5_gob.go b/migrations/migration_5_gob.go index 5ce2a40f8f..1b153ac8b0 100644 --- a/migrations/migration_5_gob.go +++ b/migrations/migration_5_gob.go @@ -59,7 +59,7 @@ type Metadata struct { Liquidated bool } -func storageShareGOBToSpecShare(share *storageShareGOB) (*types.SSVShare, error) { +func storageShareGOBToDomainShare(share *storageShareGOB) (*types.SSVShare, error) { committee := make([]*spectypes.ShareMember, len(share.Committee)) for i, c := range share.Committee { committee[i] = &spectypes.ShareMember{ @@ -75,7 +75,7 @@ func storageShareGOBToSpecShare(share *storageShareGOB) (*types.SSVShare, error) var validatorPubKey spectypes.ValidatorPK copy(validatorPubKey[:], share.ValidatorPubKey) - specShare := &types.SSVShare{ + domainShare := &types.SSVShare{ Share: spectypes.Share{ ValidatorPubKey: validatorPubKey, SharePubKey: share.SharePubKey, @@ -89,10 +89,10 @@ func storageShareGOBToSpecShare(share *storageShareGOB) (*types.SSVShare, error) } if share.BeaconMetadata != nil { - specShare.ValidatorIndex = share.BeaconMetadata.Index - specShare.Status = share.BeaconMetadata.Status - specShare.ActivationEpoch = share.BeaconMetadata.ActivationEpoch + domainShare.ValidatorIndex = share.BeaconMetadata.Index + domainShare.Status = share.BeaconMetadata.Status + domainShare.ActivationEpoch = share.BeaconMetadata.ActivationEpoch } - return specShare, nil + return domainShare, nil } diff --git a/migrations/migration_5_share_gob_to_ssz.go b/migrations/migration_5_share_gob_to_ssz.go index 1bb3308c0d..811da37601 100644 --- a/migrations/migration_5_share_gob_to_ssz.go +++ b/migrations/migration_5_share_gob_to_ssz.go @@ -50,11 +50,11 @@ var migration_5_change_share_format_from_gob_to_ssz = Migration{ return fmt.Errorf("have already seen GOB share with the same share ID: %s", sID) } sharesGOB[sID] = shareGOB - share, err := storageShareGOBToSpecShare(shareGOB) + share, err := storageShareGOBToDomainShare(shareGOB) if err != nil { - return fmt.Errorf("convert storage share to spec share: %w", err) + return fmt.Errorf("convert gob storage share to domain share: %w", err) } - shareSSZ := storage.FromSpecShare(share) + shareSSZ := storage.FromDomainShare(share) key := storage.SharesDBKey(shareSSZ.ValidatorPubKey[:]) value, err := shareSSZ.Encode() if err != nil { diff --git a/network/p2p/p2p_validation_test.go b/network/p2p/p2p_validation_test.go index 5aa65cf5c1..c9df7faafd 100644 --- a/network/p2p/p2p_validation_test.go +++ b/network/p2p/p2p_validation_test.go @@ -407,16 +407,16 @@ func generateShares(t *testing.T, count int) []*ssvtypes.SSVShare { for i := 0; i < count; i++ { validatorIndex := phase0.ValidatorIndex(i) - specShare := *spectestingutils.TestingShare(spectestingutils.Testing4SharesSet(), validatorIndex) + domainShare := *spectestingutils.TestingShare(spectestingutils.Testing4SharesSet(), validatorIndex) var pk spectypes.ValidatorPK _, err := cryptorand.Read(pk[:]) require.NoError(t, err) - specShare.ValidatorPubKey = pk + domainShare.ValidatorPubKey = pk share := &ssvtypes.SSVShare{ - Share: specShare, + Share: domainShare, Status: eth2apiv1.ValidatorStateActiveOngoing, Liquidated: false, } diff --git a/registry/storage/shares.go b/registry/storage/shares.go index 1f586df03d..302930b14f 100644 --- a/registry/storage/shares.go +++ b/registry/storage/shares.go @@ -146,9 +146,9 @@ func (s *sharesStorage) loadFromDB() error { return fmt.Errorf("failed to deserialize share: %w", err) } - share, err := ToSpecShare(val) + share, err := ToDomainShare(val) if err != nil { - return fmt.Errorf("failed to convert storage share to spec share: %w", err) + return fmt.Errorf("failed to convert storage share to domain share: %w", err) } s.shares[hex.EncodeToString(val.ValidatorPubKey[:])] = share @@ -253,7 +253,7 @@ func (s *sharesStorage) Save(rw basedb.ReadWriter, shares ...*types.SSVShare) er func (s *sharesStorage) saveToDB(rw basedb.ReadWriter, shares ...*types.SSVShare) error { return s.db.Using(rw).SetMany(s.storagePrefix, len(shares), func(i int) (basedb.Obj, error) { - share := FromSpecShare(shares[i]) + share := FromDomainShare(shares[i]) value, err := share.Encode() if err != nil { return basedb.Obj{}, fmt.Errorf("failed to serialize share: %w", err) @@ -262,7 +262,7 @@ func (s *sharesStorage) saveToDB(rw basedb.ReadWriter, shares ...*types.SSVShare }) } -func FromSpecShare(share *types.SSVShare) *Share { +func FromDomainShare(share *types.SSVShare) *Share { committee := make([]*storageOperator, len(share.Committee)) for i, c := range share.Committee { committee[i] = &storageOperator{ @@ -288,7 +288,7 @@ func FromSpecShare(share *types.SSVShare) *Share { } } -func ToSpecShare(stShare *Share) (*types.SSVShare, error) { +func ToDomainShare(stShare *Share) (*types.SSVShare, error) { committee := make([]*spectypes.ShareMember, len(stShare.Committee)) for i, c := range stShare.Committee { committee[i] = &spectypes.ShareMember{ @@ -304,7 +304,7 @@ func ToSpecShare(stShare *Share) (*types.SSVShare, error) { var validatorPubKey spectypes.ValidatorPK copy(validatorPubKey[:], stShare.ValidatorPubKey) - specShare := &types.SSVShare{ + domainShare := &types.SSVShare{ Share: spectypes.Share{ ValidatorIndex: phase0.ValidatorIndex(stShare.ValidatorIndex), ValidatorPubKey: validatorPubKey, @@ -320,7 +320,7 @@ func ToSpecShare(stShare *Share) (*types.SSVShare, error) { Liquidated: stShare.Liquidated, } - return specShare, nil + return domainShare, nil } var errShareNotFound = errors.New("share not found")