Skip to content

Commit 97caa10

Browse files
committed
Fix cmp::max execution in ChannelContext::get_dust_buffer_feerate
The current `cmp::max` doesnt align with the function comment, ie its comparing 2530 and `feerate_plus_quarter` instead of `feerate_per_kw + 2530` and `feerate_plus_quarter` which is fixed in this commit
1 parent 68d5e88 commit 97caa10

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2699,7 +2699,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
26992699
feerate_per_kw = cmp::max(feerate_per_kw, feerate);
27002700
}
27012701
let feerate_plus_quarter = feerate_per_kw.checked_mul(1250).map(|v| v / 1000);
2702-
cmp::max(2530, feerate_plus_quarter.unwrap_or(u32::max_value()))
2702+
cmp::max(feerate_per_kw + 2530, feerate_plus_quarter.unwrap_or(u32::max_value()))
27032703
}
27042704

27052705
/// Get forwarding information for the counterparty.

lightning/src/ln/functional_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9891,8 +9891,8 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
98919891
// Default test fee estimator rate is 253 sat/kw, so we set the multiplier to 5_000_000 / 253
98929892
// to get roughly the same initial value as the default setting when this test was
98939893
// originally written.
9894-
MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253)
9895-
} else { MaxDustHTLCExposure::FixedLimitMsat(5_000_000) }; // initial default setting value
9894+
MaxDustHTLCExposure::FeeRateMultiplier(6_000_000 / 253)
9895+
} else { MaxDustHTLCExposure::FixedLimitMsat(6_000_000) }; // initial default setting value
98969896
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
98979897
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config), None]);
98989898
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -10032,7 +10032,7 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
1003210032
// For the multiplier dust exposure limit, since it scales with feerate,
1003310033
// we need to add a lot of HTLCs that will become dust at the new feerate
1003410034
// to cross the threshold.
10035-
for _ in 0..20 {
10035+
for _ in 0..30 {
1003610036
let (_, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[1], Some(1_000), None);
1003710037
nodes[0].node.send_payment_with_route(&route, payment_hash,
1003810038
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
@@ -10054,12 +10054,12 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
1005410054
fn do_test_max_dust_htlc_exposure_by_threshold_type(multiplier_dust_limit: bool) {
1005510055
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, true, multiplier_dust_limit);
1005610056
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, true, multiplier_dust_limit);
10057+
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10058+
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
1005710059
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCReception, true, multiplier_dust_limit);
1005810060
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCReception, false, multiplier_dust_limit);
10059-
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
1006010061
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCReception, false, multiplier_dust_limit);
1006110062
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCReception, true, multiplier_dust_limit);
10062-
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
1006310063
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtUpdateFeeOutbound, true, multiplier_dust_limit);
1006410064
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtUpdateFeeOutbound, false, multiplier_dust_limit);
1006510065
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtUpdateFeeOutbound, false, multiplier_dust_limit);

0 commit comments

Comments
 (0)