gossipd: remove --dev-gossip-time setting, we'll use CLN_DEV_SET_TIME.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-11-13 15:41:31 +10:30
parent 0b2b92ffe3
commit 806dc89cad
8 changed files with 2 additions and 91 deletions

View File

@@ -367,19 +367,11 @@ static void master_or_connectd_gone(struct daemon_conn *dc UNUSED)
exit(2);
}
struct timeabs gossip_time_now(const struct daemon *daemon)
{
if (daemon->dev_gossip_time)
return *daemon->dev_gossip_time;
return time_now();
}
/* We don't check this when loading from the gossip_store: that would break
* our canned tests, and usually old gossip is better than no gossip */
bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp)
{
u64 now = gossip_time_now(daemon).ts.tv_sec;
u64 now = time_now().ts.tv_sec;
/* More than one day ahead? */
if (timestamp > now + 24*60*60)
@@ -393,27 +385,16 @@ bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp)
/*~ Parse init message from lightningd: starts the daemon properly. */
static void gossip_init(struct daemon *daemon, const u8 *msg)
{
u32 *dev_gossip_time;
if (!fromwire_gossipd_init(daemon, msg,
&chainparams,
&daemon->our_features,
&daemon->id,
&dev_gossip_time,
&daemon->dev_fast_gossip,
&daemon->dev_fast_gossip_prune,
&daemon->autoconnect_seeker_peers)) {
master_badmsg(WIRE_GOSSIPD_INIT, msg);
}
if (dev_gossip_time) {
assert(daemon->developer);
daemon->dev_gossip_time = tal(daemon, struct timeabs);
daemon->dev_gossip_time->ts.tv_sec = *dev_gossip_time;
daemon->dev_gossip_time->ts.tv_nsec = 0;
tal_free(dev_gossip_time);
}
/* Gossmap manager starts up */
daemon->gm = gossmap_manage_new(daemon, daemon);
@@ -481,18 +462,6 @@ static void dev_gossip_memleak(struct daemon *daemon, const u8 *msg)
found_leak)));
}
static void dev_gossip_set_time(struct daemon *daemon, const u8 *msg)
{
u32 time;
if (!fromwire_gossipd_dev_set_time(msg, &time))
master_badmsg(WIRE_GOSSIPD_DEV_SET_TIME, msg);
if (!daemon->dev_gossip_time)
daemon->dev_gossip_time = tal(daemon, struct timeabs);
daemon->dev_gossip_time->ts.tv_sec = time;
daemon->dev_gossip_time->ts.tv_nsec = 0;
}
/*~ lightningd tells us when about a gossip message directly, when told to by
* the addgossip RPC call. That's usually used when a plugin gets an update
* returned in an payment error. */
@@ -584,12 +553,6 @@ static struct io_plan *recv_req(struct io_conn *conn,
goto done;
}
/* fall thru */
case WIRE_GOSSIPD_DEV_SET_TIME:
if (daemon->developer) {
dev_gossip_set_time(daemon, msg);
goto done;
}
/* fall thru */
/* We send these, we don't receive them */
case WIRE_GOSSIPD_INIT_CUPDATE:
@@ -623,7 +586,6 @@ int main(int argc, char *argv[])
daemon = tal(NULL, struct daemon);
daemon->developer = developer;
daemon->dev_gossip_time = NULL;
daemon->peers = new_htable(daemon, peer_node_id_map);
daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0);
daemon->current_blockheight = 0; /* i.e. unknown */

View File

@@ -66,9 +66,6 @@ struct daemon {
/* Features lightningd told us to set. */
struct feature_set *our_features;
/* Override local time for gossip messages */
struct timeabs *dev_gossip_time;
/* Speed up gossip. */
bool dev_fast_gossip;
@@ -164,13 +161,6 @@ void tell_lightningd_peer_update(struct daemon *daemon,
struct amount_msat htlc_minimum,
struct amount_msat htlc_maximum);
/**
* Get the local time.
*
* This gets overridden in dev mode so we can use canned (stale) gossip.
*/
struct timeabs gossip_time_now(const struct daemon *daemon);
/**
* Is this gossip timestamp reasonable?
*/

View File

@@ -9,7 +9,6 @@ msgtype,gossipd_init,3000
msgdata,gossipd_init,chainparams,chainparams,
msgdata,gossipd_init,our_features,feature_set,
msgdata,gossipd_init,id,node_id,
msgdata,gossipd_init,dev_gossip_time,?u32,
msgdata,gossipd_init,dev_fast_gossip,bool,
msgdata,gossipd_init,dev_fast_gossip_prune,bool,
msgdata,gossipd_init,autoconnect_seeker_peers,u32,
@@ -27,10 +26,6 @@ msgdata,gossipd_init_nannounce,nannounce,u8,len
msgtype,gossipd_init_reply,3100
# In developer mode, we can mess with time.
msgtype,gossipd_dev_set_time,3001
msgdata,gossipd_dev_set_time,dev_gossip_time,u32,
# Gossipd->master get this tx output please.
msgtype,gossipd_get_txout,3018
msgdata,gossipd_get_txout,short_channel_id,short_channel_id,
1 #include <common/cryptomsg.h>
9 msgdata,gossipd_init,our_features,feature_set,
10 msgdata,gossipd_init,id,node_id,
11 msgdata,gossipd_init,dev_gossip_time,?u32, msgdata,gossipd_init,dev_fast_gossip,bool,
msgdata,gossipd_init,dev_fast_gossip,bool,
12 msgdata,gossipd_init,dev_fast_gossip_prune,bool,
13 msgdata,gossipd_init,autoconnect_seeker_peers,u32,
14 # Gossipd tells us all our public channel_updates before init_reply.
26 msgdata,gossipd_dev_set_time,dev_gossip_time,u32, msgdata,gossipd_get_txout,short_channel_id,short_channel_id,
27 # Gossipd->master get this tx output please. # master->gossipd here is the output, or empty if none.
28 msgtype,gossipd_get_txout,3018 msgtype,gossipd_get_txout_reply,3118
msgdata,gossipd_get_txout,short_channel_id,short_channel_id,
# master->gossipd here is the output, or empty if none.
msgtype,gossipd_get_txout_reply,3118
msgdata,gossipd_get_txout_reply,short_channel_id,short_channel_id,
29 msgdata,gossipd_get_txout_reply,satoshis,amount_sat, msgdata,gossipd_get_txout_reply,short_channel_id,short_channel_id,
30 msgdata,gossipd_get_txout_reply,len,u16, msgdata,gossipd_get_txout_reply,satoshis,amount_sat,
31 msgdata,gossipd_get_txout_reply,outscript,u8,len msgdata,gossipd_get_txout_reply,len,u16,

View File

@@ -357,7 +357,7 @@ static bool channel_already_dying(const struct chan_dying dying_channels[],
/* Every half a week we look for dead channels (faster in dev) */
static void prune_network(struct gossmap_manage *gm)
{
u64 now = gossip_time_now(gm->daemon).ts.tv_sec;
u64 now = time_now().ts.tv_sec;
/* Anything below this highwater mark ought to be pruned */
const s64 highwater = now - GOSSIP_PRUNE_INTERVAL(gm->daemon->dev_fast_gossip_prune);
const struct gossmap_node *me;

View File

@@ -192,7 +192,6 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
case WIRE_GOSSIPD_GET_TXOUT_REPLY:
case WIRE_GOSSIPD_OUTPOINTS_SPENT:
case WIRE_GOSSIPD_DEV_MEMLEAK:
case WIRE_GOSSIPD_DEV_SET_TIME:
case WIRE_GOSSIPD_NEW_BLOCKHEIGHT:
case WIRE_GOSSIPD_ADDGOSSIP:
/* This is a reply, so never gets through to here. */
@@ -319,7 +318,6 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
chainparams,
ld->our_features,
&ld->our_nodeid,
ld->dev_gossip_time ? &ld->dev_gossip_time: NULL,
ld->dev_fast_gossip,
ld->dev_fast_gossip_prune,
ld->autoconnect_seeker_peers);
@@ -488,29 +486,3 @@ static const struct json_command dev_set_max_scids_encode_size = {
.dev_only = true,
};
AUTODATA(json_command, &dev_set_max_scids_encode_size);
static struct command_result *json_dev_gossip_set_time(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
{
u8 *msg;
u32 *time;
if (!param(cmd, buffer, params,
p_req("time", param_number, &time),
NULL))
return command_param_failed();
msg = towire_gossipd_dev_set_time(NULL, *time);
subd_send_msg(cmd->ld->gossip, take(msg));
return command_success(cmd, json_stream_success(cmd));
}
static const struct json_command dev_gossip_set_time = {
"dev-gossip-set-time",
json_dev_gossip_set_time,
.dev_only = true,
};
AUTODATA(json_command, &dev_gossip_set_time);

View File

@@ -125,7 +125,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->dev_disconnect_fd = -1;
ld->dev_subdaemon_fail = false;
ld->dev_allow_localhost = false;
ld->dev_gossip_time = 0;
ld->dev_fast_gossip = false;
ld->dev_fast_gossip_prune = false;
ld->dev_throttle_gossip = false;

View File

@@ -305,9 +305,6 @@ struct lightningd {
/* Allow and accept localhost node_announcement addresses */
bool dev_allow_localhost;
/* Timestamp to use for gossipd, iff non-zero */
u32 dev_gossip_time;
/* Speedup gossip propagation, for testing. */
bool dev_fast_gossip;
bool dev_fast_gossip_prune;

View File

@@ -824,10 +824,6 @@ static void dev_register_opts(struct lightningd *ld)
opt_set_bool,
&ld->dev_fast_gossip_prune,
"Make gossip pruning 120 seconds");
clnopt_witharg("--dev-gossip-time", OPT_DEV|OPT_SHOWINT,
opt_set_u32, opt_show_u32,
&ld->dev_gossip_time,
"UNIX time to override gossipd to use.");
clnopt_witharg("--dev-force-privkey", OPT_DEV,
opt_force_privkey, NULL, ld,
"Force HSM to use this as node private key");