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

Peer Storage Feature – Part 2

Open adi2011 opened this issue 9 months ago • 13 comments

This is the second PR in the peer storage feature series.

Key Changes

  • Enable ChainMonitor to send peer storage to all channel partners whenever a new block is mined.
  • Add get_peer_storage_key() to NodeSigner.
  • Implement decryption logic for peer storage in handle_peer_storage_retrieval().

In the next one, I will add serialisation logic for ChannelMonitors inside peer storage.

adi2011 avatar Feb 26 '25 15:02 adi2011

Seems this isn't properly rebased, hence CI is failing?

tnull avatar Feb 27 '25 08:02 tnull

Seems this isn't properly rebased, hence CI is failing?

I think #3626 will fix this.

adi2011 avatar Feb 27 '25 11:02 adi2011

Seems this isn't properly rebased, hence CI is failing?

I think #3626 will fix this.

No, it fails with:

src/ln/our_peer_storage.rs - ln::our_peer_storage::OurPeerStorage (line 48) stdout ----
error[E0433]: failed to resolve: use of undeclared type `OurPeerStorage`
 --> src/ln/our_peer_storage.rs:49:28
  |
3 | let mut our_peer_storage = OurPeerStorage::new();
  |                            ^^^^^^^^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
2 | use lightning::ln::our_peer_storage::OurPeerStorage;
  |

error[E0433]: failed to resolve: use of undeclared type `OurPeerStorage`
 --> src/ln/our_peer_storage.rs:54:1
  |
8 | OurPeerStorage::decrypt_our_peer_storage(&mut decrypted, &encrypted).unwrap();
  | ^^^^^^^^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
2 | use lightning::ln::our_peer_storage::OurPeerStorage;
  |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.

failures:
    src/ln/our_peer_storage.rs - ln::our_peer_storage::OurPeerStorage (line 48)

test result: FAILED. 28 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.00s

error: test failed, to rerun pass '--doc'

tnull avatar Feb 27 '25 11:02 tnull

That is because it’s trying to compile the commented code in the documentation, I will fix it in a bit.

adi2011 avatar Feb 27 '25 12:02 adi2011

Thanks for the review @tnull.

Fixed the CI :)

adi2011 avatar Mar 01 '25 07:03 adi2011

Codecov Report

Attention: Patch coverage is 83.91960% with 32 lines in your changes missing coverage. Please review.

Project coverage is 89.37%. Comparing base (c355ea4) to head (7d56ef7). Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 74.00% 12 Missing and 1 partial :warning:
lightning/src/chain/chainmonitor.rs 80.95% 8 Missing :warning:
lightning/src/ln/peer_handler.rs 60.00% 5 Missing and 1 partial :warning:
lightning/src/ln/our_peer_storage.rs 95.55% 2 Missing :warning:
lightning/src/util/test_utils.rs 66.66% 2 Missing :warning:
lightning/src/ln/blinded_payment_tests.rs 0.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3623      +/-   ##
==========================================
+ Coverage   89.20%   89.37%   +0.16%     
==========================================
  Files         155      156       +1     
  Lines      119377   121060    +1683     
  Branches   119377   121060    +1683     
==========================================
+ Hits       106496   108193    +1697     
+ Misses      10266    10262       -4     
+ Partials     2615     2605      -10     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Mar 01 '25 07:03 codecov[bot]

This unfortunately needs a rebase now.

tnull avatar Mar 07 '25 14:03 tnull

Thank you so much, @tnull and @TheBlueMatt, for taking the time to review this. I’ve done my best to address all the comments. Please let me know if there’s anything I might have missed or if further changes are needed.

adi2011 avatar Mar 11 '25 11:03 adi2011

@tnull Thank you for the review. I’m really sorry for squashing the fixups, I won’t do that again without approval.

adi2011 avatar Mar 14 '25 15:03 adi2011

@tnull We're calling send_peer_storage from ChainMonitor, which doesn't have access to entropy_source to derive random_bytes. Is there any other way to generate random bytes?

adi2011 avatar Apr 04 '25 14:04 adi2011

We're calling send_peer_storage from ChainMonitor, which doesn't have access to entropy_source to derive random_bytes. Is there any other way to generate random bytes?

We'll need to provide ChainMonitor with an EntropySource, sadly.

TheBlueMatt avatar Apr 04 '25 17:04 TheBlueMatt

@tnull Thank you so much for your patience and reviews on this.

If it looks good now, can I squash the fixups?

adi2011 avatar Apr 14 '25 03:04 adi2011

@tnull if these fixups looks good to you I will squash and work on fixing the CI...

adi2011 avatar Apr 30 '25 18:04 adi2011

@adi2011 #3784 has landed, please rebase to fix CI!

tnull avatar May 21 '25 20:05 tnull

Pushed changes for the benchmark check.

adi2011 avatar May 22 '25 11:05 adi2011