Skip to content

Log peer's features if they require some unknown features we don't support #2947

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 3 commits into from
Jun 3, 2024

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Mar 19, 2024

Previously, when a peer sends us features we don't understand we wouldn't log them, but just log Peer requires features unknown to us.

Here, we fix this.

@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 95.23810% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 89.41%. Comparing base (1d2a27d) to head (9ee73df).
Report is 2 commits behind head on main.

Files Patch % Lines
lightning/src/ln/peer_handler.rs 50.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2947      +/-   ##
==========================================
+ Coverage   89.40%   89.41%   +0.01%     
==========================================
  Files         117      117              
  Lines       96016    96217     +201     
  Branches    96016    96217     +201     
==========================================
+ Hits        85842    86033     +191     
- Misses       7957     7964       +7     
- Partials     2217     2220       +3     

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

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

IIRC the to-string for a feature doesn't actually say which features are set which are unknown, only that there are some unknown features. In this case it seems like we should probably include what those features are.

@tnull tnull force-pushed the 2024-03-log-features-if-mismatch branch from a832dd1 to 1176ba2 Compare April 8, 2024 13:13
@tnull
Copy link
Contributor Author

tnull commented Apr 8, 2024

IIRC the to-string for a feature doesn't actually say which features are set which are unknown, only that there are some unknown features. In this case it seems like we should probably include what those features are.

Done, we now log which features are unknown to us (in BOLT09 bit number format).

Also rebased to make CI pass.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

I think the first commit can now just get the rest of them squashed.

@tnull tnull force-pushed the 2024-03-log-features-if-mismatch branch from 5198054 to c472b30 Compare April 9, 2024 15:09
@TheBlueMatt
Copy link
Collaborator

LGTM, feel free to squash the fixups.

@tnull tnull force-pushed the 2024-03-log-features-if-mismatch branch from c472b30 to 5e80316 Compare April 11, 2024 08:07
@tnull
Copy link
Contributor Author

tnull commented Apr 11, 2024

Squashed fixups without further changes.

dunxen
dunxen previously approved these changes Apr 11, 2024
Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

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

LGTM (with optout's comment on duplicate resolved or as a follow-up)

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

I'm pretty sure the first commit should be squashed-into, its entirely changed by the second commit.

@tnull tnull force-pushed the 2024-03-log-features-if-mismatch branch from 5e80316 to 0db201c Compare April 12, 2024 08:50
@tnull
Copy link
Contributor Author

tnull commented Apr 12, 2024

I'm pretty sure the first commit should be squashed-into, its entirely changed by the second commit.

Ah, true, squashed it in and rebased to make CI happy. However now created a new fixup to address your last comment.

@TheBlueMatt
Copy link
Collaborator

LGTM, feel free to squash.

@tnull tnull force-pushed the 2024-03-log-features-if-mismatch branch from 0db201c to 9ee73df Compare April 15, 2024 06:10
@tnull
Copy link
Contributor Author

tnull commented Apr 15, 2024

Squashed without further changes.

@tnull tnull force-pushed the 2024-03-log-features-if-mismatch branch from 9ee73df to 44cf692 Compare April 15, 2024 15:41
@tnull
Copy link
Contributor Author

tnull commented Apr 15, 2024

Force-pushed the following fixups:

> git diff-tree -U2  9ee73dfb3 44cf6928d

diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs
index 9a0c2b30e..8de57c2b9 100644
--- a/lightning/src/ln/features.rs
+++ b/lightning/src/ln/features.rs
@@ -788,5 +788,5 @@ impl<T: sealed::Context> Features<T> {
                        if byte & unknown_features != 0 {
                                for bit in (0..8).step_by(2) {
-                                       if byte >> bit & 1 == 1 {
+                                       if ((byte & unknown_features) >> bit) & 1 == 1 {
                                                unknown_bits.push(i * 8 + bit);
                                        }
@@ -1067,9 +1067,13 @@ mod tests {

                let mut features = ChannelFeatures::empty();
-               features.set_unknown_feature_optional();
+               features.set_unknown_feature_required();
                features.set_custom_bit(123456786).unwrap();
                assert!(features.requires_unknown_bits());
                assert!(features.supports_unknown_bits());
-               assert_eq!(features.required_unknown_bits_from(&ChannelFeatures::empty()), vec![123456786]);
+               assert_eq!(features.required_unknown_bits_from(&ChannelFeatures::empty()), vec![123456786, 123456788]);
+
+               let mut limiter = ChannelFeatures::empty();
+               limiter.set_unknown_feature_optional();
+               assert_eq!(features.required_unknown_bits_from(&limiter), vec![123456786]);
        }

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Your turn @dunxen

@tnull tnull requested a review from dunxen April 25, 2024 15:38
Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

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

Very sorry for the delay here @tnull. Completely fell off my radar.

Thankfully no conflicts? LGTM now.

@dunxen dunxen merged commit c9de650 into lightningdevkit:main Jun 3, 2024
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