Skip to content

Conversation

@morehouse
Copy link
Owner

@yyforyongyu: here's the initial outline.

@morehouse morehouse force-pushed the lnd_deadline_aware_budget_sweeper branch from eb5e5fb to 0b7fdd7 Compare March 7, 2025 16:52
@morehouse morehouse marked this pull request as ready for review March 7, 2025 23:33
Copy link
Contributor

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well put, thanks!


In this strategy, the fee rate estimator is used to determine the initial fee rate, after which a fixed multiplier is used to increase fee rates for each RBF transaction.

[eclair](https://github.com/ACINQ/eclair/blob/95bbf063c9283b525c2bf9f37184cfe12c860df1/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisher.scala#L221-L248) uses this strategy when deadlines are within 6 blocks, increasing fee rates by 20% each block.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL - do you happen to know whether they cap the fees? Given 20%, the fee rate doubles after 4 blocks😂

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eclair caps it by input amount: https://github.com/ACINQ/eclair/blob/e3b3261c2cc19e21f70ec4be56f5a851e98625bb/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunder.scala#L98

LDK is more complicated -- when a wallet input is needed, LDK tells the API user what feerate is needed and the user is responsible for constructing the needed transaction and publishing it. For HTLC claims, LDK's documentation suggests that the user should not claim the HTLC if the fee needed is larger than the HTLC value: https://github.com/lightningdevkit/rust-lightning/blob/4c43a5b3df2afc7ffb74df84168aafdf47b965a2/lightning/src/events/bump_transaction.rs#L188-L191.
But I don't see any similar recommendation for commitment transactions, so it's possible that users will overpay for those...

Do you think it's worth mentioning this in the blog post, or is that too much information?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that overshooting fees are not covered here, I'd say leave it. Tho may be one sentence there saying it's capped by the input amount, sth like,

Suggested change
[eclair](https://github.com/ACINQ/eclair/blob/95bbf063c9283b525c2bf9f37184cfe12c860df1/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisher.scala#L221-L248) uses this strategy when deadlines are within 6 blocks, increasing fee rates by 20% each block.
[eclair](https://github.com/ACINQ/eclair/blob/95bbf063c9283b525c2bf9f37184cfe12c860df1/eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisher.scala#L221-L248) uses this strategy when deadlines are within 6 blocks, increasing fee rates by 20% each block, and caps the fees paid by the input amount.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@morehouse morehouse force-pushed the lnd_deadline_aware_budget_sweeper branch from 7c61de4 to 275a3c4 Compare March 10, 2025 16:27
@morehouse
Copy link
Owner Author

@Arvin21M: I plan to publish this blog post tomorrow. If you have a chance to review it, I'd really appreciate it.

Copy link

@Arvin21M Arvin21M left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • A few small copy edit suggestions.
  • All links work and appear to be pointing to the proper destination.
  • Great work!
  • :shipit:

When an unreliable (or malicious) Lightning node goes offline while HTLCs are in flight, the other node in the channel can no longer claim the HTLCs *off chain* and will eventually have to force close and claim the HTLCs *on chain*.
When this happens, it is critical that all HTLCs are claimed before certain deadlines:

- Incoming HTLCs need to be claimed before their timelocks expire and the channel counterparty can submit a competing timeout claim.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Incoming HTLCs need to be claimed before their timelocks expire and the channel counterparty can submit a competing timeout claim.
- Incoming HTLCs need to be claimed before their timelocks expire; otherwise, the channel counterparty can submit a competing timeout claim.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

When this happens, it is critical that all HTLCs are claimed before certain deadlines:

- Incoming HTLCs need to be claimed before their timelocks expire and the channel counterparty can submit a competing timeout claim.
- Outgoing HTLCs need to be claimed before their corresponding upstream HTLCs expire and the upstream node can reclaim them on chain.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Outgoing HTLCs need to be claimed before their corresponding upstream HTLCs expire and the upstream node can reclaim them on chain.
- Outgoing HTLCs need to be claimed before their corresponding upstream HTLCs expire; otherwise, the upstream node can reclaim them on-chain.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

---

Starting with [v0.18.0](https://github.com/lightningnetwork/lnd/releases/tag/v0.18.0-beta), LND has a completely rewritten *sweeper* subsystem for managing transaction batching and fee bumping.
The new sweeper uses HTLC deadlines and fee budgets to compute a *fee rate curve* over which urgent transactions are fee bumped.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The new sweeper uses HTLC deadlines and fee budgets to compute a *fee rate curve* over which urgent transactions are fee bumped.
The new sweeper uses HTLC deadlines and fee budgets to compute a *fee rate curve*, dynamically adjusting fees (fee bumping) to prioritize urgent transactions.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Co-authored-by: Yong Yu <yong2452@gmail.com>
@morehouse morehouse force-pushed the lnd_deadline_aware_budget_sweeper branch from 275a3c4 to fed6043 Compare March 11, 2025 16:19
@morehouse morehouse merged commit e86e082 into main Mar 11, 2025
@morehouse morehouse deleted the lnd_deadline_aware_budget_sweeper branch March 11, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants