connectd: take dev-suppress-gossip from gossipd.

Gossipd didn't actually suppress all gossip, resulting in a flake!
Doing it in connectd now makes much more sense.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-03-31 16:26:22 +10:30
parent 2f7f7ec255
commit 9bddfc2048
10 changed files with 44 additions and 62 deletions

View File

@ -1547,6 +1547,7 @@ static void connect_init(struct daemon *daemon, const u8 *msg)
/*~ Clearly mark these as developer-only flags! */
daemon->dev_fast_gossip = dev_fast_gossip;
daemon->dev_no_ping_timer = dev_no_ping_timer;
daemon->dev_suppress_gossip = false;
#endif
if (!pubkey_from_node_id(&daemon->mykey, &daemon->id))
@ -1980,6 +1981,11 @@ static void dev_connect_memleak(struct daemon *daemon, const u8 *msg)
take(towire_connectd_dev_memleak_reply(NULL,
found_leak)));
}
static void dev_suppress_gossip(struct daemon *daemon, const u8 *msg)
{
daemon->dev_suppress_gossip = true;
}
#endif /* DEVELOPER */
static struct io_plan *recv_req(struct io_conn *conn,
@ -2031,6 +2037,11 @@ static struct io_plan *recv_req(struct io_conn *conn,
#if DEVELOPER
dev_connect_memleak(daemon, msg);
goto out;
#endif
case WIRE_CONNECTD_DEV_SUPPRESS_GOSSIP:
#if DEVELOPER
dev_suppress_gossip(daemon, msg);
goto out;
#endif
/* We send these, we don't receive them */
case WIRE_CONNECTD_INIT_REPLY:

View File

@ -193,6 +193,8 @@ struct daemon {
bool dev_fast_gossip;
/* Hack to avoid ping timeouts */
bool dev_no_ping_timer;
/* Hack to no longer send gossip */
bool dev_suppress_gossip;
#endif
};

View File

@ -153,3 +153,7 @@ msgtype,connectd_custommsg_out,2011
msgdata,connectd_custommsg_out,id,node_id,
msgdata,connectd_custommsg_out,msg_len,u16,
msgdata,connectd_custommsg_out,msg,u8,msg_len
# master -> connect: stop sending gossip.
msgtype,connectd_dev_suppress_gossip,2032

1 #include <bitcoin/block.h>
153
154
155
156
157
158
159

View File

@ -169,7 +169,7 @@ void setup_peer_gossip_store(struct peer *peer,
}
peer->gs.gossip_timer = gossip_stream_timer(peer);
peer->gs.active = true;
peer->gs.active = IFDEV(!peer->daemon->dev_suppress_gossip, true);
peer->gs.timestamp_min = 0;
peer->gs.timestamp_max = UINT32_MAX;
@ -344,7 +344,7 @@ static struct io_plan *encrypt_and_send(struct peer *peer,
/* Kicks off write_to_peer() to look for more gossip to send from store */
static void wake_gossip(struct peer *peer)
{
peer->gs.active = true;
peer->gs.active = IFDEV(!peer->daemon->dev_suppress_gossip, true);
io_wake(peer->peer_outq);
/* And go again in 60 seconds (from now, now when we finish!) */

View File

@ -805,16 +805,6 @@ static void new_blockheight(struct daemon *daemon, const u8 *msg)
}
#if DEVELOPER
/* Another testing hack */
static void dev_gossip_suppress(struct daemon *daemon, const u8 *msg)
{
if (!fromwire_gossipd_dev_suppress(msg))
master_badmsg(WIRE_GOSSIPD_DEV_SUPPRESS, msg);
status_unusual("Suppressing all gossip");
dev_suppress_gossip = true;
}
static void dev_gossip_memleak(struct daemon *daemon, const u8 *msg)
{
struct htable *memtable;
@ -1058,9 +1048,6 @@ static struct io_plan *recv_req(struct io_conn *conn,
case WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
dev_set_max_scids_encode_size(daemon, msg);
goto done;
case WIRE_GOSSIPD_DEV_SUPPRESS:
dev_gossip_suppress(daemon, msg);
goto done;
case WIRE_GOSSIPD_DEV_MEMLEAK:
dev_gossip_memleak(daemon, msg);
goto done;
@ -1072,7 +1059,6 @@ static struct io_plan *recv_req(struct io_conn *conn,
goto done;
#else
case WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
case WIRE_GOSSIPD_DEV_SUPPRESS:
case WIRE_GOSSIPD_DEV_MEMLEAK:
case WIRE_GOSSIPD_DEV_COMPACT_STORE:
case WIRE_GOSSIPD_DEV_SET_TIME:

View File

@ -46,9 +46,6 @@ msgdata,gossipd_get_txout_reply,outscript,u8,len
msgtype,gossipd_outpoint_spent,3024
msgdata,gossipd_outpoint_spent,short_channel_id,short_channel_id,
# master -> gossipd: stop gossip timers.
msgtype,gossipd_dev_suppress,3032
# master -> gossipd: do you have a memleak?
msgtype,gossipd_dev_memleak,3033

1 #include <common/cryptomsg.h>
46 # master -> gossipd: please rewrite the gossip_store # gossipd -> master: ok
47 msgtype,gossipd_dev_compact_store,3034 msgtype,gossipd_dev_compact_store_reply,3134
48 # gossipd -> master: ok msgdata,gossipd_dev_compact_store_reply,success,bool,
msgtype,gossipd_dev_compact_store_reply,3134
msgdata,gossipd_dev_compact_store_reply,success,bool,
# master -> gossipd: blockheight increased.
49 msgtype,gossipd_new_blockheight,3026 # master -> gossipd: blockheight increased.
50 msgdata,gossipd_new_blockheight,blockheight,u32, msgtype,gossipd_new_blockheight,3026
51 # gossipd: got it! msgdata,gossipd_new_blockheight,blockheight,u32,

View File

@ -37,10 +37,6 @@ enum seeker_state {
ASKING_FOR_STALE_SCIDS,
};
#if DEVELOPER
bool dev_suppress_gossip;
#endif
/* Gossip we're seeking at the moment. */
struct seeker {
struct daemon *daemon;
@ -215,11 +211,6 @@ static void enable_gossip_stream(struct seeker *seeker, struct peer *peer)
u32 start = seeker->daemon->rstate->last_timestamp;
u8 *msg;
#if DEVELOPER
if (dev_suppress_gossip)
return;
#endif
if (start > polltime)
start -= polltime;
else
@ -870,11 +861,6 @@ static bool seek_any_unknown_nodes(struct seeker *seeker)
/* Periodic timer to see how our gossip is going. */
static void seeker_check(struct seeker *seeker)
{
#if DEVELOPER
if (dev_suppress_gossip)
goto out;
#endif
/* We don't do anything until we're synced. */
if (seeker->daemon->current_blockheight == 0)
goto out;
@ -914,10 +900,6 @@ void seeker_setup_peer_gossip(struct seeker *seeker, struct peer *peer)
if (!peer->gossip_queries_feature)
return;
#if DEVELOPER
if (dev_suppress_gossip)
return;
#endif
/* Don't start gossiping until we're synced. */
if (seeker->daemon->current_blockheight == 0)
return;

View File

@ -23,7 +23,4 @@ bool add_unknown_scid(struct seeker *seeker,
const struct short_channel_id *scid,
struct peer *peer);
/* A testing hack */
extern bool dev_suppress_gossip;
#endif /* LIGHTNING_GOSSIPD_SEEKER_H */

View File

@ -430,6 +430,7 @@ static unsigned connectd_msg(struct subd *connectd, const u8 *msg, const int *fd
case WIRE_CONNECTD_CONNECT_TO_PEER:
case WIRE_CONNECTD_DISCARD_PEER:
case WIRE_CONNECTD_DEV_MEMLEAK:
case WIRE_CONNECTD_DEV_SUPPRESS_GOSSIP:
case WIRE_CONNECTD_PEER_FINAL_MSG:
case WIRE_CONNECTD_PEER_MAKE_ACTIVE:
case WIRE_CONNECTD_PING:
@ -711,3 +712,27 @@ static const struct json_command dev_sendcustommsg_command = {
AUTODATA(json_command, &dev_sendcustommsg_command);
#endif /* DEVELOPER */
#endif /* COMPAT_V0100 */
#if DEVELOPER
static struct command_result *json_dev_suppress_gossip(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
{
if (!param(cmd, buffer, params, NULL))
return command_param_failed();
subd_send_msg(cmd->ld->connectd,
take(towire_connectd_dev_suppress_gossip(NULL)));
return command_success(cmd, json_stream_success(cmd));
}
static const struct json_command dev_suppress_gossip = {
"dev-suppress-gossip",
"developer",
json_dev_suppress_gossip,
"Stop this node from sending any more gossip."
};
AUTODATA(json_command, &dev_suppress_gossip);
#endif /* DEVELOPER */

View File

@ -157,7 +157,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
case WIRE_GOSSIPD_OUTPOINT_SPENT:
case WIRE_GOSSIPD_NEW_LEASE_RATES:
case WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE:
case WIRE_GOSSIPD_DEV_SUPPRESS:
case WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE:
case WIRE_GOSSIPD_DEV_MEMLEAK:
case WIRE_GOSSIPD_DEV_COMPACT_STORE:
@ -503,27 +502,6 @@ static const struct json_command dev_set_max_scids_encode_size = {
};
AUTODATA(json_command, &dev_set_max_scids_encode_size);
static struct command_result *json_dev_suppress_gossip(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
{
if (!param(cmd, buffer, params, NULL))
return command_param_failed();
subd_send_msg(cmd->ld->gossip, take(towire_gossipd_dev_suppress(NULL)));
return command_success(cmd, json_stream_success(cmd));
}
static const struct json_command dev_suppress_gossip = {
"dev-suppress-gossip",
"developer",
json_dev_suppress_gossip,
"Stop this node from sending any more gossip."
};
AUTODATA(json_command, &dev_suppress_gossip);
static void dev_compact_gossip_store_reply(struct subd *gossip UNUSED,
const u8 *reply,
const int *fds UNUSED,