Skip to content
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

Sorting coins of the genesis balances is no effect #9706

Closed
4 tasks
whylee259 opened this issue Jul 16, 2021 · 5 comments · Fixed by #9829
Closed
4 tasks

Sorting coins of the genesis balances is no effect #9706

whylee259 opened this issue Jul 16, 2021 · 5 comments · Fixed by #9829
Assignees

Comments

@whylee259
Copy link
Contributor

Summary of Bug

https://github.com/cosmos/cosmos-sdk/blob/master/x/bank/types/balance.go#L57-L58

From the above code, Sort() is no effect due to the value receiver.
If the sorting is intended, the receiver should be a pointer receiver.

func (b *Balance) Validate() error {
...
}

Version

current master branch (615f224)

Steps to Reproduce


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@tac0turtle
Copy link
Member

@alexanderbez @AmauryM do you know if sorting was intended?

@alexanderbez
Copy link
Contributor

This is a certainly a code-smell! Validate should be stateless and not mutate, i.e. it should have no side effects. This is a bug. Want to submit a PR @marbar3778?

@amaury1093
Copy link
Contributor

Agreed. I would just throw an error if the coins are not sorted.

Since @whylee259 you found the bug, maybe you want to create a PR?

@spoo-bar
Copy link
Contributor

If @marbar3778 or @whylee259 aren't working on this, maybe I will take this? 😊

@alexanderbez
Copy link
Contributor

Please and thank you @spoo-bar 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants