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

fix: InitGenesis changes account numbers (upstream fix from Provenance) #13877

Merged
merged 10 commits into from
Nov 16, 2022

Conversation

facundomedica
Copy link
Member

@facundomedica facundomedica commented Nov 15, 2022

Description

Pretty much a copy-paste from @SpicyLemon 's work at provenance-io#228 + some tiny extras (the only difference is that we set the fee_collector account in tests).

Closes: #13033


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@facundomedica facundomedica marked this pull request as ready for review November 15, 2022 20:55
@facundomedica facundomedica requested a review from a team as a code owner November 15, 2022 20:55
for _, acc := range accounts {
accNum := acc.GetAccountNumber()
for lastAccNum == nil || *lastAccNum < accNum {
n := ak.GetNextAccountNumber(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was scratching my head at this thinking "this doesn't actually do anything". Then I took a look at GetNextAccountNumber and realized it's mutative. It really should be called NextAccountNumber or IncrAccountNumber IMO.

Copy link
Contributor

@alexanderbez alexanderbez Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're backporting this to 0.47, I recommend we fix this API. If we're backporting to 0.47 and 0.46/0.45, then I recommend we create a second method that calls the existing so we don't break APIs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Get makes it sound like a read-only operation but it's doing:

bz = ak.cdc.MustMarshal(&gogotypes.UInt64Value{Value: accNumber + 1})
store.Set(types.GlobalAccountNumberKey, bz)

Not sure, if we are backporting to previous versions. @tac0turtle ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we're def. backporting to 0.47 (I added the label). Older versions I'm not sure. Which ever way, we can accommodate :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, lets at a minimum do 0.47. It would be nice to have the api make it more explicit it changes state.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so we rename it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

@alexanderbez alexanderbez added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Nov 15, 2022
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. Pending the API renaming #13877 (comment).

x/auth/keeper/keeper_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@codecov
Copy link

codecov bot commented Nov 16, 2022

Codecov Report

Merging #13877 (767fc24) into main (f82775b) will increase coverage by 0.00%.
The diff coverage is 53.84%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #13877   +/-   ##
=======================================
  Coverage   56.56%   56.56%           
=======================================
  Files         638      638           
  Lines       54877    54904   +27     
=======================================
+ Hits        31040    31056   +16     
- Misses      21317    21323    +6     
- Partials     2520     2525    +5     
Impacted Files Coverage Δ
x/auth/keeper/account.go 76.66% <0.00%> (+23.33%) ⬆️
x/group/keeper/keeper.go 56.07% <0.00%> (-0.18%) ⬇️
x/group/module/abci.go 20.00% <0.00%> (-30.00%) ⬇️
x/group/msgs.go 57.60% <0.00%> (+0.24%) ⬆️
x/group/types.go 47.57% <33.33%> (-1.22%) ⬇️
x/auth/types/genesis.go 59.29% <37.93%> (-7.38%) ⬇️
x/group/internal/math/dec.go 47.14% <60.00%> (+5.60%) ⬆️
x/group/keeper/msg_server.go 68.74% <66.66%> (+0.09%) ⬆️
x/auth/keeper/genesis.go 50.00% <100.00%> (+50.00%) ⬆️
x/auth/keeper/keeper.go 70.90% <100.00%> (ø)
... and 8 more

@@ -199,6 +200,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf
* (x/gov) [#13728](https://github.com/cosmos/cosmos-sdk/pull/13728) Fix propagation of message events to the current context in `EndBlocker`.
* (server) [#13778](https://github.com/cosmos/cosmos-sdk/pull/13778) Set Cosmos SDK default endpoints to localhost to avoid unknown exposure of endpoints.
* [#13861](https://github.com/cosmos/cosmos-sdk/pull/13861) Allow `_` characters in tx event queries, i.e. `GetTxsEvent`.
* (x/auth) [#13877](https://github.com/cosmos/cosmos-sdk/pull/13877) Handle missing account numbers during `InitGenesis`.
Copy link
Member

@julienrbrt julienrbrt Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a bug fix, wrong category. But I can shuffle it later if you want, so you don't have to wait CI another time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's under Bug Fixes, the diff viewer is bad lol

@facundomedica facundomedica merged commit 394f1b9 into main Nov 16, 2022
@facundomedica facundomedica deleted the facu/fix-13033 branch November 16, 2022 17:13
mergify bot pushed a commit that referenced this pull request Nov 16, 2022
…e) (#13877)

* fix: InitGenesis changes account numbers (upstream fix from Provenance)

* cl++

* rename GetNextAccountNumber to NextAccountNumber

* suggestion from @julienrbrt

* cl++

* fix readme

* missing replace

(cherry picked from commit 394f1b9)
tac0turtle pushed a commit that referenced this pull request Nov 16, 2022
…e) (#13877) (#13893)

* fix: InitGenesis changes account numbers (upstream fix from Provenance)

* cl++

* rename GetNextAccountNumber to NextAccountNumber

* suggestion from @julienrbrt

* cl++

* fix readme

* missing replace

(cherry picked from commit 394f1b9)

Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x/auth InitGenesis changes account numbers if there's a skipped entry.
5 participants