Skip to content

Commit 53b3d23

Browse files
authoredMay 28, 2024··
add lock to purgeMilestoneIDsList (#10493)
Fixes: #10479
1 parent d5a1725 commit 53b3d23

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
 

‎polygon/bor/finality/whitelist/milestone.go

+7
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (m *milestone) UnlockSprint(endBlockNum uint64) {
154154
}
155155

156156
m.Locked = false
157+
157158
m.purgeMilestoneIDsList()
158159

159160
err := rawdb.WriteLockField(m.db, m.Locked, m.LockedMilestoneNumber, m.LockedMilestoneHash, m.LockedMilestoneIDs)
@@ -213,6 +214,12 @@ func (m *milestone) GetMilestoneIDsList() []string {
213214

214215
// This is remove the milestoneIDs stored in the list.
215216
func (m *milestone) purgeMilestoneIDsList() {
217+
// try is used here as the finality lock is preserved over calls - so the lock state
218+
// is not clearly defined in the local code - this likely needs to be revised
219+
if m.finality.TryLock() {
220+
defer m.finality.Unlock()
221+
}
222+
216223
m.LockedMilestoneIDs = make(map[string]struct{})
217224
}
218225

‎polygon/bor/finality/whitelist/service_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,7 @@ func TestPropertyBasedTestingMilestone(t *testing.T) {
548548
}
549549

550550
fitlerFn := func(i uint64) bool {
551-
if i <= uint64(1000) {
552-
return true
553-
}
554-
555-
return false
551+
return i <= uint64(1000)
556552
}
557553

558554
var (

0 commit comments

Comments
 (0)
Please sign in to comment.