Browse Source

gossipd: advertize all our features in node_announcement.

This preempts the acceptance of
https://github.com/lightningnetwork/lightning-rfc/pull/666 but it's
clear that feature bits are going to be distinct, so this is safe to
do anyway.

See https://github.com/lightningnetwork/lightning-rfc/pull/680

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
33c658ecfb
  1. 1
      CHANGELOG.md
  2. 12
      common/features.c
  3. 1
      common/features.h
  4. 2
      gossipd/gossip_generation.c
  5. 3
      gossipd/gossipd.c
  6. 4
      gossipd/gossipd.h
  7. 2
      lightningd/gossip_control.c
  8. 4
      tests/test_connection.py
  9. 7
      tests/test_gossip.py

1
CHANGELOG.md

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Plugin: new notifications `sendpay_success` and `sendpay_failure`.
- Protocol: we now offer `option_gossip_queries_ex` for finegrained gossip control.
- Protocol: no longer ask for `initial_routing_sync` (only affects ancient peers).
- Protocol: nodes now announce features in `node_announcement` broadcasts.
### Changed

12
common/features.c

@ -54,6 +54,18 @@ u8 *get_offered_globalfeatures(const tal_t *ctx)
our_globalfeatures, ARRAY_SIZE(our_globalfeatures));
}
/* We currently advertize everything in node_announcement, except
* initial_routing_sync which the spec says not to (and we don't set
* any more anyway).
*
* FIXME: Add bolt ref when finalized!
*/
u8 *get_offered_nodefeatures(const tal_t *ctx)
{
return mkfeatures(ctx,
our_localfeatures, ARRAY_SIZE(our_localfeatures));
}
u8 *get_offered_localfeatures(const tal_t *ctx)
{
return mkfeatures(ctx,

1
common/features.h

@ -10,6 +10,7 @@ bool features_supported(const u8 *globalfeatures, const u8 *localfeatures);
/* For sending our features: tal_count() returns length. */
u8 *get_offered_globalfeatures(const tal_t *ctx);
u8 *get_offered_localfeatures(const tal_t *ctx);
u8 *get_offered_nodefeatures(const tal_t *ctx);
/* Is this feature bit requested? (Either compulsory or optional) */
bool feature_offered(const u8 *features, size_t f);

2
gossipd/gossip_generation.c

@ -35,7 +35,7 @@ static u8 *create_node_announcement(const tal_t *ctx, struct daemon *daemon,
towire_wireaddr(&addresses, &daemon->announcable[i]);
announcement =
towire_node_announcement(ctx, sig, daemon->globalfeatures, timestamp,
towire_node_announcement(ctx, sig, daemon->nodefeatures, timestamp,
&daemon->id, daemon->rgb, daemon->alias,
addresses);
return announcement;

3
gossipd/gossipd.c

@ -931,7 +931,8 @@ static struct io_plan *gossip_init(struct io_conn *conn,
if (!fromwire_gossipctl_init(daemon, msg,
&chainparams,
&daemon->id, &daemon->globalfeatures,
&daemon->id,
&daemon->nodefeatures,
daemon->rgb,
daemon->alias,
&daemon->announcable,

4
gossipd/gossipd.h

@ -43,8 +43,8 @@ struct daemon {
/* Timers: we batch gossip, and also refresh announcements */
struct timers timers;
/* Global features to list in node_announcement. */
u8 *globalfeatures;
/* Features to list in node_announcement. */
u8 *nodefeatures;
/* Alias (not NUL terminated) and favorite color for node_announcement */
u8 alias[32];

2
lightningd/gossip_control.c

@ -210,7 +210,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
tmpctx,
chainparams,
&ld->id,
get_offered_globalfeatures(tmpctx),
get_offered_nodefeatures(tmpctx),
ld->rgb,
ld->alias,
ld->announcable,

4
tests/test_connection.py

@ -1403,8 +1403,8 @@ def test_peerinfo(node_factory, bitcoind):
nodes2 = l2.rpc.listnodes(l2.info['id'])['nodes']
peer1 = l1.rpc.getpeer(l2.info['id'])
peer2 = l2.rpc.getpeer(l1.info['id'])
assert only_one(nodes1)['globalfeatures'] == peer1['globalfeatures']
assert only_one(nodes2)['globalfeatures'] == peer2['globalfeatures']
assert only_one(nodes1)['globalfeatures'] == peer1['localfeatures']
assert only_one(nodes2)['globalfeatures'] == peer2['localfeatures']
assert l1.rpc.getpeer(l2.info['id'])['localfeatures'] == lfeatures
assert l2.rpc.getpeer(l1.info['id'])['localfeatures'] == lfeatures

7
tests/test_gossip.py

@ -1012,6 +1012,11 @@ def test_node_reannounce(node_factory, bitcoind):
wait_for(lambda: 'alias' in only_one(l2.rpc.listnodes(l1.info['id'])['nodes']))
assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'].startswith('JUNIORBEAM')
lfeatures = '28a2'
# Make sure it gets features correct.
assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['globalfeatures'] == lfeatures
l1.stop()
l1.daemon.opts['alias'] = 'SENIORBEAM'
# It won't update within 5 seconds, so sleep.
@ -1429,7 +1434,7 @@ def test_gossip_store_compact_on_load(node_factory, bitcoind):
l2.restart()
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store_compact_offline: [5-8] deleted, 9 copied'))
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store: Read 1/4/2/0 cannounce/cupdate/nannounce/cdelete from store \(0 deleted\) in 1446 bytes'))
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store: Read 1/4/2/0 cannounce/cupdate/nannounce/cdelete from store \(0 deleted\) in 1450 bytes'))
def test_gossip_announce_invalid_block(node_factory, bitcoind):

Loading…
Cancel
Save