-
Notifications
You must be signed in to change notification settings - Fork 401
Add ChannelContext::get_commitment_stats
#3682
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
Add ChannelContext::get_commitment_stats
#3682
Conversation
👋 Thanks for assigning @wpaulino as a reviewer! |
0af1b43
to
31300c3
Compare
Why is this draft? |
@TheBlueMatt I don't feel great about the code duplication between Let me know what you think. |
I'm working on further cleanups now. |
d6b1f51
to
c540347
Compare
@wpaulino the PR is in a better spot now, let me know what you think. |
c540347
to
c9b30cb
Compare
e637050
to
4d6bf13
Compare
5a212d8
to
d682615
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3682 +/- ##
==========================================
- Coverage 89.18% 89.16% -0.03%
==========================================
Files 155 155
Lines 120796 120861 +65
Branches 120796 120861 +65
==========================================
+ Hits 107731 107760 +29
- Misses 10415 10446 +31
- Partials 2650 2655 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d682615
to
6f80f99
Compare
@TheBlueMatt take a look when you can thank you! |
a6c6eac
to
71df614
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.
Basically LGTM, one nit. Sorry somehow I lost track of this one.
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.
Needs rebase, it seems
6d8fb6e
to
793d4d2
Compare
A question for you in an above comment Matt thanks :) |
0c7bab6
to
285f1b9
Compare
🔔 1st Reminder Hey @wpaulino! This PR has been waiting for your review. |
285f1b9
to
39f11e6
Compare
39f11e6
to
107619e
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.
LGTM, two minor comments
It can be useful to get the stats on a potential commitment transaction without actually building it. Therefore, this commit splits the stats calculations from the actual build of a commitment transaction. This introduces an extra loop over the pending htlcs when actually building a commitment transaction, but current network behavior produces very few concurrent htlcs on channels. Furthermore, each iteration of the loop in the stats calculation is very cheap. The motivating use case for `build_commitment_stats` is to calculate the balances of the channel parties in order to validate the `funding_contribution_satoshis` field of `splice_init` and `splice_ack` messages without building a full commitment transaction.
186a320
to
fb69869
Compare
This allows us to DRY the code that calculates the `value_to_self_msat_offset` in `ChannelContext::build_commitment_stats`. HTLC success states have held their corresponding preimage since 0.0.105, and the release notes of 0.1 already require users running 0.0.123 and earlier to resolve their HTLCs before upgrading to 0.1. So this change is fully compatible with existing upgrade paths to the yet-to-be-shipped 0.2 release.
fb69869
to
671c4b0
Compare
Requested by @wpaulino in #3641