Skip to content

[13] graph/db: SQL-ize the zombie index #9937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/release-notes-0.20.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ circuit. The indices are only available for forwarding events saved after v0.20.
* [4](https://github.com/lightningnetwork/lnd/pull/9931)
* [5](https://github.com/lightningnetwork/lnd/pull/9935)
* [6](https://github.com/lightningnetwork/lnd/pull/9936)
* [7](https://github.com/lightningnetwork/lnd/pull/9937)

## RPC Updates

Expand Down
2 changes: 1 addition & 1 deletion graph/db/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3811,7 +3811,7 @@ func TestGraphZombieIndex(t *testing.T) {
ctx := context.Background()

// We'll start by creating our test graph along with a test edge.
graph := MakeTestGraph(t)
graph := MakeTestGraphNew(t)

node1 := createTestVertex(t)
node2 := createTestVertex(t)
Expand Down
16 changes: 13 additions & 3 deletions graph/db/kv_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2747,7 +2747,17 @@ func (c *KVStore) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex,

nodeKey1, nodeKey2 := edgeInfo.NodeKey1Bytes, edgeInfo.NodeKey2Bytes
if strictZombie {
nodeKey1, nodeKey2 = makeZombiePubkeys(&edgeInfo, edge1, edge2)
var e1UpdateTime, e2UpdateTime *time.Time
if edge1 != nil {
e1UpdateTime = &edge1.LastUpdate
}
if edge2 != nil {
e2UpdateTime = &edge2.LastUpdate
}

nodeKey1, nodeKey2 = makeZombiePubkeys(
&edgeInfo, e1UpdateTime, e2UpdateTime,
)
}

return &edgeInfo, markEdgeZombie(
Expand All @@ -2772,7 +2782,7 @@ func (c *KVStore) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex,
// marked with the correct lagging channel since we received an update from only
// one side.
func makeZombiePubkeys(info *models.ChannelEdgeInfo,
e1, e2 *models.ChannelEdgePolicy) ([33]byte, [33]byte) {
e1, e2 *time.Time) ([33]byte, [33]byte) {

switch {
// If we don't have either edge policy, we'll return both pubkeys so
Expand All @@ -2784,7 +2794,7 @@ func makeZombiePubkeys(info *models.ChannelEdgeInfo,
// older, we'll return edge1's pubkey and a blank pubkey for edge2. This
// means that only an update from edge1 will be able to resurrect the
// channel.
case e1 == nil || (e2 != nil && e1.LastUpdate.Before(e2.LastUpdate)):
case e1 == nil || (e2 != nil && e1.Before(*e2)):
return info.NodeKey1Bytes, [33]byte{}

// Otherwise, we're missing edge2 or edge2 is the older side, so we
Expand Down
Loading
Loading