Skip to content

Commit

Permalink
Update db migration to include ExitEpoch field
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-ssvlabs committed Jan 22, 2025
1 parent 1367942 commit f36eba7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions migrations/migration_5_gob.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func storageShareGOBToSpecShare(share *storageShareGOB) (*types.SSVShare, error)
specShare.ValidatorIndex = share.BeaconMetadata.Index
specShare.Status = share.BeaconMetadata.Status
specShare.ActivationEpoch = share.BeaconMetadata.ActivationEpoch
specShare.ExitEpoch = share.BeaconMetadata.ExitEpoch

Check warning on line 95 in migrations/migration_5_gob.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_gob.go#L95

Added line #L95 was not covered by tests
}

return specShare, nil
Expand Down
37 changes: 24 additions & 13 deletions migrations/migration_5_ssz.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type storageShareSSZ struct {

Status uint64
ActivationEpoch uint64
ExitEpoch uint64
OwnerAddress [addressLength]byte
Liquidated bool
}
Expand Down Expand Up @@ -79,6 +80,7 @@ func specShareToStorageShareSSZ(share *types.SSVShare) *storageShareSSZ {
Liquidated: share.Liquidated,
Status: uint64(share.Status), // nolint: gosec
ActivationEpoch: uint64(share.ActivationEpoch),
ExitEpoch: uint64(share.ExitEpoch),

Check warning on line 83 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L83

Added line #L83 was not covered by tests
}
}

Expand All @@ -88,7 +90,7 @@ func storageKeySSZ(pk []byte) []byte {
}

// Code generated by fastssz. DO NOT EDIT.
// Hash: 42489121add47f54f3dbbaafd9eb71f5236dbb074217e5d16cf2514b59c1b809
// Hash: db733f7dd9a2c4eff8b420f19db8693a753f5ebad67614990e209911e7010893
// Version: 0.1.3

// MarshalSSZ ssz marshals the storageShareSSZ object
Expand All @@ -99,7 +101,7 @@ func (s *storageShareSSZ) MarshalSSZ() ([]byte, error) {
// MarshalSSZTo ssz marshals the storageShareSSZ object to a target array
func (s *storageShareSSZ) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(129)
offset := int(137)

Check warning on line 104 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L104

Added line #L104 was not covered by tests

// Field (0) 'ValidatorIndex'
dst = ssz.MarshalUint64(dst, s.ValidatorIndex)
Expand Down Expand Up @@ -137,10 +139,13 @@ func (s *storageShareSSZ) MarshalSSZTo(buf []byte) (dst []byte, err error) {
// Field (8) 'ActivationEpoch'
dst = ssz.MarshalUint64(dst, s.ActivationEpoch)

// Field (9) 'OwnerAddress'
// Field (9) 'ExitEpoch'
dst = ssz.MarshalUint64(dst, s.ExitEpoch)

// Field (10) 'OwnerAddress'

Check warning on line 145 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L142-L145

Added lines #L142 - L145 were not covered by tests
dst = append(dst, s.OwnerAddress[:]...)

// Field (10) 'Liquidated'
// Field (11) 'Liquidated'

Check warning on line 148 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L148

Added line #L148 was not covered by tests
dst = ssz.MarshalBool(dst, s.Liquidated)

// Field (2) 'SharePubKey'
Expand Down Expand Up @@ -182,7 +187,7 @@ func (s *storageShareSSZ) MarshalSSZTo(buf []byte) (dst []byte, err error) {
func (s *storageShareSSZ) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 129 {
if size < 137 {

Check warning on line 190 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L190

Added line #L190 was not covered by tests
return ssz.ErrSize
}

Expand All @@ -203,7 +208,7 @@ func (s *storageShareSSZ) UnmarshalSSZ(buf []byte) error {
return ssz.ErrOffset
}

if o2 != 129 {
if o2 != 137 {

Check warning on line 211 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L211

Added line #L211 was not covered by tests
return ssz.ErrInvalidVariableOffset
}

Expand All @@ -229,11 +234,14 @@ func (s *storageShareSSZ) UnmarshalSSZ(buf []byte) error {
// Field (8) 'ActivationEpoch'
s.ActivationEpoch = ssz.UnmarshallUint64(buf[100:108])

// Field (9) 'OwnerAddress'
copy(s.OwnerAddress[:], buf[108:128])
// Field (9) 'ExitEpoch'
s.ExitEpoch = ssz.UnmarshallUint64(buf[108:116])

// Field (10) 'OwnerAddress'
copy(s.OwnerAddress[:], buf[116:136])

Check warning on line 241 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L237-L241

Added lines #L237 - L241 were not covered by tests

// Field (10) 'Liquidated'
s.Liquidated = ssz.UnmarshalBool(buf[128:129])
// Field (11) 'Liquidated'
s.Liquidated = ssz.UnmarshalBool(buf[136:137])

Check warning on line 244 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L243-L244

Added lines #L243 - L244 were not covered by tests

// Field (2) 'SharePubKey'
{
Expand Down Expand Up @@ -285,7 +293,7 @@ func (s *storageShareSSZ) UnmarshalSSZ(buf []byte) error {

// SizeSSZ returns the ssz encoded size in bytes for the storageShareSSZ object
func (s *storageShareSSZ) SizeSSZ() (size int) {
size = 129
size = 137

Check warning on line 296 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L296

Added line #L296 was not covered by tests

// Field (2) 'SharePubKey'
size += len(s.SharePubKey)
Expand Down Expand Up @@ -373,10 +381,13 @@ func (s *storageShareSSZ) HashTreeRootWith(hh ssz.HashWalker) (err error) {
// Field (8) 'ActivationEpoch'
hh.PutUint64(s.ActivationEpoch)

// Field (9) 'OwnerAddress'
// Field (9) 'ExitEpoch'
hh.PutUint64(s.ExitEpoch)

// Field (10) 'OwnerAddress'

Check warning on line 387 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L384-L387

Added lines #L384 - L387 were not covered by tests
hh.PutBytes(s.OwnerAddress[:])

// Field (10) 'Liquidated'
// Field (11) 'Liquidated'

Check warning on line 390 in migrations/migration_5_ssz.go

View check run for this annotation

Codecov / codecov/patch

migrations/migration_5_ssz.go#L390

Added line #L390 was not covered by tests
hh.PutBool(s.Liquidated)

hh.Merkleize(indx)
Expand Down

0 comments on commit f36eba7

Please sign in to comment.