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

Reliably deliver gossip messages from our ChannelMessageHandler #3142

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TheBlueMatt
Copy link
Collaborator

When our ChannelMessageHandler creates gossip broadcast
MessageSendEvents, we generally want these to be reliably
delivered to all our peers, even if there's not much buffer space
available.

Here we do this by passing an extra flag to forward_broadcast_msg
which indicates where the message came from, then ignoring the
buffer-full criteria when the flag is set.

Rather than building a single `Vec` of `MessageSendEvent`s to
handle then iterating over them, we move the body of the loop into
a lambda and run the loop twice. In some cases, this may save a
single allocation, but more importantly it sets us up for the next
commit, which needs to know from which handler the
`MessageSendEvent` it is processing came from.
When our `ChannelMessageHandler` creates gossip broadcast
`MessageSendEvent`s, we generally want these to be reliably
delivered to all our peers, even if there's not much buffer space
available.

Here we do this by passing an extra flag to `forward_broadcast_msg`
which indicates where the message came from, then ignoring the
buffer-full criteria when the flag is set.
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2024

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

Codecov Report

Attention: Patch coverage is 43.01075% with 53 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@07d991c). Learn more about missing BASE report.
Report is 17 commits behind head on main.

Files Patch % Lines
lightning/src/ln/peer_handler.rs 43.01% 8 Missing and 45 partials ⚠️

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3142   +/-   ##
=======================================
  Coverage        ?   90.35%           
=======================================
  Files           ?      122           
  Lines           ?   105863           
  Branches        ?   105863           
=======================================
  Hits            ?    95651           
  Misses          ?     7416           
  Partials        ?     2796           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

The code looks great! Just one quick note about the from_chan_handler boolean.

While the commit message clarifies that from_chan_handler suggests it originates from ChannelMessageHandler and should be forwarded to peers, allowing for a larger buffer, this isn’t immediately clear when reading the code alone.

To enhance clarity, we could either:

  1. Add a comment in the code to explain this connection.
  2. Rename from_chan_handler to allow_large_buffer.
  3. Or, rename allow_large_buffer to from_chan_handler.

Option 1 makes the purpose clear right away. I also like option 2, as it succinctly reflects that large buffers are permissible for channel events, as shown here:

for event in chan_events {
    handle_event(event, true);
}

However, if this new boolean is intended only to be used with chan_events, then option 3 would be the most fitting solution.

Let me know what you think. Looking forward to your thoughts!

@TheBlueMatt
Copy link
Collaborator Author

Pushed some additional comments/docs.

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

LGTM!
Shall we test to see if this change works as intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants