Skip to content

Conversation

@ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Oct 12, 2025

Depends on #9147

This PR implements the QueryPayments and FetchPayment SQL Payments DB backend functions.

It does not yet add testing for these functions which will be added in followup PRs once we have the ability to add payments and attempts to the database which we then can fetch.

@ziggie1984 ziggie1984 changed the base branch from master to elle-payment-sql-series-new October 12, 2025 17:19
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from fe51267 to 63aa866 Compare October 12, 2025 17:33
@ziggie1984 ziggie1984 self-assigned this Oct 13, 2025
@ziggie1984 ziggie1984 added payments Related to invoices/payments sql labels Oct 13, 2025
@ziggie1984 ziggie1984 added this to v0.21 Oct 13, 2025
@ziggie1984 ziggie1984 added this to the v0.21.0 milestone Oct 13, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from 938443e to b0361a2 Compare October 13, 2025 07:00
@ziggie1984 ziggie1984 added the database Related to the database/storage of LND label Oct 13, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from b0361a2 to ed283fa Compare October 13, 2025 14:49
@saubyk saubyk moved this to In progress in v0.21 Oct 14, 2025
@ziggie1984 ziggie1984 changed the title [Part 2|*] Implement QueryPayments for SQL Backend [Part 2|*] Implement First Part for SQL Backend functions Oct 15, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from ed283fa to aa560da Compare October 15, 2025 12:49
@ziggie1984 ziggie1984 marked this pull request as ready for review October 15, 2025 13:09
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from 08464ea to da3603e Compare October 15, 2025 13:14
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from da3603e to 069f7c6 Compare October 15, 2025 13:25
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from 1f7d395 to ef6ef5c Compare October 17, 2025 07:53
@ziggie1984
Copy link
Collaborator Author

/gemini review

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.

Code Review

This pull request implements the QueryPayments and FetchPayment functions for the new SQL backend of the payments database. The changes include new SQL queries, Go functions to execute them, and converters to transform database results into application-level types.

The implementation is well-structured, making good use of batching for efficient data fetching. I have a few suggestions to improve code clarity and adhere to best practices:

  • Simplify time value handling in sql_converters.go by using direct type assertions where the type is guaranteed.
  • Consider updating the DB interface to accept a context.Context in FetchPayment to avoid using context.TODO().
  • I also found a minor typo in a comment.

Overall, this is a solid contribution towards the SQL backend migration.

@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from ef6ef5c to 0849296 Compare October 17, 2025 08:43
@ziggie1984 ziggie1984 requested a review from ellemouton October 17, 2025 08:44
@ziggie1984
Copy link
Collaborator Author

I think it's expected that two itests will be failing correct

Yes they will only pass with: #10292

@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from bf9d3f2 to 3604e96 Compare November 10, 2025 16:59
@ziggie1984
Copy link
Collaborator Author

/gemini review

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.

Code Review

This pull request implements the QueryPayments and FetchPayment functions for the SQL payments database backend. The changes are extensive and well-structured, introducing several helper functions for data conversion and batch loading to ensure efficiency. I've identified a few areas for improvement, primarily concerning adherence to the repository's style guide for comments and a high-severity issue regarding context propagation in FetchPayment. Overall, this is a solid contribution towards migrating the payments database to SQL.

@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from 74493d8 to d786e3b Compare November 10, 2025 17:37
@ziggie1984
Copy link
Collaborator Author

This new version now supports Batch Loading for all payments as proposed by elle.

@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 3 times, most recently from 742caa8 to 6488a57 Compare November 11, 2025 11:01
@ziggie1984 ziggie1984 force-pushed the elle-payment-sql-series-new branch 2 times, most recently from 9300d69 to 0288df7 Compare November 12, 2025 13:09
Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

nice one adding the batch fetching ⚡

@yyforyongyu
Copy link
Member

Looks like it's missing a rebase 👀

Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Can be merged once the rebase conflict is fixed 🙏

@ziggie1984 ziggie1984 force-pushed the elle-payment-sql-series-new branch from 0288df7 to e991cd0 Compare November 12, 2025 20:54
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from 6488a57 to 09f8a54 Compare November 12, 2025 20:54
@ziggie1984 ziggie1984 force-pushed the elle-payment-sql-series-new branch from e991cd0 to 6860702 Compare November 13, 2025 06:45
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from 09f8a54 to 93f3a38 Compare November 13, 2025 06:46
@ziggie1984 ziggie1984 merged commit bbb73ff into lightningnetwork:elle-payment-sql-series-new Nov 13, 2025
37 of 39 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in v0.21 Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database Related to the database/storage of LND payments Related to invoices/payments sql

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants