Skip to content

Commit

Permalink
Merge pull request #1043 from jkczyz/2021-07-network-update-handler
Browse files Browse the repository at this point in the history
Handle network updates from failed payments in BackgroundProcessor
  • Loading branch information
TheBlueMatt authored Sep 15, 2021
2 parents de9fba8 + 992df51 commit bb9df69
Show file tree
Hide file tree
Showing 23 changed files with 776 additions and 733 deletions.
7 changes: 0 additions & 7 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
},
events::MessageSendEvent::SendFundingLocked { .. } => continue,
events::MessageSendEvent::SendAnnouncementSignatures { .. } => continue,
events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => continue,
events::MessageSendEvent::SendChannelUpdate { ref node_id, ref msg } => {
assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set!
if Some(*node_id) == expect_drop_id { panic!("peer_disconnected should drop msgs bound for the disconnected peer"); }
Expand Down Expand Up @@ -727,10 +726,6 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
events::MessageSendEvent::SendAnnouncementSignatures { .. } => {
// Can be generated as a reestablish response
},
events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => {
// Can be generated due to a payment forward being rejected due to a
// channel having previously failed a monitor update
},
events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => {
// When we reconnect we will resend a channel_update to make sure our
// counterparty has the latest parameters for receiving payments
Expand Down Expand Up @@ -769,7 +764,6 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
events::MessageSendEvent::SendChannelReestablish { .. } => {},
events::MessageSendEvent::SendFundingLocked { .. } => {},
events::MessageSendEvent::SendAnnouncementSignatures { .. } => {},
events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => {},
events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => {
assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set!
},
Expand All @@ -787,7 +781,6 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
events::MessageSendEvent::SendChannelReestablish { .. } => {},
events::MessageSendEvent::SendFundingLocked { .. } => {},
events::MessageSendEvent::SendAnnouncementSignatures { .. } => {},
events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => {},
events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => {
assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set!
},
Expand Down
9 changes: 5 additions & 4 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,Ig
use lightning::ln::msgs::DecodeError;
use lightning::ln::script::ShutdownScript;
use lightning::routing::router::get_route;
use lightning::routing::network_graph::NetGraphMsgHandler;
use lightning::routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
use lightning::util::config::UserConfig;
use lightning::util::errors::APIError;
use lightning::util::events::Event;
Expand Down Expand Up @@ -378,7 +378,8 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
};
let channelmanager = Arc::new(ChannelManager::new(fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, params));
let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret());
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(genesis_block(network).block_hash(), None, Arc::clone(&logger)));
let network_graph = NetworkGraph::new(genesis_block(network).block_hash());
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(network_graph, None, Arc::clone(&logger)));

let peers = RefCell::new([false; 256]);
let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {
Expand Down Expand Up @@ -434,7 +435,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
},
4 => {
let value = slice_to_be24(get_slice!(3)) as u64;
let route = match get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &get_pubkey!(), None, None, &Vec::new(), value, 42, Arc::clone(&logger)) {
let route = match get_route(&our_id, &net_graph_msg_handler.network_graph, &get_pubkey!(), None, None, &Vec::new(), value, 42, Arc::clone(&logger)) {
Ok(route) => route,
Err(_) => return,
};
Expand All @@ -451,7 +452,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
},
15 => {
let value = slice_to_be24(get_slice!(3)) as u64;
let mut route = match get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &get_pubkey!(), None, None, &Vec::new(), value, 42, Arc::clone(&logger)) {
let mut route = match get_route(&our_id, &net_graph_msg_handler.network_graph, &get_pubkey!(), None, None, &Vec::new(), value, 42, Arc::clone(&logger)) {
Ok(route) => route,
Err(_) => return,
};
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
let logger: Arc<dyn Logger> = Arc::new(test_logger::TestLogger::new("".to_owned(), out));

let our_pubkey = get_pubkey!();
let mut net_graph = NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash());
let net_graph = NetworkGraph::new(genesis_block(Network::Bitcoin).header.block_hash());

let mut node_pks = HashSet::new();
let mut scid = 42;
Expand Down
Loading

0 comments on commit bb9df69

Please sign in to comment.