lightningdevkit / rust-lightning

A highly modular Bitcoin Lightning library written in Rust. It's rust-lightning, not Rusty's Lightning!
Other
1.17k stars 368 forks source link

[Memory] Persist `counterparty_claimable_outpoints` out of channel_monitor #3049

Open G8XSU opened 6 months ago

G8XSU commented 6 months ago

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:

  1. Increased memory footprint, since all the active channel_monitors are stored in-memory.
  2. 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

G8XSU commented 6 months ago

Outlined approach in https://github.com/orgs/lightningdevkit/discussions/3050

G8XSU commented 6 months ago

++