askrene: implement reduce_num_flows in refine, using increase_flows().

Now we simply call it at the end.  We need to check it hasn't violated fee maxima, but
otherwise it's simple.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Plugins: `askrene` now handles limits on number of htlcs much more gracefully.
This commit is contained in:
Rusty Russell
2025-11-16 15:36:13 +10:30
parent 050b149e53
commit 8c7ac33f88
4 changed files with 83 additions and 87 deletions

View File

@@ -1782,8 +1782,7 @@ def test_simple_dummy_channel(node_factory):
def test_maxparts_infloop(node_factory, bitcoind):
# Three paths from l1 -> l5.
# FIXME: enhance explain_failure!
l1, l2, l3, l4, l5 = node_factory.get_nodes(5, opts=[{'broken_log': 'plugin-cln-askrene.*the obvious route'}] + [{}] * 4)
l1, l2, l3, l4, l5 = node_factory.get_nodes(5)
for intermediate in (l2, l3, l4):
node_factory.join_nodes([l1, intermediate, l5])
@@ -1805,16 +1804,14 @@ def test_maxparts_infloop(node_factory, bitcoind):
final_cltv=5)
assert len(route['routes']) == 3
# Now with maxparts == 2. Usually askrene can't figure out why it failed,
# but sometimes it gets a theory.
with pytest.raises(RpcError):
l1.rpc.getroutes(source=l1.info['id'],
destination=l5.info['id'],
amount_msat=amount,
layers=[],
maxfee_msat=amount,
final_cltv=5,
maxparts=2)
route = l1.rpc.getroutes(source=l1.info['id'],
destination=l5.info['id'],
amount_msat=amount,
layers=[],
maxfee_msat=amount,
final_cltv=5,
maxparts=2)
assert len(route['routes']) == 2
def test_askrene_timeout(node_factory, bitcoind):