Commit Graph
20254 Commits
Author SHA1 Message Date
ziggie bdea68bebf sqldb: add queries for deleting a payment and attempts 2026-02-25 08:02:08 +01:00
ziggie 27071acb6b sqldb: Change payment_intent relationship to payment table
Previously a one(intent)-to-many(payment) relationship it is now
changed to a one-to-one relationship because a payment request
only can have 1 payment related to it. Looking into the future
with BOLT12 offers, the fetched invoice from the offer could be
stored here as well and the relationship would still hold.
2026-02-25 08:02:08 +01:00
ziggie f8241748a1 paymentsdb: enhance some godoc function descriptions 2026-02-25 08:02:08 +01:00
ziggie 4c5eaad606 docs: add release-notes 2026-02-25 08:02:08 +01:00
ziggie 8aae9ffc2c paymentsdb: implement FetchPayment for sql backend 2026-02-25 08:02:08 +01:00
ziggie e8fe45fe65 paymentsdb: implement QueryPayments for sql backend 2026-02-25 08:02:08 +01:00
ziggie eeca189b87 paymentsdb: add new internal error 2026-02-25 08:02:07 +01:00
ziggie 18e7768837 multi: add relevant queries for QueryPayments implemenation 2026-02-25 08:02:04 +01:00
ziggie e7a3096621 sqldb: add index and comment to payment tables 2026-02-25 08:01:16 +01:00
ziggie b6a05f7951 docs: add release-notes 2026-02-25 08:01:15 +01:00
ziggie 8c7b2367e5 lnd: make the payment schema migration available for testing
We allow the migration of the payment schema to be applied when
the test_native_sql is active to make sure the tables are properly
contructed.
2026-02-25 08:01:15 +01:00
ziggie dd585a821b sqldb: add payment sql tables
This does not include duplicate payments yet. They will be added
when the migration code is introduced for payments.
2026-02-25 08:01:15 +01:00
ziggie 93626822f7 lnd+paymentsdb: introduce harness for the payment sql backend
We prepare the code for the sql payment backend. However no
payment db interface method for the sql backend is implemented
yet. This will be done in the following commits. They currently
use the embedded KVStore to satify the build environment.
2026-02-25 08:01:14 +01:00
Olaoluwa Osuntokun 0b00c66231 Merge pull request #10601 from ziggie1984/invoice-filter-index-optimization
invoices/sql_store: replace catch-all FilterInvoices with targeted index-friendly queries
2026-02-24 16:34:27 -08:00
Yong 344af33ac7 Merge pull request #10557 from Liongrass/master
Remove redundant documentation from /docs
2026-02-24 21:17:22 +08:00
ziggieXXX c81d69e56a Merge pull request #10586 from GeorgeTsagk/add-george-key
scripts: add gpg key for georgetsagk
2026-02-23 16:01:52 +01:00
George Tsagkarelis 05d1df6de1 scripts: add gpg key for georgetsagk 2026-02-23 14:40:07 +01:00
Elle dd65ba2b01 Merge pull request #10543 from bitromortac/2602-channel-update-events
rpc: add channel updates to SubscribeChannelEvents
2026-02-23 13:09:36 +02:00
ziggie 1e5e6f27ef docs: add release notes for invoice SQL query performance improvements 2026-02-21 17:05:44 +01:00
ziggie d26bf84843 invoices/sql_store: add tests for targeted invoice query variants
Add testFetchPendingInvoicesAccepted to explicitly verify the state
filtering behaviour of FetchPendingInvoices across all four contract
states:

  ContractOpen     (state 0) – must be returned
  ContractAccepted (state 3) – must be returned
  ContractSettled  (state 1) – must be excluded
  ContractCanceled (state 2) – must be excluded

This directly exercises the `state IN (0, 3)` predicate introduced in
the FetchPendingInvoices SQL query and addresses the review request for
explicit test coverage of the new targeted query variants. The test
runs against the KV, SQLite, and Postgres backends.
2026-02-21 17:05:44 +01:00
ziggie 9becdfa8a3 sqldb/sqlc: remove deprecated FilterInvoices query
All call sites have been migrated to the targeted replacement queries
in the previous commit. Remove FilterInvoices and its associated
params struct from the SQL source and regenerate.
2026-02-21 16:58:31 +01:00
ziggie 774ebaf126 invoices/sql_store: switch to targeted queries, default timestamp bounds
Replace all four FilterInvoices call sites with the focused queries
introduced in the previous commit:

  FetchPendingInvoices   → FetchPendingInvoices
  InvoicesSettledSince   → FilterInvoicesBySettleIndex
  InvoicesAddedSince     → FilterInvoicesByAddIndex
  QueryInvoices          → FilterInvoicesForward / FilterInvoicesReverse

The first three are straight 1:1 swaps — the new params structs carry
only the fields that are actually used, and the removed fields (Reverse,
PendingOnly, unused index bounds) were always left at their zero values.

QueryInvoices is restructured more substantially. The forward/reverse
branch now selects between FilterInvoicesForward and
FilterInvoicesReverse, each of which takes a concrete id bound that is
always set:

  forward: AddIndexGet = IndexOffset + 1   (≥ 1 when IndexOffset = 0)
  reverse: AddIndexLet = IndexOffset - 1   (or MaxInt64 when offset = 0)

Timestamp parameters are changed from nullable (sql.NullTime with
OR-based SQL fallbacks) to always-on Go-side defaults, consistent with
the approach used by the payments query:

  createdAfter  → time.Unix(0, 0).UTC()          (epoch, before any invoice)
  createdBefore → time.Date(9999, 12, 31, …)     (far future, no upper cap)

This ensures the planner always sees plain range predicates on
created_at and can use the invoices_created_at_idx index.

The SQLInvoiceQueries interface is updated to expose the five new
methods and drop FilterInvoices.
2026-02-21 16:57:08 +01:00
ziggie 866efbd7fb sqldb/sqlc: add targeted invoice queries
The existing FilterInvoices query uses optional parameters via the
pattern `(col >= param OR param IS NULL)` for every filter. SQLite
cannot use indexes with this pattern because the OR prevents the query
planner from determining at plan time which rows satisfy the condition,
resulting in a full table scan regardless of the available indexes
(invoices_state_idx, invoices_settle_index_idx, and the primary-key
clustered index on id).

Additionally, the conditional ORDER BY:

  ORDER BY CASE WHEN reverse = FALSE ... THEN id ELSE NULL END ASC,
           CASE WHEN reverse = TRUE  ... THEN id ELSE NULL END DESC

prevents the planner from using the index ordering and forces an
explicit sort.

Add five focused replacements, each with a plain sargable predicate and
a direct ORDER BY so the planner can always choose an index scan:

  - FetchPendingInvoices:        WHERE state IN (0, 3)
  - FilterInvoicesBySettleIndex: WHERE settle_index >= $1
  - FilterInvoicesByAddIndex:    WHERE id >= $1
  - FilterInvoicesForward:       WHERE id >= $1 ... ORDER BY id ASC
  - FilterInvoicesReverse:       WHERE id <= $1 ... ORDER BY id DESC

FilterInvoicesForward and FilterInvoicesReverse accept non-nullable
timestamp parameters (created_after, created_before) so the planner
always sees plain range predicates on created_at. Callers supply
Go-side defaults when no date filter is needed, following the same
convention already used by the payments query.

FilterInvoices is kept in this commit so all existing call sites
continue to compile. It will be removed once all callers have been
migrated.
2026-02-21 16:09:03 +01:00
bitromortac 3a00ed4a8d docs: update release notes 2026-02-20 10:47:48 +01:00
bitromortac fa5722355f itest: test channel update subscription 2026-02-20 10:47:04 +01:00
bitromortac 10e8a69cec lnd: handle channel update events in SubscribeChannelEvents 2026-02-20 10:47:04 +01:00
bitromortac 4f22a5130d proto: add ChannelCommitUpdate to channel event updates 2026-02-20 10:47:03 +01:00
bitromortac 4701f00cfd htlcswitch: let link notify on remote commit sig 2026-02-20 10:43:52 +01:00
bitromortac 0f1472536c peer+htlcswitch: inject notification endpoint 2026-02-20 10:43:52 +01:00
bitromortac a3d87f16b9 channelnotifier: let notifier take channel updates 2026-02-20 10:43:52 +01:00
bitromortac 19860bb9f6 lnwallet: expose channel state
We create a deep copy of the channel state as we want to later expose
the data structure to the rpc, which already has helper methods to
marshal this representation to the rpc representation.
2026-02-20 10:43:52 +01:00
Elle 78b2036f39 Merge pull request #10572 from ellemouton/g175-db-7
[g175] graph/db: add gossip-version plumbing for core graph APIs
2026-02-20 10:26:06 +02:00
Elle Mouton 09e20dc7fa docs: update release notes 2026-02-20 09:28:13 +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
Elle Mouton 2aaa52adf9 graph/db: version channelCache by gossip version
Add a channelCacheKey struct keyed by {GossipVersion, chanID}, matching
the pattern already used by rejectCache. This prevents v1 and v2
channel data from colliding in the shared cache.

All callers in KVStore (always GossipVersion1) and SQLStore (version
from context) are updated to pass the version parameter.

This will be needed for later on when we update methods that use this
cache to be versioned (like ChannelUpdatesInHorizon).
2026-02-20 08:46:57 +02:00
Olaoluwa Osuntokun 14a01eb84f Merge pull request #10577 from ellemouton/elle-cheaper-dedupe-model
ci: use haiku model for issue dedupe workflow
2026-02-17 17:28:19 -08:00
Olaoluwa Osuntokun ba4778321d Merge pull request #10576 from bhandras/bh/ephemeral-gocache-check-each-commit
scripts: use ephemeral gocache in check-each-commit
2026-02-17 17:28:06 -08:00
Olaoluwa Osuntokun c11c192b3f Merge pull request #10142 from Roasbeef/actor-mailbox-v2
actor: add new abstraction over mailbox
2026-02-17 17:27:45 -08:00