Skip to content

[sql-29]: firewalldb: implement SQL version of RulesDB (kvstores) #1030

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

Merged
merged 4 commits into from
Apr 16, 2025

Conversation

ellemouton
Copy link
Member

@ellemouton ellemouton commented Apr 7, 2025

This PR adds the SQL version of the RulesDb

part of #917

@ellemouton ellemouton added database Postgres and sql related issues sql-ize labels Apr 7, 2025
@ellemouton ellemouton self-assigned this Apr 7, 2025
@ellemouton ellemouton marked this pull request as draft April 7, 2025 12:19
@ellemouton ellemouton added the no-changelog This PR is does not require a release notes entry label Apr 7, 2025
@ellemouton ellemouton force-pushed the sql29 branch 7 times, most recently from 84ce3f0 to c3beafe Compare April 11, 2025 11:24
@ellemouton ellemouton marked this pull request as ready for review April 11, 2025 11:25
@ellemouton ellemouton requested review from ViktorTigerstrom and bitromortac and removed request for ViktorTigerstrom April 14, 2025 09:46
terminal.go Outdated
@@ -238,6 +238,7 @@ func New() *LightningTerminal {
type stores struct {
accounts accounts.Store
sessions session.Store
rules firewalldb.RulesDB

firewall *firewalldb.DB
Copy link
Contributor

Choose a reason for hiding this comment

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

there is some redundancy between rules and firewall, is it possible to remove one of them, or how will that look in the end? will we have a single firewall db here or the individual RulesDB/PrivacyDB?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's not redundant in the dev build case.

THe DB is a subsystem that needs to be started/stopped. The RulesDB is an interface that needs to be satisfied.

Currently, in the dev build, the RulesDB is either backed by the firewallDB or by the sql store. In the prod build, yes it is redundant.

eventually: we only will need the firewalldb.DB & can just pass that around.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, I think it's still possible and rules it not needed, unless I misunderstood you, see the patch
changes.txt

Copy link
Member Author

Choose a reason for hiding this comment

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

ah ok yes indeed - you're totally right. Thanks for the call out 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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

thank you for the update!

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, the diff needed one more thing i think. fixed now i hope 🤞

Here we add the SQLDB struct which will later on be used to implement
the SQL versions of the various firewall DBs.

We also add the sqlExecutor here which is the SQL version of
`DBExecutor`. This will be used for both the KVstores DB and privacy
mapper DBs.
So that we can extract the same BaseDB in other packages and use it for
initialising other SQL stores during tests.
Copy link
Member Author

@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.

@bitromortac - addressed nits. PTAL

terminal.go Outdated
@@ -238,6 +238,7 @@ func New() *LightningTerminal {
type stores struct {
accounts accounts.Store
sessions session.Store
rules firewalldb.RulesDB

firewall *firewalldb.DB
Copy link
Member Author

Choose a reason for hiding this comment

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

it's not redundant in the dev build case.

THe DB is a subsystem that needs to be started/stopped. The RulesDB is an interface that needs to be satisfied.

Currently, in the dev build, the RulesDB is either backed by the firewallDB or by the sql store. In the prod build, yes it is redundant.

eventually: we only will need the firewalldb.DB & can just pass that around.

@ellemouton ellemouton requested a review from bitromortac April 15, 2025 09:37
@ellemouton
Copy link
Member Author

note: will fix linter after next review round

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 after nits have been addressed! Great work 🚀🔥

In this commit, we let the SQLDB implement the RulesDB interface. Unit
tests are updated such that they can be run against sqlite and postgres
DBs using the SQLDB.
Copy link
Contributor

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

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

LGTM 🎉 (one comment left and a nit)

terminal.go Outdated
@@ -238,6 +238,7 @@ func New() *LightningTerminal {
type stores struct {
accounts accounts.Store
sessions session.Store
rules firewalldb.RulesDB

firewall *firewalldb.DB
Copy link
Contributor

Choose a reason for hiding this comment

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

right, I think it's still possible and rules it not needed, unless I misunderstood you, see the patch
changes.txt

Plug the new SQL version of the RulesDB into LiT for `dev` flag builds.
@ellemouton ellemouton merged commit 3f34989 into lightninglabs:master Apr 16, 2025
21 checks passed
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.

3 participants