-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat(indexer/postgres)!: add basic support for header, txs and events #22695
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request involve multiple modifications across various files, primarily focusing on enhancing error handling, logging, and event processing capabilities. Key updates include improvements to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yml ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
indexer/postgres/listener.go (2)
90-115
: Add function documentation and improve error messagesThe transaction listener implementation would benefit from:
- GoDoc comments explaining the function's purpose and parameters
- More descriptive error messages that include context about the transaction
Apply this diff to add documentation:
+// txListener returns a function that processes and stores transaction data in PostgreSQL. +// It handles both raw transaction bytes and JSON representations. func txListener(i *indexerImpl) func(data appdata.TxData) error {Also, enhance error messages:
- return err + return fmt.Errorf("failed to get transaction bytes at height %d, index %d: %w", + td.BlockNumber, td.TxIndex, err)
145-149
: Enhance error context in SQL operationsThe error message could provide more context about the event being processed.
Apply this diff to improve error handling:
_, err := i.tx.Exec("INSERT INTO event (block_number, block_stage, tx_index, msg_index, event_index, type, data) VALUES ($1, $2, $3, $4, $5, $6, $7)", e.BlockNumber, e.BlockStage, e.TxIndex, e.MsgIndex, e.EventIndex, e.Type, jsonData) if err != nil { - return fmt.Errorf("failed to index event: %w", err) + return fmt.Errorf("failed to index event (block: %d, type: %s, tx_index: %d): %w", + e.BlockNumber, e.Type, e.TxIndex, err) }
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (2)
indexer/postgres/base_sql.go
(1 hunks)indexer/postgres/listener.go
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- indexer/postgres/base_sql.go
🧰 Additional context used
📓 Path-based instructions (1)
indexer/postgres/listener.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
🔇 Additional comments (3)
indexer/postgres/listener.go (3)
4-4
: LGTM!
The added json package import is necessary for the new JSON handling functionality.
85-88
: Consider splitting the code into separate files
As suggested in a previous review, consider breaking out the transaction and event handling code into separate files (tx.go and event.go) to improve code organization and maintainability.
134-143
: Preserve all event attributes by handling duplicate keys appropriately
The current implementation may lose data when events have multiple attributes with the same key.
Adding backport label for SDK changes. The modules tagged from main can be deleted from the backport. |
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.
utACK
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
baseapp/abci.go (1)
1002-1005
: LGTM! Consider enhancing the error message.The special handling for block height 1 failures is a good addition that prevents invalid rollbacks and provides clear guidance.
Consider enhancing the error message to provide more guidance:
- return nil, fmt.Errorf("failed to commit block 1, can't automatically rollback: %w", err) + return nil, fmt.Errorf("failed to commit block 1, manual node reset required (can't automatically rollback to height 0): %w", err)
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
⛔ Files ignored due to path filters (2)
go.sum
is excluded by!**/*.sum
simapp/v2/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (12)
baseapp/abci.go
(1 hunks)go.mod
(1 hunks)runtime/v2/go.mod
(1 hunks)server/v2/cometbft/abci.go
(3 hunks)server/v2/cometbft/go.mod
(1 hunks)server/v2/go.mod
(1 hunks)simapp/go.mod
(1 hunks)simapp/v2/go.mod
(3 hunks)tests/go.mod
(1 hunks)x/accounts/go.mod
(1 hunks)x/accounts/module.go
(2 hunks)x/distribution/go.mod
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
- server/v2/cometbft/go.mod
- x/accounts/module.go
- server/v2/go.mod
- runtime/v2/go.mod
- go.mod
- tests/go.mod
- x/accounts/go.mod
- x/distribution/go.mod
- server/v2/cometbft/abci.go
- simapp/go.mod
- simapp/v2/go.mod
🧰 Additional context used
📓 Path-based instructions (1)
baseapp/abci.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
…s-sdk into facu/indexer-events
…#22695) (cherry picked from commit 332d0b1) # Conflicts: # go.mod # go.sum # indexer/postgres/base_sql.go # indexer/postgres/listener.go # runtime/v2/app.go # runtime/v2/go.mod # runtime/v2/go.sum # schema/appdata/data.go # schema/decoding/middleware.go # server/v2/cometbft/go.mod # server/v2/cometbft/go.sum # server/v2/go.mod # server/v2/go.sum # server/v2/stf/go.mod # server/v2/stf/go.sum # server/v2/stf/stf.go # simapp/go.mod # simapp/go.sum # simapp/v2/go.mod # simapp/v2/go.sum # tests/go.sum # x/accounts/go.mod # x/accounts/go.sum # x/distribution/go.mod # x/distribution/go.sum
… (backport #22695) (#22808) Co-authored-by: Facundo Medica <[email protected]> Co-authored-by: Julien Robert <[email protected]>
Description
Related to epic #20352
Missing:
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores