Support normal channel operation with async signing
This is a do-over of #2653, wherein we support asynchronous signing for 'normal' channel operation. This involves allowing the following ChannelSigner methods to return an Err result, indicating that the requested value is not available:
- get_per_commitment_point
- release_commitment_secret
- sign_counterparty_commitment
When the value does become available, channel operation can be resumed by invoking signer_unblocked.
Note that this adds the current and next per-commitment point to the state that is persisted by the channel monitor.
Walkthrough
The recent updates across various files in a Rust-based codebase focus on enhancing asynchronous operations, particularly around signing processes. These changes include the addition of new constants, modifications to the SignerProvider, and updates to message handling and error management. There's also a notable shift in how per_commitment_points are handled, alongside improved logging for debugging and more robust test utilities.
Changes
| Files | Summary |
|---|---|
fuzz/src/chanmon_consistency.rs, lightning/src/ln/channelmanager.rs, lightning/src/util/test_channel_signer.rs |
Introduced new asynchronous operation constants, updated SignerProvider, added debugging logs, and refined message handling logic. |
lightning/src/chain/channelmonitor.rs, lightning/src/chain/onchaintx.rs |
Altered how per_commitment_point is assigned and used, affecting on-chain transaction handling. |
lightning/src/ln/functional_test_utils.rs, lightning/src/ln/functional_tests.rs |
Enhanced test utilities with new functions, improved error handling, and explicit result unwrapping. |
lightning/src/sign/mod.rs |
Modified ChannelSigner trait to include error handling by returning Result types. |
🐇✨ In the realms of code, where the lightning arcs, A rabbit hopped through, leaving whimsical marks. With each line refined, and errors unwound, A trail of cleaner code is what it found. 🌟🌱
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>. -
Generate unit-tests for this file.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit tests for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository from git and render them as a table. -
@coderabbitai show all the console.log statements in this repository. -
@coderabbitai read src/utils.ts and generate unit tests. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - The JSON schema for the configuration file is available here.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json
CodeRabbit Discord Community
Join our Discord Community to get help, request features, and share feedback.
Codecov Report
Attention: Patch coverage is 65.59865% with 204 lines in your changes missing coverage. Please review.
Project coverage is 88.99%. Comparing base (
51d9ee3) to head (8db91d7). Report is 1848 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2849 +/- ##
==========================================
- Coverage 89.18% 88.99% -0.20%
==========================================
Files 116 116
Lines 93098 93477 +379
Branches 93098 93477 +379
==========================================
+ Hits 83034 83189 +155
- Misses 7538 7733 +195
- Partials 2526 2555 +29
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
One more thing we need to add to docs here before we ship is note that the signing validate_* methods may be called for two different commitments at the same height in rare cases. Specifically, if we receive a commitment update, pass it to the signer, then shut down without persisting anything we may restart, reconnect, and get a different commitment update from our peer. So the signer needs to handle this (we shouldn't need to deal with it in the actual sign methods because we wait for the monitor to persist before calling those).
Supersceded by #3115, #3150, #3152, etc.