From 5cd88f7e4861fb83ce46bdc09d0c61f4da4bd80d Mon Sep 17 00:00:00 2001 From: ziggie Date: Sun, 17 Nov 2024 18:24:38 +0100 Subject: [PATCH] contractcourt: remove 2xamount requirement for the sweeper. --- contractcourt/htlc_timeout_resolver.go | 20 ++++---------------- itest/lnd_sweep_test.go | 7 +------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go index 872a3da92..637b0110e 100644 --- a/contractcourt/htlc_timeout_resolver.go +++ b/contractcourt/htlc_timeout_resolver.go @@ -465,15 +465,9 @@ func (h *htlcTimeoutResolver) sweepTimeoutTx() error { } // Calculate the budget. - // - // TODO(yy): the budget is twice the output's value, which is needed as - // we don't force sweep the output now. To prevent cascading force - // closes, we use all its output value plus a wallet input as the - // budget. This is a temporary solution until we can optionally cancel - // the incoming HTLC, more details in, - // - https://github.com/lightningnetwork/lnd/issues/7969 budget := calculateBudget( - btcutil.Amount(inp.SignDesc().Output.Value), 2, 0, + btcutil.Amount(inp.SignDesc().Output.Value), + h.Budget.DeadlineHTLCRatio, h.Budget.DeadlineHTLC, ) h.log.Infof("offering 2nd-level HTLC timeout tx to sweeper "+ @@ -535,15 +529,9 @@ func (h *htlcTimeoutResolver) sweepDirectHtlcOutput() error { ) // Calculate the budget. - // - // TODO(yy): the budget is twice the output's value, which is needed as - // we don't force sweep the output now. To prevent cascading force - // closes, we use all its output value plus a wallet input as the - // budget. This is a temporary solution until we can optionally cancel - // the incoming HTLC, more details in, - // - https://github.com/lightningnetwork/lnd/issues/7969 budget := calculateBudget( - btcutil.Amount(sweepInput.SignDesc().Output.Value), 2, 0, + btcutil.Amount(sweepInput.SignDesc().Output.Value), + h.Budget.DeadlineHTLCRatio, h.Budget.DeadlineHTLC, ) log.Infof("%T(%x): offering offered remote timeout HTLC output to "+ diff --git a/itest/lnd_sweep_test.go b/itest/lnd_sweep_test.go index 8ad00a430..60f63ac3c 100644 --- a/itest/lnd_sweep_test.go +++ b/itest/lnd_sweep_test.go @@ -928,12 +928,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) { require.Len(ht, outgoingSweep.TxOut, 2) // Calculate the ending fee rate. - // - // TODO(yy): the budget we use to sweep the first-level outgoing HTLC - // is twice its value. This is a temporary mitigation to prevent - // cascading FCs and the test should be updated once it's properly - // fixed. - outgoingBudget := 2 * invoiceAmt + outgoingBudget := invoiceAmt.MulF64(contractcourt.DefaultBudgetRatio) outgoingTxSize := ht.CalculateTxWeight(outgoingSweep) outgoingEndFeeRate := chainfee.NewSatPerKWeight( outgoingBudget, outgoingTxSize,