diff --git a/polygon/bor/finality/whitelist/milestone.go b/polygon/bor/finality/whitelist/milestone.go index b4777c13cae..a79c712358e 100644 --- a/polygon/bor/finality/whitelist/milestone.go +++ b/polygon/bor/finality/whitelist/milestone.go @@ -154,6 +154,7 @@ func (m *milestone) UnlockSprint(endBlockNum uint64) { } m.Locked = false + m.purgeMilestoneIDsList() err := rawdb.WriteLockField(m.db, m.Locked, m.LockedMilestoneNumber, m.LockedMilestoneHash, m.LockedMilestoneIDs) @@ -213,6 +214,12 @@ func (m *milestone) GetMilestoneIDsList() []string { // This is remove the milestoneIDs stored in the list. func (m *milestone) purgeMilestoneIDsList() { + // try is used here as the finality lock is preserved over calls - so the lock state + // is not clearly defined in the local code - this likely needs to be revised + if m.finality.TryLock() { + defer m.finality.Unlock() + } + m.LockedMilestoneIDs = make(map[string]struct{}) } diff --git a/polygon/bor/finality/whitelist/service_test.go b/polygon/bor/finality/whitelist/service_test.go index 62fe3651dea..4e0de45b663 100644 --- a/polygon/bor/finality/whitelist/service_test.go +++ b/polygon/bor/finality/whitelist/service_test.go @@ -548,11 +548,7 @@ func TestPropertyBasedTestingMilestone(t *testing.T) { } fitlerFn := func(i uint64) bool { - if i <= uint64(1000) { - return true - } - - return false + return i <= uint64(1000) } var (