From: shaavan Date: Tue, 18 Jun 2024 17:03:02 +0000 (+0530) Subject: Remove path_id from Responder, and OnionMessageResponse struct X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=15d5cb09b87765386e0f4b2cf9cc06618827572b;p=rust-lightning Remove path_id from Responder, and OnionMessageResponse struct --- diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index ba76815af..07d271bce 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -341,9 +341,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 = "\ diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 40b617792..b169f21f5 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -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)); diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 85600190d..c3f920a85 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -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 { 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);