From c270367071a8c2e10bd73d3d2586b0f21bfd7d48 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 25 Feb 2026 09:41:18 +0200 Subject: [PATCH] graph/db: thread context through MarkEdgeZombie --- graph/builder.go | 4 +++- graph/db/graph.go | 4 ++-- graph/db/graph_test.go | 13 +++++++++---- graph/db/interfaces.go | 2 +- graph/db/kv_store.go | 2 +- graph/db/sql_store.go | 4 +--- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/graph/builder.go b/graph/builder.go index 25dfdf062..c72b60733 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -913,7 +913,9 @@ func (b *Builder) MarkZombieEdge(chanID uint64) error { // so we don't continue to request it. We use the "zero key" for both // node pubkeys so this edge can't be resurrected. var zeroKey [33]byte - err := b.cfg.Graph.MarkEdgeZombie(chanID, zeroKey, zeroKey) + err := b.cfg.Graph.MarkEdgeZombie( + context.TODO(), chanID, zeroKey, zeroKey, + ) if err != nil { return fmt.Errorf("unable to mark spent chan(id=%v) as a "+ "zombie: %w", chanID, err) diff --git a/graph/db/graph.go b/graph/db/graph.go index bd4cfdc85..3cc08dad8 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -564,10 +564,10 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo, // MarkEdgeZombie attempts to mark a channel identified by its channel ID as a // zombie. This method is used on an ad-hoc basis, when channels need to be // marked as zombies outside the normal pruning cycle. -func (c *ChannelGraph) MarkEdgeZombie(chanID uint64, +func (c *ChannelGraph) MarkEdgeZombie(ctx context.Context, chanID uint64, pubKey1, pubKey2 [33]byte) error { - err := c.db.MarkEdgeZombie(chanID, pubKey1, pubKey2) + err := c.db.MarkEdgeZombie(ctx, chanID, pubKey1, pubKey2) if err != nil { return err } diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 042ed7881..159f8b6f1 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -2929,6 +2929,7 @@ func TestChanUpdatesInHorizonBoundaryConditions(t *testing.T) { // FilterKnownChanIDs is tested in TestFilterKnownChanIDs. func TestFilterKnownChanIDsZombieRevival(t *testing.T) { t.Parallel() + ctx := t.Context() graph := MakeTestGraph(t) @@ -2946,9 +2947,13 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) { } // Mark channel 1 and 2 as zombies. - err := graph.MarkEdgeZombie(scid1.ToUint64(), [33]byte{}, [33]byte{}) + err := graph.MarkEdgeZombie( + ctx, scid1.ToUint64(), [33]byte{}, [33]byte{}, + ) require.NoError(t, err) - err = graph.MarkEdgeZombie(scid2.ToUint64(), [33]byte{}, [33]byte{}) + err = graph.MarkEdgeZombie( + ctx, scid2.ToUint64(), [33]byte{}, [33]byte{}, + ) require.NoError(t, err) require.True(t, isZombie(scid1)) @@ -3299,7 +3304,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) { } return graph.MarkEdgeZombie( - channel.id.ToUint64(), + ctx, channel.id.ToUint64(), node1.PubKeyBytes, node2.PubKeyBytes, ) @@ -4592,7 +4597,7 @@ func TestGraphZombieIndex(t *testing.T) { // If we mark the edge as a zombie manually, then it should show up as // being a zombie once again. err = graph.MarkEdgeZombie( - edge.ChannelID, node1.PubKeyBytes, node2.PubKeyBytes, + ctx, edge.ChannelID, node1.PubKeyBytes, node2.PubKeyBytes, ) require.NoError(t, err, "unable to mark edge as zombie") diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index db2e511f5..9f3cebec5 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -324,7 +324,7 @@ type Store interface { //nolint:interfacebloat // MarkEdgeZombie attempts to mark a channel identified by its channel // ID as a zombie. This method is used on an ad-hoc basis, when channels // need to be marked as zombies outside the normal pruning cycle. - MarkEdgeZombie(chanID uint64, + MarkEdgeZombie(ctx context.Context, chanID uint64, pubKey1, pubKey2 [33]byte) error // MarkEdgeLive clears an edge from our zombie index, deeming it as diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 2a8334dca..15140c91a 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -4243,7 +4243,7 @@ func (c *KVStore) ChannelView() ([]EdgePoint, error) { // MarkEdgeZombie attempts to mark a channel identified by its channel ID as a // zombie. This method is used on an ad-hoc basis, when channels need to be // marked as zombies outside the normal pruning cycle. -func (c *KVStore) MarkEdgeZombie(chanID uint64, +func (c *KVStore) MarkEdgeZombie(_ context.Context, chanID uint64, pubKey1, pubKey2 [33]byte) error { c.cacheMu.Lock() diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 1b2f28635..9cab515b6 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -1783,11 +1783,9 @@ func (s *SQLStore) FilterChannelRange(ctx context.Context, startHeight, // marked as zombies outside the normal pruning cycle. // // NOTE: part of the Store interface. -func (s *SQLStore) MarkEdgeZombie(chanID uint64, +func (s *SQLStore) MarkEdgeZombie(ctx context.Context, chanID uint64, pubKey1, pubKey2 [33]byte) error { - ctx := context.TODO() - s.cacheMu.Lock() defer s.cacheMu.Unlock()