-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/query indices #82
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
Conversation
I've reviewed the changes and identified a few issues that need addressing. The updates improve query capabilities but introduce a couple of potential edge cases in index management and request validation.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
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.
Pull request overview
This PR introduces secondary indices to optimize query performance by eliminating full-table scans in both Action and Supernode modules.
Key Changes:
- Added secondary indices for actions (by creator, type, block height, supernode) and supernodes (by account address)
- New
ListActionsByCreatorquery endpoint with pagination support - Optimized existing query methods to leverage indices for O(1) or O(log n) lookups instead of O(n) scans
- Enhanced CLI with autocli commands for all list query operations
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| x/supernode/v1/types/keys.go | Adds SuperNodeByAccountKey prefix for secondary index mapping account→validator address |
| x/supernode/v1/types/expected_keepers.go | Adds GetSuperNodeByAccount interface method for efficient account-based lookups |
| x/supernode/v1/mocks/expected_keepers_mock.go | Generated mock for new GetSuperNodeByAccount method |
| x/supernode/v1/keeper/supernode.go | Implements index maintenance in SetSuperNode, adds GetSuperNodeByAccount method, fixes pagination to use FilteredPaginate, updates SetSuperNodeActive default case handling |
| x/supernode/v1/keeper/query_get_super_node_by_super_node_address.go | Optimizes query from O(n) full scan to O(1) index lookup using GetSuperNodeByAccount |
| x/supernode/v1/keeper/msg_server_stop_supernode.go | Formatting fix (indentation correction) |
| x/action/v1/types/query.pb.go | Generated protobuf code for new ListActionsByCreator RPC and types |
| x/action/v1/types/query.pb.gw.go | Generated gRPC gateway handlers for ListActionsByCreator endpoint |
| x/action/v1/types/action.pb.go | Import reordering (formatting change) |
| x/action/v1/keeper/action.go | Adds index prefixes and implements comprehensive index maintenance for state, creator, type, block height, and supernode fields in SetAction |
| x/action/v1/keeper/query_list_actions.go | Refactors to use state/type indices when filters are provided, avoiding full scans |
| x/action/v1/keeper/query_list_actions_by_creator.go | New query handler using creator index for efficient lookups |
| x/action/v1/keeper/query_list_actions_by_creator_test.go | Comprehensive unit tests for the new query endpoint |
| x/action/v1/keeper/query_list_actions_by_sn.go | Optimizes to use supernode index instead of full scan |
| x/action/v1/keeper/query_list_actions_by_block_height.go | Optimizes to use block height index |
| x/action/v1/keeper/query_list_expired_actions.go | Refactors to delegate to ListActions with state filter, leveraging state index |
| x/action/v1/keeper/query_action_by_metadata.go | Updates to use type index as initial filter before metadata matching |
| x/action/v1/module/autocli.go | Adds CLI commands for all list query operations with appropriate flags |
| proto/lumera/action/v1/query.proto | Adds ListActionsByCreator RPC definition and request/response types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d9d7649 to
a67686c
Compare
a67686c to
906e106
Compare
I've reviewed the changes and all previously identified issues have been addressed in the latest commits.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Performance Improvements
IAVL iteration time as action count grows.
actions”.
supernode.go:127).
query_get_top_super_nodes_for_block.go:180).
Bug Fixes / Correctness Improvements
action/v1/keeper/action.go:496).
action.go:342 onward).
query_list_actions.go:43, x/action/v1/keeper/query_list_actions_by_sn.go:37).
v1/keeper/supernode.go:186, x/supernode/v1/keeper/supernode.go:256, x/supernode/v1/keeper/supernode.go:303).
Upgrade Handler (v1.8.8) Placeholder
into upgrade params (app/app.go:324, app/upgrades/params/params.go:9).
upgrades/v1_8_8/upgrade.go:33).