Skip to content
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 #2888

Merged
merged 13 commits into from
Dec 11, 2024
Merged

Peer storage #2888

merged 13 commits into from
Dec 11, 2024

Conversation

thomash-acinq
Copy link
Member

@thomash-acinq thomash-acinq commented Jul 25, 2024

Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was an easy PR, but as I dived into it I think there are many subtle aspects that have a big impact on scenarios where users restore from seed. That's why I have multiple comments that aren't trivial, for which we need to decide how we'd like eclair to behave.

@thomash-acinq thomash-acinq requested a review from t-bast November 22, 2024 12:19
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 73.07692% with 35 lines in your changes missing coverage. Please review.

Project coverage is 86.03%. Comparing base (5410146) to head (df24044).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
...-core/src/main/scala/fr/acinq/eclair/io/Peer.scala 67.50% 13 Missing ⚠️
.../main/scala/fr/acinq/eclair/db/DualDatabases.scala 0.00% 6 Missing ⚠️
...cala/fr/acinq/eclair/db/sqlite/SqlitePeersDb.scala 81.81% 6 Missing ⚠️
.../scala/fr/acinq/eclair/db/PeerStorageCleaner.scala 0.00% 5 Missing ⚠️
...c/main/scala/fr/acinq/eclair/db/pg/PgPeersDb.scala 86.66% 4 Missing ⚠️
...ir-core/src/main/scala/fr/acinq/eclair/Setup.scala 50.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2888      +/-   ##
==========================================
- Coverage   86.19%   86.03%   -0.16%     
==========================================
  Files         224      227       +3     
  Lines       20074    20276     +202     
  Branches      813      826      +13     
==========================================
+ Hits        17302    17445     +143     
- Misses       2772     2831      +59     
Files with missing lines Coverage Δ
...core/src/main/scala/fr/acinq/eclair/Features.scala 100.00% <100.00%> (ø)
...re/src/main/scala/fr/acinq/eclair/NodeParams.scala 91.82% <100.00%> (+0.09%) ⬆️
.../eclair/wire/protocol/LightningMessageCodecs.scala 99.47% <100.00%> (+0.01%) ⬆️
...q/eclair/wire/protocol/LightningMessageTypes.scala 99.14% <ø> (ø)
...fr/acinq/eclair/wire/protocol/PeerStorageTlv.scala 100.00% <100.00%> (ø)
...ir-core/src/main/scala/fr/acinq/eclair/Setup.scala 75.00% <50.00%> (-0.30%) ⬇️
...c/main/scala/fr/acinq/eclair/db/pg/PgPeersDb.scala 85.86% <86.66%> (+0.15%) ⬆️
.../scala/fr/acinq/eclair/db/PeerStorageCleaner.scala 0.00% <0.00%> (ø)
.../main/scala/fr/acinq/eclair/db/DualDatabases.scala 9.60% <0.00%> (-0.34%) ⬇️
...cala/fr/acinq/eclair/db/sqlite/SqlitePeersDb.scala 89.65% <81.81%> (-3.21%) ⬇️
... and 1 more

... and 12 files with indirect coverage changes

Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit afraid of the DoS risks associated with this feature: our node will be a very likely target (everyone will want to store some data with us), so we must be very careful that this cannot be exploited.

@t-bast t-bast mentioned this pull request Nov 22, 2024
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the back and forth, it all looks safe to me now (after the couple of changes from my follow-up PR).

What's the status for the other implementations? Can you check and test basic cross-compatibility (by sending a peer_storage_store message from a modified eclair and verifying whether it's correctly returned to us on reconnection)? We'd need to check this before merging it since the spec PR hasn't been merged yet. I'll ping the other implementers during the next spec meeting to see if we can merge.

@thomash-acinq
Copy link
Member Author

Thanks, I've added your fixes. I'll look at the other implementations and do some compat tests.

@thomash-acinq
Copy link
Member Author

I've found pending PRs to implement it in LND (lightningnetwork/lnd#8490) and LDK (lightningdevkit/rust-lightning#2943) but they don't seem to be ready yet.

@t-bast
Copy link
Member

t-bast commented Nov 26, 2024

Indeed, that doesn't seem to be ready at all! But IIRC cln should already have support merged to their master branch that we can test against?

@t-bast
Copy link
Member

t-bast commented Dec 3, 2024

@thomash-acinq I asked during the spec meeting, and cln has support for peer storage on their master branch. You simply need to enable experimental features, and cln will automatically send us a small blob for storage and will store ours. You should be able to work on interop tests based on this.

thomash-acinq and others added 10 commits December 10, 2024 17:52
The confusion between SQL timestamps and long resulted in always
removing storage regardless of the `peerRemovedBefore` parameter.
Added to the peer storage configuration section of `eclair.conf`.
Instead of defining new events. We also keep a set of active channels to
ensure that duplicate events don't mess up our state (even though this
shouldn't happen, it feels safer).
@thomash-acinq
Copy link
Member Author

There doesn't seem to be any progress with LND or LDK but it works with CLN (they just send their blob too early but I'm assuming it's just to test, and they store our blob well).
I've also rebased to fix a conflict.

@t-bast
Copy link
Member

t-bast commented Dec 11, 2024

they just send their blob too early

What do you mean exactly here, when do they send it? Is it worth opening an issue on their repository?

@thomash-acinq
Copy link
Member Author

I've opened an issue on their repository: ElementsProject/lightning#7931

@t-bast
Copy link
Member

t-bast commented Dec 11, 2024

Thanks, let's wait for the result of that discussion before merging. I'll raise it during the next spec meeting as well.

@thomash-acinq
Copy link
Member Author

I've changed a bit our behavior to accept peer storage updates from peers without an active channel but not persist it. If a channel becomes active, we then persist it.

@thomash-acinq thomash-acinq requested a review from t-bast December 11, 2024 11:06
but only persist it to DB when there is an active channel.
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, with that change I believe we can merge right now to our master branch. We'll wait for the spec PR to be merged to the BOLTs before merging the lightning-kmp PR though, because at that point we would be screwed if we shipped Phoenix using this and the spec changed afterwards, but I hope the spec shouldn't take too long to be added to the BOLTs now that we have cross-compatibility with cln.

eclair-core/src/main/scala/fr/acinq/eclair/io/Peer.scala Outdated Show resolved Hide resolved
@thomash-acinq thomash-acinq merged commit e28f23f into master Dec 11, 2024
1 check passed
@thomash-acinq thomash-acinq deleted the peer-storage branch December 11, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants