Skip to content

Commit

Permalink
fix: correct for premature creation of provision account during upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
JimLarson committed May 7, 2023
1 parent 2788f8d commit 4edf64f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,25 @@ func NewAgoricApp(
func upgrade10Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
app.VstorageKeeper.MigrateNoDataPlaceholders(ctx) // upgrade-10 only
migrateProvisionAccount(ctx, app.AccountKeeper)
return fromVm, nil
}
}

// migrateProvisionAccount ensures that the vbank/provision account is a module account.
func migrateProvisionAccount(ctx sdk.Context, ak authkeeper.AccountKeeper) {
provisionAddr := ak.GetModuleAddress(vbanktypes.ProvisionPoolName)
provisionAcct := ak.GetAccount(ctx, provisionAddr)
if _, ok := provisionAcct.(authtypes.ModuleAccountI); ok {
return
}
perms := maccPerms[vbanktypes.ProvisionPoolName]
newAcct := authtypes.NewEmptyModuleAccount(vbanktypes.ProvisionPoolName, perms...)
newAcct.AccountNumber = provisionAcct.GetAccountNumber()
newAcct.Sequence = provisionAcct.GetSequence()
ak.SetModuleAccount(ctx, newAcct)
}

type cosmosInitAction struct {
Type string `json:"type"`
ChainID string `json:"chainID"`
Expand Down

0 comments on commit 4edf64f

Please sign in to comment.