Skip to content

Commit fb670c8

Browse files
authored
Merge pull request #2696 from TheBlueMatt/2023-10-no-chan-feerate-upper-bound
Drop non-anchor channel fee upper bound limit entirely
2 parents 0456b0e + d30d599 commit fb670c8

File tree

5 files changed

+7
-58
lines changed

5 files changed

+7
-58
lines changed

fuzz/src/chanmon_consistency.rs

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ impl FeeEstimator for FuzzEstimator {
8080
// always return a HighPriority feerate here which is >= the maximum Normal feerate and a
8181
// Background feerate which is <= the minimum Normal feerate.
8282
match conf_target {
83-
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => MAX_FEE * 10,
8483
ConfirmationTarget::OnChainSweep => MAX_FEE,
8584
ConfirmationTarget::ChannelCloseMinimum|ConfirmationTarget::AnchorChannelFee|ConfirmationTarget::MinAllowedAnchorChannelRemoteFee|ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => 253,
8685
ConfirmationTarget::NonAnchorChannelFee => cmp::min(self.ret_val.load(atomic::Ordering::Acquire), MAX_FEE),

fuzz/src/full_stack.rs

+2-2
Large diffs are not rendered by default.

lightning/src/chain/chaininterface.rs

-17
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,6 @@ pub enum ConfirmationTarget {
5353
/// to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a
5454
/// fee - this should be a relatively high priority feerate.
5555
OnChainSweep,
56-
/// The highest feerate we will allow our channel counterparty to have in a non-anchor channel.
57-
///
58-
/// This is the feerate on the transaction which we (or our counterparty) will broadcast in
59-
/// order to close the channel unilaterally. Because our counterparty must ensure they can
60-
/// always broadcast the latest state, this value being too low will cause immediate
61-
/// force-closures.
62-
///
63-
/// Allowing this value to be too high can allow our counterparty to burn our HTLC outputs to
64-
/// dust, which can result in HTLCs failing or force-closures (when the dust HTLCs exceed
65-
/// [`ChannelConfig::max_dust_htlc_exposure`]).
66-
///
67-
/// Because most nodes use a feerate estimate which is based on a relatively high priority
68-
/// transaction entering the current mempool, setting this to a small multiple of your current
69-
/// high priority feerate estimate should suffice.
70-
///
71-
/// [`ChannelConfig::max_dust_htlc_exposure`]: crate::util::config::ChannelConfig::max_dust_htlc_exposure
72-
MaxAllowedNonAnchorChannelRemoteFee,
7356
/// This is the lowest feerate we will allow our channel counterparty to have in an anchor
7457
/// channel in order to close the channel if a channel party goes away.
7558
///

lightning/src/ln/channel.rs

+3-31
Original file line numberDiff line numberDiff line change
@@ -2268,20 +2268,6 @@ impl<SP: Deref> Channel<SP> where
22682268
feerate_per_kw: u32, cur_feerate_per_kw: Option<u32>, logger: &L
22692269
) -> Result<(), ChannelError> where F::Target: FeeEstimator, L::Target: Logger,
22702270
{
2271-
// We only bound the fee updates on the upper side to prevent completely absurd feerates,
2272-
// always accepting up to 25 sat/vByte or 10x our fee estimator's "High Priority" fee.
2273-
// We generally don't care too much if they set the feerate to something very high, but it
2274-
// could result in the channel being useless due to everything being dust. This doesn't
2275-
// apply to channels supporting anchor outputs since HTLC transactions are pre-signed with a
2276-
// zero fee, so their fee is no longer considered to determine dust limits.
2277-
if !channel_type.supports_anchors_zero_fee_htlc_tx() {
2278-
let upper_limit =
2279-
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee) as u64;
2280-
if feerate_per_kw as u64 > upper_limit {
2281-
return Err(ChannelError::Close(format!("Peer's feerate much too high. Actual: {}. Our expected upper limit: {}", feerate_per_kw, upper_limit)));
2282-
}
2283-
}
2284-
22852271
let lower_limit_conf_target = if channel_type.supports_anchors_zero_fee_htlc_tx() {
22862272
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee
22872273
} else {
@@ -3986,14 +3972,11 @@ impl<SP: Deref> Channel<SP> where
39863972
return Err(ChannelError::Close("Peer sent update_fee when we needed a channel_reestablish".to_owned()));
39873973
}
39883974
Channel::<SP>::check_remote_fee(&self.context.channel_type, fee_estimator, msg.feerate_per_kw, Some(self.context.feerate_per_kw), logger)?;
3989-
let feerate_over_dust_buffer = msg.feerate_per_kw > self.context.get_dust_buffer_feerate(None);
39903975

39913976
self.context.pending_update_fee = Some((msg.feerate_per_kw, FeeUpdateState::RemoteAnnounced));
39923977
self.context.update_time_counter += 1;
3993-
// If the feerate has increased over the previous dust buffer (note that
3994-
// `get_dust_buffer_feerate` considers the `pending_update_fee` status), check that we
3995-
// won't be pushed over our dust exposure limit by the feerate increase.
3996-
if feerate_over_dust_buffer {
3978+
// Check that we won't be pushed over our dust exposure limit by the feerate increase.
3979+
if !self.context.channel_type.supports_anchors_zero_fee_htlc_tx() {
39973980
let inbound_stats = self.context.get_inbound_pending_htlc_stats(None);
39983981
let outbound_stats = self.context.get_outbound_pending_htlc_stats(None);
39993982
let holder_tx_dust_exposure = inbound_stats.on_holder_tx_dust_exposure_msat + outbound_stats.on_holder_tx_dust_exposure_msat;
@@ -7816,7 +7799,7 @@ mod tests {
78167799
use crate::ln::PaymentHash;
78177800
use crate::ln::channelmanager::{self, HTLCSource, PaymentId};
78187801
use crate::ln::channel::InitFeatures;
7819-
use crate::ln::channel::{Channel, ChannelState, InboundHTLCOutput, OutboundV1Channel, InboundV1Channel, OutboundHTLCOutput, InboundHTLCState, OutboundHTLCState, HTLCCandidate, HTLCInitiator, commit_tx_fee_msat};
7802+
use crate::ln::channel::{ChannelState, InboundHTLCOutput, OutboundV1Channel, InboundV1Channel, OutboundHTLCOutput, InboundHTLCState, OutboundHTLCState, HTLCCandidate, HTLCInitiator, commit_tx_fee_msat};
78207803
use crate::ln::channel::{MAX_FUNDING_SATOSHIS_NO_WUMBO, TOTAL_BITCOIN_SUPPLY_SATOSHIS, MIN_THEIR_CHAN_RESERVE_SATOSHIS};
78217804
use crate::ln::features::ChannelTypeFeatures;
78227805
use crate::ln::msgs::{ChannelUpdate, DecodeError, UnsignedChannelUpdate, MAX_VALUE_MSAT};
@@ -7858,17 +7841,6 @@ mod tests {
78587841
"MAX_FUNDING_SATOSHIS_NO_WUMBO is greater than all satoshis in existence");
78597842
}
78607843

7861-
#[test]
7862-
fn test_no_fee_check_overflow() {
7863-
// Previously, calling `check_remote_fee` with a fee of 0xffffffff would overflow in
7864-
// arithmetic, causing a panic with debug assertions enabled.
7865-
let fee_est = TestFeeEstimator { fee_est: 42 };
7866-
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(&fee_est);
7867-
assert!(Channel::<&TestKeysInterface>::check_remote_fee(
7868-
&ChannelTypeFeatures::only_static_remote_key(), &bounded_fee_estimator,
7869-
u32::max_value(), None, &&test_utils::TestLogger::new()).is_err());
7870-
}
7871-
78727844
struct Keys {
78737845
signer: InMemorySigner,
78747846
}

lightning/src/util/test_utils.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,8 @@ pub struct TestFeeEstimator {
9494
pub sat_per_kw: Mutex<u32>,
9595
}
9696
impl chaininterface::FeeEstimator for TestFeeEstimator {
97-
fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
98-
match confirmation_target {
99-
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => {
100-
core::cmp::max(25 * 250, *self.sat_per_kw.lock().unwrap() * 10)
101-
}
102-
_ => *self.sat_per_kw.lock().unwrap(),
103-
}
97+
fn get_est_sat_per_1000_weight(&self, _confirmation_target: ConfirmationTarget) -> u32 {
98+
*self.sat_per_kw.lock().unwrap()
10499
}
105100
}
106101

0 commit comments

Comments
 (0)