Skip to content

Commit fef8acf

Browse files
committed
Make routing benchmark robust against path changes
If the scoring in the routing benchmark causes us to take a different path from the original scan, we may end up deciding that the only path to a node has a too-high total CLTV delta, causing us to panic in the benchmarking phase. Here we simply check for that possibility and remove paths that fail post-scoring.
1 parent 2bba1d4 commit fef8acf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5433,7 +5433,7 @@ mod benches {
54335433
let mut routes = Vec::new();
54345434
let mut route_endpoints = Vec::new();
54355435
let mut seed: usize = 0xdeadbeef;
5436-
'load_endpoints: for _ in 0..100 {
5436+
'load_endpoints: for _ in 0..150 {
54375437
loop {
54385438
seed *= 0xdeadbeef;
54395439
let src = PublicKey::from_slice(nodes.keys().skip(seed % nodes.len()).next().unwrap().as_slice()).unwrap();
@@ -5465,6 +5465,15 @@ mod benches {
54655465
}
54665466
}
54675467

5468+
// Because we've changed channel scores, its possible we'll take different routes to the
5469+
// selected destinations, possibly causing us to fail because, eg, the newly-selected path
5470+
// requires a too-high CLTV delta.
5471+
route_endpoints.retain(|(first_hop, params, amt)| {
5472+
get_route(&payer, params, &graph.read_only(), Some(&[first_hop]), *amt, 42, &DummyLogger{}, &scorer, &random_seed_bytes).is_ok()
5473+
});
5474+
route_endpoints.truncate(100);
5475+
assert_eq!(route_endpoints.len(), 100);
5476+
54685477
// ...then benchmark finding paths between the nodes we learned.
54695478
let mut idx = 0;
54705479
bench.iter(|| {

0 commit comments

Comments
 (0)