Skip to content

Misc peer_handler.rs cleanups and fixes #3865

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

Merged
merged 7 commits into from
Jun 20, 2025

Conversation

TheBlueMatt
Copy link
Collaborator

No description provided.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jun 16, 2025

👋 I see @jkczyz was un-assigned.
If you'd like another reviewer assignemnt, please click here.

@ldk-reviews-bot ldk-reviews-bot requested a review from jkczyz June 16, 2025 15:40
@@ -2186,8 +2186,7 @@ where
if peer_lock.message_batch.is_some() {
let error = format!(
"Peer {} sent start_batch for channel {} before previous batch completed",
their_node_id,
&msg.channel_id
their_node_id, &msg.channel_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised rustfmt does this. Is this a new format!-specific thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As was I! This is the MSRV rustfmt version, so its not new, and it has done it in other place in our code.

@TheBlueMatt TheBlueMatt force-pushed the 2025-06-3725-followups branch from 8123ac6 to fe634cf Compare June 16, 2025 21:44
@TheBlueMatt
Copy link
Collaborator Author

Addressed feedback.

@TheBlueMatt TheBlueMatt force-pushed the 2025-06-3725-followups branch from fe634cf to 4c1e8cf Compare June 16, 2025 21:45
@TheBlueMatt TheBlueMatt force-pushed the 2025-06-3725-followups branch from 4c1e8cf to 81642f3 Compare June 17, 2025 00:26
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically looks good, one question. Feel free to squash fixups, IMO.

@TheBlueMatt TheBlueMatt force-pushed the 2025-06-3725-followups branch from 81642f3 to 955d18e Compare June 18, 2025 17:12
@TheBlueMatt
Copy link
Collaborator Author

Squashed and rebased without further changes.

In e620310 we prep'd
`peer_handler.rs` for `rustfmt`, but left a few misc things kinda
ugly, which we clean up here.
In 9db37f2 we introduced a
`send_only_message_handler` which was intended to be used to send
messages to peers.

However, when we did so we forgot to add calls to its
`peer_connected`, `peer_disconnected`, `provided_node_features`,
and `provided_init_features` methods.

Here we add those methods, updating the comment somewhat to avoid
implying that they won't be called.
Our `peer_connected` methods can return `Err(())` to cause the peer
to be immediately disconnected. The documentation for them,
however, only described the specific case of using this to enforce
minimal set of per feature bits.

Instead, here, we tweak the documentation to describe the
high-level utility, and only mention enforcing peer feature bits as
an example use-case.
In 81e89d8 we added handling for
sending peer storage messages, however forgot to include the peer's
node_id in the log metadata when sending such messages.
`log_pubkey` is an old macro we used to format `PublicKey`s before
they supported native `Display` upstream. They do, however,
implement `Dispaly` now by logging the compressed public key in
hex, so there's no need for `log_pubkey!()`
In c0fbe42 we ran `rustfmt` on
some code in `channel.rs`, which broke some comments which referred
to code on a specific line. Here we fix those comments.
@TheBlueMatt TheBlueMatt force-pushed the 2025-06-3725-followups branch from 955d18e to 90d3961 Compare June 19, 2025 15:43
@TheBlueMatt
Copy link
Collaborator Author

Rebased to remove the addition of some new log_pubkeys and slipped in one extra commit at the end.

Copy link

codecov bot commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 53.84615% with 60 lines in your changes missing coverage. Please review.

Project coverage is 89.69%. Comparing base (3da69f7) to head (90d3961).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/peer_handler.rs 52.38% 60 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3865      +/-   ##
==========================================
- Coverage   89.72%   89.69%   -0.03%     
==========================================
  Files         164      164              
  Lines      133333   133349      +16     
  Branches   133333   133349      +16     
==========================================
- Hits       119627   119614      -13     
- Misses      11031    11053      +22     
- Partials     2675     2682       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheBlueMatt TheBlueMatt requested review from jkczyz, tnull and valentinewallace and removed request for jkczyz June 19, 2025 18:48
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jkczyz jkczyz merged commit 4392a9d into lightningdevkit:main Jun 20, 2025
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants