Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sql-7] accounts: add SQL implementation of the accounts store #954

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Jan 23, 2025

Part of #917

In this commit, we add the SQLStore type which implements the
accounts.Store interface. To demonstrate that it works as expected, we
also plug this implementation into all the account unit tests to show
that they pass against the sqlite and postgres backends.

One can use make unit pkg=accounts tags=test_db_postgres or
make unit pkg=accounts tags=test_db_sqlite to test locally.

@ellemouton ellemouton added database Postgres and sql related issues no-changelog This PR is does not require a release notes entry sql-ize labels Jan 23, 2025
@ellemouton ellemouton self-assigned this Jan 23, 2025
@ellemouton ellemouton force-pushed the sql7Accounts7 branch 2 times, most recently from f326bdb to 87fa366 Compare January 23, 2025 09:40
@ellemouton ellemouton force-pushed the sql7Accounts7 branch 3 times, most recently from 27c7272 to 9207179 Compare January 29, 2025 14:55
Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

Generally looks great 🚀🔥! Just a few minor comments.

accounts/store_sql.go Outdated Show resolved Hide resolved
accounts/store_sql.go Outdated Show resolved Hide resolved
accounts/store_sql.go Show resolved Hide resolved
Comment on lines +546 to +550
if opts.errIfAlreadyPending &&
currStatus != lnrpc.Payment_FAILED {

return fmt.Errorf("payment with hash %s is "+
"already in flight or succeeded "+
"(status %v)", hash, currStatus)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably have commented this in kvdb PR, but this will return an error if the currStatus is lnrpc.Payment_UNKOWN, which seems a bit incorrect?

Copy link
Member Author

Choose a reason for hiding this comment

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

as discussed offline, seems like a parallel issue right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've rechecked this, and the current behavior is correct—it should return an error if currStatus != lnrpc.Payment_FAILED. In other words, it should also error on lnrpc.Payment_UNKNOWN.

I believe the confusion comes from the doc comments, which state that this only fails if the payment is "in-flight or succeeded." However, we actually treat lnrpc.Payment_UNKNOWN as "in-flight" as well, which I think would be clearer if the docs mentioned that.

I can update the doc comments in a separate PR after this is merged if you'd like.

accounts/store_sql.go Outdated Show resolved Hide resolved
In this commit, we add the SQLStore type which implements the
accounts.Store interface. To demonstrate that it works as expected, we
also plug this implementation into all the account unit tests to show
that they pass against the sqlite and postgres backends.

One can use `make unit pkg=accounts tags=test_db_postgres` or
`make unit pkg=accounts tags=test_db_sqlite` to test locally.

Note that 2 small timestamp related changes are made to the unit tests.
This is to compensate for timestamp precision in postgres.
Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

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

LGTM 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Postgres and sql related issues no-changelog This PR is does not require a release notes entry sql-ize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants