Skip to content

Commit 67cbeda

Browse files
committed
Add a new ConfirmationTarget::MostConservativeEstimate
When we broke `ConfirmationTarget` out into task-specific names, we left `MaxDustHTLCExposure::FeeRateMultiplier` as using the "when we broadcast feerate" as we were mostly concerned about the dust thresholds on outbound channels where we pick the fee and drive our own funds to dust. In 51bf78d, that changed to include transaction fees on both inbound and outbound channels in our dust exposure amount, but we continued to use `ConfirmationTarget::OnChainSweep` for the fee estimator threshold. While the `MaxDustHTLCExposure::FeeRateMultiplier` value is quite conservative and shouldn't lead to force-closures unless feerate estimates disagree by something like 500 sat/vB (with only one HTLC active in a channel), this happened on Aug 22 when feerates spiked from 4 sat/vB to over 1000 sat/vB in one block. To avoid simple feerate estimate horizons causing this in the future, here we add a new `ConfirmationTarget::MostConservativeEstimate` which is used for dust calculations. This allows users to split out the estimates they use for checking counterparty feerates from the estimates used for actual broadcasting.
1 parent dced69d commit 67cbeda

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lightning/src/chain/chaininterface.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ pub trait BroadcasterInterface {
4949
/// estimation.
5050
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
5151
pub enum ConfirmationTarget {
52+
/// The most conservative feerate estimate available.
53+
///
54+
/// This is use to sanity-check our counterparty's feerates and should be as conservative as
55+
/// possible to ensure that we don't confuse a peer using a very conservative estimator for one
56+
/// trying to burn channel balance to dust.
57+
MostConservativeEstimate,
5258
/// We have some funds available on chain which we need to spend prior to some expiry time at
5359
/// which point our counterparty may be able to steal them. Generally we have in the high tens
5460
/// to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2442,7 +2442,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
24422442
fn get_dust_exposure_limiting_feerate<F: Deref>(&self,
24432443
fee_estimator: &LowerBoundedFeeEstimator<F>,
24442444
) -> u32 where F::Target: FeeEstimator {
2445-
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::OnChainSweep)
2445+
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MostConservativeEstimate)
24462446
}
24472447

24482448
pub fn get_max_dust_htlc_exposure_msat(&self, limiting_feerate_sat_per_kw: u32) -> u64 {

lightning/src/util/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ pub enum MaxDustHTLCExposure {
382382
/// to this maximum the channel may be unable to send/receive HTLCs between the maximum dust
383383
/// exposure and the new minimum value for HTLCs to be economically viable to claim.
384384
FixedLimitMsat(u64),
385-
/// This sets a multiplier on the [`ConfirmationTarget::OnChainSweep`] feerate (in sats/KW) to
386-
/// determine the maximum allowed dust exposure. If this variant is used then the maximum dust
387-
/// exposure in millisatoshis is calculated as:
385+
/// This sets a multiplier on the [`ConfirmationTarget::MostConservativeEstimate`] feerate (in
386+
/// sats/KW) to determine the maximum allowed dust exposure. If this variant is used then the
387+
/// maximum dust exposure in millisatoshis is calculated as:
388388
/// `feerate_per_kw * value`. For example, with our default value
389389
/// `FeeRateMultiplier(10_000)`:
390390
///
@@ -407,7 +407,7 @@ pub enum MaxDustHTLCExposure {
407407
/// by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat.
408408
///
409409
/// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator
410-
/// [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep
410+
/// [`ConfirmationTarget::MostConservativeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MostConservativeEstimate
411411
FeeRateMultiplier(u64),
412412
}
413413

0 commit comments

Comments
 (0)