Commit Graph

9775 Commits

Author SHA1 Message Date
Rusty Russell 8714bf903c subd: send versions at startup.
For channeld, we move status_setup_sync() to a more obvious place.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-24 13:56:58 +09:30
Rusty Russell b36e9fe473 status: new message for subdaemons to tell us their versions.
For this patch we simply abort if it's wrong.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-24 13:56:58 +09:30
Rusty Russell a8fde9f11f CI: make sure we do a fuzzing build.
Suggested-by: Christian Reitter.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-21 06:51:03 +09:30
Rusty Russell 4e2410742a tests/fuzz: update for fmt_amount changes, create pseudorand for fuzzing.
Reported-by: Christian Reitter
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-21 06:51:03 +09:30
niftynei b366453c6a dual-funding: rework how funding feerates are passed around
Cleans up some duplication/unnecessary re-assignment of the feerate.
Left over from when the feerates used to be min/max/best in
open_channel2.
2021-04-16 15:33:44 +09:30
niftynei 0ae2b0c33d dual-funding: bugfix, swapped commitment/funding feerates
Found via a protocol test, huzzah. And also whoops.
2021-04-16 15:33:44 +09:30
niftynei d5bf6bb994 dual-fund: on witness failure, route through dualopend
We want to notify the peer that we've failed and why, as a courtesy.
2021-04-16 15:33:44 +09:30
niftynei ff164cf8b3 psbt: temporarily patch over failure to parse the empty tx
libwally has a bug which results in it failing to parse the 'empty tx'
cHNidP8BAAoAAAAAAAAAAAAAAA==. While we wait for the patch to land in
libwally, we patch over it.

Fix at: https://github.com/ElementsProject/libwally-core/pull/273
2021-04-16 15:33:44 +09:30
niftynei a948cf5c10 closingd: handle custommessages
We fail on odd messages in otherwise.

--------------------------------------------------------- Captured stderr call ----------------------------------------------------------
lightning_closingd: common/read_peer_msg.c:170: handle_peer_gossip_or_error: Assertion `!is_unknown_msg_discardable(msg)' failed.
lightning_closingd: FATAL SIGNAL 6 (version v0.10.0-3-gd0c30a4)
0x563b8eabd9a2 send_backtrace
        common/daemon.c:39
0x563b8eabda4c crashdump
        common/daemon.c:52
0x7f496292020f ???
        ???:0
0x7f496292018b ???
        ???:0
0x7f49628ff858 ???
        ???:0
0x7f49628ff728 ???
        ???:0
0x7f4962910f35 ???
        ???:0
0x563b8eaca7e3 handle_peer_gossip_or_error
        common/read_peer_msg.c:170
0x563b8eab79f2 closing_read_peer_msg
        closingd/closingd.c:116
0x563b8eab838a receive_offer
        closingd/closingd.c:362
0x563b8eab9299 main
        closingd/closingd.c:752
0x7f49629010b2 ???
        ???:0
0x563b8eab75dd ???
        ???:0
0xffffffffffffffff ???
        ???:0
lightning_closingd: FATAL SIGNAL (version v0.10.0-3-gd0c30a4)
0x563b8eabd9a2 send_backtrace
        common/daemon.c:39
0x563b8eacb384 status_failed
        common/status.c:207
0x563b8eacb5f0 status_backtrace_exit
        common/subdaemon.c:25
0x563b8eabda55 crashdump
        common/daemon.c:55
0x7f496292020f ???
        ???:0
0x7f496292018b ???
        ???:0
0x7f49628ff858 ???
        ???:0
0x7f49628ff728 ???
        ???:0
0x7f4962910f35 ???
        ???:0
0x563b8eaca7e3 handle_peer_gossip_or_error
        common/read_peer_msg.c:170
0x563b8eab79f2 closing_read_peer_msg
        closingd/closingd.c:116
0x563b8eab838a receive_offer
        closingd/closingd.c:362
0x563b8eab9299 main
        closingd/closingd.c:752
0x7f49629010b2 ???
        ???:0
0x563b8eab75dd ???
        ???:0
0xffffffffffffffff ???
        ???:0
2021-04-16 15:33:44 +09:30
niftynei 9c8ce925ef dual-fund: update state before checking for 'doneness'
If we only add a single input/output for the funding transaction,
 we'll only call openchannel_update once, which results in
a crash because the dest->state will never advance to
MULTIFUNDCHANNEL_UPDATED;

Instead, we update to UPDATED before we check for doneness.
2021-04-16 15:33:44 +09:30
Rusty Russell ade10e7fc4 peer_control: fix leak false positive.
We generally hang things off our JSON response (this pattern predates
tmpctx!) but sometimes it gets reported as a memleak.  I'd prefer not
to mark JSON responses as "notleak", since they can be allocated for
a while), so use tmpctx here.

```
E           ValueError:
E           Node errors:
E           Global errors:
E            - Node /tmp/ltests-spnausnb/test_htlc_out_timeout_1/lightning-1/ has memory leaks: [
E               {
E                   "backtrace": [
E                       "ccan/ccan/tal/tal.c:442 (tal_alloc_)",
E                       "ccan/ccan/tal/tal.c:471 (tal_alloc_arr_)",
E                       "wallet/wallet.c:1775 (wallet_state_change_get)",
E                       "lightningd/peer_control.c:922 (json_add_channel)",
E                       "lightningd/peer_control.c:1424 (json_add_peer)",
E                       "lightningd/peer_control.c:1454 (json_listpeers)",
E                       "lightningd/jsonrpc.c:643 (command_exec)",
E                       "lightningd/jsonrpc.c:767 (rpc_command_hook_final)",
E                       "lightningd/plugin_hook.c:275 (plugin_hook_call_)",
E                       "lightningd/jsonrpc.c:855 (plugin_hook_call_rpc_command)",
E                       "lightningd/jsonrpc.c:942 (parse_request)",
E                       "lightningd/jsonrpc.c:1033 (read_json)",
E                       "ccan/ccan/io/io.c:59 (next_plan)",
E                       "ccan/ccan/io/io.c:435 (io_do_always)",
E                       "ccan/ccan/io/poll.c:300 (handle_always)",
E                       "ccan/ccan/io/poll.c:377 (io_loop)",
E                       "lightningd/io_loop_with_timers.c:24 (io_loop_with_timers)",
E                       "lightningd/lightningd.c:1097 (main)"
E                   ],
E                   "label": "wallet/wallet.c:1775:struct state_change_entry[]",
E                   "parents": [
E                       "common/json_stream.c:29:struct json_stream",
E                       "ccan/ccan/io/io.c:91:struct io_conn",
E                       "lightningd/lightningd.c:116:struct lightningd"
E                   ],
E                   "value": "0x55c6b02150b8"
E               }
E           ]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-12 23:03:47 +02:00
Rusty Russell 8cef2c17ad pytest: fix flake in test_v2_open_sigs_restart_while_dead
We didn't wait for the sendtx to complete before shutting down,
and hence timed out:

```
        l2.daemon.wait_for_log('Broadcasting funding tx')

        l1.stop()
        l2.stop()
        bitcoind.generate_block(6)
        l1.restart()
        l2.restart()

        # Make sure we're ok.
>       l2.daemon.wait_for_log(r'to CHANNELD_NORMAL')
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-12 23:03:47 +02:00
Rusty Russell 402f7f90c0 pytest: handle case where funding tx is not tx #1.
e.g. in test_closing_id we can get a spend from the first (closed) channel
in the same block as the open of the second.  Half the time, we'll choose
the wrong one as scid.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-12 23:03:47 +02:00
Rusty Russell c0a40b37a7 pytest: fix flake in test_pay_disconnect
Channel can be inactive before it disconnects, apparently.  Check
explicitly for the disconnected state so we get the expected error.

Here's what happened:
```
        # Can't pay while its offline.
        with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_CHANNEL_FAILURE \(First peer not ready\)'):
>           l1.rpc.sendpay(route, rhash)
E           Failed: DID NOT RAISE <class 'pyln.client.lightning.RpcError'>
```

And the logs show that the outgoing HTLC was sent to channeld before it
realized the connection was closed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-12 23:03:47 +02:00
Rusty Russell e684f87ef7 pytest: fix spurious failure in test_local_basepoints_cache.
Change the address in the canned db: it seems we won the lottery and
l1 connected, and got an error!

```
 E           ValueError:
 E           Node errors:
 E            - lightningd-1: had warning messages
 E           Global errors:
...
 lightningd-1: 2021-04-07T02:44:53.579Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-channeld-chan#1: peer_out WIRE_CHANNEL_REESTABLISH
 lightningd-1: 2021-04-07T02:44:53.579Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-channeld-chan#1: peer_in WIRE_GOSSIP_TIMESTAMP_FILTER
 lightningd-1: 2021-04-07T02:44:53.580Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-channeld-chan#1: peer_in WIRE_ERROR
 lightningd-1: 2021-04-07T02:44:53.580Z INFO    022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: Peer transient failure in CHANNELD_NORMAL: channeld WARNING: error channel fdeb1ea12e02aa043f66ba581e969a1882d21142b19429995c6733bb71070bb6: Multiple channels unsupported
 lightningd-1: 2021-04-07T02:44:53.580Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: Will try reconnect in 60 seconds
```

So I changed the port in the db to "1" which will never succeed:

```
sqlite> .dump peers
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE peers (  id INTEGER, node_id BLOB UNIQUE, address TEXT, PRIMARY KEY (id));
INSERT INTO peers VALUES(1,X'022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59','127.0.0.1:38723');
COMMIT;
sqlite> UPDATE peers SET address="127.0.0.1:1"
   ...> ;
sqlite> .dump peers
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE peers (  id INTEGER, node_id BLOB UNIQUE, address TEXT, PRIMARY KEY (id));
INSERT INTO peers VALUES(1,X'022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59','127.0.0.1:1');
COMMIT;
sqlite>
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-12 23:03:47 +02:00
niftynei bbfcae652c lnprototests: update to latest, which adds wait for test_query_channel_range
test_query_channel_range is racy, add some wait time to reduce
chances of a race-failure
2021-04-08 10:34:14 +09:30
niftynei 44b79f48d8 ci: turn on proto-tests for the CI builds
Add an extra run configuration for the proto-tests.

Proto-tests require DEVELOPER=1; enabling EXPERIMENTAL_FEATURES=1
by default ensures that experimental additions are automatically put
under test also.
2021-04-08 10:34:14 +09:30
Christian Decker 8e0d0c3e7b pyln: Pin mypy to version 0.790 since later has import path issues 2021-04-08 10:34:14 +09:30
Christian Decker 74b4f95552 gci: Remove already included requirements.txt files
These are being pulled in via the root requirements.txt file now, so
no need to install them separately.
2021-04-08 10:34:14 +09:30
Christian Decker 0dd57cbf3c pyln-spec: Clean up the setup.py files
This centralizes the setup.py file, and parametrizes it so it can
auto-detect which bolt we are building. It also uses trick 3 from [1]
to avoid importing the package itself during the manifest creation,
which'd cause an import error due to missing dependencies.

[1] https://packaging.python.org/guides/single-sourcing-package-version/
2021-04-08 10:34:14 +09:30
Christian Decker 6b0a7b173c pyln: Change the setup.py file not to import the package
This would lead to errors about missing dependencies when attempting
to install using `pyhon setup.py install`. This is because the
`setup.py` file effectively is the manifest file used to discover
which dependencies are needed, so when using it to detect dependencies
we obviously don't have them yet.

See https://packaging.python.org/guides/single-sourcing-package-version/
2021-04-08 10:34:14 +09:30
Christian Decker 1bebdfdd5f make: Setup the PYTHONPATH to include the pyln-spec packages
They are currently not installable due to circular dependencies and
stuff, so we just add their source to the path and lnprototest will
pick them up from there.
2021-04-08 10:34:14 +09:30
Christian Decker 0f217d32fa python: Use relative URLs for pyln-{client,proto,testing}
This allows to not have to worry about the source of the installation,
and we always use our in-tree version. It also means we pull in the
requirements.txt files through the setup.py and don't need to
replicate them.
2021-04-08 10:34:14 +09:30
niftynei d2477721b9 make: add lnprototests to check!!
We've got great protocolo levle tests written, let's make sure we
put them to good use!
2021-04-08 10:34:14 +09:30
niftynei 51c398b4c3 gossip: allow us to only look at 1 block
Breaks a lnprototest otherwise!
2021-04-08 10:34:14 +09:30
niftynei e3ad60150d make: include lnprototest in pythonpath 2021-04-08 10:34:14 +09:30
niftynei 144dbe6edf tests: add submodule for lnprototests (points at branch right now)
Branch has fix for break in test_query_channel_range
2021-04-08 10:34:14 +09:30
Rusty Russell c4dfac5c4b plugins: remove now-unused single-hook infrastructure.
Should have really let @mschmook do this, as he did all the work to
make it possible!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Rusty Russell 9c3cf5aff9 newaddr: don't include "address" field.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: JSON-RPC: `newaddr` no longer includes `address` field (deprecated in 0.7.1)
2021-04-07 14:34:39 +09:30
Rusty Russell da4c2cab62 plugin: always send allow-deprecated-apis in getmanifest.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: plugins: we now always send `allow-deprecated-apis` in getmanifest.
2021-04-07 14:34:39 +09:30
Rusty Russell 107c7ec0e3 lightningd: remove unused `original_directory` field.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Rusty Russell 3d1c376f1d chaintopology: remove deprecated urgent/normal/slow feerate display.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Rusty Russell d211e1ff1c devtools: add experimental section.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Rusty Russell fad4aee5da pyln: remove deprecated fundchannel/fundchannel_start variants.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: pyln: removed deprecated fundchannel/fundchannel_start `satoshi` arg.
2021-04-07 14:34:39 +09:30
Rusty Russell 0ed614d5c4 pyln: remove deprecated pay/sendpay variants.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: pyln: removed deprecated pay/sendpay `description` arg.
2021-04-07 14:34:39 +09:30
Rusty Russell 10dee030f1 pyln: remove deprecated close variant.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: pyln: removed deprecated close `force` variant.
2021-04-07 14:34:39 +09:30
Rusty Russell 162ba9d162 close: activate notifications even with deprecated-apis.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `close` now always returns notifications on delays.
2021-04-07 14:34:39 +09:30
Rusty Russell 3c5ea7fd8e Makefile: make it easier to check bolt text.
Instead of "only check suffix quotes when EXPERIMENTAL_FEATURES", make
it so we only check suffix quotes if you override BOLTVERSION on the
cmdline.

Before this, "make check-source-bolt" was effectively a NOOP with
--enable-experimental-features.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Rusty Russell 9dbac21d3b doc: remove suffix for included-in-master BOLTs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Rusty Russell 3ccb6d6e7a Makefile: update to latest BOLT versions.
The main change which affects us is that 2016 blocks to forget a channel
is a fixed number in the spec; we make this clear by renaming the
(developer-only) max_funding_unconfirmed to dev_max_funding_unconfirmed
and making it compile DEVELOPER only.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-04-07 14:34:39 +09:30
Christian Decker c8dbcac38e pay: Use gossmap for reachability check 2021-04-06 11:03:47 +09:30
niftynei 5e289efdde wire: clean up patch revision files in clean
Make all the ....csv.* things disappear
2021-04-06 11:02:08 +09:30
Rusty Russell 5ffc516133 CHANGELOG.md: update for v0.10.0
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-31 15:34:56 +10:30
Rusty Russell 7fbf728a34 gossipd: assert we're not blatting the version header.
Suggested-by: whitslack
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-31 12:26:21 +10:30
Rusty Russell 7b853d0fa5 gossip_store: don't make bogus assumption that writes are atomic wrt readers.
They're not defined to be, though we've not seen this on Linux (testing
showed that it is page-level atomic, which means it can still happen across
page boundaries though!).  This was pointed out by whitslack in
https://github.com/ElementsProject/lightning/issues/4288

In practice, this just means not complaining when it happens, and also
not trying to get tricky to use it on MacOS (we can safely seek & write,
since we're single-threaded).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Removed bogus UNUSUAL log about gossip_store 'short test'.
2021-03-31 12:26:21 +10:30
niftynei cbde1f8158 pyln-proto: make an error message more detailed
Easier to figure out what's going wrong
2021-03-30 13:44:34 +10:30
niftynei 5142dc81f6 pyln-proto: write out length of arrays of subtypes to wire
We weren't writing out the length of a nested subtype's
dynamicarraylenght, now we do. The trick is to iterate through the
fields on a subtype (since the length field is added separately)
and to also iterate down through the otherfield values as we 'descend'
2021-03-30 13:44:34 +10:30
niftynei 6db6ba6c03 dual-funding: introduce racy state
It's unlikely but possible that a race condition will result in us not
being at the 'secured' state yet here.

Crashlogs. All required msgs are received (in order)
from peers, but the crash suggests they weren't relayed/processed by the
spender plugin in the order received.

WIRE_TX_SIGNATURES is passed the the plugin via a notification;
WIRE_COMMITMENT_SIGNED is returned as the result of an RPC call.

```
021-03-25T12:12:33.5213247Z lightningd-1: 2021-03-25T11:50:13.351Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#3: peer_in WIRE_COMMITMENT_SIGNED
2021-03-25T12:12:33.5221140Z lightningd-1: 2021-03-25T11:50:13.659Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-dualopend-chan#1: peer_in WIRE_COMMITMENT_SIGNED
2021-03-25T12:12:33.5228462Z lightningd-1: 2021-03-25T11:50:14.169Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-dualopend-chan#3: peer_in WIRE_TX_SIGNATURES
2021-03-25T12:12:33.5230957Z lightningd-1: 2021-03-25T11:50:14.375Z DEBUG   plugin-spenderp: mfc 275, dest 1: openchannel_update 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d returned.
2021-03-25T12:12:33.5233307Z lightningd-1: 2021-03-25T11:50:14.539Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-dualopend-chan#1: peer_in WIRE_TX_SIGNATURES
2021-03-25T12:12:33.5235120Z lightningd-1: 2021-03-25T11:50:17.240Z INFO    plugin-spenderp: Killing plugin: exited during normal operation
2021-03-25T12:12:33.5236707Z lightningd-1: 2021-03-25T11:50:17.260Z **BROKEN** plugin-spenderp: Plugin marked as important, shutting down lightningd!
```

Fixes #4455
2021-03-30 13:44:11 +10:30
Rusty Russell f891c7096b v0.10.0-rc2
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-28 14:14:54 +10:30
Rusty Russell 2dabe35c2c CHANGELOG.md: update for recent changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-28 14:14:54 +10:30