Commit Graph

15609 Commits

Author SHA1 Message Date
Christian Decker
e839c0ebcc test: Fix up the test_pay_routeboost test 2024-10-07 14:05:47 +02:00
Christian Decker
63e663ec9c pytest: Fix up the test_mutual_connect_race
A failing payment would doom all subsequent ones. Now we step down the
amount a single satoshi so any prior channel_hints do not doom the
payment outright.

Changelog-None
2024-10-07 14:05:47 +02:00
Christian Decker
f6d410d924 pay: Remove use of temporary local channel_hint
We were using `channel_hint` to temporarily tweak the graph inside of
a payment. However, these ad-hoc `channel_hints` are stickier than
their predecessors, in that they outlive the payment attempt itself,
and interfere with later ones.

Changelog-Changed: pay: Discarding an overly long or expensive route does not blocklist channels anymore.
2024-10-07 14:05:47 +02:00
Christian Decker
0a62416c4b pay: Inject channel_hints we receive via plugin notifications
Making sure that we don't accidentally create an endless loop.
2024-10-07 14:05:47 +02:00
Christian Decker
30d2a57f50 pay: Log when and why we exclude a channel from the route 2024-10-07 14:05:47 +02:00
Christian Decker
91ffa8e424 pay: Add channel_hint_set_count primitive 2024-10-07 14:05:47 +02:00
Christian Decker
30a2933a94 pay: Add a hysteresis for channel_hint relaxation
If we have a large channel, fail to send through a small amount, and
then add a `channel_hint`, then it can happen that the call to
`channel_hint_set_update` is already late enough that it refills the
1msat we removed from the attempted amount, thus making the edge we
just excluded eligible again, which can lead into an infinite loop.

We slow down the updating of the channel_hints to once every
hysteresis timeout. This allows us to set tight constraints, while not
incurring in the accidental relaxation issue.
2024-10-07 14:05:47 +02:00
Christian Decker
50a0321759 pay: Use the global channel_hint_set and remember across payments 2024-10-07 14:05:47 +02:00
Christian Decker
603a70e7e2 pytest: Test that we remember learnt channel hints across payments 2024-10-07 14:05:47 +02:00
Christian Decker
3ad0085478 route: Change the type of the funding capacity to amount_sat
Keeping it in `amount_msat` made the comparisons easier, but it was
the wrong type for this.
2024-10-07 14:05:47 +02:00
Christian Decker
f803af782a route: Use safe amount_sat_to_msat conversion
Suggested-by: Rusty Russell <@rustyrussell>
2024-10-07 14:05:47 +02:00
Christian Decker
904eb3795c pay: Subscribe to the channel_hint_update notifications 2024-10-07 14:05:47 +02:00
Christian Decker
29df2c9f40 route: Simplify direction 2024-10-07 14:05:47 +02:00
Christian Decker
cf09314b3b pay: Rename overall_capacity to just capacity
Suggested-by: Rusty Russell <@rustyrussell>
2024-10-07 14:05:47 +02:00
Christian Decker
37a204df41 plugin: Split out the struct channel_hint handling
We're getting serious about how we manage the channel_hints, so let's
give them a proper home.
2024-10-07 14:05:47 +02:00
Christian Decker
1144088e14 make: Weaken over aggressive check-amount-access test
Changelog-None
2024-10-07 14:05:47 +02:00
Christian Decker
b897b4365d pay: Make the channel_hints global
We attach the hints to the plugin, so they get shared across multiple
payments.
2024-10-07 14:05:47 +02:00
Christian Decker
5225218094 pay: Use the total_mast amount as the upper limit for channel_hints 2024-10-07 14:05:47 +02:00
Christian Decker
1eb878be82 route: Add the total capacity to route_hops
We need to know the overall channel capacity, i.e., the amount_msat
that the channel was funded with, in order to relax the channel_hint
to refill over time.
2024-10-07 14:05:47 +02:00
Christian Decker
d60db28c41 pay: Add a function to update channel_hints based on their age
We relax constraints from the `channel_hint` through a linear refill.
2024-10-07 14:05:47 +02:00
Jesse de Wit
538a0076ca topology: call listpeerchannels_done directly
When cln is run without deprecated apis, the `listchannels` call would
still query `listpeerchannels`, even though it wouldn't use the result.
This adds unnecessary time to the call. Especially in case the node has
many channels. This commit skips the listpeerchannels call in case the
outcome won't be used.

Changelog-Fixed: Improve listchannels performance
2024-10-04 17:51:55 +02:00
ShahanaFarooqui
81e30eab52 docs: Updating release checklist with Hotfix release instructions
Changelog-None.
2024-10-03 22:24:56 -07:00
Se7enZ
fea30491c3 doc: Include documentation for test targeting via PYTEST_TESTS.
Also update the table of optional environment variables to set when
running the integration tests.
2024-10-03 21:51:26 -07:00
Se7enZ
537d613035 pytest: Support targeting specific tests using make pytest.
Select tests by setting the `PYTEST_TESTS` environment variable.

Changelog-None
2024-10-03 21:51:26 -07:00
Se7enZ
cbe94bcb42 pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130])
Changelog-Fixed: pyln-testing: Fix file descriptor leak in bitcoind fixture. ([#7130])
2024-10-03 19:04:35 -07:00
Aditya Sharma
27b4a03419 tests: Add test_getemergencyrecoverdata to test the RPC getemergencyrecoverdata. 2024-10-03 18:59:10 -07:00
Aditya Sharma
2be7433ae6 doc: Add documentation for the RPC getemergencyrecoverdata. 2024-10-03 18:59:10 -07:00
Aditya Sharma
4c775f16aa plugins/chanbackup: Add RPC to fetch data from emergency.recover file. 2024-10-03 18:59:10 -07:00
Rusty Russell
b8acd3b37c askrene: more code tweaks on feedback from Lagrang3.
1. describe_disabled should point out if node itself is disabled.
2. Hoist constraint check for neater if branching.
3. Use amount_msat_max/min for greater clarity.
4. Simply disable channels, don't zero htlc_min/max when node disabled.

I also fixed the diagnostic of htlc_max correctly, which removes a FIXME.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
e3c9bc6d3a askrene: trivial changes to avoid -O3 compiler warnings.
The code is a bit too complex for gcc to track it:

```
In file included from ccan/ccan/tal/str/str.h:7,
                 from plugins/askrene/askrene.c:11:
plugins/askrene/askrene.c: In function ‘do_getroutes’:
ccan/ccan/tal/tal.h:324:23: error: ‘routes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  324 | #define tal_count(p) (tal_bytelen(p) / sizeof(*p))
      |                       ^~~~~~~~~~~
plugins/askrene/askrene.c:476:24: note: ‘routes’ was declared here
  476 |         struct route **routes;
      |                        ^~~~~~
plugins/askrene/askrene.c:475:29: error: ‘amounts’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  475 |         struct amount_msat *amounts;
      |                             ^~~~~~~
plugins/askrene/askrene.c:488:69: error: ‘probability’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  488 |         json_add_u64(response, "probability_ppm", (u64)(probability * 1000000));
      |                                                        ~~~~~~~~~~~~~^~~~~~~~~~
cc plugins/askrene/dijkstra.c
cc1: all warnings being treated as errors
```

On my local machine, it also warns in param_dev_channel, so I fixed that too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
630ec6a566 askrene: give better feedback when we can't find a suitable route.
This turns out to be critical for users: also stops them from
bothering us when their node is offline or has insufficient capacity!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
e54c0f8ded askrene: don't replace constraints, simply accumulate.
Lagrang3 points out it's less useful (when we time them out), and probably
a premature optimization anyway.

Suggested-by: Lagrang3 <lagrang3@protonmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
c307b77d2f askrene: split askrene-create-channel into create-channel and update-channel.
This allows for explicit partial updates to channels (e.g. just change
fees, or just disable) without haveing to set the other fields.

This generalizes askrene-disable-channel, which is removed.

We also take the chance to use the proper BOLT 7 terms in the API:

- htlc_minimum_msat
- htlc_maximum_msat
- cltv_expiry_delta
- fee_base_msat
- fee_proportional_millionths

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
5052f0763f gossmap: keep capacity for locally-generated channels as well.
It was weird not to have a capacity associated with localmods channels, and
fixing it has some very nice side effects.

Now the gossmap_chan_get_capacity() call never fails (we prevented reading
of channels from gossmap in the partially-written case already), so we
make it return the capacity.  We do this in msat, because that's what
all the callers want.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
a60063e763 common/gossmods_listpeerchannels: include channel capacity in callback.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
a65e325b13 gossmap: implement partial updates.
This is actually what we want in several places: to only override one or
two fields in a channel_update.

We add a gossmap_local_setchan() with a similar API to the old
gossmap_local_updatechan(), for the case where we want to set every
field.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
bb3663c4a0 askrene: ignore disabled channels for min-cost-flow.
We also set htlc_max to 0 when disabling, so the tests worked, but
this is correct.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
154ad585ec pytest: enhance test_getroutes_auto_sourcefree with same case *without* auto.sourcefree.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
3253623785 gossmods_from_listpeerchannels: use correct type for cltv_delta.
Doesn't matter now, but will with the next change where we want to
pass a pointer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
fcc0d2bad8 askrene: remove unused parameter in layer_add_localmods.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
321ec0875f askrene: rework constraints to exist in pairs.
This is a bit more efficient, but moreover the JSONRPC API is more
logical this way.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
3c5c22b17a askrene: change inform interface, take into account reserve.
Lagrang3 points out that if we hit a maximum, we should take into account
the reserve.  This is true, but it's hard for the caller to do, so change
the API to be slightly higher level.

Tell "inform" what happened, and it adjust the constraints appropriately.
This makes the least assumptions possible (a reserve does *not* mean that
the capacity was actually used at that time).

We also add a mode to say "this succeeded": for now this does nothing,
but it could reduce both min/max capacities, and add capacity in the
other direction.  This is useful for future payments, but not as useful
for the current one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
d50838b60f askrene: implement listreservations
And actually write tests!

Suggested-by: Lagrang3 <lagrang3@protonmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
0398d2ff73 askrene: remember individual reservations, for better debugging.
Suggested-by: Lagrang3 <lagrang3@protonmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
10dc40a895 askrene: clean up reserve array handling.
I got confused, as we had a struct containing two arrays.  Simply expose the
reserve_hop struct and use arrays directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
2df53c32c2 askrene: make route_query contain pointer to the command.
This is important for errors and feedback.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
b88f4cb854 askrene: askrene-create-layer and askrene-remove-layer.
It's generally better to be explicit with these things: currently typos
would be ignored.  But it's also much easier to clean up entire layers
as we use them for temporary (per-payment) effects.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Rusty Russell
29cc227a53 askrene: use short_channel_id_dir in API.
It's generally much more convenient, and it's already present in
other APIs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30
Lagrang3
33404b03a0 add askrene-disable-channel
Changelog-EXPERIMENTAL: askrene: add askrene-disable-channel RPC
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2024-10-04 11:27:53 +09:30
Rusty Russell
f46219b505 common: round out the short_channel_id_dir JSON routines.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-04 11:27:53 +09:30