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

Rename network-related types #1159

Merged
merged 5 commits into from
Jun 2, 2022

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Nov 5, 2021

Rename some network-related types to be a bit more intuitive:

  • NetworkUpdate::ChannelClosed enum variant to NetworkUpdate::ChannelFailure
  • NetGraphMsgHandler struct to NetworkGossip P2PGossipSync
  • network_graph module to network gossip

@codecov
Copy link

codecov bot commented Nov 5, 2021

Codecov Report

Merging #1159 (1a9ff7e) into main (c0bbd4d) will increase coverage by 0.02%.
The diff coverage is 99.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1159      +/-   ##
==========================================
+ Coverage   90.14%   90.17%   +0.02%     
==========================================
  Files          70       70              
  Lines       36448    36448              
==========================================
+ Hits        32856    32866      +10     
+ Misses       3592     3582      -10     
Impacted Files Coverage Δ
lightning-invoice/src/de.rs 80.94% <ø> (+0.20%) ⬆️
lightning-invoice/src/lib.rs 88.51% <ø> (+0.12%) ⬆️
lightning-invoice/src/payment.rs 91.15% <ø> (ø)
lightning-invoice/src/utils.rs 83.48% <ø> (ø)
lightning/src/ln/channelmanager.rs 83.72% <ø> (ø)
lightning/src/ln/mod.rs 95.00% <ø> (+5.00%) ⬆️
lightning/src/ln/monitor_tests.rs 100.00% <ø> (ø)
lightning/src/ln/peer_handler.rs 49.77% <ø> (+0.11%) ⬆️
lightning/src/ln/reorg_tests.rs 100.00% <ø> (ø)
lightning/src/ln/shutdown_tests.rs 95.87% <ø> (ø)
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c0bbd4d...1a9ff7e. Read the comment docs.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Only one I'm eh on is ChannelFailure because I like the symmetry with Event::ChannelClosed and we already kinda tend to deviate from the spec on word choice (which I think is good)

I guess it wouldn't be crazy if NetworkGossip were just changed to Gossip?

Looks good as is though, nice improvement!

/// If permanent, removes a channel from the local storage.
/// May cause the removal of nodes too, if this was their last channel.
/// If not permanent, makes channels unavailable for routing.
pub fn close_channel_from_update(&self, short_channel_id: u64, is_permanent: bool) {
pub fn fail_channel(&self, short_channel_id: u64, is_permanent: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: prefer channel_failed because imo the gossip isn't the one failing the channel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also renamed fail_node.

@jkczyz
Copy link
Contributor Author

jkczyz commented Nov 8, 2021

Only one I'm eh on is ChannelFailure because I like the symmetry with Event::ChannelClosed and we already kinda tend to deviate from the spec on word choice (which I think is good)

lol it was your idea to rename it... 😛

#1117 (comment)

Note that this is describing why a payment failed (BOLT 4). The channel itself might not be closed, which should be determined by monitoring the blockchain according to BOLT 7.

Although only tangentially related, looking through BOLT 4, I think the intention is that a channel failure either has a channel_update or it does not (i.e., there is never an error code with both NODE and UPDATE set). So we may want to model NetworkUpdate in that manner at some point, IIUC. Something like:

pub struct RoutingFailure {
    cause: RoutingFailureCause,
    is_permanent: bool,
}

pub enum RoutingFailureCause {
    Channel {
        short_channel_id: u64,
        update: Option<ChannelUpdate>,
    },
    Node {
        node_id: PublicKey,
    }
}

(Though it's kinda strange that anything with BADONION set doesn't also have NODE set.)

Then NetworkGossip would interpret this as it sees fit rather than have the enum be in terms of how to handle the failure, as it currently is formed. Probably deserves further thought before making this change, though.

I guess it wouldn't be crazy if NetworkGossip were just changed to Gossip?

Hmm... I sorta like the symmetry with the other types in network. 🙂 It's specifically handling gossip about the network.

@jkczyz jkczyz force-pushed the 2021-11-network-gossip branch from f506f4d to 44f31d6 Compare November 8, 2021 17:15
@TheBlueMatt
Copy link
Collaborator

I don't really understand the reason behind renaming NetGraphMsgHandler to NetworkGossip, the second seems entirely less descriptive - the object is a message handler that handles graph (or gossip) messages, not a gossip...? Same goes for the module rename of network_graph - its all about the graph/gossip data, "network" could refer to a number of other things, I think?

@valentinewallace
Copy link
Contributor

Only one I'm eh on is ChannelFailure because I like the symmetry with Event::ChannelClosed and we already kinda tend to deviate from the spec on word choice (which I think is good)

lol it was your idea to rename it... stuck_out_tongue

#1117 (comment)

Note that this is describing why a payment failed (BOLT 4). The channel itself might not be closed, which should be determined by monitoring the blockchain according to BOLT 7.

Lol!! Oh right... Disregard that 😛

@jkczyz
Copy link
Contributor Author

jkczyz commented Nov 8, 2021

I don't really understand the reason behind renaming NetGraphMsgHandler to NetworkGossip, the second seems entirely less descriptive - the object is a message handler that handles graph (or gossip) messages, not a gossip...?

NetworkGossip describes what it is responsible for. The NetworkGraph view is a byproduct of this, while message handling is how it achieves only part of this responsibility.

IMHO, NetGraphMsgHandler focuses a bit too much on implementation details and is repetitive -- its interface takes a NetworkGraph and it implements a message handling trait. Additionally, it's a bit of a mouthful and uses abbreviations to make the name shorter.

Same goes for the module rename of network_graph - its all about the graph/gossip data, "network" could refer to a number of other things, I think?

I was thinking about this name in the context of it being a submodule of routing. But opened to another name like gossip, perhaps?

@jkczyz jkczyz force-pushed the 2021-11-network-gossip branch from 44f31d6 to 1a9ff7e Compare November 8, 2021 21:24
@TheBlueMatt
Copy link
Collaborator

is repetitive -- its interface takes a NetworkGraph

Fair.

it implements a message handling trait

I dunno if I buy the "it implements a specific trait as its main raison d'être, so the name shouldn't reference that" argument - it exists to handle the messages, trait implementation is somewhat hidden in both rustdoc and other languages, so I feel like its good to communicate that in the object naming?

I don't think I have a specific alternative to propose, but maybe GraphGossipMessageHandler or GraphGossiper?

@TheBlueMatt
Copy link
Collaborator

Needs rebase.

@TheBlueMatt
Copy link
Collaborator

really needs rebase lol

@jkczyz
Copy link
Contributor Author

jkczyz commented May 28, 2022

I don't think I have a specific alternative to propose, but maybe GraphGossipMessageHandler or GraphGossiper?

How about GossipProtocol? That encapsulates the concept of message handling in a way that isn't overly verbose.

I don't feel very strongly about renaming the module, so fully expressed it wold be either network::GossipProtocol<&NetworkGraph, ...> or network_graph::GossipProtocol<&NetworkGraph, ...>.

@TheBlueMatt
Copy link
Collaborator

How about GossipProtocol? That encapsulates the concept of message handling in a way that isn't overly verbose.

I'm not sure that it does? Protocol doesn't scream "handles the message" or "implements the protocol" to me, or at least not nearly as much as overly-verbose type names (which I think I'm generally more okay with than you are).

I don't feel very strongly about renaming the module, so fully expressed it wold be either network::GossipProtocol<&NetworkGraph, ...> or network_graph::GossipProtocol<&NetworkGraph, ...>.

I don't feel super strongly about it either, but I like your above suggestion of gossip over network. routing::gossip makes sense as a path name to me.

@jkczyz
Copy link
Contributor Author

jkczyz commented May 31, 2022

How about GossipProtocol? That encapsulates the concept of message handling in a way that isn't overly verbose.

I'm not sure that it does? Protocol doesn't scream "handles the message" or "implements the protocol" to me, or at least not nearly as much as overly-verbose type names (which I think I'm generally more okay with than you are).

Discussed offline. Will name it P2PGossipSync, which goes nicely with the forthcoming RapidGossipSync struct in #1433.

I don't feel very strongly about renaming the module, so fully expressed it wold be either network::GossipProtocol<&NetworkGraph, ...> or network_graph::GossipProtocol<&NetworkGraph, ...>.

I don't feel super strongly about it either, but I like your above suggestion of gossip over network. routing::gossip makes sense as a path name to me.

SGTM, let's go with gossip.

@jkczyz jkczyz added this to the 0.0.107 milestone Jun 1, 2022
@jkczyz jkczyz force-pushed the 2021-11-network-gossip branch from 1a9ff7e to c2ed78a Compare June 2, 2022 20:42
@codecov-commenter
Copy link

codecov-commenter commented Jun 2, 2022

Codecov Report

Merging #1159 (c2ed78a) into main (9c50083) will increase coverage by 0.37%.
The diff coverage is 99.07%.

❗ Current head c2ed78a differs from pull request most recent head 574870e. Consider uploading reports for the commit 574870e to get more accurate results

@@            Coverage Diff             @@
##             main    #1159      +/-   ##
==========================================
+ Coverage   90.94%   91.32%   +0.37%     
==========================================
  Files          80       80              
  Lines       43250    45740    +2490     
  Branches    43250    45740    +2490     
==========================================
+ Hits        39335    41772    +2437     
- Misses       3915     3968      +53     
Impacted Files Coverage Δ
lightning-invoice/src/de.rs 82.38% <ø> (ø)
lightning-invoice/src/lib.rs 87.39% <ø> (ø)
lightning-invoice/src/payment.rs 92.91% <ø> (ø)
lightning-invoice/src/utils.rs 96.77% <ø> (ø)
lightning-rapid-gossip-sync/src/lib.rs 90.66% <ø> (ø)
lightning-rapid-gossip-sync/src/processing.rs 90.17% <ø> (ø)
lightning/src/ln/mod.rs 95.00% <ø> (ø)
lightning/src/ln/peer_handler.rs 57.06% <ø> (ø)
lightning/src/routing/scoring.rs 97.08% <ø> (ø)
lightning/src/util/events.rs 42.62% <ø> (+0.96%) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c50083...574870e. Read the comment docs.

@jkczyz
Copy link
Contributor Author

jkczyz commented Jun 2, 2022

Oops, looks like git mv plus edit didn't remove network_graph.rs.

Edit: Never mind, it did

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.

LGTM. Feel free to squash IMO.

/// An error indicating only that a channel has been closed, which should be applied via
/// [`NetworkGraph::close_channel_from_update`].
ChannelClosed {
/// An error indicating only that a channel has failed, which should be applied via
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be nice to elaborate on what "failed" means here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Let me know if you'd prefer a different elaboration.

@jkczyz jkczyz force-pushed the 2021-11-network-gossip branch from c2ed78a to 7976512 Compare June 2, 2022 21:58
TheBlueMatt
TheBlueMatt previously approved these changes Jun 2, 2022
@TheBlueMatt
Copy link
Collaborator

LGTM (still) feel free to squash.

jkczyz added 2 commits June 2, 2022 15:15
A NetworkUpdate indicating ChannelClosed actually corresponds to a
channel failure as described in BOLT 4:

0x2000 (NODE): node failure (otherwise channel)

Rename the enum variant to ChannelFailure and rename NetworkGraph
methods close_channel_from_update and fail_node to channel_failed and
node_failed, respectively.
NetGraphMsgHandler implements RoutingMessageHandler to handle gossip
messages defined in BOLT 7 and maintains a view of the network by
updating NetworkGraph. Rename it to P2PGossipSync, which better
describes its purpose, and to contrast with RapidGossipSync.
The routing::network_graph module contains a few structs related to p2p
gossip. So renaming the module to 'gossip' seems more appropriate.
@jkczyz jkczyz force-pushed the 2021-11-network-gossip branch from d7a1b2f to 574870e Compare June 2, 2022 22:15
@TheBlueMatt TheBlueMatt merged commit 0017bc8 into lightningdevkit:main Jun 2, 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