From b7e20b327cc75485a5e2bc3145813a577dea2f85 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 16 May 2025 21:34:23 +0930 Subject: [PATCH] lightningd: enable peer storage by default, Now we've make it only on existing channels, and not have to call listdatastore every time, that means we can safely turn it on by default. Changelog-Added: Protocol: we now offer peer storage to any peers who create a channel. Changelog-Deprecated: Config: `--experimental-peer-storage` (it's now the default). Signed-off-by: Rusty Russell --- doc/lightningd-config.5.md | 6 ------ lightningd/lightningd.c | 1 + lightningd/options.c | 8 ++++---- tests/test_cln_rs.py | 3 +++ tests/test_misc.py | 31 +++++++------------------------ tests/test_plugin.py | 3 +-- tests/utils.py | 4 ++-- 7 files changed, 18 insertions(+), 38 deletions(-) diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index 8c6d1a998..d7cfc0ba8 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -811,12 +811,6 @@ The operations will be bundled into a single transaction. The channel will remai active while awaiting splice confirmation, however you can only spend the smaller of the prior channel balance and the new one. -* **experimental-peer-storage** - - Specifying this option means we will store up to 64k of encrypted -data for our peers, and give them our (encrypted!) backup data to -store as well, based on a protocol similar to [bolt][bolt] #881. - * **experimental-quiesce** Specifying this option advertizes `option_quiesce`. Not very useful diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 4e8a14562..68b2e2462 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -931,6 +931,7 @@ static struct feature_set *default_features(const tal_t *ctx) OPTIONAL_FEATURE(OPT_ONION_MESSAGES), OPTIONAL_FEATURE(OPT_CHANNEL_TYPE), OPTIONAL_FEATURE(OPT_ROUTE_BLINDING), + OPTIONAL_FEATURE(OPT_PROVIDE_STORAGE), /* Removed later for elements */ OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX), }; diff --git a/lightningd/options.c b/lightningd/options.c index 36942fc5a..6ba5d6c4a 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1260,9 +1260,9 @@ static char *opt_set_shutdown_wrong_funding(struct lightningd *ld) static char *opt_set_peer_storage(struct lightningd *ld) { - feature_set_or(ld->our_features, - take(feature_set_for_feature(NULL, - OPTIONAL_FEATURE(OPT_PROVIDE_STORAGE)))); + if (!opt_deprecated_ok(ld, "experimental-peer-storage", NULL, + "v25.05", "v25.11")) + return "--experimental-peer-storage is now enabled by default"; return NULL; } @@ -1472,7 +1472,7 @@ static void register_opts(struct lightningd *ld) "EXPERIMENTAL: allow shutdown with alternate txids"); opt_register_early_noarg("--experimental-peer-storage", opt_set_peer_storage, ld, - "EXPERIMENTAL: enable peer backup storage and restore"); + opt_hidden); opt_register_early_noarg("--experimental-quiesce", opt_set_quiesce, ld, "experimental: Advertise ability to quiesce" diff --git a/tests/test_cln_rs.py b/tests/test_cln_rs.py index b93e6f56d..8822c67bc 100644 --- a/tests/test_cln_rs.py +++ b/tests/test_cln_rs.py @@ -452,6 +452,9 @@ def test_grpc_custommsg_notification(node_factory): l2.rpc.sendcustommsg(l1.info["id"], "3131313174657374") for custommsg in custommsg_stream: + # Ignore peer storage message! + if custommsg.payload.hex().startswith('0007'): + continue assert custommsg.peer_id.hex() == l2.info["id"] assert custommsg.payload.hex() == "3131313174657374" assert custommsg.payload == b"1111test" diff --git a/tests/test_misc.py b/tests/test_misc.py index 415bced57..c0f551cea 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2404,6 +2404,7 @@ def test_list_features_only(node_factory): 'option_shutdown_anysegwit/odd', 'option_quiesce/odd', 'option_onion_messages/odd', + 'option_provide_storage/odd', 'option_channel_type/odd', 'option_scid_alias/odd', 'option_zeroconf/odd'] @@ -3088,27 +3089,11 @@ def test_emergencyrecover(node_factory, bitcoind): @pytest.mark.openchannel('v1') @pytest.mark.openchannel('v2') def test_recover_plugin(node_factory, bitcoind): - l1 = node_factory.get_node( - may_reconnect=True, - allow_warning=True, - feerates=(7500, 7500, 7500, 7500), - options={ - 'log-level': 'info', - 'experimental-peer-storage': None, - 'dev-no-reconnect': None, - }, - ) - l2 = node_factory.get_node( - may_reconnect=True, - feerates=(7500, 7500, 7500, 7500), - broken_log='.*', - allow_bad_gossip=True, - options={ - 'log-level': 'info', - 'experimental-peer-storage': None, - 'dev-no-reconnect': None, - }, - ) + l1, l2 = node_factory.get_nodes(2, opts=[{'may_reconnect': True, + 'dev-no-reconnect': None}, + {'may_reconnect': True, + 'dev-no-reconnect': None, + 'broken_log': 'Cannot broadcast our commitment tx: they have a future one|ERROR: Unknown commitment #[0-9]*, recovering our funds!'}]) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l2.fundchannel(l1, 10**6) @@ -3159,11 +3144,9 @@ def test_restorefrompeer(node_factory, bitcoind): Test restorefrompeer """ l1, l2 = node_factory.get_nodes(2, [{'broken_log': 'ERROR: Unknown commitment #.*, recovering our funds!', - 'experimental-peer-storage': None, 'may_reconnect': True, 'allow_bad_gossip': True}, - {'experimental-peer-storage': None, - 'may_reconnect': True}]) + {'may_reconnect': True}]) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 24a6915df..5d9e58673 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -4563,8 +4563,7 @@ def test_exposesecret(node_factory): def test_peer_storage(node_factory, bitcoind): """Test that we offer and re-xmit peer storage for our peers if they have a channel or are explicitly enabled""" l1, l2, l3 = node_factory.get_nodes(3, - opts={'experimental-peer-storage': None, - 'may_reconnect': True, + opts={'may_reconnect': True, 'dev-no-reconnect': None}) # Connect them, no peer storage yet anyway. diff --git a/tests/utils.py b/tests/utils.py index d4647733a..5b682c6c3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -41,7 +41,7 @@ def hex_bits(features): def expected_peer_features(extra=[]): """Return the expected peer features hexstring for this configuration""" - features = [0, 5, 7, 8, 11, 12, 14, 17, 19, 25, 27, 35, 39, 45, 47, 51] + features = [0, 5, 7, 8, 11, 12, 14, 17, 19, 25, 27, 35, 39, 43, 45, 47, 51] if EXPERIMENTAL_DUAL_FUND: # option_dual_fund features += [29] @@ -57,7 +57,7 @@ def expected_peer_features(extra=[]): # features for the 'node' and the 'peer' feature sets def expected_node_features(extra=[]): """Return the expected node features hexstring for this configuration""" - features = [0, 5, 7, 8, 11, 12, 14, 17, 19, 25, 27, 35, 39, 45, 47, 51, 55] + features = [0, 5, 7, 8, 11, 12, 14, 17, 19, 25, 27, 35, 39, 43, 45, 47, 51, 55] if EXPERIMENTAL_DUAL_FUND: # option_dual_fund features += [29]