From b09e5196695f031d7b979a7266a57bb9592c3a6b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 20 Aug 2020 16:20:47 +0930 Subject: [PATCH] options: be more conservative with timeouts on mainnet. As per https://github.com/lightningnetwork/lightning-rfc/pull/785 Signed-off-by: Rusty Russell Changelog-Changed: config: the default CLTV expiry is now 34 blocks, and final expiry 18 blocks as per new BOLT recommendations. --- Makefile | 2 +- lightningd/options.c | 8 ++++---- lightningd/peer_htlcs.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 991b146e60a9..fc7b0fa21339 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../lightning-rfc/ -BOLTVERSION := c053ce7afb4cbf88615877a0d5fc7b8dbe2b9ba0 +BOLTVERSION := 886bf7a430db706b483b7b02d64a82bf175c0b46 -include config.vars diff --git a/lightningd/options.c b/lightningd/options.c index a1dad4f2248c..2614a73ca0ba 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -639,16 +639,16 @@ static const struct config mainnet_config = { /* BOLT #2: * * 1. the `cltv_expiry_delta` for channels, `3R+2G+2S`: if in doubt, a - * `cltv_expiry_delta` of 12 is reasonable (R=2, G=1, S=2) + * `cltv_expiry_delta` of at least 34 is reasonable (R=2, G=2, S=12) */ - /* R = 2, G = 1, S = 3 */ - .cltv_expiry_delta = 14, + /* R = 2, G = 2, S = 12 */ + .cltv_expiry_delta = 34, /* BOLT #2: * * 4. the minimum `cltv_expiry` accepted for terminal payments: the * worst case for the terminal node C is `2R+G+S` blocks */ - .cltv_final = 10, + .cltv_final = 18, /* Send commit 10msec after receiving; almost immediately. */ .commit_time_ms = 10, diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 128b19269b54..e692175a3edb 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -2278,7 +2278,7 @@ void free_htlcs(struct lightningd *ld, const struct channel *channel) * * 2. the deadline for offered HTLCs: the deadline after which the channel has * to be failed and timed out on-chain. This is `G` blocks after the HTLC's - * `cltv_expiry`: 1 block is reasonable. + * `cltv_expiry`: 1 or 2 blocks is reasonable. */ static u32 htlc_out_deadline(const struct htlc_out *hout) { @@ -2290,7 +2290,7 @@ static u32 htlc_out_deadline(const struct htlc_out *hout) * 3. the deadline for received HTLCs this node has fulfilled: the deadline * after which the channel has to be failed and the HTLC fulfilled on-chain * before its `cltv_expiry`. See steps 4-7 above, which imply a deadline of - * `2R+G+S` blocks before `cltv_expiry`: 7 blocks is reasonable. + * `2R+G+S` blocks before `cltv_expiry`: 18 blocks is reasonable. */ /* We approximate this, by using half the cltv_expiry_delta (3R+2G+2S), * rounded up. */