-
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
peer: always send channel update on reconnect #8963
peer: always send channel update on reconnect #8963
Conversation
Important Review skippedAuto reviews are limited to specific labels. Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
6c9af4e
to
ee4b52e
Compare
f82ac07
to
bf5ff04
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.
Following this analysis, even a disconnection happens, the msg won't be deleted and will be retried again during the next connection? Unless it's considered stale here,
lnd/discovery/reliable_sender.go
Lines 255 to 256 in b7c59b3
if s.cfg.IsMsgStale(msg) { | |
err := s.cfg.MessageStore.DeleteMessage(msg, peerPubKey) |
which checks the channel_update
via,
Lines 2136 to 2168 in b7c59b3
case *lnwire.ChannelUpdate: | |
_, p1, p2, err := d.cfg.Graph.GetChannelByID(msg.ShortChannelID) | |
// If the channel cannot be found, it is most likely a leftover | |
// message for a channel that was closed, so we can consider it | |
// stale. | |
if errors.Is(err, channeldb.ErrEdgeNotFound) { | |
return true | |
} | |
if err != nil { | |
log.Debugf("Unable to retrieve channel=%v from graph: "+ | |
"%v", msg.ShortChannelID, err) | |
return false | |
} | |
// Otherwise, we'll retrieve the correct policy that we | |
// currently have stored within our graph to check if this | |
// message is stale by comparing its timestamp. | |
var p *models.ChannelEdgePolicy | |
if msg.ChannelFlags&lnwire.ChanUpdateDirection == 0 { | |
p = p1 | |
} else { | |
p = p2 | |
} | |
// If the policy is still unknown, then we can consider this | |
// policy fresh. | |
if p == nil { | |
return false | |
} | |
timestamp := time.Unix(int64(msg.Timestamp), 0) | |
return p.LastUpdate.After(timestamp) |
which seems to be related to #7261.
Hmm, I think you're right. For channel updates, staleness comes down to if the on disk update is newer than the one we're trying to send: Lines 2172 to 2173 in c262b1b
So if we haven't sent a newer channel update (compared to the default one we generated once everything confirmed), then this the update won't be seen as stale, and we'll continue to try and send it. However, we do have dynamic enable/disable logic, so if that triggers and disables/enables the channel, it'll generate a newer update, marking the one written to disk as stale. With all that said, I think this PR does still cover an existing gap:
|
bf5ff04
to
5546080
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.
Pushed revision 3 here: https://reviewable.io/reviews/lightningnetwork/lnd/8963
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.
Cool pending linter and unit tests fix, otherwise it's good to go!
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.
looks good just need to add FetchLastChanUpdate
to the test config
5546080
to
37cea0e
Compare
Fixed the unit test issue, and also added a slim one to exercise this new feature ( Linter also should be good now.... |
37cea0e
to
3e0cbfa
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.
LGTM🦐 Need to fix the new race inTestAlwaysSendChannelUpdate
before merging tho.
|
||
// TestAlwaysSendChannelUpdate tests that each time we connect to the peer if | ||
// an active channel, we always send the latest channel update. | ||
func TestAlwaysSendChannelUpdate(t *testing.T) { |
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.
🙏
a6f6fbc
to
0add08d
Compare
We have existing logic to attempt to reliably send a channel update to the remote peer. In the wild, we've seen this fail, as it's possible right when we send the update the peer disconnects. In this commit, we implement a simple fix which is just to send the chan update each time we connect to the remote party. Fixes lightningnetwork#6870.
0add08d
to
9acad37
Compare
We have existing logic to attempt to reliably send a channel update to the remote peer. In the wild, we've seen this fail, as it's possible right when we send the update the peer disconnects.
In this commit, we implement a simple fix which is just to send the chan update each time we connect to the remote party.
Fixes #6870.