rust-lightning
rust-lightning copied to clipboard
Allow responding asynchronously to OnionMessage
This PR addresses second part of #2882 and builds on #2907
This PR converts handle_onion_message_response into the public function which can be used for asynchronous response to a separately created ResponseInstruction.
Also, this introduces a new variant of ResponseInstruction. This allows creating a reply_path for the receiver while responding to their message.
Codecov Report
Attention: Patch coverage is 96.74419% with 7 lines in your changes are missing coverage. Please review.
Project coverage is 89.87%. Comparing base (
df01208) to head (d8adbb0).
| Files | Patch % | Lines |
|---|---|---|
| lightning/src/onion_message/messenger.rs | 92.72% | 3 Missing and 1 partial :warning: |
| lightning/src/onion_message/functional_tests.rs | 98.12% | 1 Missing and 2 partials :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## main #2996 +/- ##
==========================================
- Coverage 89.90% 89.87% -0.03%
==========================================
Files 117 117
Lines 97105 97257 +152
Branches 97105 97257 +152
==========================================
+ Hits 87300 87412 +112
- Misses 7245 7275 +30
- Partials 2560 2570 +10
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Updated from pr2996.01 to pr2996.02 (diff):
Update:
- Synced with base PR (#2907) to solve merge conflicts.
cc @jkczyz, @TheBlueMatt
Updated from pr2996.02 to pr2996.03 (diff): Addressed @jkczyz comments:
Updates:
- Address nit comments.
- Expanded return type of
handle_onion_message_response. This change allows access to the success/failure status of sending the response to the user which they can handle appropriately.
Updated from pr2996.03 to pr2996.04 (diff):
Updates:
- Rebase on main, to resolve conflicts post #2907 merge.
Updated from pr2996.04 to pr2996.05 (diff): Addressed @TheBlueMatt, @jkczyz comments
Updates:
- Expanded
respond(), andrespond_with_reply_path()documentation. - Updated test to check if we got the expected variant of SendSuccess, when calling
handle_onion_message_response. - Refactor the code to improve brevity.
- Update handle_onion_message response to fail in case we fail to create a blinded_path.
- Fix the Fuzz test.
Updated from pr2996.05 to pr2996.06 (diff): Addressed @jkczyz comments
Updates:
- Simplify the respond, and respond_with_reply_path docs to make them concise.
- Simplify the result check in the added test.
- Introduced logging in handle_onion_message_response if create_blinded_path fails to create reply_path.
Updated from pr2996.07 to pr2996.08 (diff): Addressed @TheBlueMatt and @jkczyz comments
Changes:
- Expanded docs for
respondandrespond_with_reply_pathso that there purpose is more clearly explained. - Expand log message to also contain the error itself.
- nit
blinded_path->reply_path. - Simplified
logger->self.logger, since there are no context to add with the error message within the function. - Improve the code style to be more idiomatic.
- Simplified
format_args!->format!forlog_trace!
Updated from pr2996.08 to pr2996.09 (diff): Addressed @jkczyz comment
Update:
- Fix grammatical error.
- Update logging so that a string will not be created in case it is not being logged.
Updated from pr2996.09 to pr2996.10 (diff): Addressed @jkczyz comments
Changes:
- Corrected a nit,
reply_path->reply path - Expanded SendError::PathNotFound documentation as it can also be triggered when we fail to create a reply_path.
- Introduce two new variants in TestCustomMessage, to allow an arbitrary number of back-and-forth communication, allowing test response functionality properly.
- Introduce a new test to test the reply_path creation success, creation failure, and usage functionality.
Updated from pr2996.10 to pr2996.11 (diff): Addressed @TheBlueMatt comment
Changes:
- Reverted
handle_custom_messageto default to avoid API changes. - Introduced a new
test_handle_custom_messagehandler for theResponseInstructiontests.
Updated from pr2996.11 to pr2996.12 (diff): Addressed @jkczyz comment.
- Removed the test-specific handle_custom_message, and instead utilized the newly introduced
TestCustomMessagevariants to facilitate therespond_with_reply_pathtest. - Expanded the
TestCustomMessagedocs, to properly explain each variant's role.
Updated from pr2996.12 to pr2996.13 (diff): Addressed @jkczyz comment
Changes:
- Removed redundant diff to keep commits atomic.
- Improved the
SendError::PathNotFounddocs. - Removed the redundant granular comments from the added test.
Updated from pr2996.13 to pr2996.14 (diff): Addressed @jkczyz comment
Changes:
- Renamed
RequestandResponsetoPingandPongto better suit their new roles of being each other's response. - Removed the now redundant variants
ResponseAandResponseB. - Introduced a new variable in
TestCustomMessageHandlerthat signals tohandle_custom_messagewhichResponseInstructionit should create. - Updated the introduced test to utilize this new setup.
Updated from pr2996.14 to pr2996.15 (diff): Addressed @jkczyz comment
Changes:
- Introduce the add_reply_path boolean as part of expectations. This allows saving up on a mutex variable and keeps things consistent with the current test suite.
- Introduce a new struct
Expectationto keep the current (and future) expectations neatly ordered.
Updated from pr2996.15 to pr2996.16 (diff): Addressed @jkczyz comments
- Refactor the function and improve naming structs for TestCustomMessageHandler.
- Improve the test readability by properly structuring and separating success and failure cases in separate tests.
@jkczyz, @TheBlueMatt A gentle ping! :)
Updated from pr2996.17 to pr2996.18 (diff): Addressed @jkczyz comment
Update:
- Rebase on main.
- Update the
create_blinded_pathfunction andBlindedPath::new_for_messageto match the API change. - Expanded
handle_onion_message_responsedocs.
Updated from pr2996.18 to pr2996.19 (diff): Addressed @jkczyz's comment:
Changes:
- Removed the redundant commented code.
- Applied nit fixes to docs.
@jkczyz:
BTW, please avoid rebasing mid-review as it makes it difficult for reviewers to tell what has changed.
Understood! I tried to keep the changes with rebase separate, but for this one, I took a shortcut since the suggestion was a small one. I can see how that would have made reviewing difficult. I’ll make sure to keep the rebase and changes separate in the future. Thanks!