You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InstantSend: re-check stored locks against the active chain after a restart #8225
A node can keep a block that conflicts with an InstantSend lock it has already stored, and nothing checks that block against the lock again after a restart.
ConnectBlock rejects a block that conflicts with a stored lock. A block that was connected before the lock was stored is handled instead by NetInstantSend::ResolveBlockConflicts, which runs right after the lock is written and invalidates the conflicting block. That resolution is not persisted. If it does not finish, nothing retries it:
Crash in between. Blocks reconnected at startup skip the InstantSend check in ConnectBlock, because the node is still importing blocks then, which counts as initial block download, so a block whose index entry was already flushed is accepted again.
In both cases the lock is already known after the restart, so a peer relaying it again doesn't trigger resolution either. The node stays on the conflicting block until its chain is reorged away, usually by a ChainLock.
Expected
After startup, every stored lock is enforced against the active chain the same way it would have been had resolution completed: a non-ChainLocked block that conflicts with a stored lock is invalidated, and the node moves to the best valid chain.
Possible approach
Once the chainstate and the InstantSend db are loaded, and the node leaves initial block download, check the stored locks' inputs against the active chain (or check the blocks connected since the last flush against the stored locks) and run the existing conflict resolution for any hit. The InstantSend db already indexes locks by input, so the check can work from the coins spent by recent blocks rather than scanning every lock.
Context
Raised in review of #8212, which replaces the assert that previously crashed the node when shutdown interrupted conflict resolution.
Activity