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: v2.6 migrations #192

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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 @@
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
Loading