From 3190c26bc9003b250f466fd2d261b9fee4a4935b Mon Sep 17 00:00:00 2001 From: niftynei Date: Tue, 31 Oct 2023 18:01:54 -0500 Subject: [PATCH] dualfund: error on out of order sigs We weren't blocking if the tx-sigs arrived before the commitment sigs. This was causing problems in the openchannel (spender plugin) spenderp: FATAL SIGNAL 11 (version v23.08.1-404-g62ff475-modded) 0x559836dc98ba send_backtrace common/daemon.c:33 0x559836dc9951 crashdump common/daemon.c:75 0x7f37f42c351f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x7f37f441ac92 ??? ../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:83 0x559836db7760 bitcoin_txid_eq ./bitcoin/tx.h:29 0x559836db7760 collect_sigs plugins/spender/openchannel.c:509 0x559836db81de check_sigs_ready plugins/spender/openchannel.c:531 0x559836db84dd json_peer_sigs plugins/spender/openchannel.c:611 0x559836dbcad7 ld_command_handle plugins/libplugin.c:1611 0x559836dbcd9d ld_read_json_one plugins/libplugin.c:1721 0x559836dbce29 ld_read_json plugins/libplugin.c:1741 0x559836ef3bff next_plan ccan/ccan/io/io.c:59 0x559836ef40da do_plan ccan/ccan/io/io.c:407 0x559836ef4177 io_ready ccan/ccan/io/io.c:417 0x559836ef5b14 io_loop ccan/ccan/io/poll.c:453 0x559836dbd48d plugin_main plugins/libplugin.c:1948 0x559836db22bf main plugins/spender/main.c:35 0x7f37f42aad8f __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x7f37f42aae3f __libc_start_main_impl ../csu/libc-start.c:392 0x559836da3774 ??? ???:0 0xffffffffffffffff ??? ???:0 2023-10-31T15:15:57.458Z INFO plugin-spenderp: Killing plugin: exited during normal operation 2023-10-31T15:15:57.458Z **BROKEN** plugin-spenderp: Plugin marked as important, shutting down lightningd! 2023-10-31T15:15:57.458Z DEBUG lightningd: io_break: lightningd_exit 2023-10-31T15:15:57.458Z DEBUG lightningd: io_loop_with_timers: main 2023-10-31T15:15:57.458Z DEBUG connectd: REPLY WIRE_CONNECTD_START_SHUTDOWN_REPLY with 0 fds 2023-10-31T15:15:57.458Z DEBUG lightningd: io_break: connectd_start_shutdown_reply 2023-10-31T15:15:57.458Z DEBUG 021ccce7bc396996c8f3b7bfeb1e30c6600269517026a74adfe2217b7187879797-dualopend-chan#1: Status closed, but not exited. Killing 2023-10-31T15:15:57.458Z DEBUG lightningd: Command returned result after jcon close 2023-10-31T15:15:57.458Z INFO 021ccce7bc396996c8f3b7bfeb1e30c6600269517026a74adfe2217b7187879797-chan#1: Unsaved peer failed. Deleting channel. 2023-10-31T15:15:57.464Z DEBUG lightningd: io_break: destroy_plugin 2023-10-31T15:15:57.464Z DEBUG connectd: Shutting down 2023-10-31T15:15:57.464Z DEBUG gossipd: Shutting down 2023-10-31T15:15:57.464Z DEBUG hsmd: Shutting down Reported-By: @t-bast --- openingd/dualopend.c | 6 ++++++ tests/test_opening.py | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 5a2311874743..b26b8544b2c6 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -1252,6 +1252,7 @@ static char *do_commit_signed_received(const tal_t *ctx, tx_state->psbt)); } + tx_state->has_commitments = true; return NULL; } @@ -1345,6 +1346,11 @@ static void handle_tx_sigs(struct state *state, const u8 *msg) struct bitcoin_txid, &tx_state->funding.txid)); + if (!tx_state->has_commitments) + open_err_fatal(state, + "tx_signatures sent before commitment sigs %s", + tal_hex(msg, msg)); + /* We put the PSBT + sigs all together */ for (size_t i = 0, j = 0; i < tx_state->psbt->num_inputs; i++) { struct wally_psbt_input *in = diff --git a/tests/test_opening.py b/tests/test_opening.py index d35782020172..25ff00fd1eb7 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -217,7 +217,6 @@ def test_v2_open_sigs_reconnect_1(node_factory, bitcoind): @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') -@pytest.mark.xfail @pytest.mark.openchannel('v2') def test_v2_open_sigs_out_of_order(node_factory, bitcoind): """ Test what happens if the tx-sigs get sent "before" commitment signed """