-
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
Don't over-penalize channels with inflight HTLCs #3356
Don't over-penalize channels with inflight HTLCs #3356
Conversation
Unclear why this change causes |
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.
Code changes lgtm except the one comment.
0677c21
to
69594e9
Compare
|
AFAICT, this has to due with using unstable sort with rust-lightning/lightning/src/routing/router.rs Lines 3240 to 3243 in d4e8b49
Next, the rust-lightning/lightning/src/routing/router.rs Lines 3246 to 3258 in d4e8b49
Thus, the test fails because it wants two paths but it only gets one (i.e., the one not applying |
Ok, I took a closer look. Unstable sort isn't actually the problem. Since the the penalty has decreased, the cost per value on those paths where |
69594e9
to
9ac1737
Compare
Changing the amount used in the test from |
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.
Does what it says in commit description.
- We now send inflight_htlc_amount and htlc_amount separately to calculate penalty.
- Uses htlc_amount to calculate penalty multiplers(negative).
- Uses total_amount (inflight_htlc+htlc_amount) to calculate success probability(positive) and bounds.
- All instances of htlc_amount and total_amount (inflight_htlc+htlc_amount) checked.
let (numerator, denominator) = success_probability( | ||
total_inflight_amount_msat, 0, available_capacity, available_capacity, | ||
score_params, true, | ||
); | ||
let negative_log10_times_2048 = | ||
log_approx::negative_log10_times_2048(numerator, denominator); | ||
res = res.saturating_add(Self::combined_penalty_msat(amount_msat, negative_log10_times_2048, |
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.
Doubt: Can you explain why liquidity_penalty
only needs to be applied over htlc_amount_msat
and not total_inflight
?
Previously, this penalty would increase with each new htlc being routed through the same channel, but now, every htlc(whether the 1st or the 10th) will be treated equal for liquidity penalty iiuc.
I understand it might not be working as designed/intended at first but how was it wrong?
Is it because we don't want to penalize twice(once for liquidity_penalty
and next for success_probability
), since success_probability
is already non-linear for increasing amounts?
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, we want to use the total amount when computing the success probability since in-flight HTLCs will affect this. However, when computing the actual penalties we use the payment amount (i.e., amount_msat
) and the success probability. So each successive HTLC in-flight would cause the penalty to increase since the success probability would decrease (assuming the total amount is above the minimum liquidity estimate).
That said, as written, our docs may need to be clearer about what amount is used to compute the success probability (total amount) and what amount is used for the penalty (payment amount w/ success probability).
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.
That said, as written, our docs may need to be clearer about what amount is used to compute the success probability (total amount) and what amount is used for the penalty (payment amount w/ success probability).
Updated the docs in the latest push, BTW.
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, feel free to squash fixups.
Commit df52da7 modified ProbabilisticScorer to apply some penalty amount multipliers (e.g., liquidity_penalty_amount_multiplier_msat) to the total amount flowing over the channel (i.e., including inflight HTLCs), not just the payment in question. This led to over-penalizing in-use channels. Instead, only apply the total amount when calculating success probability.
Commit df52da7 modified ProbabilisticScorer to apply some penalty amount multipliers to the total amount flowing over the channel. However, the commit updated the docs for base_penalty_amount_multiplier_msat even though that behavior didn't change. This commit reverts those docs.
Rename parameters used when calculating success probability to make it clear that the total mount in-flight should be used rather than the payment amount.
9ac1737
to
0305000
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!
@@ -1074,26 +1074,30 @@ fn three_f64_pow_3(a: f64, b: f64, c: f64) -> (f64, f64, f64) { | |||
/// | |||
/// Must not return a numerator or denominator greater than 2^31 for arguments less than 2^31. | |||
/// | |||
/// `total_inflight_amount_msat` includes the amount of the HTLC and any HTLCs in flight over the |
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.
nit: there is a typo in last commit's description,
mount -> amount.
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.
Not gonna hold this up on a commit message typo.
Yes, was just waiting for your review. |
Commit df52da7 modified
ProbabilisticScorer
to apply some penalty amount multipliers (e.g.,liquidity_penalty_amount_multiplier_msat
) to the total amount flowing over the channel (i.e., including inflight HTLCs), not just the payment in question. This led to over-penalizing in-use channels. Instead, only apply the total amount when calculating success probability.Fixes #3271