gossipd: don't gather dying channels during compaction.
What changed, and why it matters
This commit removes dead code in the Lightning node's gossip subsystem. During startup compaction of the gossip database, the code used to collect a list of 'dying channels' but never actually used that list. The change simply stops collecting that unused list. There is no obvious security problem being fixed here; it appears to be a minor cleanup that may also avoid a small memory waste or confusion during startup.
Treat as routine cleanup. No urgent action required. Reviewers may verify that no other caller relied on the removed `dying` parameter, and that `chan_dying` markers are still handled correctly elsewhere in gossipd.
Security signals we found
Removal of unused 'dying channels' collection during gossip store compaction
No input validation, memory safety, or cryptographic changes visible in diff
No mention of security, CVE, bug, crash, or exploit in commit message
Evidence from the diff
The patch removes the dying output parameter from gossip_store_compact() and gossip_store_new(). Previously, when compacting the gossip_store, WIRE_GOSSIP_STORE_CHAN_DYING records were parsed into a struct chan_dying array and returned to the caller. In gossmap_manage.c, setup_gossmap() immediately freed that array with a ‘FIXME: Remove’ comment. The commit deletes the parsing/return path and the now-unused chan_dying local. This is code cleanup of an unneeded data flow, not a vulnerability fix.
Changed components
gossipd/gossip_store.cgossipd/gossip_store.hgossipd/gossmap_manage.cInspect captured patch +5 / −28
diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c
index 2c358bec..92d8d732 100644
--- a/gossipd/gossip_store.c
+++ b/gossipd/gossip_store.c
@@ -199,8 +199,7 @@ static u8 *new_uuid_record(const tal_t *ctx, int fd, u64 *off)
*/
static int gossip_store_compact(struct daemon *daemon,
u64 *total_len,
- bool *populated,
- struct chan_dying **dying)
+ bool *populated)
{
size_t cannounces = 0, cupdates = 0, nannounces = 0, deleted = 0;
int old_fd, new_fd;
@@ -324,20 +323,6 @@ static int gossip_store_compact(struct daemon *daemon,
case WIRE_CHANNEL_ANNOUNCEMENT:
cannounces++;
break;
- case WIRE_GOSSIP_STORE_CHAN_DYING: {
- struct chan_dying cd;
-
- if (!fromwire_gossip_store_chan_dying(msg,
- &cd.scid,
- &cd.deadline)) {
- bad = "Bad gossip_store_chan_dying";
- goto badmsg;
- }
- /* By convention, these offsets are *after* header */
- cd.gossmap_offset = *total_len + sizeof(hdr);
- tal_arr_expand(dying, cd);
- break;
- }
case WIRE_CHANNEL_UPDATE:
cupdates++;
break;
@@ -421,14 +406,12 @@ void gossip_store_corrupt(void)
struct gossip_store *gossip_store_new(const tal_t *ctx,
struct daemon *daemon,
- bool *populated,
- struct chan_dying **dying)
+ bool *populated)
{
struct gossip_store *gs = tal(ctx, struct gossip_store);
gs->daemon = daemon;
- *dying = tal_arr(ctx, struct chan_dying, 0);
- gs->fd = gossip_store_compact(daemon, &gs->len, populated, dying);
+ gs->fd = gossip_store_compact(daemon, &gs->len, populated);
if (gs->fd < 0)
return tal_free(gs);
tal_add_destructor(gs, gossip_store_destroy);
diff --git a/gossipd/gossip_store.h b/gossipd/gossip_store.h
index 853b772d..5d839169 100644
--- a/gossipd/gossip_store.h
+++ b/gossipd/gossip_store.h
@@ -27,14 +27,12 @@ struct chan_dying {
* @ctx: the context to allocate from
* @daemon: the daemon context
* @populated: set to false if store is empty/obviously partial.
- * @dying: an array of channels we found dying markers for.
*
* Returns NULL on error.
*/
struct gossip_store *gossip_store_new(const tal_t *ctx,
struct daemon *daemon,
- bool *populated,
- struct chan_dying **dying);
+ bool *populated);
/**
* Move the old gossip store out the way. Log a broken message about it.
diff --git a/gossipd/gossmap_manage.c b/gossipd/gossmap_manage.c
index 6260673a..5aa97c96 100644
--- a/gossipd/gossmap_manage.c
+++ b/gossipd/gossmap_manage.c
@@ -459,7 +459,6 @@ static bool setup_gossmap(struct gossmap_manage *gm,
struct daemon *daemon)
{
u64 expected_len;
- struct chan_dying *dying = NULL;
gm->dying_channels = tal_arr(gm, struct chan_dying, 0);
@@ -467,13 +466,10 @@ static bool setup_gossmap(struct gossmap_manage *gm,
* necessary */
gm->gs = gossip_store_new(gm,
daemon,
- &gm->gossip_store_populated,
- &dying);
+ &gm->gossip_store_populated);
if (!gm->gs)
return false;
- /* FIXME: Remove */
- tal_free(dying);
expected_len = gossip_store_len_written(gm->gs);
/* This actually loads it into memory, with strict checks. */
Why this scored 11/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.