@@ -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))]
@@ -4480,20 +4463,6 @@ where
4480
4463
}
4481
4464
#[cfg(any(test, fuzzing))]
4482
4465
{
4483
- if funding.is_outbound() {
4484
- let projected_commit_tx_info = funding.next_local_commitment_tx_fee_info_cached.lock().unwrap().take();
4485
- *funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
4486
- if let Some(info) = projected_commit_tx_info {
4487
- let total_pending_htlcs = self.pending_inbound_htlcs.len() + self.pending_outbound_htlcs.len()
4488
- + self.holding_cell_htlc_updates.len();
4489
- if info.total_pending_htlcs == total_pending_htlcs
4490
- && info.next_holder_htlc_id == self.next_holder_htlc_id
4491
- && info.next_counterparty_htlc_id == self.next_counterparty_htlc_id
4492
- && info.feerate == self.feerate_per_kw {
4493
- assert_eq!(commitment_data.stats.commit_tx_fee_sat, info.fee / 1000);
4494
- }
4495
- }
4496
- }
4497
4466
let PredictedNextFee { predicted_feerate, predicted_nondust_htlc_count, predicted_fee_sat } = *funding.next_local_fee.lock().unwrap();
4498
4467
if predicted_feerate == commitment_data.tx.feerate_per_kw() && predicted_nondust_htlc_count == commitment_data.tx.nondust_htlcs().len() {
4499
4468
assert_eq!(predicted_fee_sat, commitment_data.stats.commit_tx_fee_sat);
@@ -5327,31 +5296,7 @@ where
5327
5296
}
5328
5297
5329
5298
let num_htlcs = included_htlcs + addl_htlcs;
5330
- let commit_tx_fee_msat = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000;
5331
- #[cfg(any(test, fuzzing))]
5332
- {
5333
- let mut fee = commit_tx_fee_msat;
5334
- if fee_spike_buffer_htlc.is_some() {
5335
- fee = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs - 1, funding.get_channel_type()) * 1000;
5336
- }
5337
- let total_pending_htlcs = context.pending_inbound_htlcs.len() + context.pending_outbound_htlcs.len()
5338
- + context.holding_cell_htlc_updates.len();
5339
- let commitment_tx_info = CommitmentTxInfoCached {
5340
- fee,
5341
- total_pending_htlcs,
5342
- next_holder_htlc_id: match htlc.origin {
5343
- HTLCInitiator::LocalOffered => context.next_holder_htlc_id + 1,
5344
- HTLCInitiator::RemoteOffered => context.next_holder_htlc_id,
5345
- },
5346
- next_counterparty_htlc_id: match htlc.origin {
5347
- HTLCInitiator::LocalOffered => context.next_counterparty_htlc_id,
5348
- HTLCInitiator::RemoteOffered => context.next_counterparty_htlc_id + 1,
5349
- },
5350
- feerate: context.feerate_per_kw,
5351
- };
5352
- *funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
5353
- }
5354
- commit_tx_fee_msat
5299
+ SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000
5355
5300
}
5356
5301
5357
5302
/// Get the commitment tx fee for the remote's next commitment transaction based on the number of
@@ -5428,30 +5373,7 @@ where
5428
5373
}
5429
5374
5430
5375
let num_htlcs = included_htlcs + addl_htlcs;
5431
- let commit_tx_fee_msat = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000;
5432
- #[cfg(any(test, fuzzing))]
5433
- if let Some(htlc) = &htlc {
5434
- let mut fee = commit_tx_fee_msat;
5435
- if fee_spike_buffer_htlc.is_some() {
5436
- fee = SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs - 1, funding.get_channel_type()) * 1000;
5437
- }
5438
- let total_pending_htlcs = context.pending_inbound_htlcs.len() + context.pending_outbound_htlcs.len();
5439
- let commitment_tx_info = CommitmentTxInfoCached {
5440
- fee,
5441
- total_pending_htlcs,
5442
- next_holder_htlc_id: match htlc.origin {
5443
- HTLCInitiator::LocalOffered => context.next_holder_htlc_id + 1,
5444
- HTLCInitiator::RemoteOffered => context.next_holder_htlc_id,
5445
- },
5446
- next_counterparty_htlc_id: match htlc.origin {
5447
- HTLCInitiator::LocalOffered => context.next_counterparty_htlc_id,
5448
- HTLCInitiator::RemoteOffered => context.next_counterparty_htlc_id + 1,
5449
- },
5450
- feerate: context.feerate_per_kw,
5451
- };
5452
- *funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = Some(commitment_tx_info);
5453
- }
5454
- commit_tx_fee_msat
5376
+ SpecTxBuilder {}.commit_tx_fee_sat(context.feerate_per_kw, num_htlcs, funding.get_channel_type()) * 1000
5455
5377
}
5456
5378
5457
5379
#[rustfmt::skip]
@@ -6106,15 +6028,6 @@ macro_rules! promote_splice_funding {
6106
6028
};
6107
6029
}
6108
6030
6109
- #[cfg(any(test, fuzzing))]
6110
- struct CommitmentTxInfoCached {
6111
- fee: u64,
6112
- total_pending_htlcs: usize,
6113
- next_holder_htlc_id: u64,
6114
- next_counterparty_htlc_id: u64,
6115
- feerate: u32,
6116
- }
6117
-
6118
6031
#[cfg(any(test, fuzzing))]
6119
6032
#[derive(Clone, Copy, Default)]
6120
6033
struct PredictedNextFee {
@@ -7623,16 +7536,6 @@ where
7623
7536
return Err(ChannelError::close("Received an unexpected revoke_and_ack".to_owned()));
7624
7537
}
7625
7538
7626
- #[cfg(any(test, fuzzing))]
7627
- {
7628
- for funding in
7629
- core::iter::once(&mut self.funding).chain(self.pending_funding.iter_mut())
7630
- {
7631
- *funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
7632
- *funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
7633
- }
7634
- }
7635
-
7636
7539
match &self.context.holder_signer {
7637
7540
ChannelSignerType::Ecdsa(ecdsa) => {
7638
7541
ecdsa
@@ -11074,19 +10977,6 @@ where
11074
10977
11075
10978
#[cfg(any(test, fuzzing))]
11076
10979
{
11077
- if !funding.is_outbound() {
11078
- let projected_commit_tx_info = funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap().take();
11079
- *funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
11080
- if let Some(info) = projected_commit_tx_info {
11081
- let total_pending_htlcs = self.context.pending_inbound_htlcs.len() + self.context.pending_outbound_htlcs.len();
11082
- if info.total_pending_htlcs == total_pending_htlcs
11083
- && info.next_holder_htlc_id == self.context.next_holder_htlc_id
11084
- && info.next_counterparty_htlc_id == self.context.next_counterparty_htlc_id
11085
- && info.feerate == self.context.feerate_per_kw {
11086
- assert_eq!(commitment_data.stats.commit_tx_fee_sat, info.fee);
11087
- }
11088
- }
11089
- }
11090
10980
let PredictedNextFee { predicted_feerate, predicted_nondust_htlc_count, predicted_fee_sat } = *funding.next_remote_fee.lock().unwrap();
11091
10981
if predicted_feerate == counterparty_commitment_tx.feerate_per_kw() && predicted_nondust_htlc_count == counterparty_commitment_tx.nondust_htlcs().len() {
11092
10982
assert_eq!(predicted_fee_sat, commitment_data.stats.commit_tx_fee_sat);
@@ -13712,10 +13602,6 @@ where
13712
13602
#[cfg(debug_assertions)]
13713
13603
counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
13714
13604
13715
- #[cfg(any(test, fuzzing))]
13716
- next_local_commitment_tx_fee_info_cached: Mutex::new(None),
13717
- #[cfg(any(test, fuzzing))]
13718
- next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
13719
13605
#[cfg(any(test, fuzzing))]
13720
13606
next_local_fee: Mutex::new(PredictedNextFee::default()),
13721
13607
#[cfg(any(test, fuzzing))]
0 commit comments