fix: expire stale pending cooperative exits after configurable threshold - #130
Open
vwinee21 wants to merge 2 commits into
Open
fix: expire stale pending cooperative exits after configurable threshold#130vwinee21 wants to merge 2 commits into
vwinee21 wants to merge 2 commits into
Conversation
Replace fragile prefix matching with proper btcutil.DecodeAddress validation which includes checksum verification. Resolves TODO in IsBitcoinAddressForNetwork.
Pending coop exits with ConfirmationHeightIsNil() can accumulate indefinitely if the L1 transaction is never confirmed (e.g. evicted from mempool due to low fee or replaced via RBF). Add expiry logic that runs each block cycle and deletes pending coop exits older than KnobWatchChainCoopExitPendingExpiryDays (default: 14 days). The 14-day default matches Bitcoin Core's DEFAULT_MEMPOOL_EXPIRY so entries are cleaned up around the time Bitcoin Core would drop them. Expiry count is logged at Info level when non-zero for observability. The threshold is runtime-configurable via the knob system without a code deploy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pending cooperative exits (
ConfirmationHeightIsNil()) accumulate indefinitely if the L1 transaction is never confirmed — for example, when evicted from the Bitcoin mempool due to low fees or replaced via RBF. This was noted in a TODO comment inwatch_chain.go.Solution
Add expiry logic that runs each block processing cycle. Pending coop exits older than
KnobWatchChainCoopExitPendingExpiryDays(default: 14 days) are deleted.Why 14 days? This matches Bitcoin Core's
DEFAULT_MEMPOOL_EXPIRY— by this point, any unconfirmed transaction would have been dropped from the mempool, so the pending record serves no purpose.Changes
so/knobs/knobs.go— addKnobWatchChainCoopExitPendingExpiryDaysknob +CoopExitPendingExpiryDays = 14default constantso/chain/watch_chain.go— replace TODO with expiry logic; logs count at Info level when non-zeroBehavior
ConfirmationHeightIsNil()entries — confirmed exits are untouched