-
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
refactor(genutil): Use sdk types genesis validator #21678
Conversation
📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe changes introduce a new Changes
Possibly related PRs
Suggested reviewers
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.
If you can re-add the new GenesisValdiator struct in genutil/v2, then it will solve this as well: #21634
i will added it in, just need to fix it to work with json unmarshal |
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)
runtime/v2/app.go (1)
106-112
: LGTM: New Query method implemented correctly.The
Query
method is well-implemented and consistent with the codebase. It correctly handles state retrieval and delegates tostf.Query
. Good use ofcontext.Context
for better control over the operation.A minor suggestion for improvement:
Consider wrapping the error returned from
db.StateAt
to provide more context:state, err := a.db.StateAt(version) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to get state at version %d: %w", version, err) }This change would make debugging easier by providing more information about the error's origin.
x/genutil/client/cli/migrate.go (1)
65-73
: LGTM with suggestion: Consider further refactoring to reduce duplication.The new code block correctly handles the v0.52 migration differently and uses the
v52
constant for comparison, which is good practice. The error handling is consistent with the rest of the function.However, there's still some duplication in the error handling. Consider further refactoring to reduce this duplication:
var err error var appGenesis *types.AppGenesis if target == v52 { appGenesis, err = v052.MigrateGenesisFile(importGenesis) } else { appGenesis, err = types.AppGenesisFromFile(importGenesis) } if err != nil { return err }This refactoring would consolidate the error handling and further reduce code duplication.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (3)
- runtime/v2/app.go (2 hunks)
- simapp/v2/app_di.go (3 hunks)
- x/genutil/client/cli/migrate.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- simapp/v2/app_di.go
🧰 Additional context used
📓 Path-based instructions (2)
runtime/v2/app.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/client/cli/migrate.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
🔇 Additional comments (5)
runtime/v2/app.go (1)
4-4
: LGTM: Import statement added correctly.The addition of the
context
package import is necessary for the newQuery
method and follows the Uber Go Style Guide for import grouping.x/genutil/client/cli/migrate.go (4)
16-16
: LGTM: Import statement is correct and follows style guidelines.The new import statement for the v0.52 migration package is correctly aliased and follows the Uber Go Style Guide for imports.
21-21
: LGTM: Constant declaration improves code maintainability.The new constant
v52
is well-named and follows the Uber Go Style Guide. Using a constant instead of a string literal improves maintainability. This change also addresses the previous review comment suggesting to use a constant instead of a string.
24-26
: LGTM: MigrationMap correctly updated with v0.52 migration.The MigrationMap has been properly updated to include the v0.52 migration. It correctly uses the newly defined
v52
constant and follows Go conventions for map initialization.
63-64
: LGTM: Improved organization of flag retrieval.Moving the
outputDocument
flag retrieval earlier in the function improves code organization by grouping flag retrievals together. This change doesn't affect functionality and potentially enhances readability.
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.
Could you merge main and run make lint fix?
question, do we still keeps |
I guess we don't need to do all the genesis cleanup we did in v1. That should do it to demonstrate how to export a genesis file. |
Maybe we can just add a comment saying that export may need to be extended at the user discretion for ending in a cleaner genesis state. |
if ok { | ||
state, err := writerMap.GetWriter(g.actor) | ||
if err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods Warning
} | ||
|
||
func (r readonlyKVStore) Set(key, value []byte) error { | ||
panic("tried to call Set on a readonly store") |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods Warning
} | ||
|
||
func (r readonlyKVStore) Delete(key []byte) error { | ||
panic("tried to call Delete on a readonly store") |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods Warning
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
…22183) Co-authored-by: son trinh <trinhleson2000@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
Description
follow up to: #21382
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
Refactor