From f7eacb779fae4c880eff38ecdbfa2b5d38249daf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 26 Mar 2024 06:50:22 +1030 Subject: [PATCH 1/2] lightningd: revert f450dfeb5591d69f78c66a1e1e6fbbd455be6902 to allow non-gossip_query nodes. LDK doesn't set this feature if they don't have any useful gossip (mobile nodes) and it was agreed at the spec meeting that we should repurpose this feature to mean "I don't have any useful gossip". Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 2 +- tests/test_misc.py | 2 +- tests/utils.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 4fe9d1a160d8..691e213445d3 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -893,7 +893,7 @@ static struct feature_set *default_features(const tal_t *ctx) static const u32 features[] = { COMPULSORY_FEATURE(OPT_DATA_LOSS_PROTECT), OPTIONAL_FEATURE(OPT_UPFRONT_SHUTDOWN_SCRIPT), - COMPULSORY_FEATURE(OPT_GOSSIP_QUERIES), + OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES), COMPULSORY_FEATURE(OPT_VAR_ONION), COMPULSORY_FEATURE(OPT_PAYMENT_SECRET), OPTIONAL_FEATURE(OPT_BASIC_MPP), diff --git a/tests/test_misc.py b/tests/test_misc.py index 37d2c023c39c..82efe820fa99 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2263,7 +2263,7 @@ def test_list_features_only(node_factory): '--list-features-only']).decode('utf-8').splitlines() expected = ['option_data_loss_protect/even', 'option_upfront_shutdown_script/odd', - 'option_gossip_queries/even', + 'option_gossip_queries/odd', 'option_var_onion_optin/even', 'option_gossip_queries_ex/odd', 'option_static_remotekey/even', diff --git a/tests/utils.py b/tests/utils.py index 6a109b80915a..001cbec818fa 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -36,7 +36,7 @@ def hex_bits(features): def expected_peer_features(extra=[]): """Return the expected peer features hexstring for this configuration""" - features = [0, 5, 6, 8, 11, 12, 14, 17, 19, 25, 27, 45, 47, 51] + features = [0, 5, 7, 8, 11, 12, 14, 17, 19, 25, 27, 45, 47, 51] if EXPERIMENTAL_DUAL_FUND: # option_dual_fund features += [29] @@ -53,7 +53,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, 6, 8, 11, 12, 14, 17, 19, 25, 27, 45, 47, 51, 55] + features = [0, 5, 7, 8, 11, 12, 14, 17, 19, 25, 27, 45, 47, 51, 55] if EXPERIMENTAL_DUAL_FUND: # option_dual_fund features += [29] From 06e850c74e3b9c672386a4415ce6671034b93524 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 26 Mar 2024 09:22:11 +1030 Subject: [PATCH 2/2] gossipd: be stricter with non-gossip_query nodes. We now *never* consider asking them anything, even if they are capable (e.g. enabling full gossip stream). This aligns with the latest spec proposal, where lack of `gossip_queries` means "we don't have anything useful to say". Signed-off-by: Rusty Russell --- gossipd/seeker.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gossipd/seeker.c b/gossipd/seeker.c index f62d4a99fc91..5fbd4073d685 100644 --- a/gossipd/seeker.c +++ b/gossipd/seeker.c @@ -239,6 +239,16 @@ static void normal_gossip_start(struct seeker *seeker, struct peer *peer) { bool enable_stream = false; + /* BOLT-remove-old-features #7: + * Understanding of messages used to be indicated with the `gossip_queries` + * feature bit; now these messages are universally supported, that feature has + * now been slightly repurposed. Not offering this feature means a node is not + * worth querying for gossip: either they do not store the entire gossip map, or + * they are only connected to a single peer (this one). + */ + if (!peer->gossip_queries_feature) + return; + /* Make this one of our streaming gossipers if we aren't full */ for (size_t i = 0; i < ARRAY_SIZE(seeker->gossiper); i++) { if (seeker->gossiper[i] == NULL) { @@ -850,6 +860,13 @@ static bool peer_is_not_gossipper(const struct peer *peer) { const struct seeker *seeker = peer->daemon->seeker; + /* BOLT-remove-old-features #7: + * `gossip_queries`... Not offering this feature means a node is not + * worth querying for gossip + */ + if (!peer->gossip_queries_feature) + return false; + for (size_t i = 0; i < ARRAY_SIZE(seeker->gossiper); i++) { if (seeker->gossiper[i] == peer) return false; @@ -864,7 +881,7 @@ static void maybe_rotate_gossipers(struct seeker *seeker) struct peer *peer; size_t i; - /* If all peers are gossiping, we're done */ + /* If all (usable) peers are gossiping, we're done */ peer = random_seeker(seeker, peer_is_not_gossipper); if (!peer) return;