-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix (x/accounts): Fix genesis condition check #20645
Conversation
This reverts commit 214605b.
Warning Rate limit exceeded@sontrinh16 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 32 minutes and 49 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe change in the Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
can we modify a test case to make sure this isnt changed in the future
gotcha |
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: 1
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- x/accounts/genesis.go (1 hunks)
Additional context used
Path-based instructions (1)
x/accounts/genesis.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (1)
x/accounts/genesis.go (1)
77-77
: The change from checking ifgenState.Accounts
is nil to checking its length is a logical improvement. It ensures that the function behaves correctly even whengenState.Accounts
is an empty slice, not just nil.
@@ -74,7 +74,7 @@ func (k Keeper) ImportState(ctx context.Context, genState *v1.GenesisState) erro | |||
|
|||
// we set the latest account number only if there were any genesis accounts, otherwise | |||
// we leave it unset. | |||
if genState.Accounts != nil { | |||
if len(genState.Accounts) != 0 { |
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.
Consider enhancing the error message formatting to include more context about the error, which could help in debugging. For example, including the account number along with the address might provide quicker insights during issues.
- return fmt.Errorf("%w: %s", err, acc.Address)
+ return fmt.Errorf("error importing account %d (%s): %w", acc.AccountNumber, acc.Address, err)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if len(genState.Accounts) != 0 { | |
if len(genState.Accounts) != 0 { | |
for _, acc := range genState.Accounts { | |
if err := k.importAccount(ctx, acc); err != nil { | |
return fmt.Errorf("error importing account %d (%s): %w", acc.AccountNumber, acc.Address, err) | |
} | |
} | |
} |
@sontrinh16 your pull request is missing a changelog! |
done |
* main: fix(x/staking): stop validators from rotating to the same key on the same block (#20649) perf: add cache to address codec (#20122) build(deps): Bump google.golang.org/protobuf from 1.34.1 to 1.34.2 (#20632) fix: remove recipient amount from map (#20625) fix(proto): remove conditional preventing proper generated file placement (#20650) (serverv2/cometbft) Read config from commands & handle `FlagNode` (#20621) fix(x/consensus): fix .proto file placement (#20646) fix(store): avoid nil error on not exhausted payload stream (#20644) fix (x/accounts): Fix genesis condition check (#20645) feat(accounts): add genesis account initialization (#20642) fix(x/gov): limit execution in gov (#20348)
Description
Closes: #XXXX
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