Skip to content

contractcourt: implement smarter "go to chain" heuristics in the channelArbitrator  #1226

@Roasbeef

Description

@Roasbeef

The channelArbitrator, amongst may other things is responsible for deciding when we should go to chain in order to sweep outputs on-chain from expired contracts. We use the shouldGoOnChain function currently to decide exactly when we should go on chain. Atm, the function is very basic, and will determine that we need to go on chain if the HTLC is about to expire. However, this doesn't capture the cost of going on chain. For example, if we have a 1000 satoshi HTLC that's about to expire, and it would take 20k satoshis to actually fully sweep the output, then the cost simply isn't worth it. The shouldGoOnChain function should be modified to capture such opportunity cost heuristics.

Steps To Completion

  • Extend the shouldGoOnChain method to take into account (all or some of): the on chain fees to sweep an HTLC, the duration that an HTLC has been active, the fee revenue related to the channel we're examining (as if the channel is popular we shouldn't close it to sweep a single HTLC), the CSV value.

  • A series of tests should be written to ensure that each of the heuristics are properly implemented and are adhered to by the channelArbitrator.

Metadata

Metadata

Assignees

Labels

P3might get fixed, nice to havechannel managementThe management of the nodes channelschannelscommitmentsCommitment transactions containing the state of the channelintermediateIssues suitable for developers moderately familiar with the codebase and LN

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions