Skip to content
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

Move checking of specific require peer feature bits to handlers #1717

Conversation

TheBlueMatt
Copy link
Collaborator

As we remove the concept of a global "known/supported" feature set
in LDK, we should also remove the concept of a global "required"
feature set. This does so by moving the checks for specific
required features into handlers.

Specifically, it allows the handler peer_connected method to
return an Err if the peer should be disconnected. Only one such
required feature bit is currently set - static_remote_key, which
is required in ChannelManager.

@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2022

Codecov Report

Base: 90.84% // Head: 90.83% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (f725c5a) compared to base (15a5966).
Patch coverage: 89.47% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1717      +/-   ##
==========================================
- Coverage   90.84%   90.83%   -0.02%     
==========================================
  Files          86       86              
  Lines       46448    47509    +1061     
  Branches    46448    47509    +1061     
==========================================
+ Hits        42198    43153     +955     
- Misses       4250     4356     +106     
Impacted Files Coverage Δ
lightning/src/ln/msgs.rs 86.24% <ø> (ø)
lightning/src/ln/peer_handler.rs 61.11% <46.15%> (+4.23%) ⬆️
lightning/src/util/test_utils.rs 76.90% <75.00%> (+0.05%) ⬆️
lightning/src/ln/channelmanager.rs 84.96% <77.77%> (-0.04%) ⬇️
lightning-background-processor/src/lib.rs 96.23% <100.00%> (ø)
lightning-net-tokio/src/lib.rs 76.73% <100.00%> (-0.31%) ⬇️
lightning/src/ln/chanmon_update_fail_tests.rs 97.72% <100.00%> (ø)
lightning/src/ln/channel.rs 88.88% <100.00%> (+<0.01%) ⬆️
lightning/src/ln/functional_test_utils.rs 93.44% <100.00%> (ø)
lightning/src/ln/functional_tests.rs 97.07% <100.00%> (+0.11%) ⬆️
... and 18 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -6034,7 +6034,12 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
}
}

fn peer_connected(&self, counterparty_node_id: &PublicKey, init_msg: &msgs::Init) {
fn peer_connected(&self, counterparty_node_id: &PublicKey, init_msg: &msgs::Init) -> Result<(), ()> {
if !init_msg.features.supports_static_remote_key() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not obvious to me why we wouldn't also disallow peers that don't support payment_secret, since it looks like we'll fail payments that don't have one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Payment_secret is really between us and the sender - we can have a channel with someone who doesn't speak payment_secret, and our counterparty can't pay us directly, but we can still receive funds via them.

@TheBlueMatt TheBlueMatt force-pushed the 2022-09-req-features-in-handlers branch from dc3e512 to 7e0c8fe Compare September 13, 2022 02:20
Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

LGTM after squash.

It appears our code is already correct here, but its also nice to
add a quick safety check in `channel.rs` which ensures we will
remain idempotent.
In the next commit we'll enforce counterparty `InitFeatures`
matching our required set in `ChannelManager`, implying they must
be set for many tests where they previously did not need to be (as
they were enforced in `PeerManager`, which is not used in
functional tests).
As we remove the concept of a global "known/supported" feature set
in LDK, we should also remove the concept of a global "required"
feature set. This does so by moving the checks for specific
required features into handlers.

Specifically, it allows the handler `peer_connected` method to
return an `Err` if the peer should be disconnected. Only one such
required feature bit is currently set - `static_remote_key`, which
is required in `ChannelManager`.
@TheBlueMatt TheBlueMatt force-pushed the 2022-09-req-features-in-handlers branch from 7e0c8fe to f725c5a Compare September 13, 2022 16:59
@TheBlueMatt
Copy link
Collaborator Author

Squashed without change.

@valentinewallace valentinewallace merged commit d2a9ae0 into lightningdevkit:main Sep 13, 2022
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.

4 participants