Skip to content

Commit f0de37a

Browse files
committed
Add a new ConfirmationTarget::MaximumFeeEstimate
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::MaximumFeeEstimate` 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 f0de37a

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl FeeEstimator for FuzzEstimator {
9797
// always return a HighPriority feerate here which is >= the maximum Normal feerate and a
9898
// Background feerate which is <= the minimum Normal feerate.
9999
match conf_target {
100-
ConfirmationTarget::OnChainSweep => MAX_FEE,
100+
ConfirmationTarget::MaximumFeeEstimate | ConfirmationTarget::OnChainSweep => MAX_FEE,
101101
ConfirmationTarget::ChannelCloseMinimum
102102
| ConfirmationTarget::AnchorChannelFee
103103
| ConfirmationTarget::MinAllowedAnchorChannelRemoteFee

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 aggressive (i.e. highest) feerate estimate available.
53+
///
54+
/// This is used 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+
MaximumFeeEstimate,
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::MaximumFeeEstimate)
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: 7 additions & 7 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::MaximumFeeEstimate`] 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::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate
411411
FeeRateMultiplier(u64),
412412
}
413413

@@ -514,12 +514,12 @@ pub struct ChannelConfig {
514514
/// Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement
515515
/// will scale linearly with increases (or decreases) in the our feerate estimates. Further,
516516
/// for anchor channels we expect our counterparty to use a relatively low feerate estimate
517-
/// while we use [`ConfirmationTarget::OnChainSweep`] (which should be relatively high) and
518-
/// feerate disagreement force-closures should only occur when theirs is higher than ours.
517+
/// while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high)
518+
/// and feerate disagreement force-closures should only occur when theirs is higher than ours.
519519
///
520520
/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000`
521521
///
522-
/// [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep
522+
/// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate
523523
pub max_dust_htlc_exposure: MaxDustHTLCExposure,
524524
/// The additional fee we're willing to pay to avoid waiting for the counterparty's
525525
/// `to_self_delay` to reclaim funds.

0 commit comments

Comments
 (0)