Skip to content

Commit 7c355be

Browse files
authored
fix(test): make immutable deadline check more conservative (#13112)
Fixes: #13098
1 parent d7a2700 commit 7c355be

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

itests/kit/node_unmanaged.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ func (tm *TestUnmanagedMiner) submitProveCommit(
803803

804804
// Step 6: Submit the ProveCommit to the network
805805
if proofType.IsNonInteractive() {
806-
if tm.IsImmutableDeadline(provingDeadline) {
806+
if tm.MaybeImmutableDeadline(provingDeadline) {
807807
// avoid immutable deadlines
808808
provingDeadline = 5
809809
}
@@ -1701,12 +1701,17 @@ func (tm *TestUnmanagedMiner) AssertDisputeFails(sector abi.SectorNumber) {
17011701
req.Contains(err.Error(), "(RetCode=16)")
17021702
}
17031703

1704-
func (tm *TestUnmanagedMiner) IsImmutableDeadline(deadlineIndex uint64) bool {
1704+
// MaybeImmutableDeadline checks if the deadline index is immutable. Immutable deadlines are defined
1705+
// as being the current deadline for the miner or their next deadline. But we also include the
1706+
// deadline after the next deadline in our check here to be conservative to avoid race conditions of
1707+
// the chain progressing before messages land.
1708+
func (tm *TestUnmanagedMiner) MaybeImmutableDeadline(deadlineIndex uint64) bool {
17051709
req := require.New(tm.t)
17061710
di, err := tm.FullNode.StateMinerProvingDeadline(tm.ctx, tm.ActorAddr, types.EmptyTSK)
17071711
req.NoError(err)
17081712
currentDeadlineIdx := CurrentDeadlineIndex(di)
1709-
return currentDeadlineIdx == deadlineIndex || currentDeadlineIdx == deadlineIndex-1
1713+
// Check if deadlineIndex is the current, next, or the one after next.
1714+
return deadlineIndex >= currentDeadlineIdx && deadlineIndex <= currentDeadlineIdx+2
17101715
}
17111716

17121717
// CurrentDeadlineIndex manually calculates the current deadline index. This may be useful in

0 commit comments

Comments
 (0)