-
Notifications
You must be signed in to change notification settings - Fork 339
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
Direct connect for OnionMessage
sending
#2723
Direct connect for OnionMessage
sending
#2723
Commits on Dec 6, 2023
-
Use a message buffer abstraction in OnionMessenger
Onion messages are buffered for sending to the next node. Since the network has limited adoption, connecting directly to a peer may be necessary. Add an OnionMessageBuffer abstraction that can differentiate between connected peers and those are pending a connection. This allows for buffering messages before a connection is established and applying different buffer policies for peers yet to be connected.
Configuration menu - View commit details
-
Copy full SHA for 79f212b - Browse repository at this point
Copy the full SHA 79f212bView commit details -
Destination in OnionMessenger::send_onion_message
OnionMessenger::send_onion_message takes an OnionMessagePath. This isn't very useful as it requires finding a path manually. Instead, have the method take a Destination and use OnionMessenger's MessageRouter to construct the path. Later, this will allow for buffering messages where the first node in the path isn't a direct connection.
Configuration menu - View commit details
-
Copy full SHA for 8412e83 - Browse repository at this point
Copy the full SHA 8412e83View commit details -
Buffer onion messages requiring a connection
MessageRouter::find_path returns a path to use when sending an onion message. If the first node on the path is not connected or does not support onion messages, sending will fail with InvalidFirstHop. Instead of failing outright, buffer the message for later sending once the first node is a connected peer.
Configuration menu - View commit details
-
Copy full SHA for ddee928 - Browse repository at this point
Copy the full SHA ddee928View commit details -
Add NetworkGraph reference to DefaultMessageRouter
When buffering onion messages for a node that is not connected as a peer, it's possible that the node does not exist. Include a NetworkGraph reference in DefaultMessageRouter so that it can be used to check if the node actually exists. Otherwise, an malicious node may send an onion message where the reply path's introduction node doesn't exist. This would result in buffering messages that may never be delivered.
Configuration menu - View commit details
-
Copy full SHA for 17af8d5 - Browse repository at this point
Copy the full SHA 17af8d5View commit details -
Add Option<Vec<SocketAddress>> to OnionMessagePath
MessageRouter::find_path is given a Destination to reach via a set of peers. If a path cannot be found, it may return a partial path such that OnionMessenger can signal a direct connection to the first node in the path is needed. Include a list of socket addresses in the returned OnionMessagePath to allow OnionMessenger to know how to connect to the node. This allows DefaultMessageRouter to use its NetworkGraph to return socket addresses for gossiped nodes.
Configuration menu - View commit details
-
Copy full SHA for 1114c3c - Browse repository at this point
Copy the full SHA 1114c3cView commit details -
Return socket addresses from DefaultMessageRouter
When there isn't a direct connection with the Destination of an OnionMessage, look up socket addresses from the NetworkGraph. This is used to signal to OnionMessenger that a direct connection is needed to send the message.
Configuration menu - View commit details
-
Copy full SHA for b86f02a - Browse repository at this point
Copy the full SHA b86f02aView commit details -
Add Event::ConnectionNeeded for onion messages
A MessageRouter may be unable to find a complete path to an onion message's destination. This could because no such path exists or any needs on a potential path don't support onion messages. Add an event that indicates a connection with a node is needed in order to send the message.
Configuration menu - View commit details
-
Copy full SHA for ba2a822 - Browse repository at this point
Copy the full SHA ba2a822View commit details -
Make OnionMessageHandler extend EventsProvider
An OnionMessageHandler may buffer messages that can't be sent because the recipient is not a peer. Have the trait extend EventsProvider so that implementation so that an Event::ConnectionNeeded can be generated for any nodes that fall into this category. Also, implement EventsProvider for OnionMessenger and IgnoringMessageHandler.
Configuration menu - View commit details
-
Copy full SHA for 06b05df - Browse repository at this point
Copy the full SHA 06b05dfView commit details -
Drop buffered messages for timed out nodes
OnionMessenger buffers onion messages for nodes that are pending a connection. To prevent DoS concerns, add a timer_tick_occurred method to OnionMessageHandler so that buffered messages can be dropped. This will be called in lightning-background-processor every 10 seconds.
Configuration menu - View commit details
-
Copy full SHA for cfaa7f3 - Browse repository at this point
Copy the full SHA cfaa7f3View commit details -
Configuration menu - View commit details
-
Copy full SHA for ae98517 - Browse repository at this point
Copy the full SHA ae98517View commit details -
Re-wrap define_run_body macro parameters
Some code hygiene before another parameter is added and rustfmt is eventually used.
Configuration menu - View commit details
-
Copy full SHA for 36ecc8e - Browse repository at this point
Copy the full SHA 36ecc8eView commit details -
Re-order define_run_body macro parameters
Simply to avoid excessive wrapping when possible.
Configuration menu - View commit details
-
Copy full SHA for ce68f22 - Browse repository at this point
Copy the full SHA ce68f22View commit details -
Process OnionMessageHandler events in background
OnionMessageHandler implementations now also implement EventsProvider. Update lightning-background-processor to also process any events the PeerManager's OnionMessageHandler provides.
Configuration menu - View commit details
-
Copy full SHA for 6ca81ff - Browse repository at this point
Copy the full SHA 6ca81ffView commit details -
Call OnionMessageHandler::timer_tick_occurred
lightning-background-processor processes events provided by the PeerManager's OnionMessageHandler for when a connection is needed. If a connection is not established in a reasonable amount of time, drop any buffered onion messages by calling timer_tick_occurred.
Configuration menu - View commit details
-
Copy full SHA for e25af3e - Browse repository at this point
Copy the full SHA e25af3eView commit details -
Reuse MessengerNode in spec_test_vector
Additional tests will be added needing a similar node struct, so consolidate its usage.
Configuration menu - View commit details
-
Copy full SHA for 210407e - Browse repository at this point
Copy the full SHA 210407eView commit details -
Test pending connection onion message buffering
Add tests for onion message buffering checking that messages are cleared upon disconnection and timed out after MAX_TIMER_TICKS. Also, checks that ConnectionNeeded events are generated.
Configuration menu - View commit details
-
Copy full SHA for 89e630b - Browse repository at this point
Copy the full SHA 89e630bView commit details -
Configuration menu - View commit details
-
Copy full SHA for d46519b - Browse repository at this point
Copy the full SHA d46519bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0b83116 - Browse repository at this point
Copy the full SHA 0b83116View commit details