mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 23:06:44 +01:00
This test seems confused: l2 won't be able to reconnect to l1 (l1 connected to l2 in the first place, it's the only one which can reconnect). Also, there's a commitment_signed early on when we have dual funding, so this doesn't actually test splicing disconnect in that case? The race seems to happen when l1 reconnectd, and l2 hasn't registered the disconnect yet. ``` ________________________ test_splice_disconnect_commit _________________________ [gw9] linux -- Python 3.10.16 /home/runner/.cache/pypoetry/virtualenvs/cln-meta-project-AqJ9wMix-py3.10/bin/python node_factory = <pyln.testing.utils.NodeFactory object at 0x7f53ebc1a950> bitcoind = <pyln.testing.utils.BitcoinD object at 0x7f53ebc1b760> executor = <concurrent.futures.thread.ThreadPoolExecutor object at 0x7f53ebc1a170> @pytest.mark.openchannel('v1') @pytest.mark.openchannel('v2') @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') def test_splice_disconnect_commit(node_factory, bitcoind, executor): l1 = node_factory.get_node(options={'experimental-splicing': None}, may_reconnect=True) l2 = node_factory.get_node(disconnect=['+WIRE_COMMITMENT_SIGNED'], options={'experimental-splicing': None, 'dev-no-reconnect': None}, may_reconnect=True) > l1.openchannel(l2, 1000000) tests/test_splicing_disconnect.py:77: ... elif "error" in resp: > raise RpcError(method, payload, resp['error']) E pyln.client.lightning.RpcError: RPC call failed: method: fundchannel, payload: {'id': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'amount': 1000000, 'announce': True}, error: {'code': -1, 'message': 'Disconnected', 'data': {'id': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'method': 'openchannel_update'}} ``` From the logs: ``` 2025-01-23T23:50:25.4098040Z lightningd-2 2025-01-23T23:47:12.443Z DEBUG 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: dev_disconnect: +WIRE_COMMITMENT_SIGNED (WIRE_COMMITMENT_SIGNED) ... 2025-01-23T23:50:25.4107026Z lightningd-2 2025-01-23T23:47:12.444Z DEBUG 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-dualopend-chan#1: peer_out WIRE_COMMITMENT_SIGNED 2025-01-23T23:50:25.4108070Z lightningd-2 2025-01-23T23:47:12.444Z INFO 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-dualopend-chan#1: Peer connection lost 2025-01-23T23:50:25.4109375Z lightningd-2 2025-01-23T23:47:12.445Z INFO 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#1: Peer transient failure in DUALOPEND_OPEN_COMMIT_READY: dualopend: Owning subdaemon dualopend died (62208) ... 2025-01-23T23:50:25.4111195Z lightningd-2 2025-01-23T23:47:12.445Z DEBUG plugin-cln-grpc: Received a message: CustomNotification(Object {\"jsonrpc\": String(\"2.0\"), \"method\": String(\"channel_open_failed\"), \"params\": Object {\"channel_open_failed\": Object {\"channel_id\": String(\"252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7\")}}}) 2025-01-23T23:50:25.4113039Z lightningd-2 2025-01-23T23:47:12.445Z DEBUG plugin-cln-grpc: Dispatching custom notification Object {\"jsonrpc\": String(\"2.0\"), \"method\": String(\"channel_open_failed\"), \"params\": Object {\"channel_open_failed\": Object {\"channel_id\": String(\"252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7\")}}} 2025-01-23T23:50:25.4114525Z lightningd-2 2025-01-23T23:47:12.446Z DEBUG plugin-funder: Cleaning up inflights for peer id 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 2025-01-23T23:50:25.4115550Z lightningd-2 2025-01-23T23:47:12.446Z DEBUG plugin-funder: Cleaning up inflight for channel_id 252d1b0a1e57895e84137f28cf19ab2c35847e284c112fefdecc7afeaa5c1de7 2025-01-23T23:50:25.4116406Z lightningd-2 2025-01-23T23:47:12.446Z TRACE lightningd: Calling rpc_command hook of plugin cln-xpay 2025-01-23T23:50:25.4117134Z lightningd-2 2025-01-23T23:47:12.447Z TRACE lightningd: Plugin cln-xpay returned from rpc_command hook call 2025-01-23T23:50:25.4117728Z lightningd-1 2025-01-23T23:47:12.448Z DEBUG connectd: drain_peer 2025-01-23T23:50:25.4118229Z lightningd-1 2025-01-23T23:47:12.448Z DEBUG connectd: drain_peer draining subd! 2025-01-23T23:50:25.4119066Z lightningd-1 2025-01-23T23:47:12.448Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-lightningd: peer_disconnect_done 2025-01-23T23:50:25.4119792Z lightningd-1 2025-01-23T23:47:12.449Z DEBUG connectd: maybe_free_peer freeing peer! ... 2025-01-23T23:50:25.4135647Z lightningd-2 2025-01-23T23:47:12.455Z DEBUG 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Connect IN 2025-01-23T23:50:25.4136554Z lightningd-1 2025-01-23T23:47:12.455Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: Connected out, starting crypto 2025-01-23T23:50:25.4137502Z lightningd-1 2025-01-23T23:47:12.456Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: Connect OUT 2025-01-23T23:50:25.4138483Z lightningd-1 2025-01-23T23:47:12.456Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: peer_out WIRE_INIT 2025-01-23T23:50:25.4139407Z lightningd-1 2025-01-23T23:47:12.456Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: peer_in WIRE_INIT 2025-01-23T23:50:25.4140714Z lightningd-1 2025-01-23T23:47:12.456Z INFO 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: Peer transient failure in DUALOPEND_OPEN_COMMIT_READY: Disconnected ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
116 lines
4.3 KiB
Python
116 lines
4.3 KiB
Python
from fixtures import * # noqa: F401,F403
|
|
import pytest
|
|
import unittest
|
|
import time
|
|
from pyln.testing.utils import EXPERIMENTAL_DUAL_FUND
|
|
from utils import (
|
|
TEST_NETWORK
|
|
)
|
|
|
|
|
|
@pytest.mark.openchannel('v1')
|
|
@pytest.mark.openchannel('v2')
|
|
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
|
def test_splice_disconnect_sig(node_factory, bitcoind):
|
|
# Dual open and splicing both use tx_sig messages. If we have dual enabled, ignore the first one.
|
|
disconnect = ['-WIRE_TX_SIGNATURES']
|
|
if EXPERIMENTAL_DUAL_FUND:
|
|
disconnect = ['=WIRE_TX_SIGNATURES'] + disconnect
|
|
|
|
l1 = node_factory.get_node(disconnect=disconnect,
|
|
options={'experimental-splicing': None, 'dev-no-reconnect': None},
|
|
may_reconnect=True)
|
|
l2 = node_factory.get_node(options={'experimental-splicing': None}, may_reconnect=True)
|
|
l1.openchannel(l2, 1000000)
|
|
|
|
chan_id = l1.get_channel_id(l2)
|
|
|
|
# add extra sats to pay fee
|
|
funds_result = l1.rpc.fundpsbt("109000sat", "slow", 166, excess_as_change=True)
|
|
|
|
result = l1.rpc.splice_init(chan_id, 100000, funds_result['psbt'])
|
|
result = l1.rpc.splice_update(chan_id, result['psbt'])
|
|
assert(result['commitments_secured'] is False)
|
|
result = l1.rpc.splice_update(chan_id, result['psbt'])
|
|
assert(result['commitments_secured'] is True)
|
|
result = l1.rpc.signpsbt(result['psbt'])
|
|
result = l1.rpc.splice_signed(chan_id, result['signed_psbt'])
|
|
|
|
l1.daemon.wait_for_log(r'dev_disconnect: \-WIRE_TX_SIGNATURES')
|
|
time.sleep(.2)
|
|
|
|
print("Killing l1 without sending WIRE_TX_SIGNATURES")
|
|
l1.daemon.kill()
|
|
|
|
# Restart l1, without disconnect stuff.
|
|
del l1.daemon.opts['dev-no-reconnect']
|
|
del l1.daemon.opts['dev-disconnect']
|
|
|
|
# Should reconnect, and reestablish the splice.
|
|
l1.start()
|
|
|
|
# Wait until nodes are reconnected
|
|
l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
|
|
l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
|
|
|
|
bitcoind.generate_block(6, wait_for_mempool=1)
|
|
|
|
l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
|
|
l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
|
|
|
|
inv = l2.rpc.invoice(10**2, '3', 'no_3')
|
|
l1.rpc.pay(inv['bolt11'])
|
|
|
|
# Check that the splice doesn't generate a unilateral close transaction
|
|
time.sleep(5)
|
|
assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0
|
|
|
|
|
|
@pytest.mark.openchannel('v1')
|
|
@pytest.mark.openchannel('v2')
|
|
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
|
def test_splice_disconnect_commit(node_factory, bitcoind, executor):
|
|
l1 = node_factory.get_node(options={'experimental-splicing': None, 'dev-no-reconnect': None},
|
|
may_reconnect=True)
|
|
# Note: for dual-fund, there's a COMMITMENT_SIGNED for the initial tx, before splicing!
|
|
if EXPERIMENTAL_DUAL_FUND:
|
|
disconnects = ['+WIRE_COMMITMENT_SIGNED*2']
|
|
else:
|
|
disconnects = ['+WIRE_COMMITMENT_SIGNED']
|
|
l2 = node_factory.get_node(disconnect=disconnects,
|
|
options={'experimental-splicing': None, 'dev-no-reconnect': None},
|
|
may_reconnect=True)
|
|
l1.openchannel(l2, 1000000)
|
|
|
|
chan_id = l1.get_channel_id(l2)
|
|
|
|
# add extra sats to pay fee
|
|
funds_result = l1.rpc.fundpsbt("109000sat", "slow", 166, excess_as_change=True)
|
|
|
|
result = l1.rpc.splice_init(chan_id, 100000, funds_result['psbt'])
|
|
result = l1.rpc.splice_update(chan_id, result['psbt'])
|
|
assert(result['commitments_secured'] is False)
|
|
|
|
executor.submit(l1.rpc.splice_update, chan_id, result['psbt'])
|
|
|
|
print("l2 waiting for dev_disconnect msg")
|
|
|
|
l2.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
|
|
|
|
l1.daemon.kill()
|
|
|
|
# Restart l1, should reconnect
|
|
del l1.daemon.opts['dev-no-reconnect']
|
|
|
|
# Should reconnect, and reestablish the splice.
|
|
l1.start()
|
|
|
|
# Splice should be abandoned via tx_abort
|
|
|
|
# Wait until nodes are reconnected
|
|
l1.daemon.wait_for_log(r'billboard: Channel ready for use.')
|
|
l2.daemon.wait_for_log(r'billboard: Channel ready for use.')
|
|
|
|
# Check that the splice doesn't generate a unilateral close transaction
|
|
time.sleep(5)
|
|
assert l1.db_query("SELECT count(*) as c FROM channeltxs;")[0]['c'] == 0
|