Skip to content

Commit

Permalink
common: gossmap now always ignores private gossip_store messages.
Browse files Browse the repository at this point in the history
In the next PR, they'll be removed, but for now all our code doesn't
want them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Nov 16, 2023
1 parent ebd7334 commit f3d9f7b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 269 deletions.
6 changes: 0 additions & 6 deletions common/gossmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include <unistd.h>
#include <wire/peer_wire.h>

bool gossmap_public_only;

/* We need this global to decode indexes for hash functions */
static struct gossmap *map;

Expand Down Expand Up @@ -638,12 +636,8 @@ static bool map_catchup(struct gossmap *map, size_t *num_rejected)
type = map_be16(map, off);
if (type == WIRE_CHANNEL_ANNOUNCEMENT)
add_channel(map, off, false);
else if (type == WIRE_GOSSIP_STORE_PRIVATE_CHANNEL && !gossmap_public_only)
add_channel(map, off + 2 + 8 + 2, true);
else if (type == WIRE_CHANNEL_UPDATE)
num_bad += !update_channel(map, off);
else if (type == WIRE_GOSSIP_STORE_PRIVATE_UPDATE && !gossmap_public_only)
num_bad += !update_channel(map, off + 2 + 2);
else if (type == WIRE_GOSSIP_STORE_DELETE_CHAN)
remove_channel_by_deletemsg(map, off);
else if (type == WIRE_NODE_ANNOUNCEMENT)
Expand Down
3 changes: 0 additions & 3 deletions common/gossmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ struct gossmap_chan {
} half[2];
};

/* Temporary flag for testing: don't load private gossip info! */
extern bool gossmap_public_only;

/* If num_channel_updates_rejected is not NULL, indicates how many channels we
* marked inactive because their values were too high to be represented. */
struct gossmap *gossmap_load(const tal_t *ctx, const char *filename,
Expand Down
188 changes: 0 additions & 188 deletions common/test/run-gossmap_canned.c

This file was deleted.

57 changes: 5 additions & 52 deletions common/test/run-gossmap_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,27 +309,22 @@ int main(int argc, char *argv[])
map = gossmap_load(tmpctx, gossfile, NULL);
assert(map);

/* There is a public channel 2<->3 (103x1x0), and private
* 1<->2 (110x1x1). */
/* There is a public channel 2<->3 (103x1x0). */
assert(node_id_from_hexstr("0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", 66, &l1));
assert(node_id_from_hexstr("022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", 66, &l2));
assert(node_id_from_hexstr("035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", 66, &l3));
assert(gossmap_find_node(map, &l1));
assert(!gossmap_find_node(map, &l1));
assert(gossmap_find_node(map, &l2));
assert(gossmap_find_node(map, &l3));

assert(short_channel_id_from_str("103x1x0", 7, &scid23));
assert(short_channel_id_from_str("110x1x1", 7, &scid12));
assert(gossmap_find_chan(map, &scid23));
assert(!gossmap_find_chan(map, &scid23)->private);
assert(gossmap_find_chan(map, &scid12));
assert(gossmap_find_chan(map, &scid12)->private);
assert(!gossmap_find_chan(map, &scid12));
assert(gossmap_chan_get_capacity(map, gossmap_find_chan(map, &scid23),
&capacity));
assert(amount_sat_eq(capacity, AMOUNT_SAT(1000000)));
assert(gossmap_chan_get_capacity(map, gossmap_find_chan(map, &scid12),
&capacity));
assert(amount_sat_eq(capacity, AMOUNT_SAT(1000000)));

gossmap_chan_get_update_details(map, gossmap_find_chan(map, &scid23),
0,
Expand Down Expand Up @@ -365,55 +360,13 @@ int main(int argc, char *argv[])
assert(amount_msat_eq(htlc_minimum_msat, AMOUNT_MSAT(0)));
assert(amount_msat_eq(htlc_maximum_msat, AMOUNT_MSAT(990000000)));

gossmap_chan_get_update_details(map, gossmap_find_chan(map, &scid12),
0,
&timestamp,
&message_flags,
&channel_flags,
&fee_base_msat,
&fee_proportional_millionths,
&htlc_minimum_msat,
&htlc_maximum_msat);
assert(timestamp == 1612141439);
assert(message_flags == 1);
assert(channel_flags == 0);
assert(fee_base_msat == 20);
assert(fee_proportional_millionths == 1000);
assert(amount_msat_eq(htlc_minimum_msat, AMOUNT_MSAT(0)));
assert(amount_msat_eq(htlc_maximum_msat, AMOUNT_MSAT(990000000)));

gossmap_chan_get_update_details(map, gossmap_find_chan(map, &scid12),
1,
&timestamp,
&message_flags,
&channel_flags,
&fee_base_msat,
&fee_proportional_millionths,
&htlc_minimum_msat,
&htlc_maximum_msat);
assert(timestamp == 1612141439);
assert(message_flags == 1);
assert(channel_flags == 1);
assert(fee_base_msat == 20);
assert(fee_proportional_millionths == 1000);
assert(amount_msat_eq(htlc_minimum_msat, AMOUNT_MSAT(0)));
assert(amount_msat_eq(htlc_maximum_msat, AMOUNT_MSAT(990000000)));

assert(tal_bytelen(gossmap_chan_get_features(tmpctx, map,
gossmap_find_chan(map, &scid12))) == 0);
assert(tal_bytelen(gossmap_chan_get_features(tmpctx, map,
gossmap_find_chan(map, &scid23))) == 0);

cann = gossmap_chan_get_announce(tmpctx, map,
gossmap_find_chan(map, &scid12));
check_cannounce(cann, &scid12, &l1, &l2);
cann = gossmap_chan_get_announce(tmpctx, map,
gossmap_find_chan(map, &scid23));
check_cannounce(cann, &scid23, &l2, &l3);

nann = gossmap_node_get_announce(tmpctx, map,
gossmap_find_node(map, &l1));
assert(!nann);
nann = gossmap_node_get_announce(tmpctx, map,
gossmap_find_node(map, &l2));
check_nannounce(nann, &l2);
Expand Down Expand Up @@ -482,11 +435,11 @@ int main(int argc, char *argv[])

assert(!gossmap_find_node(map, &l4));
assert(!gossmap_find_chan(map, &scid_local));
assert(gossmap_find_node(map, &l1));
assert(!gossmap_find_node(map, &l1));
assert(gossmap_find_node(map, &l2));
assert(gossmap_find_node(map, &l3));
assert(gossmap_find_chan(map, &scid23));
assert(gossmap_find_chan(map, &scid12));
assert(!gossmap_find_chan(map, &scid12));

chan = gossmap_find_chan(map, &scid23);
assert(chan->half[0].enabled);
Expand Down
2 changes: 0 additions & 2 deletions plugins/fetchinvoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,6 @@ static const struct plugin_hook hooks[] = {
int main(int argc, char *argv[])
{
setup_locale();
/* We are migrated, ready for public-only gossmap! */
gossmap_public_only = true;
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL,
commands, ARRAY_SIZE(commands),
/* No notifications */
Expand Down
2 changes: 0 additions & 2 deletions plugins/keysend.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,6 @@ int main(int argc, char *argv[])
features->bits[i] = tal_arr(features, u8, 0);
set_feature_bit(&features->bits[NODE_ANNOUNCE_FEATURE], KEYSEND_FEATUREBIT);

/* We are migrated, ready for public-only gossmap! */
gossmap_public_only = true;
plugin_main(argv, init, PLUGIN_STATIC, true, features, commands,
ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks),
notification_topics, ARRAY_SIZE(notification_topics), NULL);
Expand Down
2 changes: 0 additions & 2 deletions plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,6 @@ static const char *notification_topics[] = {
int main(int argc, char *argv[])
{
setup_locale();
/* We are migrated, ready for public-only gossmap! */
gossmap_public_only = true;
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL, commands,
ARRAY_SIZE(commands), NULL, 0, NULL, 0,
notification_topics, ARRAY_SIZE(notification_topics),
Expand Down
3 changes: 0 additions & 3 deletions plugins/renepay/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,9 +1339,6 @@ int main(int argc, char *argv[])
pay_plugin = tal(NULL, struct pay_plugin);
pay_plugin->debug_mcf = pay_plugin->debug_payflow = false;

/* We are migrated, ready for public-only gossmap! */
gossmap_public_only = true;

plugin_main(
argv,
init,
Expand Down
Loading

0 comments on commit f3d9f7b

Please sign in to comment.