What changed, and why it matters
This change simply passes an existing request context (a standard cancellation/timeout carrier) into a database query that counts 'zombie' channels. It does not fix a crash, bug, or security flaw by itself; it is a code-cleanup and consistency change that lets callers cancel or time out the query properly. There is no indication this was a security patch.
No security action required. Treat as routine code hygiene. If auditing, verify that downstream SQL query timeouts/cancellation behave as expected under the new context, but this is a normal engineering review, not an incident response.
Security signals we found
No security-relevant signal in commit title or message
No mention of vulnerability, CVE, bug bounty, or researcher attribution
Change is API signature refactor (context plumbing)
No bounds checks, input validation, or cryptographic changes
No test additions beyond updating existing call sites to pass t.Context()
Evidence from the diff
The commit threads context.Context through ChannelGraph.NumZombies and the Store interface implementations (KVStore, SQLStore). The SQL implementation previously used context.TODO(), which cannot be cancelled by the caller; now it uses the caller-supplied ctx. The KV implementation accepts the parameter but ignores it because its kvdb.View path does not currently support context cancellation. rpcserver.go’s GetNetworkInfo now passes its gRPC context. This is a maintainability/consistency refactor, not a vulnerability fix.
Changed components
graph/db/graph.gograph/db/interfaces.gograph/db/kv_store.gograph/db/sql_store.gorpcserver.gograph/db/graph_test.goInspect captured patch +7 / −8
diff --git a/graph/db/graph.go b/graph/db/graph.go
index b02ef79..8abca82 100644
--- a/graph/db/graph.go
+++ b/graph/db/graph.go
@@ -761,8 +761,8 @@ func (c *ChannelGraph) IsZombieEdge(ctx context.Context,
}
// NumZombies returns the current number of zombie channels in the graph.
-func (c *ChannelGraph) NumZombies() (uint64, error) {
- return c.db.NumZombies()
+func (c *ChannelGraph) NumZombies(ctx context.Context) (uint64, error) {
+ return c.db.NumZombies(ctx)
}
// PutClosedScid stores a SCID for a closed channel in the database.
diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go
index 79a1542..2503f58 100644
--- a/graph/db/graph_test.go
+++ b/graph/db/graph_test.go
@@ -4535,7 +4535,7 @@ func putSerializedPolicy(t *testing.T, db kvdb.Backend, from []byte,
func assertNumZombies(t *testing.T, graph *ChannelGraph, expZombies uint64) {
t.Helper()
- numZombies, err := graph.NumZombies()
+ numZombies, err := graph.NumZombies(t.Context())
require.NoError(t, err, "unable to query number of zombies")
require.Equal(t, expZombies, numZombies)
}
diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go
index 2540ca1..a42836f 100644
--- a/graph/db/interfaces.go
+++ b/graph/db/interfaces.go
@@ -339,7 +339,7 @@ type Store interface { //nolint:interfacebloat
// NumZombies returns the current number of zombie channels in the
// graph.
- NumZombies() (uint64, error)
+ NumZombies(ctx context.Context) (uint64, error)
// PutClosedScid stores a SCID for a closed channel in the database.
// This is so that we can ignore channel announcements that we know to
diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go
index abf0111..98308ae 100644
--- a/graph/db/kv_store.go
+++ b/graph/db/kv_store.go
@@ -4405,7 +4405,7 @@ func isZombieEdge(zombieIndex kvdb.RBucket,
}
// NumZombies returns the current number of zombie channels in the graph.
-func (c *KVStore) NumZombies() (uint64, error) {
+func (c *KVStore) NumZombies(_ context.Context) (uint64, error) {
var numZombies uint64
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
edges := tx.ReadBucket(edgeBucket)
diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go
index 86a0c71..dc8492e 100644
--- a/graph/db/sql_store.go
+++ b/graph/db/sql_store.go
@@ -1912,9 +1912,8 @@ func (s *SQLStore) IsZombieEdge(ctx context.Context, v lnwire.GossipVersion,
// NumZombies returns the current number of zombie channels in the graph.
//
// NOTE: part of the Store interface.
-func (s *SQLStore) NumZombies() (uint64, error) {
+func (s *SQLStore) NumZombies(ctx context.Context) (uint64, error) {
var (
- ctx = context.TODO()
numZombies uint64
)
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
diff --git a/rpcserver.go b/rpcserver.go
index 8cbeb74..f0eecd4 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -7376,7 +7376,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
}
// Query the graph for the current number of zombie channels.
- numZombies, err := graph.NumZombies()
+ numZombies, err := graph.NumZombies(ctx)
if err != nil {
return nil, err
}
Why this scored 18/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.