Commit Graph

14518 Commits

Author SHA1 Message Date
Alex Myers
47c81995e3 reckless: initialize repos with submodules and other cleanup 2024-02-21 14:33:11 +01:00
Alex Myers
61bbd70bc7 reckless: reduce github API calls
Github API calls are now ratelimited to 60 per hour.  Searching through
the subdirectory contents of lightningd/plugins will hit this limit after
two searches or installs.  The simple answer is to look for the directory
rather than verifying a valid entrypoint in a suitably-named directory
prior to cloning the repository.

Also corrects a bug that was flagging submodules as files while
populating directory contents.
2024-02-21 14:33:11 +01:00
Jon Griffiths
6fffba0746 tx_parts: use wally to clone tx inputs
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-02-21 12:01:33 +01:00
Christian Decker
a3d7f05b52 gh: Recude parallelism of Pre-flight checks' 2024-02-21 11:59:41 +01:00
Christian Decker
6e980c45eb make: The protobuf files are a grouped target 2024-02-21 11:59:41 +01:00
Christian Decker
d185b0fa90 core: Defer extracting the script until we're sure we'll use it
We were extracting the output script for all outputs, and discarding
them immediately again if they were not P2WSH outputs which are the
ones of interest to us. This patch move the extraction until after we
have determined it is useful, and so we should save a couple thousand
`tal()` and `tal_free()` calls.

Changelog-Changed: lightningd: Speed up blocksync by not parsing unused parts of the transactions
2024-02-21 11:59:31 +01:00
Christian Decker
c329756723 core: Add a function check if a script is P2WSH without allocating
Processing blocks is rather slow at the moment, but one thing we can
do, is to prevent copying all output scripts, when really all we are
interested in are the couple of outputs that are P2WSH.

This builds the foundation of that by adding a method to introspect
the script without having to clone it first, saving us some
allocations, and deallocations.

Changelog-Changed: core: Processing blocks should now be faster
2024-02-21 11:59:31 +01:00
Christian Decker
052542ea28 pytest: Stabilize the test_recover_plugin test 2024-02-20 17:59:06 +01:00
Rusty Russell
e2aa4f1a6d libwally: upgrade to latest master, fixes testnet block with huge tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-20 12:31:31 +01:00
Warren Togami
897ed22f67 channeld: Splice resume check should log to DEBUG
You otherwise get thousands of these zero count Splice resume checks
spamming your logs while most of the time it is only informing you
of "nothing is happening".

Reduces log noise.

Signed-off-by: Warren Togami <wtogami@gmail.com>
2024-02-20 12:41:41 +10:30
Aditya Sharma
cdb0001ce6 tests/test_misc.py: Add test_recover_plugin to check if the funds are being recovered when we lose some state and enter recover mode. 2024-02-16 22:17:46 +01:00
Aditya Sharma
e3b4ed416c plugins/recover: Load gossmap, connect to old peers and fetch peer_storage and then call restorefrompeer repeatedly. 2024-02-16 22:17:46 +01:00
Aditya Sharma
7afdea363d plugins/recover: entering_recovering_mode should connect to most connected nodes on the network and call emergency_recover immediately. 2024-02-16 22:17:46 +01:00
Aditya Sharma
9c1f2b312c plugins/recover: Initialise process to detect lost state through listpeerchannels. 2024-02-16 22:17:46 +01:00
Aditya Sharma
4031bafc87 Plugins: Add recover plugin which'd identify if we've lost some state and try to recover the node by entering mode. 2024-02-16 22:17:46 +01:00
Aditya Sharma
9acc1d7db6 peer_control: Add lost_state param inside listpeerchannels rpc, which'd help us identify if we've fall behind or lost some state. 2024-02-16 22:17:46 +01:00
Erik De Smedt
7827a26685 Docfix: connec-notification
The previous example was updated.
2024-02-16 17:54:31 +01:00
Rusty Russell
1018b5449b gossipd: handle case where block closes multiple channels requiring node_announcement moves more than once.
If we delete it the first time a channel before it is closed, we will
crash when we try to move it again:

```
$ lightning_gossipd: gossip_store: get delete entry offset 47411992/51608943 (version v23.11-378-gac2a386-modded)
0x1002544b send_backtrace
        common/daemon.c:33
0x1003415f status_failed
        common/status.c:221
0x10016ef3 gossip_store_get_with_hdr
        gossipd/gossip_store.c:466
0x10016faf check_msg_type
        gossipd/gossip_store.c:491
0x1001722b gossip_store_set_flag
        gossipd/gossip_store.c:509
0x1001752b gossip_store_del
        gossipd/gossip_store.c:561
0x10017f5b remove_channel
        gossipd/gossmap_manage.c:299
0x100181cf kill_spent_channel
        gossipd/gossmap_manage.c:1144
0x1001a7df gossmap_manage_new_block
        gossipd/gossmap_manage.c:1183
0x10014673 new_blockheight
        gossipd/gossipd.c:483
0x10014d73 recv_req
        gossipd/gossipd.c:594
```

Reported-by: @microsatosi on Discord
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 16:02:46 +01:00
Rusty Russell
8d7a99b589 gossipd: don't try to delete node_announcement twice if it's the same node.
Theoretical problem, but still...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 16:02:46 +01:00
jrakibi
1fdc018b74 Fix incorrect hex value for Signet port 2024-02-16 15:54:29 +01:00
Rusty Russell
4c5c53cac7 lightningd: add --dev-allow-shutdown-destination-change to unstick existing nodes.
This will solve the problem for users who already hit the bug fixed by
the previous patch!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Rusty Russell
eb6e6bd373 lightningd: clean up close logic, fix bug where we can't override destination.
Watchtowers changed the code so that we *always* have a channel->shutdown_scriptpubkey[LOCAL]
(see new_channel()).  The previous code had several problems:

1. It tested this for NULL, unnecessarily.
2. It allowed overriding if it was a default, *even* if we were already using it.
3. If the peer opened without option_shutdown_anysegwit, but upgraded before we closed,
   we would not recognize the default.
4. It set the final scriptpubkey (and other things!) even if the command failed.

Changelog-Fixed: JSON-RPC: `close` with `destination` works even if prior `destination` was rejected.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Rusty Russell
df44431f8c common: add tal_arr_eq helper.
We do `memeq(a, tal_bytelen(a), b, tal_bytelen(b))` remarkably often...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Rusty Russell
b6cc0ce425 lightningd: reindent closing_control.c
Tabs vs spaces, it's weird.  No code changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Rusty Russell
c02a278669 pytest: add test for issue #7014
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Lagrang3
c916066f85 renepay: update the gossmap after addgossip
Whenever there is a payment failure that requires gossip update, for
example changing the fee rates of remote channels, we call addgossip.
For renepay to consider this changes in the coming payment attempts, it
must update gossmap.
2024-02-16 14:51:14 +01:00
Lagrang3
e39e712eed autoformat test_renepay.py 2024-02-16 14:51:14 +01:00
Lagrang3
7e0d6d396e renepay bug fix: list previous sendpays
- previous pending sendpays must add up so that the plugin tries to pay
the rest of the amount,
- avoid groupid, partid collisions,
- add shadow fees if the option is set and the payment amount - total
  delivering = 0
- add a test,
- also fix a buggy shadow routing test
2024-02-16 14:51:14 +01:00
Rusty Russell
23460eb89d lightnignd: Fix another assert crash.
If we accept a channel_update in state "NEED_SIGS" we should not set
refresh timer: we're simply holding it for the moment we get to that state
(which will happen as we mine the block).

```
0x7fd1cce39205 __assert_fail
	./assert/assert.c:101
0x55c103cc6ee9 check_channel_gossip
	lightningd/channel_gossip.c:128
0x55c103cc8a13 channel_gossip_update_from_gossipd
	lightningd/channel_gossip.c:821
0x55c103cd752d handle_init_cupdate
	lightningd/gossip_control.c:138
0x55c103cd79a3 gossip_msg
	lightningd/gossip_control.c:190
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 14:07:22 +01:00
Rusty Russell
c755dfdfc9 connectd: fix bad assert.
This code was trying to check that the address type is not one of the ADDR_TYPE_TOR*
types, but the is_toraddr() function checks a domain name!  The cast should have been
a clue that this was wrong!

Anyway, wireaddr_to_addrinfo() aborts on these cases already, so the asserts here are
superfluous.

Found in unrelated CI run:

```
Valgrind error file: valgrind-errors.20610
==20610== Conditional jump or move depends on uninitialised value(s)
==20610==    at 0x484ED28: strlen (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==20610==    by 0x138FA3: is_toraddr (wireaddr.c:344)
==20610==    by 0x11499B: conn_init (connectd.c:729)
==20610==    by 0x28FD73: next_plan (io.c:59)
==20610==    by 0x28FF94: io_new_conn_ (io.c:116)
==20610==    by 0x11531B: try_connect_one_addr (connectd.c:927)
==20610==    by 0x1182A8: try_connect_peer (connectd.c:1781)
==20610==    by 0x11834E: connect_to_peer (connectd.c:1797)
==20610==    by 0x119241: recv_req (connectd.c:2074)
==20610==    by 0x12836F: handle_read (daemon_conn.c:35)
==20610==    by 0x28FD73: next_plan (io.c:59)
==20610==    by 0x2909A8: do_plan (io.c:407)
==20610==
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-15 12:07:47 +01:00
Rusty Russell
d716e6db73 lightningd: don't force state if gossipd gives us an unexpected channel_update.
This was triggered by the recover plugin tests (not yet merged!) and causes a crash
because we don't have signatures yet.  It can only happen if we lost our database,
but at least don't crash!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-14 13:19:21 +10:30
Yaacov Akiba Slama
a81c1c51f6 Add no-reconnect-private option to disable automatic reconnect-attempts
to peers connected to our node with private channels only
2024-02-13 17:50:00 +01:00
Christian Decker
abfe55e214 pyetst: Fix up a test checking fees after fee calc change 2024-02-13 15:47:48 +01:00
Rusty Russell
f9d02b6486 channeld: fix update_fee cap.
We would sometimes propose fees which we couldn't afford, and thus the
peer would get upset: if we didn't recover it could cause force closes.

This was because we didn't take into account that pending htlcs will
remove our total available funds.

Changelog-Fixes: Protocol: Don't upset peers by sending `update_fee` with fees we cannot afford in the case where HTLCs are large.
2024-02-13 15:47:48 +01:00
Rusty Russell
1350194698 gossipd: don't assert on redundant flag write, just log message.
This happens to Vincenzo, and I think it's due to previous gossip_store issues.

Fixes: https://github.com/ElementsProject/lightning/issues/7051
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 18:05:06 +01:00
Rusty Russell
e7f1f29dbd connectd: don't suppress channel_announcement without channel_update yet.
This happens if:
1. The peer sets a timestamp filter to non-zero, and
2. We have a channel_announcement without a channel_update.

The timestamp is 0 as a placeholder as part of the recent gossip rework
(we used to hold these channel_announcement in memory, which was complex).

But this means we won't send it in this case, and if we later send the
channel_update, CI will complain about 'Bad gossip order'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
a0ed61199a gossipd: make sure to mark node_announcement dying if we fast-path remove last channel.
Normally, channels are marked dying, the 12 blocks later, removed.
But for local channels, we can access any spliced channel already, so
we remove them immediately from our local gossip.  This left a hole in
our logic, if that channel was the last one keeping a
node_announcement alive.

Solution is to unify with the "moved node_announcement" path.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
f57d1f460e gossipd: don't consider dying channels when seeking preceeding channel_announcements.
We make sure a node_announcement is preceeded by at least one channel_announcement,
but dying ones don't count (as they are not broadcast!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
e86093a944 gossipd: set dying flag on node_announcements when initially created.
We accept node_announcements on dying channels, but make sure we
set the dying flag it channels are alll dying.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
b3439a18fe gossipd: preserve the dying flag when moving node_announcement.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
365bf2d84d gossipd: when applying a new channel_update, preserve the dying flag.
We can update dying channels, though it seems weird!  We accept gossip about them,
we just don't propagate it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
aab283ca7e gossipd: make sure to unmark dying node_announcement if we see a new channel!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
450d78ad67 gossipd: set dying flag on node_announcement when all channels are dying.
This avoids us gossiping about nodes which don't have live channels.

Interstingly, we previously tested that we *did* gossip such node
announcements, and now we fix that test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
ca5b7b00b6 gossipd: clean up flags accessors.
We want to be able to clear them, and fetch them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
5135658805 common: add gossmap_chan_is_dying() helper to check flags.
And fix up gossip_store backwards comment!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
27ef4b98c1 devtools: remove warning message from dump-gossipstore.
It prints a message to stderr, but actually it's fine with this version:

```
dump-gossipstore: UNKNOWN GOSSIP minor VERSION 14 (expected 12)
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
Rusty Russell
6ed17e9e0c pyln-testing: dump gossip store when we complain about bad gossip.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
shuoer86
6c04a6c15a doc: fix typos 2024-02-11 11:27:41 +01:00
Christian Decker
89c7cad4b8 fixup! dual-fund: add require_confirmed_inputs to RBF flows 2024-02-11 10:46:40 +01:00
niftynei
bc98cafe9e dual-fund: add require_confirmed_inputs to RBF flows
We now require peers to reaffirm their preference for
`require_confirmed_inputs` when executing an RBF.

Requested-By: @t-bast
2024-02-11 10:46:40 +01:00