-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[11] graph/db: Implement various "ForEach" methods on the graph SQLStore #9935
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
[11] graph/db: Implement various "ForEach" methods on the graph SQLStore #9935
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
d7e3433
to
f0c7d2b
Compare
graph/db/sql_store.go
Outdated
|
||
return cb(nodePub, features) | ||
}) | ||
}, func() {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll replace with sqldb.NoOpReset
& will address linter issue after first review round
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
sqldb/sqlc/queries/graph.sql
Outdated
@@ -27,6 +27,11 @@ FROM nodes | |||
WHERE pub_key = $1 | |||
AND version = $2; | |||
|
|||
-- name: ListNodes :many |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's likely useful if we add pagination (with sane defaults at the call site if we know it's safe to fetch all nodes at once).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea! updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did the same for ListNodeIDsAndPubKeys
graph/db/sql_store.go
Outdated
return nodePub | ||
} | ||
|
||
dbNode, err := db.GetNodeByPubKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really only need the node ID. Alternatively we could add more complex queries to get features/channels by a (version, nodePub), ie use an additional JOIN. Of course it's hard to say if overall we'd be better off with the extra roundtrip vs JOIN. I suggest just taking note and fixing this later if performance gain is non-negligible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really only need the node ID
Added a query that just fetches the ID 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest just taking note and fixing this later if performance gain is non-negligible.
cool yeah sounds good! I'll add this to the epic
var ctx = context.TODO() | ||
|
||
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { | ||
dbNode, err := db.GetNodeByPubKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note here, we could likely avoid needing to fetch the node altogether and use more complex queries. (same recommendation too, let's wait until we have numbers to justify such change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool - yeah this isnt used (at the moment) for anything performance critical. So should be ok but will make a note in the epic
note: will address this comment as first commit here: #9931 (comment) |
Use a length check to determine if a bitcoin signature has been set or not. Also add a clarifying comment to explain why we only need to check if one signature field is set to determine if we have the auth proof for the channel or not.
Ensure that it does a sanity check on the length of its input and also only call it if the nullable SQL string is not null. Expand an existing unit tests to cover the DecodeHexColor such that it would have caught the bug.
An error in TestChanUpdatesInHorizon was previously not checked correctly.
f0c7d2b
to
0c94f73
Compare
0c94f73
to
3f27102
Compare
In this commit the `ForEachNode` method is added to the SQLStore. With this, the `TestGraphCacheTraversal` unit test can be run against SQL backends.
Here we add the `ForEachNodeDirectedChannel` and `ForEachNodeCacheable` SQLStore implementations which then lets us run `TestGraphTraversalCacheable` and `TestGraphCacheForEachNodeChannel` against SQL backends.
Which lets us then run `TestIncompleteChannelPolicies` and `BenchmarkForEachChannel` against our SQL backends.
3f27102
to
ece157b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
In this PR, the following methods are implemented on the graph SQLStore:
Part of #9795
See #9932 for the full picture that we are aiming at