-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
discovery/gossiper: reliably send channel update msg to remote peer #1595
discovery/gossiper: reliably send channel update msg to remote peer #1595
Conversation
b3f3aa9
to
23d81bd
Compare
23d81bd
to
e64662d
Compare
e64662d
to
9749e00
Compare
Any updates on this? I experience this a lot since i tend to leave the house without waiting for X confirmations for my mobile wallet to establish a channel. |
@robtex hoping to get this addressed within the next week or two. |
Bump on this PR. |
Looks more or less LGTM, just a few suggestions 😁 |
When we merge this, the downgrade path to 0.5.2 will be closed because of the db migration in this PR. |
1e2a0cb
to
2d7bf4b
Compare
Broke up the reliable send logic into its own file. PTAL @cfromknecht @halseth. |
8e413a6
to
b793f92
Compare
ba04fbf
to
0112d58
Compare
PTAL @halseth @cfromknecht. |
0112d58
to
e3e0ec5
Compare
In this commit, we add a new store within the database that'll be responsible for storing gossip messages which we need to reliably send to peers. This aims to replace the current messageStore that exists within the gossiper, so much of this logic is borrowed from there. One of the main differences between the two is that we now index messages with a new key format in which we take into account the message's type. This allows us to store different messages for a specific channel with a peer. The old key format is still supported in order to prevent a database migration.
In this commit, we introduce a migration for the message store sub-bucket that will migrate all keys within it to a new key format. This new key format is composed of the peer's public key, followed by the short channel ID, followed by the message type. This migration is needed in order to provide backwards-compatibility with messages that were previously stored before the introduction of the new key format.
Now that we've replaced the built-in messageStore with the channeldb.GossipMessageStore, the reference to channeldb.DB is no longer needed.
In this commit, we implement a new subsystem for the gossiper that uses some of the existing logic for resending channel announcement signatures and implements it in a way to make it message-agnostic, meaning that any type of message can be resent. Along the way we also modify the way this works to prevent multiple goroutines per peer _and_ message. A peerHandler will be spawned for each peer for which we attempt to send a message reliably to. This handler is responsible for managing requests to reliably send messages to a peer while also taking the peer's connection lifecycle into account by requesting notifications for when the peer connects/disconnects. A peer connection notification is first requested to determine when we should attempt to send any pending messages. After the messages are sent, a peer disconnection notification is requested to ensure we don't continue to request connection notifications while the peer remains connected. Once there are no more pending messages left to be sent for a given peer, the peerHandler can be torn down.
In this commit, we also allow channel updates for our channels to be sent reliably to our channel counterparty. This is especially crucial for private channels, since they're not announced, in order to ensure each party can receive funds from the other side.
e3e0ec5
to
12168f0
Compare
Tested the migration via dryrun on my mainnet node, no issues to report. Very clean and structured PR, LGTM 🔥 |
So do we want to add the |
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.
This PR LGTM now ⚡️
discovery/gossiper.go
Outdated
// to assemble the full proof yet (maybe because of a crash), | ||
// we will send them the full proof if we notice that they | ||
// retry sending their half proof. | ||
if chanInfo.AuthProof != nil { |
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.
Check can be removed indeed. Not that it matters though...
} | ||
|
||
// Otherwise, we'll attempt to stream the message to the handler. | ||
// There's a subtle race condition where the handler can be torn down |
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.
This is still a bit strange, but I guess it is okay 🙃 Current solution should work.
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.
I don't think there are any other ways around it. Do you have any suggestions?
In this commit, we address an issue where it's possible that we failed
to send the channel update message for a channel to the remote peer due
to them being offline. This would cause issues with private channels, as
a channel update message is needed for the remote peer to be aware of
the channel's forwarding policy. Due to the latest changes to
NotifyWhenOnline, we can now attempt to send the message every time we
detect the remote peer is online until success.
Depends on #1505.
Fixes #1347.