Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The sweeper subsystem uses now also the configured budget values for HTLCs #9274

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions contractcourt/htlc_timeout_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
bitromortac marked this conversation as resolved.
Show resolved Hide resolved
h.Budget.DeadlineHTLCRatio, h.Budget.DeadlineHTLC,
)

h.log.Infof("offering 2nd-level HTLC timeout tx to sweeper "+
Expand Down Expand Up @@ -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 "+
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@
block. Check
[here](https://github.com/lightningnetwork/lnd/blob/master/chainio/README.md)
to learn more.

* [The sweeper](https://github.com/lightningnetwork/lnd/pull/9274) does now also
use the configured budget values for HTLCs (first level sweep) in parcticular
`--sweeper.budget.deadlinehtlcratio` and `--sweeper.budget.deadlinehtlc`.

## RPC Updates

Expand Down
7 changes: 1 addition & 6 deletions itest/lnd_sweep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading