gossipd: remove --dev-gossip-time setting, we'll use CLN_DEV_SET_TIME.
What changed, and why it matters
This commit removes a developer-only testing option that let operators override the clock used by the gossip subsystem. It is a cleanup/refactoring change, not a security fix. The removed option was only available in developer builds and was being replaced by a more general time-override mechanism (CLN_DEV_SET_TIME).
No security action required. Treat as routine developer-cleanup. If CLN_DEV_SET_TIME is intended to replace this, verify that the new mechanism covers the same test scenarios.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes the –dev-gossip-time command-line option, the dev-gossip-set-time RPC, and the gossipd_dev_set_time wire message. It also removes the dev_gossip_time field from daemon/lightningd state and replaces gossip_time_now() calls with plain time_now(). The functionality is superseded by the global CLN_DEV_SET_TIME facility, so this is a consolidation of developer tooling rather than a vulnerability remediation.
Changed components
gossipdlightningd option handlinglightningd gossip controldeveloper-only RPC commandsInspect captured patch +2 / −91
diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c
index a3661912..629059d2 100644
--- a/gossipd/gossipd.c
+++ b/gossipd/gossipd.c
@@ -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 */
diff --git a/gossipd/gossipd.h b/gossipd/gossipd.h
index 9ee193e5..d558f58f 100644
--- a/gossipd/gossipd.h
+++ b/gossipd/gossipd.h
@@ -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?
*/
diff --git a/gossipd/gossipd_wire.csv b/gossipd/gossipd_wire.csv
index c5868eb7..1721b3ae 100644
--- a/gossipd/gossipd_wire.csv
+++ b/gossipd/gossipd_wire.csv
@@ -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,
diff --git a/gossipd/gossmap_manage.c b/gossipd/gossmap_manage.c
index bf4faee5..b93c091a 100644
--- a/gossipd/gossmap_manage.c
+++ b/gossipd/gossmap_manage.c
@@ -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;
diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c
index 0043de96..0f013b76 100644
--- a/lightningd/gossip_control.c
+++ b/lightningd/gossip_control.c
@@ -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);
diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c
index d2d4e525..7e0bf26c 100644
--- a/lightningd/lightningd.c
+++ b/lightningd/lightningd.c
@@ -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;
diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h
index 6415e659..2d3f028d 100644
--- a/lightningd/lightningd.h
+++ b/lightningd/lightningd.h
@@ -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;
diff --git a/lightningd/options.c b/lightningd/options.c
index 2175d434..02b84877 100644
--- a/lightningd/options.c
+++ b/lightningd/options.c
@@ -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");
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.