Commit Graph
19966 Commits
Author SHA1 Message Date
Elle Mouton cbcb6a4dcf go.mod: update btcec dep
To include the update to the musig2 Session which allows the aggregate
nonce for the session to be registered instead of requiring the
individual nonces to be registered.
2025-12-10 07:14:59 +02:00
Elle bc670fab82 Merge pull request #10396 from ziggie1984/enhance-lsp-heuritic
Enhance Lsp Heuristic when probing a payment
2025-12-09 10:43:43 +02:00
Yong 0a6907d44b Merge pull request #10415 from yyforyongyu/race-test-sql
github: add `unit-race` for sql tests
2025-12-08 22:40:18 +08:00
yyforyongyu 57448a90c8 github: add unit-race for sql tests 2025-12-08 19:31:56 +08:00
Yong d962b146b0 Merge pull request #10420 from ellemouton/removePubKeyCaching
graph: fix various races
2025-12-08 19:31:32 +08:00
Elle Mouton e68bf6c58d docs: add release notes for race condition fixes 2025-12-08 11:57:01 +02:00
Elle Mouton 9f715555c4 graph/db: fix race in DisconnectBlockAtHeight cache access
The DisconnectBlockAtHeight method was modifying the rejectCache and
chanCache without holding the cacheMu lock. This caused races with
other operations that properly held the lock, such as AddChannelEdge
which modifies the caches in its OnCommit callback while the batch
scheduler holds cacheMu.

Fix by acquiring cacheMu before removing channels from the caches.
2025-12-08 11:56:36 +02:00
Elle Mouton 31b3e7424d graph/db/models: fix race conditions in ChannelEdgeInfo
Both NodeKey1 and NodeKey2 methods had the same race condition as the
Node.PubKey method, where concurrent calls could race to write to the
cached fields.

Remove the caching for the same reasons: parsing overhead is minimal
and doesn't justify the complexity and race risk.
2025-12-08 11:56:36 +02:00
Elle Mouton 9906e61774 graph/db/models: fix race condition in Node.PubKey
The PubKey method had a race condition where concurrent calls could
all pass the nil check and race to write to the cached pubKey field.
This is a classic check-then-act race.

Remove the caching entirely to fix the race. The overhead of parsing
a public key is minimal and doesn't justify the added complexity and
race risk of caching.
2025-12-08 11:56:35 +02:00
Yong a76f22da9d Merge pull request #10419 from AbelLykens/patch-2
[docs] Document use-native-sql=true for SQL migration step 2
2025-12-04 19:27:30 +08:00
AbelLykens f811805c65 docs: update sql migration guide 2025-12-04 09:34:58 +00:00
Elle 20473482d4 Merge pull request #10371 from ellemouton/fixSourceNodeSetting
graph/db: fix SetSourceNode no rows error
2025-12-03 15:34:41 +02:00
Elle Mouton 3e0bc6b18c docs: add release note 2025-12-03 13:09:22 +02:00
Elle Mouton c04aa655b9 graph/db: fix SetSourceNode race with lenient upsert
This commit fixes a race condition where multiple goroutines call
SetSourceNode concurrently during startup, causing sql.ErrNoRows
errors. The race occurs when multiple code paths (setSelfNode,
createNewHiddenService, RPC updates) read the same old timestamp,
independently increment it to the same new value (T+1), and race to
write.

The fix uses the new UpsertSourceNode SQL query (without strict
timestamp constraint) instead of UpsertNode. This allows
last-write-wins semantics for our own node, ensuring all parameter
changes persist even when timestamps collide.

Refactored sql_store.go for reusability:
- upsertNodeAncillaryData: common logic for features/addresses/extras
- populateNodeParams: common parameter building with callback pattern
- buildNodeUpsertParams: builds params for strict UpsertNode
- buildSourceNodeUpsertParams: builds params for lenient UpsertSourceNode
- upsertSourceNode: new function using lenient query

Updated TestSetSourceNodeSameTimestamp to verify that concurrent
updates with the same timestamp now succeed and parameter changes
persist.

Fixes the itest error:
"unable to upsert source node: upserting node(...): sql: no rows in
result set"
2025-12-03 13:08:31 +02:00
Elle Mouton 8349a6f84d sqldb: add UpsertSelfNode query
This query is less strict in terms of the latest update timestamp field.
We want to be less strict with our own node data since we always want
our own updates recorded.
2025-12-03 13:08:31 +02:00
Elle Mouton 41615f74a5 graph/db: add test for SetSourceNode same timestamp behavior
This commit adds TestSetSourceNodeSameTimestamp to demonstrate the
current behavior when SetSourceNode is called with the same last update
timestamp. The test reveals a difference between the SQL and bbolt
implementations:

- SQL store returns sql.ErrNoRows when attempting to update with the
  same timestamp, as the upsert query's UPDATE clause requires the new
  timestamp to be strictly greater than the existing one
- bbolt store silently ignores stale updates and returns no error

This behavior is important to document because our own node
announcements may change quickly with the same timestamp, unlike
announcements from other nodes where same timestamp typically means
identical parameters.
2025-12-03 13:08:30 +02:00
Yong 4b1c4998ad Merge pull request #10399 from mohamedawnallah/handle-partial-tls-files
tls_manager: Handle partial TLS files
2025-12-03 18:27:39 +08:00
Mohamed Awnallah 0a6f69dd7e docs: update release notes 2025-12-03 09:13:23 +00:00
Olaoluwa Osuntokun 140248ba9d Merge pull request #10383 from ziggie1984/bugfix/fix-mission-control-startup
routing: allow misson control manager to startup despite errors
2025-12-02 16:19:15 -08:00
ziggie 17b77b64a3 docs: add release-notes for LND 20.1 2025-12-02 20:38:55 +01:00
ziggie f6bc88f348 routing: allow misson control manager to startup despite errors
We now allow the mission control manager to skip over deserializable
errors. We cannot repair this these results but we just skip over
it so we can startup properly.

When fetchAll() encounters entries that fail to deserialize, in
addition to skipping them, now also:

- Delete the corrupted entries from the database
- Remove them from the in-memory keysMap and keys tracking structures

This prevents corrupted entries from:
- Being counted toward maxRecords, which would cause valid entries
  to be pruned prematurely
- Persisting in the database indefinitely
- Causing inaccurate entry counts in startup logs
2025-12-02 20:38:55 +01:00
ziggie de0424eca8 docs: add release-notes for LND 20.1 2025-12-01 18:07:57 +01:00
ziggie 34619d4758 docs: update api documentation for estimateRouteFee 2025-12-01 18:07:56 +01:00
ziggie 0e6bab1730 itest: enhance testEstimateRouteFee with multi-LSP scenarios
This commit enhances the integration test to validate the LSP heuristic
end-to-end with real network topology and payment probing.

Network topology additions:
- Added Frank node as a private destination
- Created multi-LSP test scenario with Bob, Eve, and Dave as LSPs

New test cases:

1. "probe based estimate, public target with public hop hints"
   - Validates Rule 1: public invoice target routes directly
   - Even with public hop hints, direct routing is used
   - Expected: standard single-hop fees

2. "probe based estimate, multiple different public LSPs"
   - Validates multi-LSP worst-case selection
   - Frank has routes through Bob (low fee), Eve (HIGH fee), Dave (medium)
   - Expected: Eve's worst-case fees (most expensive)
   - Tests griefing protection (max 3 LSP probes)
2025-12-01 18:07:56 +01:00
ziggie 79fe67619b routerrpc: implement LSP heuristic and multi-LSP worst-case probing
This commit implements a comprehensive LSP (Lightning Service Provider)
detection heuristic and updates the payment probing logic to handle
multiple LSPs with worst-case fee estimation.

Key changes:

1. LSP Detection Heuristic (isLSP function):
   Implements three rules to detect LSP setups:
   - Rule 1: If invoice target is public → NOT an LSP (route directly)
   - Rule 2: If at least one destination hop is public → IS an LSP
   - Rule 3: If all destination hops are private → NOT an LSP

2. LSP Route Preparation (prepareLspRouteHints function):
   - Groups route hints by unique public LSP nodes
   - Filters out non-LSP routes based on the heuristic
   - Tracks worst-case fees and CLTV delays for each LSP
   - Returns adjusted route hints with LSP hop stripped

3. Multi-LSP Probing (probePaymentRequest updates):
   - Probes up to 3 unique LSPs maximum (griefing protection)
   - Selects the WORST-CASE (most expensive) route for conservative
     fee estimation
   - Adds comprehensive debug logging for worst-case selection process
   - Properly formats vertex logging using %v (calls Vertex.String())

The worst-case approach ensures users won't be surprised by higher fees
when the actual payment is sent, providing a more conservative and
reliable fee estimate.

This commit also  adds extensive unit test coverage for the LSP detection
heuristic and route preparation logic.

TestIsLsp:
- Edge cases: empty route hints, nil scenarios
- Rule 1: Public invoice target (3 tests)
- Rule 2: All private destination hops (4 tests)
- Rule 3: At least one public destination hop (6 tests)

TestPrepareLspRouteHints:
- LSP grouping and filtering logic
- Worst-case fee selection across route hints
- Worst-case CLTV delta tracking
- Adjusted route hints validation (LSP hop stripped)
- Multi-LSP scenarios with different fees
2025-12-01 18:07:56 +01:00
ziggie 48da56b285 routerrpc: add HasNode backend function for LSP heuristic
This commit adds the HasNode function to the RouterBackend struct,
which checks if a node exists in the graph (i.e., has public channels).
This function is needed by the LSP detection heuristic to determine
if a node is publicly reachable.

The function is wired up in rpcserver.go to query the graph database.
2025-11-29 01:04:28 +01:00
ziggie 06886e71b2 graph/db: fix HasNode comment
The comment was incorrectly referring to HasLightningNode but the
function is named HasNode. Update the comment to match the actual
function name.
2025-11-29 01:04:25 +01:00
Yong 0a2a5b29c7 Merge pull request #10394 from ziggie1984/add-back-globallock
lncfg: readd global lock for postgres and the channeldb_kv table
2025-11-28 20:19:40 +08:00
ziggie 565633578f docs: add release-notes for LND 20.1 2025-11-28 09:22:20 +01:00
ziggie 4f051d97ea lncfg+scripts: use configurable global lock for postgres backends
Replace hardcoded WithGlobalLock assignment with configurable
options wallet postgres backends. Also add the WithGlobalLock
option to the channeldb table for postgres backends.

Defaults:
- channeldb: false (allow concurrent access)
- wallet: true (maintain safe single-writer behavior)

Users can now override these defaults via:
- db.postgres.channeldb-with-global-lock
- db.postgres.walletdb-with-global-lock

This gives operators flexibility while maintaining safe defaults
until full native SQL migration is complete.

Moreover exclude db.postgres.walletdb-with-global-lock check
in the sample config file script. We cannot easily check the
correct default because we set it later in the LND startup
sequence so we exclude it.
2025-11-28 09:22:19 +01:00
ziggie 2e16efed30 sqldb: add global lock config options for postgres
Add two configuration options to control global lock usage for
different postgres database backends:

- ChannelDBWithGlobalLock: for channeldb access (default: false)
- WalletDBWithGlobalLock: for wallet database access (default: true)

These allow fine-grained control over which databases use global
locks, rather than hardcoding the behavior. This is a temporary
measure until the revocation log and wallet are migrated to native
SQL and become fully concurrent-safe.
2025-11-28 09:22:19 +01:00
Thiago Romão Barcala c7fe6425f3 tls_manager.go: handle case when either TLS pair files exist 2025-11-27 13:33:14 +00:00
Mohamed Awnallah c9dea6d621 tls_manager_test.go: reproduce partial tls files handling
When there is only one of the tls pairs (key/certificate) and the
other is missing, the TLS manager currently assumes it exists
and ignore generating them. This results in error propgated to user
that the other tls pair file is missing/not found.
2025-11-27 13:33:06 +00:00
Yong 85a5bf294c Merge pull request #10341 from bitromortac/2511-fix-tor-healthcheck
server: prevent duplicate onion addresses in getinfo
2025-11-27 18:40:27 +08:00
bitromortac b513efc5c1 docs: add release-notes for lnd v0.20.1 2025-11-26 16:58:45 +01:00
bitromortac 031903f275 server: ensure unique addresses for node ann
Modifiers of the node announcement may add duplicate addresses, which we
remove here after the modifications were applied. This also ensures that
any previously added duplicate addresses are removed as well.
2025-11-26 16:56:07 +01:00
Yong c746aeed31 Merge pull request #10391 from ffranr/wip/add-field-committxblockheight-to-resolutionreq
lnwallet: add field `CommitTxBlockHeight` to `ResolutionReq`
2025-11-26 10:50:53 +08:00
ffranr 3d2b0d703e lnwallet: add field CommitTxBlockHeight to ResolutionReq
Introduce `CommitTxBlockHeight` field to the `ResolutionReq` structure
and related methods. This field records the block height where a
commitment transaction has confirmed.
2025-11-25 17:06:18 +00:00
Olaoluwa Osuntokun 7e70e3dbd8 Merge pull request #10387 from ziggie1984/fix-scanning-issue
fix scanning issue
2025-11-24 10:09:48 -08:00
ziggie db3add1c9c docs: add release-notes for LND 20.1 2025-11-22 01:19:44 +01:00
ziggie 79b92a9fa3 contractcourt: use confheight instead of rescanning the chain 2025-11-22 01:19:43 +01:00
ziggie 5538803252 contracourt: fix comment 2025-11-22 01:17:38 +01:00
ziggie 8824244656 contracourt: rename broadcastHeight to confirmHeight
The broadcastHeight was misleading because the commit resolver
is only created when the commitment transaction is confirmed.
2025-11-22 01:17:34 +01:00
Yong 8c8662c86a Merge pull request #10384 from starius/rm-dead-code
lncli: remove dead code
2025-11-20 16:09:02 +08:00
Boris Nagaev 031c792b56 lncli: remove dead code
Variable chanPoints was accumulated but never used. Found with staticcheck tool.

The code is dead since 8f5d78c875
2025-11-19 21:51:40 -03:00
András Bánki-Horváth 194a9f7597 Merge pull request #10378 from ziggie1984/bugfix/graph-cache
graph: fix graph-cache issue
2025-11-19 18:01:31 +01:00
ziggie 4f40d45d06 docs: add release-notes for 20.1 2025-11-19 16:09:33 +01:00
ziggie 5225b9bbbc graph: add regression test for the fixed behaviour 2025-11-19 16:09:33 +01:00
ziggie 575766c5f4 graph: fix graph cache population for channels with both policies disabled
Fix a bug where channels with both policies disabled were not added to
the graph cache during startup. When a policy update later re-enabled
one of the directions, the update would succeed in the database but fail
to update the graph cache (since the channel structure was never added),
preventing the channel from being used for routing.
2025-11-19 10:12:08 +01:00
Yong 31452a66a5 Merge pull request #10374 from ziggie1984/bugfix/fix-unit-test
Fix unit test for onion messages
2025-11-17 21:25:45 +08:00