@@ -9888,11 +9888,13 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
9888
9888
let chanmon_cfgs = create_chanmon_cfgs(2);
9889
9889
let mut config = test_default_channel_config();
9890
9890
config.channel_config.max_dust_htlc_exposure = if multiplier_dust_limit {
9891
- // Default test fee estimator rate is 253 sat/kw, so we set the multiplier to 5_000_000 / 253
9892
- // to get roughly the same initial value as the default setting when this test was
9893
- // originally written.
9894
- MaxDustHTLCExposure::FeeRateMultiplier(5_000_000 / 253)
9895
- } else { MaxDustHTLCExposure::FixedLimitMsat(5_000_000) }; // initial default setting value
9891
+ // Default test fee estimator rate is 253 sat/kw plus 2530
9892
+ // sat/kw buffer added by `get_dust_buffer_feerate`, so we
9893
+ // set the multiplier to 5_002_500 / 253 to get roughly
9894
+ // the same initial value as the default setting when this
9895
+ // test was originally written.
9896
+ MaxDustHTLCExposure::FeeRateMultiplier(5_002_500 / 253)
9897
+ } else { MaxDustHTLCExposure::FixedLimitMsat(5_002_500) };
9896
9898
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
9897
9899
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config), None]);
9898
9900
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
@@ -9958,34 +9960,34 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
9958
9960
9959
9961
if on_holder_tx {
9960
9962
if dust_outbound_balance {
9961
- // Outbound dust threshold: 2223 sats (`dust_buffer_feerate` * HTLC_TIMEOUT_TX_WEIGHT / 1000 + holder's `dust_limit_satoshis`)
9962
- // Outbound dust balance: 4372 sats
9963
- // Note, we need sent payment to be above outbound dust threshold on counterparty_tx of 2132 sats
9963
+ // Outbound dust threshold: 2390 sats (`dust_buffer_feerate` * HTLC_TIMEOUT_TX_WEIGHT / 1000 + holder's `dust_limit_satoshis`)
9964
+ // Outbound dust balance: 4780 sats(dust_outbound_htlc_on_holder_tx * dust_outbound_htlc_on_holder_tx_msat)
9965
+ // Note, we need sent payment to be above outbound dust threshold on counterparty_tx of 1500 sats(dust_htlc_on_counterparty_tx * dust_htlc_on_counterparty_tx_msat)
9964
9966
for _ in 0..dust_outbound_htlc_on_holder_tx {
9965
9967
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], dust_outbound_htlc_on_holder_tx_msat);
9966
9968
nodes[0].node.send_payment_with_route(&route, payment_hash,
9967
9969
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
9968
9970
}
9969
9971
} else {
9970
- // Inbound dust threshold: 2324 sats (`dust_buffer_feerate` * HTLC_SUCCESS_TX_WEIGHT / 1000 + holder's `dust_limit_satoshis`)
9971
- // Inbound dust balance: 4372 sats
9972
- // Note, we need sent payment to be above outbound dust threshold on counterparty_tx of 2031 sats
9972
+ // Inbound dust threshold: 2501 sats (`dust_buffer_feerate` * HTLC_SUCCESS_TX_WEIGHT / 1000 + holder's `dust_limit_satoshis`)
9973
+ // Inbound dust balance: 5002 sats(dust_inbound_htlc_on_holder_tx * dust_inbound_htlc_on_holder_tx_msat)
9974
+ // Note, we need sent payment to be above outbound dust threshold on counterparty_tx of 1500 sats(dust_htlc_on_counterparty_tx * dust_htlc_on_counterparty_tx_msat)
9973
9975
for _ in 0..dust_inbound_htlc_on_holder_tx {
9974
9976
route_payment(&nodes[1], &[&nodes[0]], dust_inbound_htlc_on_holder_tx_msat);
9975
9977
}
9976
9978
}
9977
9979
} else {
9978
9980
if dust_outbound_balance {
9979
- // Outbound dust threshold: 2132 sats (`dust_buffer_feerate` * HTLC_TIMEOUT_TX_WEIGHT / 1000 + counteparty's `dust_limit_satoshis`)
9980
- // Outbound dust balance: 5000 sats
9981
+ // Outbound dust threshold: 2198 sats (`dust_buffer_feerate` * HTLC_TIMEOUT_TX_WEIGHT / 1000 + counteparty's `dust_limit_satoshis`)
9982
+ // Outbound dust balance: 4396 sats(dust_outbound_htlc_on_holder_tx * dust_outbound_htlc_on_holder_tx_msat)
9981
9983
for _ in 0..dust_htlc_on_counterparty_tx - 1 {
9982
9984
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], dust_htlc_on_counterparty_tx_msat);
9983
9985
nodes[0].node.send_payment_with_route(&route, payment_hash,
9984
9986
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
9985
9987
}
9986
9988
} else {
9987
- // Inbound dust threshold: 2031 sats (`dust_buffer_feerate` * HTLC_TIMEOUT_TX_WEIGHT / 1000 + counteparty's `dust_limit_satoshis`)
9988
- // Inbound dust balance: 5000 sats
9989
+ // Inbound dust threshold: 2309 sats (`dust_buffer_feerate` * HTLC_SUCCESS_TX_WEIGHT / 1000 + counteparty's `dust_limit_satoshis`)
9990
+ // Inbound dust balance: 4618 sats(dust_inbound_htlc_on_holder_tx * dust_inbound_htlc_on_holder_tx_msat)
9989
9991
for _ in 0..dust_htlc_on_counterparty_tx - 1 {
9990
9992
route_payment(&nodes[1], &[&nodes[0]], dust_htlc_on_counterparty_tx_msat);
9991
9993
}
@@ -10016,12 +10018,12 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
10016
10018
nodes[0].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &payment_event.msgs[0]);
10017
10019
// With default dust exposure: 5000 sats
10018
10020
if on_holder_tx {
10019
- // Outbound dust balance: 6399 sats
10021
+ // Outbound dust balance: 7503 sats (dust_outbound_htlc_on_holder_tx * dust_outbound_htlc_on_holder_tx_msat + dust_inbound_htlc_on_holder_tx_msat)
10020
10022
let dust_inbound_overflow = dust_inbound_htlc_on_holder_tx_msat * (dust_inbound_htlc_on_holder_tx + 1);
10021
10023
let dust_outbound_overflow = dust_outbound_htlc_on_holder_tx_msat * dust_outbound_htlc_on_holder_tx + dust_inbound_htlc_on_holder_tx_msat;
10022
10024
nodes[0].logger.assert_log("lightning::ln::channel", format!("Cannot accept value that would put our exposure to dust HTLCs at {} over the limit {} on holder commitment tx", if dust_outbound_balance { dust_outbound_overflow } else { dust_inbound_overflow }, max_dust_htlc_exposure_msat), 1);
10023
10025
} else {
10024
- // Outbound dust balance: 5200 sats
10026
+ // Outbound dust balance: 6000 sats(dust_htlc_on_counterparty_tx * dust_htlc_on_counterparty_tx_msat)
10025
10027
nodes[0].logger.assert_log("lightning::ln::channel",
10026
10028
format!("Cannot accept value that would put our exposure to dust HTLCs at {} over the limit {} on counterparty commitment tx",
10027
10029
dust_htlc_on_counterparty_tx_msat * (dust_htlc_on_counterparty_tx - 1) + dust_htlc_on_counterparty_tx_msat + 4,
@@ -10032,7 +10034,7 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
10032
10034
// For the multiplier dust exposure limit, since it scales with feerate,
10033
10035
// we need to add a lot of HTLCs that will become dust at the new feerate
10034
10036
// to cross the threshold.
10035
- for _ in 0..20 {
10037
+ for _ in 0..30 {
10036
10038
let (_, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[1], Some(1_000), None);
10037
10039
nodes[0].node.send_payment_with_route(&route, payment_hash,
10038
10040
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)).unwrap();
@@ -10054,12 +10056,12 @@ fn do_test_max_dust_htlc_exposure(dust_outbound_balance: bool, exposure_breach_e
10054
10056
fn do_test_max_dust_htlc_exposure_by_threshold_type(multiplier_dust_limit: bool) {
10055
10057
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, true, multiplier_dust_limit);
10056
10058
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, true, multiplier_dust_limit);
10059
+ do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10060
+ do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCForward, false, multiplier_dust_limit);
10057
10061
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtHTLCReception, true, multiplier_dust_limit);
10058
10062
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);
10060
10063
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtHTLCReception, false, multiplier_dust_limit);
10061
10064
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);
10063
10065
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtUpdateFeeOutbound, true, multiplier_dust_limit);
10064
10066
do_test_max_dust_htlc_exposure(true, ExposureEvent::AtUpdateFeeOutbound, false, multiplier_dust_limit);
10065
10067
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtUpdateFeeOutbound, false, multiplier_dust_limit);
0 commit comments