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

ADR 11: Generalize Gen Accounts implementation #5017

Merged
merged 26 commits into from
Sep 12, 2019

Conversation

fedekunze
Copy link
Collaborator

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md

  • Re-reviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

x/auth/simulation/genesis.go Outdated Show resolved Hide resolved
x/auth/types/genesis.go Outdated Show resolved Hide resolved
@fedekunze fedekunze added R4R and removed WIP labels Sep 10, 2019
@fedekunze fedekunze marked this pull request as ready for review September 10, 2019 14:54
@rhuairahrighairidh
Copy link
Contributor

I was working on this implementation for a couple of days, didn’t realise you were also @fedekunze .
What’s the procedure in cosmos-sdk to avoid duplicating work?

@codecov
Copy link

codecov bot commented Sep 10, 2019

Codecov Report

Merging #5017 into master will increase coverage by 0.08%.
The diff coverage is 61.11%.

@@            Coverage Diff             @@
##           master    #5017      +/-   ##
==========================================
+ Coverage   54.85%   54.94%   +0.08%     
==========================================
  Files         291      290       -1     
  Lines       17846    17805      -41     
==========================================
- Hits         9790     9783       -7     
+ Misses       7351     7316      -35     
- Partials      705      706       +1

@fedekunze
Copy link
Collaborator Author

I was working on this implementation for a couple of days, didn’t realize you were also @fedekunze .
What’s the procedure in cosmos-sdk to avoid duplicating work?

Sorry about that. Usually self-assigning to an open issue and opening a work-in-progress PR

@alexanderbez
Copy link
Contributor

@fedekunze @rhuairahrighairidh what do you recommend in order to proceed?

@fedekunze
Copy link
Collaborator Author

@alexanderbez the one from Kava Labs is still WIP Kava-Labs#3. I'd suggest reviewing this one and be more in sync with who's doing what.

@rhuairahrighairidh
Copy link
Contributor

that sounds good, this one is further ahead

@karzak karzak mentioned this pull request Sep 11, 2019
4 tasks
x/auth/alias.go Outdated Show resolved Hide resolved
x/auth/client/cli/genaccounts.go Outdated Show resolved Hide resolved
x/auth/exported/exported.go Outdated Show resolved Hide resolved
x/auth/genesis.go Outdated Show resolved Hide resolved
x/auth/genesis.go Outdated Show resolved Hide resolved
x/auth/types/codec.go Outdated Show resolved Hide resolved
x/auth/types/genesis.go Outdated Show resolved Hide resolved
x/genutil/legacy/v0_36/migrate.go Outdated Show resolved Hide resolved
x/supply/internal/types/account.go Outdated Show resolved Hide resolved
x/supply/internal/types/codec.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor

Reviewed, thanks @fedekunze! I think this PR needs to be tested thoroughly against/with Gaia. In addition, the add-genesis command needs to be implemented in the app, not here. Furthermore, there should be an actual GenesisAccount implementation...also, probably in Gaia.

fedekunze and others added 4 commits September 11, 2019 18:54
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Left a few more tidbits. Also, I believe we should leave the existing legacy migration logic in x/genaccounts/legacy/* and we must also implementation a migration in x/auth.

x/supply/internal/types/account.go Show resolved Hide resolved
x/genaccounts/legacy/v0_36/types.go Outdated Show resolved Hide resolved
x/genaccounts/legacy/v0_36/migrate_test.go Outdated Show resolved Hide resolved
@rigelrozanski
Copy link
Contributor

So this isn't actually and ADR but an ADR implementation.. we should make that more clear in the title of this PR

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

Minor comments throughout. Although obviously need to resolve all CI issues before merge

x/auth/types/codec.go Show resolved Hide resolved

// Register the module account type with the auth module codec so it can decode module accounts stored in a genesis file
func init() {
authTypes.RegisterAccountTypeCodec(ModuleAccount{}, "cosmos-sdk/ModuleAccount")
authtypes.RegisterAccountTypeCodec(ModuleAccount{}, "cosmos-sdk/ModuleAccount")
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally we should provided a function: SealAccountTypeCodec to be used after all auth types have been registered

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this function is necessary. The application will call {module}.ModuleCdc.Seal() somewhere near the end in the app constructor (e.g. gov.ModuleCdc.Seal()).

db := dbm.NewMemDB()
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)

// initialize the chain with the passed in genesis accounts
genesisState := NewDefaultGenesisState()
genesisState = genaccounts.SetGenesisStateInAppState(app.Codec(), genesisState, genaccounts.GenesisState(genAccs))

authGenesis := auth.NewGenesisState(auth.DefaultParams(), genAccs)
Copy link
Contributor

Choose a reason for hiding this comment

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

what are the default params here btw?

@@ -57,3 +57,9 @@ type VestingAccount interface {
GetDelegatedFree() sdk.Coins
GetDelegatedVesting() sdk.Coins
}

// GenesisAccount defines a genesis account that embeds an Account with validation capabilities.
type GenesisAccount interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice! I'm a fan of this pattern

x/auth/genesis.go Outdated Show resolved Hide resolved
x/auth/simulation/genesis.go Outdated Show resolved Hide resolved
x/auth/simulation/genesis.go Outdated Show resolved Hide resolved
x/auth/simulation/genesis.go Show resolved Hide resolved
x/auth/types/account.go Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

testedACK:

  • Fixed migration logic
  • Updated changelog
  • Added concrete simulation genesis account type
  • Added tests
  • Tested migration against gaia 2.0.0

@alexanderbez alexanderbez merged commit ed63666 into master Sep 12, 2019
@alexanderbez alexanderbez deleted the fedekunze/ADR-11-generalize-gen-accs branch September 12, 2019 19:24
@alexanderbez alexanderbez mentioned this pull request Sep 13, 2019
4 tasks
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
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.

6 participants