From ef45eacc95e7d87024b97600fe0650f519b672f0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 27 Mar 2024 13:39:01 +1030 Subject: [PATCH] lightningd: allow *outgoing* HTLCs before full bitcoind sync. This allows for faster startup for Greenlight. We still require full sync before *incoming* htlcs, and onchain operations. Signed-off-by: Rusty Russell --- lightningd/peer_htlcs.c | 8 +++++--- tests/test_misc.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index ac694e767..83b24446e 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -629,10 +629,12 @@ const u8 *send_htlc_out(const tal_t *ctx, channel_update_for_error(tmpctx, out)); } + /* Note: we allow outgoing HTLCs before sync, for fast startup. */ if (!topology_synced(out->peer->ld->topology)) { - log_info(out->log, "Attempt to send HTLC but still syncing" - " with bitcoin network"); - return towire_temporary_node_failure(ctx); + log_debug(out->log, "Sending HTLC while still syncing" + " with bitcoin network (%u vs %u)", + get_block_height(out->peer->ld->topology), + get_network_blockheight(out->peer->ld->topology)); } /* Make peer's daemon own it, catch if it dies. */ diff --git a/tests/test_misc.py b/tests/test_misc.py index 82efe820f..e3ef1febe 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -188,9 +188,9 @@ def test_lightningd_still_loading(node_factory, bitcoind, executor): # Make sure it's connected to l2 (otherwise we get TEMPORARY_CHANNEL_FAILURE) wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) - # Payments will fail. FIXME: More informative msg? - with pytest.raises(RpcError, match=r'TEMPORARY_NODE_FAILURE'): - l1.pay(l2, 1000) + # Payments will succced. + l1.pay(l2, 1000) + assert l1.daemon.is_in_log(r"Sending HTLC while still syncing with bitcoin network \(104 vs 105\)") # Can't fund a new channel. l1.rpc.connect(l3.info['id'], 'localhost', l3.port)