-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
…dekunze/ADR-11-generalize-gen-accs
I was working on this implementation for a couple of days, didn’t realise you were also @fedekunze . |
Codecov Report
@@ 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 |
Sorry about that. Usually self-assigning to an open issue and opening a work-in-progress PR |
@fedekunze @rhuairahrighairidh what do you recommend in order to proceed? |
@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. |
that sounds good, this one is further ahead |
Reviewed, thanks @fedekunze! I think this PR needs to be tested thoroughly against/with Gaia. In addition, the |
Co-Authored-By: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
….com/cosmos/cosmos-sdk into fedekunze/ADR-11-generalize-gen-accs
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.
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
.
So this isn't actually and ADR but an ADR implementation.. we should make that more clear in the title of this PR |
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.
Minor comments throughout. Although obviously need to resolve all CI issues before merge
|
||
// 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") |
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.
Additionally we should provided a function: SealAccountTypeCodec
to be used after all auth types have been registered
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.
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) |
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.
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 { |
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.
nice! I'm a fan of this pattern
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.
testedACK:
- Fixed migration logic
- Updated changelog
- Added concrete simulation genesis account type
- Added tests
- Tested migration against gaia 2.0.0
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 inCHANGELOG.md
Re-reviewed
Files changed
in the github PR explorerFor Admin Use: