-
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
graph: refactor Builder network message handling #9534
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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 🤓
graph/builder.go
Outdated
if err != nil { | ||
// Log as a debug message if this is not an error we need to be | ||
// concerned about. | ||
if IsError(err, ErrIgnored, ErrOutdated) { |
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: the logging block could be extracted to a helper function so that any later changes affect all updates handlers.
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.
done!
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.
🛳️
The exposed AddNode, AddEdge and UpdateEdge methods of the Builder are currently synchronous since even though they pass messages to the network handler which spins off the handling in a goroutine, the public methods still wait for a response from the handling before returning. The only part that is actually done asynchronously is the topology notifications. We previously tried to simplify things in [this commit](lightningnetwork@d757b3b) but we soon realised that there was a reason for sending the messages to the central/synchronous network handler first: it was to ensure consistency for topology clients: ie, the ordering between when there is a new topology client or if it is cancelled needs to be consistent and handled synchronously with new network updates. So for example, if a new update comes in right after a topology client cancels its subscription, then it should _not_ be notified. Similariy for new subscriptions. So this commit was reverted soon after. We can, however, still simplify things as is done in this commit by noting that _only topology subscriptions and notifications_ need to be handled separately. The actual network updates do not need to. So that is what is done here. This refactor will make moving the topology subscription logic to a new subsystem later on much easier.
graph: refactor Builder network message handling
The exposed
AddNode
,AddEdge
andUpdateEdge
methods of the Builder are currently synchronous since even though they pass messages to the network handler which spins off the handling in a goroutine, the public methods still wait for a response from the handling before returning. The only part that is actually done asynchronously is the topology notifications.We previously tried to simplify things in this
commit but we soon realised that there was a reason for sending the messages to the central/synchronous network handler first: it was to ensure consistency for topology clients: ie, the ordering between when there is a new topology client or if it is cancelled needs to be consistent and handled synchronously with new network updates. So for example, if a new update comes in right after a topology client cancels its subscription, then it should not be notified. Similarly for new subscriptions. So this commit was reverted soon after.
We can, however, still simplify things as is done in this commit by noting that only topology subscriptions and notifications need to be handled separately. The actual network updates do not need to. So that is what is done here.
This refactor will make moving the topology subscription logic to a new subsystem later on much easier. Another reason we want to do this is in preparation for a
context.Context
being passed through from these exposed methods right through to the persistence calls.This covers one commit in #9529
This is part of #9494