Skip to content

Commit

Permalink
fix: v2.6 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Oct 23, 2023
1 parent 62957f0 commit 6ae6822
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ integration-test-all: init-test-framework \
test-relayer \
test-ica \
test-ibc-hooks \
test-vesting-accounts \
test-tokenfactory

init-test-framework: clean-testing-data install
Expand Down
8 changes: 8 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,13 @@ func NewTerraApp(
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
} else if upgradeInfo.Name == terraappconfig.Upgrade2_6 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
feesharetypes.StoreKey,
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if loadLatest {
Expand Down Expand Up @@ -1194,6 +1201,7 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) {
app.appCodec,
app.IBCKeeper.ClientKeeper,
app.AccountKeeper,
app.FeeShareKeeper,
),
)
}
Expand Down
19 changes: 16 additions & 3 deletions app/upgrades/v2.6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
pobtypes "github.com/skip-mev/pob/x/builder/types"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"
)

func CreateUpgradeHandler(
Expand All @@ -23,8 +25,12 @@ func CreateUpgradeHandler(
cdc codec.Codec,
clientKeeper clientkeeper.Keeper,
authKeeper authkeeper.AccountKeeper,
feesharekeeper feesharekeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// feeshare module is a new module added in v2.6,
// we need to set the default params
feesharekeeper.SetParams(ctx, feesharetypes.DefaultParams())

Check failure on line 33 in app/upgrades/v2.6/upgrade.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `feesharekeeper.SetParams` is not checked (errcheck)

// overwrite pob account to a module account for pisco-1
overwritePobModuleAccount(ctx, authKeeper)
Expand All @@ -43,9 +49,16 @@ func overwritePobModuleAccount(ctx sdk.Context, authKeeper authkeeper.AccountKee
if ctx.ChainID() == "pisco-1" {
macc := authtypes.NewEmptyModuleAccount(pobtypes.ModuleName)
pobaccount := authKeeper.GetAccount(ctx, macc.GetAddress())
macc.AccountNumber = pobaccount.GetAccountNumber()
maccI := (authKeeper.NewAccount(ctx, macc)).(authtypes.ModuleAccountI)
authKeeper.SetModuleAccount(ctx, maccI)
// if pob account exists, overwrite it
// if not, create a new one
if pobaccount != nil {
macc.AccountNumber = pobaccount.GetAccountNumber()
maccI := (authKeeper.NewAccount(ctx, macc)).(authtypes.ModuleAccountI)
authKeeper.SetModuleAccount(ctx, maccI)
} else {
maccI := (authKeeper.NewAccount(ctx, macc)).(authtypes.ModuleAccountI)
authKeeper.SetModuleAccount(ctx, maccI)
}
}
}

Expand Down

0 comments on commit 6ae6822

Please sign in to comment.