rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Skip most chain sync on startup

Open TheBlueMatt opened this issue 2 years ago • 4 comments

The naive issues with running before we have finished chain sync are not an issue - if we step the channel after the peer has broadcasted the peer has revoked their latest state and we get their money, if we have broadcasted our ChannelMonitor should refuse to let us step the channel state machine.

There is the issue of if we're way behind and our peer has broadcasted their state, waited the timeout period, then got their funds back. At this point if we step the channel state we potentially lose funds. Still, we could just sync until we reach being behind by the CSV delay on our channels and then sync from there after startup.

May be a bit complicated to do in our sync utils, but we should look into it.

TheBlueMatt avatar Oct 31 '23 20:10 TheBlueMatt

For electrum/esplora clients, to implement this, we probably need to think about switching the order from best_block_updated -> transaction confirmation to transaction confirmation -> best_block_updated.

TheBlueMatt avatar Nov 14 '23 17:11 TheBlueMatt

Kinda related to https://github.com/lightning/bolts/issues/934

benthecarman avatar Nov 17 '23 07:11 benthecarman

That's pretty unrelated - that's just about when our counterparty is stale/has reverted to a previous state. We actually already do that. This is more about us having the latest state, but not the latest blockchain data.

TheBlueMatt avatar Nov 27 '23 23:11 TheBlueMatt

Sadly I don't think we have the bandwidth in 0.0.119 to dig into this, but hopefully its mostly a documentation thing in a release soon.

TheBlueMatt avatar Nov 28 '23 22:11 TheBlueMatt