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 auth genesis account number handling. #228

Merged
merged 7 commits into from
Aug 18, 2022

Conversation

SpicyLemon
Copy link

@SpicyLemon SpicyLemon commented Aug 18, 2022

Description

This fixes the account keeper's InitGenesis to
a) Allow for missing account numbers.
b) Only change account numbers that are duplicated.
c) Accounts with duplicated account numbers get updated account numbers in a deterministic way (based on the order they were originally provided).

This also adds a simulation decoder for the newly added AccountNumberStoreKeyPrefix.

Prior to this PR, all account numbers in the provided accounts were rewritten to be sequential starting with 0. The list was sorted by account number before doing that, but if there was a missing account number, all account numbers larger than the missing one were reduced by 1. Also, since sort.Slice isn't guaranteed to be stable, if there were accounts with duplicate account numbers, the final "sorted" list was nondeterministic.


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)

@SpicyLemon
Copy link
Author

All unit tests passed locally (on the 3rd run).

1st run:

  • /client failed: panic leveldb closed.
  • /x/auth/client/testutil failed: couldn't find a transaction
  • /x/auth/tx failed: queries were 1 tx short.
  • x/feegrant/client/testutil couldn't find an account.

All of those are pretty usual on the first make test run.

2nd run:

  • /client failed: empty proof.

3rd run:

  • No failures.

@SpicyLemon SpicyLemon merged this pull request into release-pio/v0.46.x Aug 18, 2022
SpicyLemon added a commit that referenced this pull request Aug 18, 2022
* Add a sim state decocoder for the auth account number entries.

* Don't change account numbers during auth InitGenesis when the genesis state is missing one.

* Tweak auth InitGenesis to make sure that GetNextAccountNumber is called when there's only 1 account with the number 0.

* Update SanitizeGenesisAccounts to update accounts with duplicated account numbers so that all account numbers are unique.

* Add some unit tests on the AccountKeeper's InitGenesis function.

* Add some unit tests on the SanitizeGenesisAccounts changes.

* add a comment about using a *uint64 (instead of just a uint64).
@SpicyLemon SpicyLemon deleted the prov/dwedul-0.46-fix-auth-sim-decoder branch June 8, 2023 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants