Skip to content

MPP on the router side #646

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 6 commits into from
Mar 3, 2021
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
3 changes: 2 additions & 1 deletion fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
proportional_millionths: slice_to_be32(get_slice!(4)),
},
cltv_expiry_delta: slice_to_be16(get_slice!(2)),
htlc_minimum_msat: slice_to_be64(get_slice!(8)),
htlc_minimum_msat: Some(slice_to_be64(get_slice!(8))),
htlc_maximum_msat: None,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3167,7 +3167,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
// Upper bound by capacity. We make it a bit less than full capacity to prevent attempts
// to use full capacity. This is an effort to reduce routing failures, because in many cases
// channel might have been used to route very small values (either by honest users or as DoS).
self.channel_value_satoshis * 9 / 10,
self.channel_value_satoshis * 1000 * 9 / 10,

Channel::<ChanSigner>::get_holder_max_htlc_value_in_flight_msat(self.channel_value_satoshis)
);
Expand Down
15 changes: 10 additions & 5 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,8 @@ fn test_channel_reserve_holding_cell_htlcs() {

// attempt to send amt_msat > their_max_htlc_value_in_flight_msat
{
let (route, our_payment_hash, _) = get_route_and_payment_hash!(recv_value_0 + 1);
let (mut route, our_payment_hash, _) = get_route_and_payment_hash!(recv_value_0);
route.paths[0].last_mut().unwrap().fee_msat += 1;
assert!(route.paths[0].iter().rev().skip(1).all(|h| h.fee_msat == feemsat));
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
assert!(regex::Regex::new(r"Cannot send value that would put us over the max HTLC value in flight our peer will accept \(\d+\)").unwrap().is_match(err)));
Expand Down Expand Up @@ -6472,7 +6473,7 @@ fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high() {
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 0, InitFeatures::known(), InitFeatures::known());
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 0, InitFeatures::known(), InitFeatures::known());
let logger = test_utils::TestLogger::new();

let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
Expand Down Expand Up @@ -6544,9 +6545,13 @@ fn test_update_add_htlc_bolt2_sender_exceed_max_htlc_value_in_flight() {
send_payment(&nodes[0], &vec!(&nodes[1])[..], max_in_flight, max_in_flight);

let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
let logger = test_utils::TestLogger::new();
let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, &[], max_in_flight+1, TEST_FINAL_CLTV, &logger).unwrap();
// Manually create a route over our max in flight (which our router normally automatically
// limits us to.
let route = Route { paths: vec![vec![RouteHop {
pubkey: nodes[1].node.get_our_node_id(), node_features: NodeFeatures::known(), channel_features: ChannelFeatures::known(),
short_channel_id: nodes[1].node.list_usable_channels()[0].short_channel_id.unwrap(),
fee_msat: max_in_flight + 1, cltv_expiry_delta: TEST_FINAL_CLTV
}]] };
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
assert!(regex::Regex::new(r"Cannot send value that would put us over the max HTLC value in flight our peer will accept \(\d+\)").unwrap().is_match(err)));

Expand Down
7 changes: 7 additions & 0 deletions lightning/src/routing/network_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
}
}

/// Adds a provider used to check new announcements. Does not affect
/// existing announcements unless they are updated.
/// Add, update or remove the provider would replace the current one.
pub fn add_chain_access(&mut self, chain_access: Option<C>) {
self.chain_access = chain_access;
}

/// Take a read lock on the network_graph and return it in the C-bindings
/// newtype helper. This is likely only useful when called via the C
/// bindings as you can call `self.network_graph.read().unwrap()` in Rust
Expand Down
Loading