Skip to content

Commit

Permalink
remove with loop to make sure even skipepd slots are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
y0sher committed Nov 20, 2024
1 parent 2e2577f commit e4ed505
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions protocol/v2/ssv/validator/non_committee_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/ssvlabs/ssv/utils/casts"
)

const postConsensusContainerCapacity = 34

type CommitteeObserver struct {
logger *zap.Logger
Storage *storage.QBFTStores
Expand Down Expand Up @@ -82,7 +84,7 @@ func NewCommitteeObserver(identifier convert.MessageID, opts CommitteeObserverOp
attesterRoots: opts.AttesterRoots,
syncCommRoots: opts.SyncCommRoots,
domainCache: opts.DomainCache,
postConsensusContainer: make(map[phase0.Slot]map[phase0.ValidatorIndex]*ssv.PartialSigContainer),
postConsensusContainer: make(map[phase0.Slot]map[phase0.ValidatorIndex]*ssv.PartialSigContainer, postConsensusContainerCapacity),
}
}

Expand Down Expand Up @@ -259,8 +261,14 @@ func (ncv *CommitteeObserver) processMessage(
}

// Remove older slots container
thresholdSlot := currentSlot - 12 // won't get new messages after 12 slots
delete(ncv.postConsensusContainer, thresholdSlot)
if len(ncv.postConsensusContainer) >= postConsensusContainerCapacity {
thresholdSlot := currentSlot - postConsensusContainerCapacity
for slot := range ncv.postConsensusContainer {
if slot < thresholdSlot {
delete(ncv.postConsensusContainer, slot)
}
}
}

return quorums, nil
}
Expand Down

0 comments on commit e4ed505

Please sign in to comment.