Skip to content

Commit 2dce8c8

Browse files
fix(tbtc): re-check nonce after delay wait in inactivity claim submitter
The member-index delay (N * 2 blocks) could expire while another member submitted and the context cancellation hadn't reached this goroutine yet. A post-wait nonce check closes the TOCTOU window: if the nonce advanced while we waited, exit cleanly instead of hitting a stale-nonce error.
1 parent 74923b2 commit 2dce8c8

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

pkg/tbtc/inactivity.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,22 @@ func (ics *inactivityClaimSubmitter) SubmitClaim(
436436
return nil
437437
}
438438

439+
// Re-check the nonce after the delay wait. Another member may have
440+
// submitted the claim while we were waiting.
441+
currentNonce, err = ics.chain.GetInactivityClaimNonce(ecdsaWalletID)
442+
if err != nil {
443+
return fmt.Errorf("could not get nonce for wallet: [%v]", err)
444+
}
445+
446+
if currentNonce.Cmp(inactivityNonce) > 0 {
447+
ics.inactivityLogger.Infof(
448+
"[member:%v] inactivity claim already submitted; "+
449+
"aborting inactivity claim on-chain submission",
450+
memberIndex,
451+
)
452+
return nil
453+
}
454+
439455
ics.inactivityLogger.Infof(
440456
"[member:%v] submitting inactivity claim with [%v] supporting "+
441457
"member signatures",

0 commit comments

Comments
 (0)