-
Notifications
You must be signed in to change notification settings - Fork 421
Open
Description
Problem:
After every commitment signed, counterparty_claimable_outpoints keeps on growing without bounds within a channel_monitor, with a new hashmap entry for each commitment_tx.
It poses two problems mainly:
- Increased memory footprint, since all the active channel_monitors are stored in-memory.
- Increased channel_monitor on-disk size, where these are currently stored.
We don't want to keep on storing outpoints which will only be used for revoked_tx / funding_spend, instead we would like to store them in cold storage and read them only when required.
Ideal outcome: After doing this, Ldk's memory footprint should be drastically decreased owing to removed in-memory hashmap entries of counterparty_claimable_outpoints
- Outline approach [Doc]
- Minimize current set of non-current/previous_commitment reads to
counterparty_claimable_outpointsby re-using existing get calls and refactors [Minimize reads to counterparty_claimable_outpoints #3057 ] - Remove watched_outputs dependency on per_commitment_claimable_data. (because if they depend on claimable_data, we won't outputs untill user provides us with ClaimInfo, and they won't be returned from tx_confirmed) [Watch all outputs irrespective of claimable outpoints #3081]
- Introduce new event variants:
PersistClaimInfoandRequestClaimInfo[Add PersistClaimInfo and ClaimInfoRequest events #3067] - Add pub fn in chain-monitor that can be called after both of those events. [Add functions to handle ClaimInfoRequest and PersistClaimInfo events. #3217]
- Start publishing 2 new events, one in provide_secret and other in check_spend [Persist counterparty_claimable_outpoints out of channel_monitor #3106]
- In case when no htlcs have been forwarded, counterparty_claimable_outpoints will not have ClaimInfo. We don't want to treat missing ClaimInfo as acceptable, hence we need to write empty ClaimInfo so that user can always provide us with Some() ClaimInfo after ClaimInfoRequest.
- Refactor
check_spend_counterparty_transactionandcancel_prev_commitment_claimsto act after we receiveClaimInfo - Once funding_spent_seen and we receive
ClaimInfo, Re-insertClaimInfoincounterparty_claimable_outpoints, so thatget_claimable_balancescan account for it. (Done as part of handle events functions.)
Metadata
Metadata
Assignees
Labels
No labels