Skip to content

Commit 115f7f0

Browse files
committed
Correct RBF bump rate calculation
Dating back to its introduction in 757bcc2, `get_height_timer` has never used the `MIDDLE_FREQUENCY_BUMP_INTERVAL` (then not even a constant) as its if tree was in the wrong order. This fixes that.
1 parent dbbb23b commit 115f7f0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lightning/src/chain/package.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,13 @@ pub(crate) const LOW_FREQUENCY_BUMP_INTERVAL: u32 = 15;
114114

115115
/// Height delay at which transactions are fee-bumped/rebroadcasted with a middle priority.
116116
const MIDDLE_FREQUENCY_BUMP_INTERVAL: u32 = 3;
117+
117118
/// Height delay at which transactions are fee-bumped/rebroadcasted with a high priority.
119+
#[cfg(not(test))]
118120
const HIGH_FREQUENCY_BUMP_INTERVAL: u32 = 1;
121+
/// Height delay at which transactions are fee-bumped/rebroadcasted with a high priority.
122+
#[cfg(test)]
123+
pub(crate) const HIGH_FREQUENCY_BUMP_INTERVAL: u32 = 1;
119124

120125
/// A struct to describe a revoked output and corresponding information to generate a solving
121126
/// witness spending a commitment `to_local` output or a second-stage HTLC transaction output.

lightning/src/ln/functional_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::chain::chaininterface::LowerBoundedFeeEstimator;
1717
use crate::chain::channelmonitor;
1818
use crate::chain::channelmonitor::{CLOSED_CHANNEL_UPDATE_ID, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY};
1919
use crate::chain::transaction::OutPoint;
20+
use crate::chain::package::{LOW_FREQUENCY_BUMP_INTERVAL, HIGH_FREQUENCY_BUMP_INTERVAL};
2021
use crate::sign::{ecdsa::EcdsaChannelSigner, EntropySource, OutputSpender, SignerProvider};
2122
use crate::events::{Event, FundingInfo, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, ClosureReason, HTLCDestination, PaymentFailureReason};
2223
use crate::ln::types::{ChannelId, PaymentPreimage, PaymentSecret, PaymentHash};
@@ -7526,7 +7527,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() {
75267527
};
75277528

75287529
// After exhaustion of height timer, a new bumped justice tx should have been broadcast, check it
7529-
connect_blocks(&nodes[1], 15);
7530+
connect_blocks(&nodes[1], LOW_FREQUENCY_BUMP_INTERVAL);
75307531
let mut penalty_2 = penalty_1;
75317532
let mut feerate_2 = 0;
75327533
{
@@ -7549,7 +7550,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() {
75497550
assert_ne!(feerate_2, 0);
75507551

75517552
// After exhaustion of height timer for a 2nd time, a new bumped justice tx should have been broadcast, check it
7552-
connect_blocks(&nodes[1], 1);
7553+
connect_blocks(&nodes[1], HIGH_FREQUENCY_BUMP_INTERVAL);
75537554
let penalty_3;
75547555
let mut feerate_3 = 0;
75557556
{

0 commit comments

Comments
 (0)