Skip to content

Commit

Permalink
add missing HasBeaconMetadata check, rename HasBeaconMetadata to HasO…
Browse files Browse the repository at this point in the history
…nChainData, group share on-chain data into separate struct
  • Loading branch information
iurii-ssv committed Jan 9, 2025
1 parent c4f0089 commit 47c5e6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions eth/eventhandler/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ func (eh *EventHandler) handleValidatorExited(txn basedb.Txn, event *contract.Co
return nil, &MalformedEventError{Err: ErrShareBelongsToDifferentOwner}
}

if !share.HasBeaconMetadata() {
return nil, nil
}

pk := phase0.BLSPubKey{}
copy(pk[:], share.ValidatorPubKey[:])

Expand Down
20 changes: 12 additions & 8 deletions protocol/v2/types/ssvshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@ const (
// SSVShare is a spectypes.Share with extra data that fully describes SSV validator share.
type SSVShare struct {
spectypes.Share
ShareOnChainData

// lastUpdated is used to keep track of share last update time. Note, we don't
// store this field in DB - it just serves as a helper-indicator for when we might want
// to update SSVShare data so it doesn't get super stale.
lastUpdated time.Time

// committeeID is a cached value for committee ID so we don't recompute it every time.
committeeID atomic.Pointer[spectypes.CommitteeID]
}

// ShareOnChainData is share-related data pulled from blockchain.
type ShareOnChainData struct {
// Balance is validator (this share belongs to) balance.
Balance phase0.Gwei
// Status is validator (this share belongs to) state.
Expand All @@ -35,14 +47,6 @@ type SSVShare struct {
OwnerAddress common.Address
// Liquidated is validator (this share belongs to) liquidation status (true or false).
Liquidated bool

// lastUpdated is used to keep track of share last update time. Note, we don't
// store this field in DB - it just serves as a helper-indicator for when we might want
// to update SSVShare data so it doesn't get super stale.
lastUpdated time.Time

// committeeID is a cached value for committee ID so we don't recompute it every time.
committeeID atomic.Pointer[spectypes.CommitteeID]
}

// BelongsToOperator checks whether the share belongs to operator.
Expand Down

0 comments on commit 47c5e6a

Please sign in to comment.