Skip to content

Rename network-related types #1159

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 5 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ARCH.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ receive `ChannelMonitorUpdate`s from `ChannelManager` and persist them to disk b
channel steps forward.

There are two additional important structures that you may use either on the same device
as the `ChannelManager` or on a separate one. `NetGraphMsgHandler` handles receiving channel
and node announcements, which are then used to calculate routes by `get_route` for sending payments.
`PeerManager` handles the authenticated and encrypted communication protocol,
monitoring for liveness of peers, routing messages to `ChannelManager` and `NetGraphMsgHandler`
as the `ChannelManager` or on a separate one. `P2PGossipSync` handles receiving channel
and node announcements, which are then used to calculate routes by `find_route` for sending
payments. `PeerManager` handles the authenticated and encrypted communication protocol,
monitoring for liveness of peers, routing messages to `ChannelManager` and `P2PGossipSync`
instances directly, and receiving messages from them via the `EventsProvider` interface.

These structs communicate with each other using a public API, so that you can easily add
Expand Down Expand Up @@ -56,7 +56,7 @@ At a high level, some of the common interfaces fit together as follows:
| ----------------- \ / ----------------
| ^ \ / |
(as RoutingMessageHandler) | v v
\ ---------------------- --------- -----------------
-----------------> | NetGraphMsgHandler | | Event | | chain::Filter |
---------------------- --------- -----------------
\ ----------------- --------- -----------------
-----------------> | P2PGossipSync | | Event | | chain::Filter |
----------------- --------- -----------------
```
8 changes: 4 additions & 4 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use lightning::ln::channelmanager::{ChainParameters, ChannelManager};
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
use lightning::ln::msgs::DecodeError;
use lightning::ln::script::ShutdownScript;
use lightning::routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
use lightning::routing::router::{find_route, PaymentParameters, RouteParameters};
use lightning::routing::scoring::FixedPenaltyScorer;
use lightning::util::config::UserConfig;
Expand Down Expand Up @@ -163,7 +163,7 @@ type ChannelMan = ChannelManager<
EnforcingSigner,
Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>, Arc<dyn Logger>>;
type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<NetGraphMsgHandler<Arc<NetworkGraph>, Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>, IgnoringMessageHandler>;
type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<P2PGossipSync<Arc<NetworkGraph>, Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>, IgnoringMessageHandler>;

struct MoneyLossDetector<'a> {
manager: Arc<ChannelMan>,
Expand Down Expand Up @@ -396,13 +396,13 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
keys_manager.counter.fetch_sub(1, Ordering::AcqRel);
let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret(Recipient::Node).unwrap());
let network_graph = Arc::new(NetworkGraph::new(genesis_block(network).block_hash()));
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
let gossip_sync = Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
let scorer = FixedPenaltyScorer::with_penalty(0);

let peers = RefCell::new([false; 256]);
let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {
chan_handler: channelmanager.clone(),
route_handler: net_graph_msg_handler.clone(),
route_handler: gossip_sync.clone(),
}, our_network_key, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0], Arc::clone(&logger), IgnoringMessageHandler{}));

let mut should_forward = false;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/process_network_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use utils::test_logger;
/// Actual fuzz test, method signature and name are fixed
fn do_test(data: &[u8]) {
let block_hash = bitcoin::BlockHash::default();
let network_graph = lightning::routing::network_graph::NetworkGraph::new(block_hash);
let network_graph = lightning::routing::gossip::NetworkGraph::new(block_hash);
let rapid_sync = RapidGossipSync::new(&network_graph);
let _ = rapid_sync.update_network_graph(data);
}
Expand Down
4 changes: 2 additions & 2 deletions fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use lightning::chain::transaction::OutPoint;
use lightning::ln::channelmanager::{ChannelDetails, ChannelCounterparty};
use lightning::ln::features::InitFeatures;
use lightning::ln::msgs;
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
use lightning::routing::router::{find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
use lightning::routing::scoring::FixedPenaltyScorer;
use lightning::util::logger::Logger;
use lightning::util::ser::Readable;
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};

use bitcoin::hashes::Hash;
use bitcoin::secp256k1::PublicKey;
Expand Down Expand Up @@ -196,7 +196,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
},
4 => {
let short_channel_id = slice_to_be64(get_slice!(8));
net_graph.close_channel_from_update(short_channel_id, false);
net_graph.channel_failed(short_channel_id, false);
},
_ if node_pks.is_empty() => {},
_ => {
Expand Down
Loading