Skip to content

Refactor Payment PR 5 (discarded because merged into wrong branch)#10151

Merged
ziggie1984 merged 40 commits intolightningnetwork:elle-payment-sql-seriesfrom
ziggie1984:refactor-payments-code-05
Aug 13, 2025
Merged

Refactor Payment PR 5 (discarded because merged into wrong branch)#10151
ziggie1984 merged 40 commits intolightningnetwork:elle-payment-sql-seriesfrom
ziggie1984:refactor-payments-code-05

Conversation

@ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Aug 12, 2025

Depends on #9847 (only new commits beginning at the 5 commit)

ellemouton and others added 27 commits August 7, 2025 08:04
Let the helper method only take the params it needs so that we dont need
to construct an entire models.ChannelEdgeInfo object to pass to it. This
will be useful later on.
Since the type returned from the DB is not a pointer. This will be
useful later on.
The following performance gains were measured using the new benchmark
test.

```
name                                      old time/op  new time/op  delta
ChanUpdatesInHorizon-native-sqlite-10     18.5s ± 3%    2.0s ± 5%  -89.11%  (p=0.000 n=9+9)
ChanUpdatesInHorizon-native-postgres-10   59.0s ± 3%    0.8s ±10%  -98.65%  (p=0.000 n=10+9)
```
…ng-version

update Golang version to v1.23.12 to fix potential SQL bug
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`.
[8] graph/db: use batch loading for various graph SQL methods
We add a new update type to the payment descriptor to describe this new
type of htlc. This type of HTLC will only end up being set if explicitly
signalled by external software.
We also add the IsAdd helper to the AuxHtlcDescriptor, as external
software using the aux framework might want to know which type of HTLC
this is.
We update the lightning channel state machine in some key areas. If the
noop TLV is set in the update_add_htlc custom records then we change the
entry type to noop. When settling the HTLC if the type is noop we credit
the satoshi amount back to the sender.
Adds some simple tests to check the noop HTLC logic of the lightning
channel.
To make sure we don't cause force-closures because of commit sig
mismatches, we add a test case to verify that the retransmitted HTLC
matches the original HTLC.
This error is returned when one attempts to use taproot overlay channels
without the necessary auxiliary funding controller being supplied. In
practice, when running lnd via litd, the latter will always supply
'tapd' as the aux funding controller, but a standalone lnd has no
knowledge of that.

The previous message sort of reads like the lnd user has forgotten to
set some available option or flag, but nothing or the sort actually
exists. The update makes it clearer that the feature isn't available in
the standalone build.
server: don't mention aux controllers in error message
@ziggie1984 ziggie1984 changed the base branch from master to elle-payment-sql-series August 12, 2025 16:21
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ziggie1984, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant refactoring of the payment management system by introducing a dedicated paymentsdb package. The primary goal is to modularize payment-related database operations and data structures, moving them out of the more general channeldb package. This change enhances code organization, improves maintainability, and lays the groundwork for potential future database backend implementations. The refactoring involves creating new interfaces, migrating existing code, and updating all dependent modules to interact with the new payment database abstraction.

Highlights

  • New Payments Database Package: Introduced a new top-level Go package named paymentsdb to encapsulate all payment-related database logic and data structures, promoting better modularity and separation of concerns.
  • Code Migration and Reorganization: Migrated core payment entities such as FailureReason, PaymentCreationInfo, MPPayment, and HTLCAttempt from the channeldb package to the new paymentsdb package, along with their associated serialization/deserialization logic.
  • Database Interface Abstraction: Defined a PaymentDB interface within paymentsdb to standardize interactions with the payment database, allowing for future flexibility (e.g., supporting SQL backends) without impacting existing logic.
  • Channeldb Decoupling: Updated channeldb to remove its direct payment management responsibilities, including migrations and data structures, now delegating these to the paymentsdb package.
  • System-Wide Integration: Adjusted various components across the codebase, including config_builder, lnrpc services, routing logic, and rpcserver, to reflect the new paymentsdb package structure and its defined interfaces and types.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ziggie1984 ziggie1984 self-assigned this Aug 12, 2025
@ziggie1984 ziggie1984 added the payments Related to invoices/payments label Aug 12, 2025
@ziggie1984 ziggie1984 added this to the v0.20.0 milestone Aug 12, 2025
@gemini-code-assist
Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@ziggie1984 ziggie1984 force-pushed the refactor-payments-code-05 branch 2 times, most recently from ad1b241 to d106ffd Compare August 12, 2025 16:59
@saubyk saubyk moved this to In progress in lnd v0.20 Aug 12, 2025
@ziggie1984 ziggie1984 force-pushed the refactor-payments-code-05 branch from d106ffd to 461dfb1 Compare August 13, 2025 08:28
yyforyongyu and others added 12 commits August 13, 2025 06:05
We export some methods related to the pagination logic be the
kv store implemenation of the payment data will live in another
package.
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.
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.
We also rename the struct since it is now in its own package
there is no need to prefix it.
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.
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.
@ziggie1984 ziggie1984 force-pushed the refactor-payments-code-05 branch from 461dfb1 to 3e885a4 Compare August 13, 2025 11:06
@ziggie1984 ziggie1984 merged commit 3e885a4 into lightningnetwork:elle-payment-sql-series Aug 13, 2025
30 of 33 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in lnd v0.20 Aug 13, 2025
@ziggie1984 ziggie1984 changed the title Refactor Payment PR 5 Refactor Payment PR 5 (discarded) Aug 13, 2025
@ziggie1984 ziggie1984 changed the title Refactor Payment PR 5 (discarded) Refactor Payment PR 5 (discarded because merged into wrong branch) Aug 13, 2025
@ziggie1984 ziggie1984 deleted the refactor-payments-code-05 branch August 13, 2025 11:12
@ziggie1984 ziggie1984 restored the refactor-payments-code-05 branch August 13, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

payments Related to invoices/payments

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants