-
Notifications
You must be signed in to change notification settings - Fork 404
Fix off-by-one finalized transaction locktime #2212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix off-by-one finalized transaction locktime #2212
Conversation
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #2212 +/- ##
==========================================
+ Coverage 91.53% 91.54% +0.01%
==========================================
Files 104 104
Lines 51332 51553 +221
Branches 51332 51553 +221
==========================================
+ Hits 46985 47195 +210
- Misses 4347 4358 +11
... and 16 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, and makes total sense. Please fix the tests though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, indeed gotta fix the bench.
The `height` argument passed to `OnchainTxHandler::block_disconnected` represents the height being disconnected, and not the current height. Due to the incorrect assumption, we'd generate a claim with a locktime in the future. Ultimately, we shouldn't be generating claims within `block_disconnected`. Rather, we should retry the claim at a later block height, since the bitcoin blockchain does not ever roll back without connecting a new block. Addressing this is left for future work.
In a future commit, we plan to correctly enforce that the spending transaction has a valid locktime relative to the chain for the node broascasting it in `TestBroadcaster::broadcast_transaction` to. We catch up these test node instances to their expected height, such that we do not fail said enforcement.
While these transactions were still valid, we incorrectly assumed that they would propagate with a locktime of `current_height + 1`, when in reality, only those with a locktime strictly lower than the next height in the chain are allowed to enter the mempool.
b8ba85b
to
97e4344
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post-merge review ACK 97e4344
@@ -1036,8 +1036,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner> | |||
} | |||
} | |||
for ((_package_id, _), ref mut request) in bump_candidates.iter_mut() { | |||
// `height` is the height being disconnected, so our `current_height` is 1 lower. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to claim at next block connection works well, until a user calls invalidateblock
and break this assumption, I think (though it’s a quite unorthodox uses of the consensus engine).
While these transactions were still valid, we incorrectly assumed that they would propagate with a locktime of
current_height + 1
, when in reality, only those with a locktime strictly lower than the next height in the chain are allowed to enter the mempool.Fixes #2181.