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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-03-27 13:39:01 +10:30 committed by Vincenzo Palazzo
parent 05ef69fde1
commit ef45eacc95
2 changed files with 8 additions and 6 deletions

View file

@ -629,10 +629,12 @@ const u8 *send_htlc_out(const tal_t *ctx,
channel_update_for_error(tmpctx, out)); channel_update_for_error(tmpctx, out));
} }
/* Note: we allow outgoing HTLCs before sync, for fast startup. */
if (!topology_synced(out->peer->ld->topology)) { if (!topology_synced(out->peer->ld->topology)) {
log_info(out->log, "Attempt to send HTLC but still syncing" log_debug(out->log, "Sending HTLC while still syncing"
" with bitcoin network"); " with bitcoin network (%u vs %u)",
return towire_temporary_node_failure(ctx); get_block_height(out->peer->ld->topology),
get_network_blockheight(out->peer->ld->topology));
} }
/* Make peer's daemon own it, catch if it dies. */ /* Make peer's daemon own it, catch if it dies. */

View file

@ -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) # 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']) wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected'])
# Payments will fail. FIXME: More informative msg? # Payments will succced.
with pytest.raises(RpcError, match=r'TEMPORARY_NODE_FAILURE'): l1.pay(l2, 1000)
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. # Can't fund a new channel.
l1.rpc.connect(l3.info['id'], 'localhost', l3.port) l1.rpc.connect(l3.info['id'], 'localhost', l3.port)