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

Swap gossip message PublicKey for NodeId #2016

Conversation

alecchendev
Copy link
Contributor

Closes #1973. Swaps PublicKey for NodeId in UnsignedChannelAnnouncement and UnsignedNodeAnnouncement and updates any affected areas.

@alecchendev
Copy link
Contributor Author

Note: for channel_announcement messages, public keys are parsed for 1. signature verification, but also 2. recreating the funding output to check if the output corresponding to the channel announcement matches. For 2. it’s possible to avoid doing this again after parsing for signature verification (by passing the previously parsed public keys as arguments to NetworkGraph::update_channel_from_unsigned_announcement_intern) but didn’t think it was super necessary. Open to suggestions:)

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2023

Codecov Report

Base: 90.89% // Head: 90.88% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (04c84ac) compared to base (760ab65).
Patch coverage: 72.00% of modified lines in pull request are covered.

❗ Current head 04c84ac differs from pull request most recent head 3c0152e. Consider uploading reports for the commit 3c0152e to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2016      +/-   ##
==========================================
- Coverage   90.89%   90.88%   -0.02%     
==========================================
  Files          99       99              
  Lines       53026    53034       +8     
  Branches    53026    53034       +8     
==========================================
+ Hits        48197    48198       +1     
- Misses       4829     4836       +7     
Impacted Files Coverage Δ
lightning-net-tokio/src/lib.rs 77.77% <0.00%> (ø)
lightning/src/ln/peer_handler.rs 55.50% <0.00%> (-0.10%) ⬇️
lightning/src/routing/gossip.rs 91.39% <75.86%> (-0.48%) ⬇️
lightning/src/util/test_utils.rs 73.99% <80.00%> (ø)
lightning/src/ln/channel.rs 88.76% <100.00%> (+<0.01%) ⬆️
lightning/src/ln/msgs.rs 86.22% <100.00%> (ø)
lightning/src/routing/scoring.rs 97.33% <100.00%> (ø)
lightning/src/routing/test_utils.rs 97.93% <100.00%> (ø)
lightning/src/util/events.rs 30.50% <0.00%> (-0.69%) ⬇️
... and 2 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.

@alecchendev alecchendev force-pushed the 2023-02-gossip-msg-pubkey-to-nodeid branch from 2f2d167 to 5cbda98 Compare February 6, 2023 23:02
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.

Nice! This turned out to be pretty straightforward and a huge gain, as expected.

CI (which has tons of noise) says read_network_graph is now test 527,259,818 ns/iter (+/- 44,143,324), down from 3,304,538,463 ns/iter (+/- 182,981,140)

fuzz/src/router.rs Outdated Show resolved Hide resolved
lightning/src/routing/gossip.rs Outdated Show resolved Hide resolved
@TheBlueMatt
Copy link
Collaborator

Feel free to go ahead and squash the fixups down into the original commits.

@alecchendev alecchendev force-pushed the 2023-02-gossip-msg-pubkey-to-nodeid branch from 04c84ac to 3c0152e Compare February 7, 2023 01:01
@dunxen dunxen self-requested a review February 7, 2023 06:11
dunxen
dunxen previously approved these changes Feb 7, 2023
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.

Whoa, big win! 🥳

lightning/src/ln/chan_utils.rs Outdated Show resolved Hide resolved
Adds the macro `get_pubkey_from_node_id`
to parse `PublicKey`s back from `NodeId`s for signature
verification, as well as `make_funding_redeemscript_from_slices`
to avoid parsing back and forth between types.
Also swaps `PublicKey` for `NodeId` in `get_next_node_announcement`
and `InitSyncTracker` to avoid unnecessary deserialization that came
from changing `UnsignedNodeAnnouncement`.
peer.their_node_id.as_ref() == Some(&msg.contents.node_id_2) {
continue;
if let Some(their_node_id) = peer.their_node_id {
let their_node_id = NodeId::from_pubkey(&their_node_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, serializing the keys of all our peers every time we go to forward a gossip message blows, Let's keep a cached NodeId copy for each peer (though it can go in a followup).

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.

Swap Gossip Message PublicKeys for NodeIds
4 participants