-
Notifications
You must be signed in to change notification settings - Fork 378
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
Tweak htlc dust exposure due to excess fees #3572
base: main
Are you sure you want to change the base?
Conversation
We account for the fees of the htlc transaction only in case the channel does _not_ support zero fee htlc transactions.
See commit 51bf78d for further background. |
lightning/src/ln/channel.rs
Outdated
let htlc_dust_exposure_msat = | ||
per_outbound_htlc_counterparty_commit_tx_fee_msat(excess_feerate, &self.context.channel_type); | ||
let counterparty_tx_dust_exposure = | ||
htlc_stats.on_counterparty_tx_dust_exposure_msat.saturating_add(htlc_dust_exposure_msat); |
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.
IIUC, since can_accept_incoming_htlc
is now called once it's been irrevocably committed on both sides, I think the dust exposure for this HTLC is already being accounted for in get_pending_htlc_stats
. I think we just need to enforce the check below? Having a test would be helpful here to confirm the behavior.
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.
thanks for the review. I mistakenly assumed can_accept_incoming_htlc
== "can we add this htlc to the commit tx?"
But at this point in the flow, the htlc is already on the commit tx !
Now I struggle to understand the point of checking here whether that htlc pushes us over the dust limit if it has already been added to the commit tx.
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.
as i understand now, this is a limitation of the spec - you cannot really complain about dust limits in direct response to an update_add_htlc
msg.
133e661
to
188f299
Compare
Thanks! Some test coverage here would still be nice if you're keen and it's not too much trouble. |
907c100
to
188f299
Compare
a80a769
to
41a54dc
Compare
In `can_accept_incoming_htlc`, `get_pending_htlc_stats` accounts for the incoming htlc. Therefore, `on_counterparty_tx_dust_exposure_msat` already includes the excess tx fees of the incoming non-dust htlc.
The widely used sats/kWU ratio is equivalent to msats/WU
The goal is to align `per_outbound_htlc_counterparty_commit_tx_fee_msat` with the slope `commit_tx_fee_sat` / `num_htlcs`. This is a minor detail - no existing LDK code multiplies the value returned by `per_outbound_htlc_counterparty_commit_tx_fee_msat` with `num_htlcs`.
Specifically, we check that the slope `commit_tx_fee_sat` / `num_htlcs` is consistent with `per_outbound_htlc_counterparty_commit_tx_fee_msat`.
41a54dc
to
eae77c0
Compare
eae77c0
to
b63b336
Compare
and