]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove path_id from Responder, and OnionMessageResponse struct
authorshaavan <shaavan.github@gmail.com>
Tue, 18 Jun 2024 17:03:02 +0000 (22:33 +0530)
committershaavan <shaavan.github@gmail.com>
Mon, 8 Jul 2024 20:14:14 +0000 (01:44 +0530)
1. The path_id will be removed from the codebase in the following
   commits.

fuzz/src/onion_message.rs
lightning/src/onion_message/functional_tests.rs
lightning/src/onion_message/messenger.rs

index e60d13d57a90aea5a18c13454a0f432c21fce3cb..8e71a41f9586e70ce8787fdf592dec572e92a327 100644 (file)
@@ -346,9 +346,9 @@ mod tests {
                                                "Received an onion message with path_id None and a reply_path: Custom(TestCustomMessage)"
                                                .to_string())), Some(&1));
                        assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
-                                               "Constructing onion message when responding with Custom Message to an onion message with path_id None: TestCustomMessage".to_string())), Some(&1));
+                                               "Constructing onion message when responding with Custom Message to an onion message: TestCustomMessage".to_string())), Some(&1));
                        assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
-                                               "Buffered onion message when responding with Custom Message to an onion message with path_id None".to_string())), Some(&1));
+                                               "Buffered onion message when responding with Custom Message to an onion message".to_string())), Some(&1));
                }
 
                let two_unblinded_hops_om = "\
index 40b6177921fb144a66924707fab1101a2a0dced0..b169f21f52ede1042bbbd3f7bd0aaaf273bb6750 100644 (file)
@@ -427,14 +427,13 @@ fn async_response_over_one_blinded_hop() {
 
        // 2. Define the message sent from Bob to Alice.
        let message = TestCustomMessage::Ping;
-       let path_id = Some([2; 32]);
 
        // 3. Simulate the creation of a Blinded Reply path provided by Bob.
        let secp_ctx = Secp256k1::new();
        let reply_path = BlindedPath::new_for_message(&[], nodes[1].node_id, &*nodes[1].entropy_source, &secp_ctx).unwrap();
 
        // 4. Create a responder using the reply path for Alice.
-       let responder = Some(Responder::new(reply_path, path_id));
+       let responder = Some(Responder::new(reply_path));
 
        // 5. Expect Alice to receive the message and create a response instruction for it.
        alice.custom_message_handler.expect_message(message.clone());
@@ -466,11 +465,10 @@ fn async_response_with_reply_path_succeeds() {
 
        // Alice receives a message from Bob with an added reply_path for responding back.
        let message = TestCustomMessage::Ping;
-       let path_id = Some([2; 32]);
        let reply_path = BlindedPath::new_for_message(&[], bob.node_id, &*bob.entropy_source, &secp_ctx).unwrap();
 
        // Alice asynchronously responds to Bob, expecting a response back from him.
-       let responder = Responder::new(reply_path, path_id);
+       let responder = Responder::new(reply_path);
        alice.custom_message_handler.expect_message_and_response(message.clone());
        let response_instruction = alice.custom_message_handler.handle_custom_message(message, Some(responder));
 
@@ -503,13 +501,12 @@ fn async_response_with_reply_path_fails() {
 
        // Alice receives a message from Bob with an added reply_path for responding back.
        let message = TestCustomMessage::Ping;
-       let path_id = Some([2; 32]);
        let reply_path = BlindedPath::new_for_message(&[], bob.node_id, &*bob.entropy_source, &secp_ctx).unwrap();
 
        // Alice tries to asynchronously respond to Bob, but fails because the nodes are unannounced and
        // disconnected. Thus, a reply path could no be created for the response.
        disconnect_peers(alice, bob);
-       let responder = Responder::new(reply_path, path_id);
+       let responder = Responder::new(reply_path);
        alice.custom_message_handler.expect_message_and_response(message.clone());
        let response_instruction = alice.custom_message_handler.handle_custom_message(message, Some(responder));
 
index 21012bd7fed2f471c4601b6047feb17cc3107c8a..abab6714df1e50aed2c293fee3398726b7e1cd34 100644 (file)
@@ -344,20 +344,17 @@ impl OnionMessageRecipient {
 pub struct Responder {
        /// The path along which a response can be sent.
        reply_path: BlindedPath,
-       path_id: Option<[u8; 32]>
 }
 
 impl_writeable_tlv_based!(Responder, {
        (0, reply_path, required),
-       (2, path_id, option),
 });
 
 impl Responder {
        /// Creates a new [`Responder`] instance with the provided reply path.
-       pub(super) fn new(reply_path: BlindedPath, path_id: Option<[u8; 32]>) -> Self {
+       pub(super) fn new(reply_path: BlindedPath) -> Self {
                Responder {
                        reply_path,
-                       path_id,
                }
        }
 
@@ -368,7 +365,6 @@ impl Responder {
                ResponseInstruction::WithoutReplyPath(OnionMessageResponse {
                        message: response,
                        reply_path: self.reply_path,
-                       path_id: self.path_id,
                })
        }
 
@@ -379,7 +375,6 @@ impl Responder {
                ResponseInstruction::WithReplyPath(OnionMessageResponse {
                        message: response,
                        reply_path: self.reply_path,
-                       path_id: self.path_id,
                })
        }
 }
@@ -388,7 +383,6 @@ impl Responder {
 pub struct OnionMessageResponse<T: OnionMessageContents> {
        message: T,
        reply_path: BlindedPath,
-       path_id: Option<[u8; 32]>,
 }
 
 /// `ResponseInstruction` represents instructions for responding to received messages.
@@ -1272,9 +1266,8 @@ where
                                Err(err) => {
                                        log_trace!(
                                                self.logger,
-                                               "Failed to create reply path when responding with {} to an onion message \
-                                               with path_id {:02x?}: {:?}",
-                                               message_type, response.path_id, err
+                                               "Failed to create reply path when responding with {} to an onion message: {:?}",
+                                               message_type, err
                                        );
                                        return Err(err);
                                }
@@ -1284,9 +1277,8 @@ where
                self.find_path_and_enqueue_onion_message(
                        response.message, Destination::BlindedPath(response.reply_path), reply_path,
                        format_args!(
-                               "when responding with {} to an onion message with path_id {:02x?}",
+                               "when responding with {} to an onion message",
                                message_type,
-                               response.path_id
                        )
                ).map(|result| Some(result))
        }
@@ -1446,9 +1438,7 @@ where
                                        "Received an onion message with path_id {:02x?} and {} reply_path: {:?}",
                                        path_id, if reply_path.is_some() { "a" } else { "no" }, message);
 
-                               let responder = reply_path.map(
-                                       |reply_path| Responder::new(reply_path, path_id)
-                               );
+                               let responder = reply_path.map(Responder::new);
                                match message {
                                        ParsedOnionMessageContents::Offers(msg) => {
                                                let response_instructions = self.offers_handler.handle_message(msg, responder);