-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Peer Storage Feature – Part 2 #3623
base: main
Are you sure you want to change the base?
Peer Storage Feature – Part 2 #3623
Conversation
d8df7cf
to
361738d
Compare
Seems this isn't properly rebased, hence CI is failing? |
361738d
to
a1006e0
Compare
I think #3626 will fix this. |
No, it fails with:
|
That is because it’s trying to compile the commented code in the documentation, I will fix it in a bit. |
ff7fec7
to
465da4a
Compare
465da4a
to
4f29813
Compare
Add get_peer_storage_key method to derive a 32-byte encryption key for securing Peer Storage. This method utilizes HKDF with the node's secret key as input and a fixed info string to generate the encryption key. - Add 'get_peer_storage_key' to NodeSigner. - Implement 'get_peer_storage_key' for KeysManager & PhantomKeysManager.
Introduce the OurPeerStorage struct to manage serialized channel data for peer storage backups. This struct facilitates the distribution of peer storage to channel partners and includes versioning and timestamping for comparison between retrieved peer storage instances. - Add the OurPeerStorage struct with fields for version, timestamp, and serialized channel data (ser_channels). - Implement methods to encrypt and decrypt peer storage securely. - Add functionality to update channel data within OurPeerStorage.
To enable ChainMonitor sending peer storage to channel partners whenever a new block is added, a new message handler, `SendingOnlyMessageHandler`, has been introduced. This allows the `ChainMonitor` to handle the peer storage distribution. Key changes: - Introduce the SendingOnlyMessageHandler trait to facilitate peer storage distribution. - Add SendingOnlyMessageHandler into the MessageHandler. - Implement SendingOnlyMessageHandler for ChainMonitor and IgnoringMessageHandler. - Process SendingOnlyMessageHandler events inside process_events().
Everytime a new block is added we send PeerStorage to all of our channel partner. - Add our_peer_storage and our_peerstorage_encryption_key to ChainMonitor - Write send_peer_storage() and send it to all channel partners whenever a new block is added
Ensure ChannelManager properly handles peer_storage_retrieval. - Write internal_peer_storage_retreival to verify if we recv correct peer storage. - Send error if we get invalid peer_storage data.
Ensure that we correctly handle the sendpeerstorage message event from chainmonitor and process it through channelmonitor. Key Changes: - Retrieve sendpeerstorage message event from chainmonitor for both nodes. - Handle peer storage messages exchanged between nodes and verify correct decryption.
4f29813
to
2113034
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately CI is still failing as the code doesn't work in no_std
.
lightning/src/ln/our_peer_storage.rs
Outdated
use crate::ln::msgs::DecodeError; | ||
|
||
/// [`OurPeerStorage`] is used to store channel information that allows for the creation of a | ||
/// PeerStorage backup. It includes versioning and timestamping for comparison between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: IIRC, we settled on snake_case here?
/// PeerStorage backup. It includes versioning and timestamping for comparison between | |
/// `peer_storage` backup. It includes versioning and timestamping for comparison between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad. Fixed!
lightning/src/ln/our_peer_storage.rs
Outdated
impl OurPeerStorage { | ||
/// Returns a [`OurPeerStorage`] with version 1 and current timestamp. | ||
pub fn new() -> Self { | ||
let duration_since_epoch = std::time::SystemTime::now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As LDK also supports no_std
, we need to make this code work in no_std
environments. As accessing time is only available in std
, it means we either need to find a way to have the user provide the timestamp
themselves, or feature-gate the peer storage to only work on std
.
That said, are we positive that we need a timestamp in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I have added a timestamp so that if we receive multiple peer storage instances, we can select the latest one. I was thinking of replacing the timestamp with block height...
Thanks for the review @tnull. Fixed the CI :) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3623 +/- ##
==========================================
+ Coverage 89.16% 89.98% +0.82%
==========================================
Files 152 153 +1
Lines 118791 124698 +5907
Branches 118791 124698 +5907
==========================================
+ Hits 105921 112213 +6292
+ Misses 10312 9992 -320
+ Partials 2558 2493 -65 ☔ View full report in Codecov by Sentry. |
This is the second PR in the peer storage feature series.
Key Changes
In the next one, I will add serialisation logic for ChannelMonitors inside peer storage.