Commit 124bd42
committed
Improve prediction of commitment stats in
`ChannelContext::get_pending_htlc_stats` predicts that the set of HTLCs
on the next commitment will be all the HTLCs in
`ChannelContext.pending_inbound_htlcs`, and
`ChannelContext.pending_outbound_htlcs`, as well as all the outbound
HTLC adds in the holding cell.
This is an overestimate:
* Outbound HTLC removals which have been ACK'ed by the counterparty will
certainly not be present in any *next* commitment, even though they
remain in `pending_outbound_htlcs` (I refer to states
`AwaitingRemoteRevokeToRemove` and `AwaitingRemovedRemoteRevoke`).
* Outbound HTLCs in the `RemoteRemoved` state, will not be present in
the next *local* commitment.
* Inbound HTLCs in the `LocalRemoved` state will not be present in the
next *remote* commitment.
`ChannelContext::build_commitment_stats(funding, true, true, ..)` makes
these errors when predicting the HTLC count on the remote commitment:
* Inbound HTLCs in the state `RemoteAnnounced` are not included, but
they will be in the next remote commitment transaction if the local
ACK's the addition before producing the next remote commitment.
* Inbound HTLCs in the state `AwaitingRemoteRevokeToAnnounce` are not
included, even though the local has ACK'ed the addition.
* Outbound HTLCs in the state `AwaitingRemoteRevokeToRemove` are
counted, even though the local party has ACK'ed the removal.
This commit replaces these functions in favor of the newly added
`ChannelContext::get_next_{local, remote}_commitment_stats` methods,
and fixes the issues described above.
We now always calculate dust exposure using a buffer from
`msg.feerate_per_kw`, and not from
`max(feerate_per_kw, self.feerate_per_kw, self.pending_update_fee)`.can_send_update_fee
1 parent d36fdab commit 124bd42
1 file changed
+9
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
1119 | | - | |
1120 | | - | |
1121 | 1119 | | |
1122 | 1120 | | |
1123 | 1121 | | |
| |||
4462 | 4460 | | |
4463 | 4461 | | |
4464 | 4462 | | |
4465 | | - | |
4466 | | - | |
4467 | | - | |
| 4463 | + | |
| 4464 | + | |
| 4465 | + | |
| 4466 | + | |
4468 | 4467 | | |
4469 | | - | |
| 4468 | + | |
4470 | 4469 | | |
4471 | 4470 | | |
4472 | 4471 | | |
4473 | 4472 | | |
4474 | 4473 | | |
4475 | 4474 | | |
4476 | 4475 | | |
4477 | | - | |
| 4476 | + | |
4478 | 4477 | | |
4479 | 4478 | | |
4480 | 4479 | | |
4481 | | - | |
| 4480 | + | |
| 4481 | + | |
| 4482 | + | |
4482 | 4483 | | |
4483 | 4484 | | |
4484 | 4485 | | |
| |||
4844 | 4845 | | |
4845 | 4846 | | |
4846 | 4847 | | |
4847 | | - | |
4848 | | - | |
4849 | 4848 | | |
4850 | 4849 | | |
4851 | 4850 | | |
| |||
4866 | 4865 | | |
4867 | 4866 | | |
4868 | 4867 | | |
4869 | | - | |
4870 | 4868 | | |
4871 | 4869 | | |
4872 | 4870 | | |
4873 | 4871 | | |
4874 | 4872 | | |
4875 | 4873 | | |
4876 | 4874 | | |
4877 | | - | |
4878 | | - | |
4879 | 4875 | | |
4880 | 4876 | | |
4881 | 4877 | | |
| |||
4913 | 4909 | | |
4914 | 4910 | | |
4915 | 4911 | | |
4916 | | - | |
4917 | | - | |
4918 | 4912 | | |
4919 | 4913 | | |
4920 | 4914 | | |
| |||
0 commit comments