lightning icon indicating copy to clipboard operation
lightning copied to clipboard

Peer storage feature

Open adi2011 opened this issue 2 years ago • 2 comments

PEER STORAGE BACKUP

This PR implements peer storage backup which will enable nodes to exchange their respective SCBs (Static channel backup), This will be useful in case of complete data loss.

WHY

One of the major features of lightning is that the transactions are off-chain and are stored in a local database, which makes this DB highly dynamic and complex to backup. Peer storage backup will allow users to send their encrypted backup to their peers, which can be used to recover their funds in case of complete data loss.

HOW

The strategy is that we'll store the data received in the datastore. So to implement this I've introduced 2 new messages i.e. PEER_STORAGE and YOUR_PEER_STORAGE, these will be used to exchange the data stored between the nodes. -PEER_STORAGE will be used to send our own encrypted backup to the peer. -YOUR_PEER_STORAGE will be used to send the most recent backup of the peer.

The general flow of messages every time we connect is:

Alice ----------------------- :hearts: ------------------------------ Bob

PEER_STORAGE :outbox_tray:-------------:incoming_envelope:-------------> :inbox_tray: YOUR_PEER_STORAGE :outbox_tray:---------:incoming_envelope:------------> :inbox_tray:

:inbox_tray: <------------:incoming_envelope:--------------PEER_STORAGE :outbox_tray: :inbox_tray: <-----------:incoming_envelope:------------YOUR_PEER_STORAGE :outbox_tray:


On receiving YOUR_PEER_STORAGE bob will verify if it's correct and Alice has not changed anything in his last sent backup. On receiving PEER_STORAGE bob will update the backup he has stored for Alice in his own datastore.

Every time we open a new channel or close an old one we will send PEER_STORAGE to every peer we're connected to (Haven't figured out yet, maybe a new RPC (sendcustommsgmulti) which will enable plugins to send a single message to multiple users at once, because the interaction between lightningd and plugins is single-threaded)

They can choose to ignore the messages since they are odd (It's okay to be odd)

In case of complete data loss, the user will reconnect to their peers and hope that they get a YOUR_PEER_STORAGE message. Then they can directly use the RPC specified in the plugin to recover the channels.

adi2011 avatar Jun 30 '22 08:06 adi2011

Thanks for the review @vincenzopalazzo, I have mostly fixed all the mentioned changes in the SCB PR, This one will get in after that :)

adi2011 avatar Jul 06 '22 07:07 adi2011

Ops! my bad I did not see that this was built on top of another PR! my bad!

vincenzopalazzo avatar Jul 07 '22 09:07 vincenzopalazzo

@adi2011: this is marked for release 22.11 for which we're trying to publish a first RC this week, but it is also marked as a draft. What's the current status of this? Happy to review and merge it if it is ready, otherwise we can also postpone it to the next release, which'll happen in ~2 months again.

cdecker avatar Nov 01 '22 13:11 cdecker

After talking to @adi2011 we decided that we'll be pushing this PR to the next release.

cdecker avatar Nov 02 '22 12:11 cdecker

Thanks! Will get onto it once my semester exams are over.

adi2011 avatar Nov 03 '22 09:11 adi2011