Commit Graph
100 Commits
Author SHA1 Message Date
ziggie 5580c40cb0 routerrpc: fix comment in lsp heuristic 2025-12-14 09:25:30 +01:00
ziggie 4af13745e5 docs: add comprehensive backport workflow documentation
This commit adds detailed documentation for the automated backport
workflow and updates the contribution guidelines to reference it.

New documentation (docs/backport-workflow.md):
- Complete overview of the automated backport process
- Step-by-step usage instructions with examples
- Detailed explanation of workflow triggers and label format
- Technical details about workflow implementation
- Conflict resolution procedures and best practices
- Multiple backport scenarios and examples
- Comprehensive troubleshooting guide

Updated contribution guidelines (docs/code_contribution_guidelines.md):
- Replaced detailed backport instructions with brief overview
- Added reference to the new detailed documentation
- Keeps contribution guidelines focused and concise

The detailed documentation provides:
- How to use backport labels correctly
- What happens when labels are added before/after merge
- How the workflow validates branches and handles errors
- Step-by-step conflict resolution instructions
- Solutions for common problems and edge cases
- Examples of valid vs invalid label formats

This documentation ensures contributors and maintainers have clear
guidance on using the automated backport workflow effectively.
2025-12-12 22:48:51 +01:00
ziggie 7ecdb9b807 ci: add automated backport workflow
This commit introduces an automated GitHub Actions workflow to streamline
the backporting process for merged PRs from master to release branches.

Key features:
- Triggers on merged PRs with labels matching 'backport-v*' pattern
  (e.g., backport-v0.20.x-branch)
- Validates that target branches exist before attempting backport
- Creates separate backport PRs for each target branch
- Automatically adds 'no-changelog' label to backport PRs
- Handles merge conflicts by creating draft PRs with conflict markers
- Supports multiple simultaneous backports via multiple labels

Workflow steps:
1. Checkout repository with full git history
2. Validate all target branches exist in the remote repository
3. For each valid backport label:
   - Create a new branch (backport-<pr-num>-to-<target-branch>)
   - Cherry-pick commits from the master PR
   - Create a new PR targeting the release branch
   - Link back to the original PR
4. If conflicts occur, create a draft PR for manual resolution

Label format:
- Valid: backport-v0.20.x-branch, backport-v0.19.x-branch
- Invalid: backport candidate, backport-candidate, backport-needed

This automation reduces manual work and ensures consistency in the
backporting process while maintaining full visibility and control
for maintainers.
2025-12-12 22:48:51 +01:00
ziggie fe9a3e103b funding: fix race in itest for zero-conf funding
Fix a race condition where forwarding through a public zero-conf channel
could fail with UnknownNextPeer when using the confirmed SCID. The issue
occurred because ReportShortChanID (which updates the switch's baseIndex
to handle the confirmed SCID) was called AFTER addToGraph (which announces
the confirmed SCID to the network).

With slow backends like postgres, addToGraph takes significant time,
creating a window where other nodes learn about the confirmed SCID from
gossip and attempt to route through it, but the receiving node's switch
hasn't been updated yet to handle forwards using the confirmed SCID.

The fix reorders operations to call ReportShortChanID before addToGraph,
ensuring the switch is ready to handle the confirmed SCID before it's
announced to the network. Forwards using either the alias or confirmed
SCID will work since getLinkByMapping uses baseIndex to map both to the
same link in forwardingIndex.

Fixes flaky test: zero_conf-channel_policy_update_public_zero_conf
2025-12-10 19:44:18 +01:00
ziggie ac30443cc1 docs: add release-notes for LND 20.1 2025-12-10 09:49:57 +01:00
ziggie 1c4bcc3b7d routerrpc: fix payment address deep copy
using copy for a slice of size 0 will not copy anything so we need
to first initialize the slice before we do the deep copy.
2025-12-10 09:49:57 +01:00
ziggie f289e4920e docs: add release-notes for LND 20.1 2025-12-09 11:51:47 +01:00
ziggie 2d25bce1bf graphdb: fix potential sql tx exhaustion
We should avoid taking the lock of a mutex inside transaction.
Currently we also take this lock in other places and there is a
chance that in case the application lock aquires the lock but
all transactions are already blocked waiting for the mutex to
unlock, we end up in a deadlock.
2025-12-09 11:51:46 +01: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
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
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
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
ziggie 84504fa8c5 lnwire: implement SerializedSize for onion messages 2025-11-16 09:28:12 +01:00
ziggie c08f918ffc paymentsdb: make verifyAttempt more robust
We now return an error when blinded and non blinded attempts are
combined. This was theoretically possible to register a legacy
attempt in combination with a blinded payment. This would have
been prevented by other checks in the code because legacy payments
are not split into shards.
2025-11-12 22:54:03 +08:00
ziggie cbfc0e0dc2 mulit: don't set customData on the lnrpc route level
We now make sure we only set the custom channel data in the
lnrpc.Route only if it contains relevant data.
2025-11-12 22:54:03 +08:00
ziggie 6cc7a88e99 makefile: add linter config check 2025-11-12 22:54:02 +08:00
ziggie c324922a47 CI: remove unnecessary custom-gcl.yml file
The custom file is only needed in the tools directory.
2025-11-12 22:54:02 +08:00
ziggie b6dd3a32f7 CI: also use go tool for gosimports 2025-11-12 22:54:02 +08:00
ziggie d2d56f2968 linter: remove unsupported linters from the codebase 2025-11-12 22:54:02 +08:00
ziggie 13e7a6e782 tools: update golangci-lint to v2
The config file format changed. The tool golangci-lint migrate
was used to migrate the old config. However old comments and also
the structure of the disabled linters was preserved.

Moreover the new v2 version introduced new linters, we disable
3 of them because they are very noise and we do not really want
to check for them: funcorder, noinlineerr, embeddedstructfieldcheck.
2025-11-12 22:54:01 +08:00
ziggie f9dccd3e20 tools: use new golang 1.24 tool directive 2025-11-12 22:54:01 +08:00
ziggie 870d603ce5 multi: allow invalid tlv data when decoding payment fail info
Older payments might have a invalid tlv stream, we now catch this
case and add a unit test.
2025-11-03 12:54:29 +01:00
ziggie 7c92c88270 docs: add release-notes 2025-10-13 12:50:05 +02:00
ziggie bed021fc4a contractcourt: patch 0 timelock baby outputs
Older LND versions had a bug which would create HTLCs with
0 locktime. The utxonursery will have problems dealing with such
htlc outputs because we do not allow height hints of 0. Now we
will fetch the closeSummary of the channel and will add a
conservative height for rescanning.
2025-10-13 12:50:04 +02:00
ziggie b8a855f572 docs: add release-notes LND 0.21.0 2025-09-30 19:06:27 +02:00
ziggie 1dda376404 mod: update etcd/bbolt lib to newest version
Version v1.4.3 has some important bugfixes. We bump both version
in the same go so we do not need to tag the kvdb package and the
latest version of will be used.
2025-09-16 23:08:27 +02:00
ziggie 1f23c8b0eb docs: add release-notes 2025-09-16 14:25:42 +02:00
ziggie 9a83b3838f mulit: use min relay fee error 2025-09-16 14:25:42 +02:00
ziggie 5bcea78dc2 sweep: fix bug in mock interface 2025-09-16 14:25:42 +02:00
ziggie d257198365 sweep: add missing output to the weight estimation
When overlay channels are used the extra output needs to be
considered.
2025-09-16 14:25:42 +02:00
ziggie 22ac4082a4 chainntfs: zero out pkscript in logging when taproot is enabled 2025-09-16 14:25:42 +02:00
ziggie a26a7a3082 mod: update btcwallet version to v16.17 2025-09-16 14:13:27 +02:00
ziggie f540e9c8ec paymentsdb: add helper method to set session key
This is only used for testing because we have now a unique
contraint on the session key and need to swap it in tests for
the sql backend.
pick f17baec94 paymentsdb: fix linter
2025-09-08 08:23:58 +02:00
ziggie 335a9b3f40 lnd: reduce max limit when querying for payments 2025-09-05 09:54:00 +02:00
ziggie a9c30dacb5 sqldb: add helper for type boolean 2025-09-05 09:53:59 +02:00
ziggie 2d032044f9 sqldb: Make sure we do not replace keywords if they have a prefix
We don't for example want to replace CURRENT_TIMESTAMP when using
it in our tables.
2025-09-05 09:52:41 +02:00
ziggie e20a34de46 paymentsdb: refactor attempt verification 2025-09-05 09:52:41 +02:00
ziggie 0320dfcc89 paymentsdb: add compile time check for the kv db implementation 2025-09-05 09:52:40 +02:00
ziggie 3d4ee8b874 paymentsdb: rename defaultKVStoreOptions func
We rename the modifier to use the same naming as used in the
graphDB to align the codebase.
2025-09-05 09:52:40 +02:00
ziggie bf6131ba02 routing: Add comment to DeleteFailedAttempts func call 2025-08-20 09:08:19 +02:00
ziggie 039b5994f3 routing: add more comments to the ControlTower interface 2025-08-20 09:08:19 +02:00
ziggie b16782caeb multi: move DBMPPayment to paymentsdb package 2025-08-20 09:08:19 +02:00
ziggie 9ac93e75ac paymentsdb: fix linter 2025-08-20 09:08:18 +02:00
ziggie f87841d638 paymentsdb: declare helper functions and add comments 2025-08-20 09:07:53 +02:00
ziggie 82242f5342 multi: rename KVPaymentDB to KVStore
This matches the same naming as used in the graph package.
2025-08-20 09:07:53 +02:00
ziggie 6abd539a2d paymentsdb: add missing function comments 2025-08-20 09:07:53 +02:00
ziggie 8245e356e5 paymentsdb: move serialization methods to kv_store file 2025-08-20 09:07:53 +02:00
ziggie 7423bfece9 paymentsdb: rename assertPaymentstatus 2025-08-20 09:07:53 +02:00
ziggie a1fc8a3eee paymentsdb: rename db agnostic tests to highlight their behaviour 2025-08-20 09:07:52 +02:00
ziggie 68a8cf199d paymentsdb: rename assertPayments 2025-08-20 09:07:52 +02:00
ziggie 8726ba3d7c paymentsdb: move more tests
we make the index assertion db independant so it is a noop for
a future native sql backend. This allows us to reuse even more
tests for the different db architectures.
2025-08-20 09:07:52 +02:00
ziggie e22b898c1e paymentsdb: move db interface dependant tests to different file
This commit starts reusing test cases which are not dependant on
the kv db backend. So they can be later used with the native db
implementation as well.
2025-08-20 09:07:52 +02:00
ziggie 39b7417797 paymentsdb: use querypayments method to make test db agnostic 2025-08-20 09:07:52 +02:00
ziggie 46500f94e0 multi: fix comment of InitPayment method 2025-08-20 09:07:51 +02:00
ziggie 9f824fe1ee multi: introduce interface for payment database 2025-08-20 09:07:48 +02:00
ziggie 1fb284fa26 github actions: move pgp key to daily builds 2025-08-19 08:35:42 +02:00
ziggie 2b856f036e multi: fix linter 2025-08-14 19:53:18 +02:00
ziggie e24ae0d7f3 paymentsdb: add missing comments for variables 2025-08-14 19:53:18 +02:00
ziggie df9bac2ecf multi: move PaymentCreationInfo to payment pkg 2025-08-14 19:53:18 +02:00
ziggie d138e23919 multi: move FailureReason to payment package 2025-08-14 19:53:18 +02:00
ziggie d77b2f9c26 mulit: move payment query code to separate file
We also rename the struct since it is now in its own package
there is no need to prefix it.
2025-08-14 19:53:18 +02:00
ziggie 03af9858d2 multi: move payment related code into own package
This commit moves most of the code into its own package. It is
the smallest code move possible without moving import cycles and
keeping the changes to the code base as small as possible during
refactor.
2025-08-14 19:53:15 +02:00
ziggie 35e9979d67 docs: add schema update doc 2025-08-14 12:00:40 +02:00
ziggie b98cc24cfe docs: add release-notes 2025-08-14 12:00:40 +02:00
ziggie ea9fb80eff sqldb: use the new schema
We put this new schema update into the main line and change the
versions of the schema updates which are currently only available
in dev builds. The schemas need to be chronological therefore we
also need to rename the file numbers.
2025-08-14 11:59:09 +02:00
ziggie dccb669ad1 scripts: remove expired key 2025-08-14 09:37:53 +02:00
ziggie 506d226eb3 sqldb: add missing index for settled invoices 2025-08-14 08:17:15 +02:00
ziggie 22fbbee837 sqldb: delete wrong index names and add missing one 2025-08-14 08:17:15 +02:00
ziggie 77a6b577eb channeldb: move helper function to codec.go
This method is not only used by the payment logic so we need to
move it to a generalized place because in the following commits
we move payment related code into its own package.
2025-08-14 08:08:51 +02:00
ziggie 4bb21a7284 channeldb: export pagination method
We export some methods related to the pagination logic be the
kv store implemenation of the payment data will live in another
package.
2025-08-14 08:08:50 +02:00
ziggie 4e0af2f495 channeldb: rename storedPaymentSeq 2025-08-11 16:44:15 +02:00
ziggie a4b1569647 channeldb: rename currPaymentSeq 2025-08-11 16:44:15 +02:00
ziggie 6bae3c98b3 channeldb: rename paymentSeqMx 2025-08-11 16:44:14 +02:00
ziggie 88da582526 mulit: use kvdb.Backend for the kv payment db
Instead of the ChannelState struct we now use the kv backend
interface for the payment kv database.
2025-08-11 16:44:14 +02:00
ziggie 3aec40293d paymentsdb: add subsystem logging for payments package 2025-08-11 16:44:14 +02:00
ziggie 18afd4442d multi: introduce new paymentsDB package
We introduce a new package paymentsDB and start by moving the
payment specifc errors from the channeldb package to the
paymentsDB package. We also fix linter issues which showed up
due to changing this code part.
2025-08-11 16:44:14 +02:00
ziggie db2c50a599 channeldb: add context to query method
We add a context for the query method because the query method
is part of the paymentDB interface and for the SQL case
we will need the context for this method because the native
SQL drivers demand one. So we add it for the kv implementation
here as well so we can then make use of the new interface type.
2025-08-11 16:44:13 +02:00
ziggie dc7bea147a docs: add release-notes 2025-08-08 10:46:26 +02:00
ziggie 79e1cf0db7 routing: make sure attempts are always resolved after a timeout
We check the context of the payment lifecycle at the beginning of
the `resumepayment` loop. This will make sure we have always the
latest state of the payment before deciding on the next steps in
the function `decideNextStep`.
2025-08-08 09:23:07 +02:00
ziggie ab6f1fcab8 docs: add release notes 2025-08-07 16:53:45 +02:00
ziggie 87844cd5b4 multi: bump Golang version to v1.23.12 2025-08-07 16:53:45 +02:00
ziggie 3afac74413 scripts: remove expired pgp key 2025-08-06 11:24:54 +02:00
ziggie a19e7f2e5f docs: add release-notes 2025-08-06 09:37:09 +02:00
ziggie 28f286a2c1 docs: fix 19.2 release-notes 2025-08-06 09:37:09 +02:00
ziggie 5c22e5eb25 itest: add payment test with max htlc restriction 2025-08-06 09:37:09 +02:00
ziggie e2a9b17254 multi: skip range check in pathfinder and switch for custom htlc payments 2025-08-06 09:37:08 +02:00