Skip to content

Conversation

ellemouton
Copy link
Collaborator

@ellemouton ellemouton commented Jun 12, 2025

In this PR, the following methods are implemented on the graph SQLStore:

  • ForEachNode
  • ForEachNodeDirectedChannel
  • ForEachNodeCacheable
  • ForEachNodeChannel

Part of #9795
See #9932 for the full picture that we are aiming at

Copy link
Contributor

coderabbitai bot commented Jun 12, 2025

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ellemouton ellemouton changed the title graph/db: Implement various "ForEach" methods on the graph SQLStore [11] graph/db: Implement various "ForEach" methods on the graph SQLStore Jun 12, 2025
@ellemouton ellemouton force-pushed the graphSQL11-forEachMethods branch from d7e3433 to f0c7d2b Compare June 12, 2025 09:09
@ellemouton ellemouton self-assigned this Jun 12, 2025
@ellemouton ellemouton added this to the v0.20.0 milestone Jun 12, 2025
@ellemouton ellemouton requested a review from bhandras June 12, 2025 09:26

return cb(nodePub, features)
})
}, func() {})
Copy link
Collaborator Author

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

Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@@ -27,6 +27,11 @@ FROM nodes
WHERE pub_key = $1
AND version = $2;

-- name: ListNodes :many
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

great idea! updated

Copy link
Collaborator Author

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

return nodePub
}

dbNode, err := db.GetNodeByPubKey(
Copy link
Collaborator

@bhandras bhandras Jun 12, 2025

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.

Copy link
Collaborator Author

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 👍

Copy link
Collaborator Author

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(
Copy link
Collaborator

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

Copy link
Collaborator Author

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

@ellemouton
Copy link
Collaborator Author

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.
@ellemouton ellemouton force-pushed the graphSQL11-forEachMethods branch from f0c7d2b to 0c94f73 Compare June 18, 2025 13:39
@ellemouton ellemouton changed the base branch from elle-graph11 to master June 18, 2025 13:39
@ellemouton ellemouton force-pushed the graphSQL11-forEachMethods branch from 0c94f73 to 3f27102 Compare June 18, 2025 14:16
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.
@ellemouton ellemouton force-pushed the graphSQL11-forEachMethods branch from 3f27102 to ece157b Compare June 18, 2025 14:55
@ellemouton ellemouton requested a review from guggero June 18, 2025 14:55
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@guggero guggero merged commit e0a9705 into lightningnetwork:master Jun 19, 2025
32 of 38 checks passed
@ellemouton ellemouton deleted the graphSQL11-forEachMethods branch June 19, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants