Commit graph

490 commits

Author SHA1 Message Date
ziggieXXX
2aec8f3380
Merge pull request #10485 from ziggie1984/migration-kvdb-sql-payments-part1
payments: kv-to-sql migration (tests + wiring)
2026-03-02 10:29:46 +01:00
ziggie
932fbc33f0
graph/db/migration1: fix defer commit/rollback in test tx executor
The defer closure checked a local err variable for commit/rollback
decisions, but err remained nil after a successful BeginTx. When
txBody failed, the error was returned directly without assigning to
err, so the defer always committed instead of rolling back.

Additionally, since err was not a named return value, the defer's
Commit error assignment was silently swallowed.

Replace the error-prone defer pattern with explicit rollback on
txBody failure and a direct Commit return.
2026-02-25 18:52:34 +01:00
Elle Mouton
262e9208b9
graphdb: thread topology update context 2026-02-25 16:11:47 +02:00
Elle Mouton
0bb0d66952
graphdb: pass context to GraphSession 2026-02-25 16:11:46 +02:00
Elle Mouton
8722a96a4e
graphdb: pass context to IsClosedScid 2026-02-25 16:11:46 +02:00
Elle Mouton
4dcaf1c16a
graphdb: pass context to PutClosedScid 2026-02-25 16:11:46 +02:00
Elle Mouton
68c5206017
graphdb: pass context to AddEdgeProof 2026-02-25 16:11:46 +02:00
Elle Mouton
3dc2efd7f3
graphdb: pass context to DisconnectBlockAtHeight 2026-02-25 16:11:46 +02:00
Elle Mouton
a31c86b0ee
graphdb: pass context to PruneTip 2026-02-25 16:11:46 +02:00
Elle Mouton
9f855175d5
graphdb: pass context to ChannelView 2026-02-25 16:11:46 +02:00
Elle Mouton
7dbaa691c4
graphdb: pass context to PruneGraph 2026-02-25 16:11:46 +02:00
Elle Mouton
13668ce45f
graphdb: pass context to PruneGraphNodes 2026-02-25 16:11:46 +02:00
Elle Mouton
072244ee18
graphdb: pass context to FilterKnownChanIDs 2026-02-25 16:11:46 +02:00
Elle Mouton
46d37a691f
graphdb: pass context to FetchChanInfos 2026-02-25 16:11:46 +02:00
Elle Mouton
f62ea62cfe
graphdb: pass context to IsPublicNode 2026-02-25 16:11:42 +02:00
Elle Mouton
397330cbdb
graphdb: pass context to ChannelID 2026-02-25 16:11:29 +02:00
Elle Mouton
3079c07afb
graphdb: pass context to HasChannelEdge 2026-02-25 16:11:29 +02:00
Elle Mouton
87ed09a829
graphdb: pass context to HasV1ChannelEdge 2026-02-25 16:11:29 +02:00
Elle Mouton
1d4c6aadb4
graph/db: thread context through FetchChannelEdgesByOutpoint 2026-02-25 16:11:29 +02:00
Elle Mouton
6bbb9a32fc
graph/db: thread context through FetchChannelEdgesByID 2026-02-25 16:11:25 +02:00
Elle Mouton
acdef84d30
graph/db: thread context through DeleteChannelEdges 2026-02-25 15:33:59 +02:00
Elle Mouton
37cc6b29d9
graph/db: thread context through NumZombies 2026-02-25 15:33:34 +02:00
Elle Mouton
f98905ae99
graph/db: thread context through IsZombieEdge 2026-02-25 15:33:34 +02:00
Elle Mouton
8a96e5f3d2
graph/db: thread context through MarkEdgeLive 2026-02-25 15:33:34 +02:00
Elle Mouton
c270367071
graph/db: thread context through MarkEdgeZombie 2026-02-25 15:33:34 +02:00
Elle Mouton
bb38aa8922
graph/db: thread context through FilterChannelRange 2026-02-25 15:33:34 +02:00
Elle Mouton
e8e714f6a3
graph/db: thread context through ForEachChannelCacheable 2026-02-25 15:33:34 +02:00
Elle Mouton
dc9dae8dd6
graph/db: thread context through ChanUpdatesInHorizon 2026-02-25 15:33:34 +02:00
Elle Mouton
6ccf93c2c9
graph/db: thread context through ForEachNodeDirectedChannel 2026-02-25 15:33:34 +02:00
Elle Mouton
2f0d2962dd
graph/db: thread context through NodeUpdatesInHorizon 2026-02-25 15:33:34 +02:00
Elle Mouton
0597250ae4
graph/db: thread context through DisabledChannelIDs 2026-02-25 15:33:33 +02:00
Elle Mouton
b1873e63ec
graph/db: thread context through FetchNodeFeatures 2026-02-25 15:32:05 +02:00
Elle Mouton
160c2a9f68
graph/db tests: make compareEdgePolicies assert internally
Convert compareEdgePolicies into a test helper that accepts a
testing handle and performs assertions directly.

Update call sites to invoke the helper instead of threading errors
into immediate require.NoError checks.
2026-02-25 11:34:31 +02:00
Elle Mouton
ceb939ebb1
graph/tests: make createChannelEdge assert internally
Update createChannelEdge to take a testing handle, mark itself as a
helper, and call require.NoError for funding script generation.

All call sites now consume only returned values and no longer plumb
an immediately-asserted error value.
2026-02-25 11:34:05 +02:00
Elle Mouton
963975135c
graph/tests: make randEdgePolicy assert internally
Update randEdgePolicy to take a testing handle, mark itself as a
helper, and assert internal packing errors directly with require.

Call sites now receive only the policy value without plumbing an
error through immediate require.NoError checks.
2026-02-25 11:32:04 +02:00
Elle Mouton
8dfe747c02
graph: migrate tests from Fatal to require helpers
Replace remaining fatal-style assertions in graph package tests with
direct testify/require helpers. This simplifies control flow and makes
test intent clearer by using NoError, True/False, Len, Empty, and
Equal/EqualValues assertions.

Also remove FailNow-style patterns in favor of specific assertion
helpers.
2026-02-25 11:31:28 +02:00
Elle Mouton
f8899dd324
graph/db: migrate tests from Fatal to require helpers
Replace remaining fatal-style assertions in graph/db tests with direct
testify/require helpers. This simplifies control flow and reduces
indentation by using NoError, True/False, Equal, Len, Empty, and Nil
assertions directly.
2026-02-25 11:14:55 +02:00
Elle Mouton
7c7a0ae13d
graph/db: fetch policy version in cache paginated query
The ListChannelsWithPoliciesForCachePaginated query was missing the
policy version column, causing extractChannelPolicies to hardcode
lnwire.GossipVersion1 for that row type. Add cp1.version and
cp2.version to the query and use the fetched values instead.
2026-02-20 09:28:13 +02:00
Elle Mouton
acb3240d3d
graph/db: version fetch chan infos
Add a gossip version parameter to FetchChanInfos in the Store interface
and both KV/SQL implementations. Update the graph builder caller and
refactor related tests.
2026-02-20 09:28:13 +02:00
Elle Mouton
769d6260f5
graph/db: version highest chan id
Add a gossip version parameter to HighestChanID in the Store interface
and both KV/SQL implementations. Update callers in the discovery
ChanSeries and server bootstrap code.
2026-02-20 09:28:13 +02:00
Elle Mouton
95d6af12d4
graph/db: version batched edge and cache node channel tests
Convert testBatchedAddChannelEdge and testGraphCacheForEachNodeChannel
to run against both v1 and v2 gossip versions.
2026-02-20 09:19:24 +02:00
Elle Mouton
fc19a24d07
graph/db: version disabled channel IDs
Add a gossip version parameter to DisabledChannelIDs in the Store
interface and both implementations. Add a new version-filtered SQL
query and update the builder caller.
2026-02-20 09:19:23 +02:00
Elle Mouton
672b999d22
graph/db: version edge info and policy update tests
Convert testEdgeInfoUpdates and testBatchedUpdateEdgePolicy to run
against both v1 and v2 gossip versions, exercising the versioned
Store methods added in prior commits.
2026-02-20 09:19:23 +02:00
Elle Mouton
28fe3585ac
graph/db: version ChannelID lookup
Add a gossip version parameter to the ChannelID method (outpoint to
short channel ID lookup) in the Store interface and both KV/SQL
implementations. Update the VersionedGraph wrapper and tests.
2026-02-20 09:19:22 +02:00
Elle Mouton
2f6cc185a7
graph/db: version createChannelEdge
Refactor the createChannelEdge test helper to be version-aware,
supporting both v1 and v2 channel and policy creation. This prepares
the test infrastructure for subsequent commits that version individual
Store methods.
2026-02-20 09:19:20 +02:00
Elle Mouton
0b1a1e3dc5
graph/db: version ForEachNodeDirectedChannel and cacheable traversal
Add a gossip version parameter to ForEachNodeDirectedChannel on the
Store interface and both DB implementations (KVStore, SQLStore). The
NodeTraverser and routing.Graph interfaces remain unversioned since
pathfinding operates on the merged cross-version cache view.

The cache population in populateCache is updated in the same commit
because it is logically atomic with the versioning changes: the graph
cache is the unversioned, merged view used by pathfinding, so it must
be populated with data from all gossip versions. Without this change,
only v1 data would be loaded into the cache, making v2 nodes and
channels invisible to pathfinding.
2026-02-20 08:50:46 +02:00
Elle Mouton
f5c91691bc
graph/db: version cacheable iteration methods
Add gossip version parameters to ForEachNodeCacheable and
ForEachChannelCacheable in the Store interface and both implementations.

Thread the version through SQL helpers and update call sites/tests
accordingly.
2026-02-20 08:50:43 +02:00
Elle Mouton
d48a16036d
graph/db: version fillTestGraph test helper
Make fillTestGraph version-aware and update its call sites to pass an
explicit gossip version (currently v1 at these call sites).

This is a test-helper refactor only; cacheable-iteration API versioning
is handled in the next commit.
2026-02-20 08:48:42 +02:00
Elle Mouton
898e4ef854
graph/db: add gossip version aliases
Introduce gossipV1 and gossipV2 package-level aliases in sql_store.go
to reduce verbosity in version switch statements. Leave hard-coded
v1/v2 call sites untouched so remaining upgrades are obvious.

In other words, it is now easy to see where our remaining work in the
sql_store.go file is by just searching for instances of
`lnwire.GossipVersion1`.
2026-02-20 08:46:59 +02:00
Elle Mouton
3ea2423f25
graph/db: version ForEachSourceNodeChannel
Add a gossip version parameter to ForEachSourceNodeChannel in the Store
interface and both KV/SQL implementations. The VersionedGraph wrapper
delegates with its baked-in version. Convert the
testAddChannelEdgeShellNodes and testForEachSourceNodeChannel tests to
run against both v1 and v2 gossip versions.
2026-02-20 08:46:58 +02:00