@@ -1976,14 +1976,9 @@ pub(super) struct FundingScope {
1976
1976
/// Max to_local and to_remote outputs in a remote-generated commitment transaction
1977
1977
counterparty_max_commitment_tx_output: Mutex<(u64, u64)>,
1978
1978
1979
- // We save these values so we can make sure `next_local_commit_tx_fee_msat` and
1980
- // `next_remote_commit_tx_fee_msat` properly predict what the next commitment transaction fee will
1981
- // be, by comparing the cached values to the fee of the transaction generated by
1982
- // `build_commitment_transaction`.
1983
- #[cfg(any(test, fuzzing))]
1984
- next_local_commitment_tx_fee_info_cached: Mutex<Option<CommitmentTxInfoCached>>,
1985
- #[cfg(any(test, fuzzing))]
1986
- next_remote_commitment_tx_fee_info_cached: Mutex<Option<CommitmentTxInfoCached>>,
1979
+ // We save these values so we can make sure validation of channel updates properly predicts
1980
+ // what the next commitment transaction fee will be, by comparing the cached values to the
1981
+ // fee of the transaction generated by `build_commitment_transaction`.
1987
1982
#[cfg(any(test, fuzzing))]
1988
1983
next_local_fee: Mutex<PredictedNextFee>,
1989
1984
#[cfg(any(test, fuzzing))]
@@ -2061,10 +2056,6 @@ impl Readable for FundingScope {
2061
2056
short_channel_id,
2062
2057
minimum_depth_override,
2063
2058
#[cfg(any(test, fuzzing))]
2064
- next_local_commitment_tx_fee_info_cached: Mutex::new(None),
2065
- #[cfg(any(test, fuzzing))]
2066
- next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
2067
- #[cfg(any(test, fuzzing))]
2068
2059
next_local_fee: Mutex::new(PredictedNextFee::default()),
2069
2060
#[cfg(any(test, fuzzing))]
2070
2061
next_remote_fee: Mutex::new(PredictedNextFee::default()),
@@ -3210,10 +3201,6 @@ where
3210
3201
#[cfg(debug_assertions)]
3211
3202
counterparty_max_commitment_tx_output: Mutex::new((value_to_self_msat, (channel_value_satoshis * 1000 - msg_push_msat).saturating_sub(value_to_self_msat))),
3212
3203
3213
- #[cfg(any(test, fuzzing))]
3214
- next_local_commitment_tx_fee_info_cached: Mutex::new(None),
3215
- #[cfg(any(test, fuzzing))]
3216
- next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
3217
3204
#[cfg(any(test, fuzzing))]
3218
3205
next_local_fee: Mutex::new(PredictedNextFee::default()),
3219
3206
#[cfg(any(test, fuzzing))]
@@ -3457,10 +3444,6 @@ where
3457
3444
#[cfg(debug_assertions)]
3458
3445
counterparty_max_commitment_tx_output: Mutex::new((channel_value_satoshis * 1000 - push_msat, push_msat)),
3459
3446
3460
- #[cfg(any(test, fuzzing))]
3461
- next_local_commitment_tx_fee_info_cached: Mutex::new(None),
3462
- #[cfg(any(test, fuzzing))]
3463
- next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
3464
3447
#[cfg(any(test, fuzzing))]
3465
3448
next_local_fee: Mutex::new(PredictedNextFee::default()),
3466
3449
#[cfg(any(test, fuzzing))]
@@ -4456,20 +4439,6 @@ where
4456
4439
}
4457
4440
#[cfg(any(test, fuzzing))]
4458
4441
{
4459
- if funding.is_outbound() {
4460
- let projected_commit_tx_info = funding.next_local_commitment_tx_fee_info_cached.lock().unwrap().take();
4461
- *funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
4462
- if let Some(info) = projected_commit_tx_info {
4463
- let total_pending_htlcs = self.pending_inbound_htlcs.len() + self.pending_outbound_htlcs.len()
4464
- + self.holding_cell_htlc_updates.len();
4465
- if info.total_pending_htlcs == total_pending_htlcs
4466
- && info.next_holder_htlc_id == self.next_holder_htlc_id
4467
- && info.next_counterparty_htlc_id == self.next_counterparty_htlc_id
4468
- && info.feerate == self.feerate_per_kw {
4469
- assert_eq!(commitment_data.stats.commit_tx_fee_sat, info.fee / 1000);
4470
- }
4471
- }
4472
- }
4473
4442
let PredictedNextFee { predicted_feerate, predicted_htlcs, predicted_fee_sat } = funding.next_local_fee.lock().unwrap().clone();
4474
4443
let mut actual_nondust_htlcs: Vec<_> = commitment_data.tx.nondust_htlcs().iter().map(|&HTLCOutputInCommitment { offered, amount_msat, .. } | HTLCAmountDirection { outbound: offered, amount_msat }).collect();
4475
4444
actual_nondust_htlcs.sort_unstable();
@@ -5350,31 +5319,7 @@ where
5350
5319
}
5351
5320
5352
5321
let num_htlcs = included_htlcs + addl_htlcs;
5353
- let commit_tx_fee_msat = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000;
5354
- #[cfg(any(test, fuzzing))]
5355
- {
5356
- let mut fee = commit_tx_fee_msat;
5357
- if fee_spike_buffer_htlc.is_some() {
5358
- fee = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs - 1, funding.get_channel_type()) * 1000;
5359
- }
5360
- let total_pending_htlcs = context.pending_inbound_htlcs.len() + context.pending_outbound_htlcs.len()
5361
- + context.holding_cell_htlc_updates.len();
5362
- let commitment_tx_info = CommitmentTxInfoCached {
5363
- fee,
5364
- total_pending_htlcs,
5365
- next_holder_htlc_id: match htlc.origin {
5366
- HTLCInitiator::LocalOffered => context.next_holder_htlc_id + 1,
5367
- HTLCInitiator::RemoteOffered => context.next_holder_htlc_id,
5368
- },
5369
- next_counterparty_htlc_id: match htlc.origin {
5370
- HTLCInitiator::LocalOffered => context.next_counterparty_htlc_id,
5371
- HTLCInitiator::RemoteOffered => context.next_counterparty_htlc_id + 1,
5372
- },
5373
- feerate: context.feerate_per_kw,
5374
- };
5375
- *funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
5376
- }
5377
- commit_tx_fee_msat
5322
+ SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000
5378
5323
}
5379
5324
5380
5325
/// Get the commitment tx fee for the remote's next commitment transaction based on the number of
@@ -5451,30 +5396,7 @@ where
5451
5396
}
5452
5397
5453
5398
let num_htlcs = included_htlcs + addl_htlcs;
5454
- let commit_tx_fee_msat = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000;
5455
- #[cfg(any(test, fuzzing))]
5456
- if let Some(htlc) = &htlc {
5457
- let mut fee = commit_tx_fee_msat;
5458
- if fee_spike_buffer_htlc.is_some() {
5459
- fee = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs - 1, funding.get_channel_type()) * 1000;
5460
- }
5461
- let total_pending_htlcs = context.pending_inbound_htlcs.len() + context.pending_outbound_htlcs.len();
5462
- let commitment_tx_info = CommitmentTxInfoCached {
5463
- fee,
5464
- total_pending_htlcs,
5465
- next_holder_htlc_id: match htlc.origin {
5466
- HTLCInitiator::LocalOffered => context.next_holder_htlc_id + 1,
5467
- HTLCInitiator::RemoteOffered => context.next_holder_htlc_id,
5468
- },
5469
- next_counterparty_htlc_id: match htlc.origin {
5470
- HTLCInitiator::LocalOffered => context.next_counterparty_htlc_id,
5471
- HTLCInitiator::RemoteOffered => context.next_counterparty_htlc_id + 1,
5472
- },
5473
- feerate: context.feerate_per_kw,
5474
- };
5475
- *funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
5476
- }
5477
- commit_tx_fee_msat
5399
+ SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000
5478
5400
}
5479
5401
5480
5402
#[rustfmt::skip]
@@ -6129,15 +6051,6 @@ macro_rules! promote_splice_funding {
6129
6051
};
6130
6052
}
6131
6053
6132
- #[cfg(any(test, fuzzing))]
6133
- struct CommitmentTxInfoCached {
6134
- fee: u64,
6135
- total_pending_htlcs: usize,
6136
- next_holder_htlc_id: u64,
6137
- next_counterparty_htlc_id: u64,
6138
- feerate: u32,
6139
- }
6140
-
6141
6054
#[cfg(any(test, fuzzing))]
6142
6055
#[derive(Clone, Default)]
6143
6056
struct PredictedNextFee {
@@ -7646,16 +7559,6 @@ where
7646
7559
return Err(ChannelError::close("Received an unexpected revoke_and_ack".to_owned()));
7647
7560
}
7648
7561
7649
- #[cfg(any(test, fuzzing))]
7650
- {
7651
- for funding in
7652
- core::iter::once(&mut self.funding).chain(self.pending_funding.iter_mut())
7653
- {
7654
- *funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
7655
- *funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
7656
- }
7657
- }
7658
-
7659
7562
match &self.context.holder_signer {
7660
7563
ChannelSignerType::Ecdsa(ecdsa) => {
7661
7564
ecdsa
@@ -11097,19 +11000,6 @@ where
11097
11000
11098
11001
#[cfg(any(test, fuzzing))]
11099
11002
{
11100
- if !funding.is_outbound() {
11101
- let projected_commit_tx_info = funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap().take();
11102
- *funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
11103
- if let Some(info) = projected_commit_tx_info {
11104
- let total_pending_htlcs = self.context.pending_inbound_htlcs.len() + self.context.pending_outbound_htlcs.len();
11105
- if info.total_pending_htlcs == total_pending_htlcs
11106
- && info.next_holder_htlc_id == self.context.next_holder_htlc_id
11107
- && info.next_counterparty_htlc_id == self.context.next_counterparty_htlc_id
11108
- && info.feerate == self.context.feerate_per_kw {
11109
- assert_eq!(commitment_data.stats.commit_tx_fee_sat, info.fee);
11110
- }
11111
- }
11112
- }
11113
11003
let PredictedNextFee { predicted_feerate, predicted_htlcs, predicted_fee_sat } = funding.next_remote_fee.lock().unwrap().clone();
11114
11004
let mut actual_nondust_htlcs: Vec<_> = counterparty_commitment_tx.nondust_htlcs().iter().map(|&HTLCOutputInCommitment { offered, amount_msat, .. }| HTLCAmountDirection { outbound: !offered, amount_msat }).collect();
11115
11005
actual_nondust_htlcs.sort_unstable();
@@ -13737,10 +13627,6 @@ where
13737
13627
#[cfg(debug_assertions)]
13738
13628
counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
13739
13629
13740
- #[cfg(any(test, fuzzing))]
13741
- next_local_commitment_tx_fee_info_cached: Mutex::new(None),
13742
- #[cfg(any(test, fuzzing))]
13743
- next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
13744
13630
#[cfg(any(test, fuzzing))]
13745
13631
next_local_fee: Mutex::new(PredictedNextFee::default()),
13746
13632
#[cfg(any(test, fuzzing))]
0 commit comments