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

Dang/upgrade handler #200

Merged
merged 12 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
tfmwKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
tfmwKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
)

// Link to default ante handler used by cosmos sdk:
Expand Down
2 changes: 1 addition & 1 deletion app/ante/ibc_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/cosmos/cosmos-sdk/x/authz"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
tfmwKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
tfmwKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
)

type IBCPermissionDecorator struct {
Expand Down
82 changes: 65 additions & 17 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/bank"
bech32stakingmigration "github.com/notional-labs/centauri/v3/bech32-migration/staking"
bech32stakingmigration "github.com/notional-labs/centauri/v4/bech32-migration/staking"

"github.com/notional-labs/centauri/v4/app/keepers"
v4 "github.com/notional-labs/centauri/v4/app/upgrades/v4"

"github.com/notional-labs/centauri/v3/app/keepers"
// bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/capability"
Expand Down Expand Up @@ -82,34 +84,35 @@
icq "github.com/strangelove-ventures/async-icq/v7"
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"

reward "github.com/notional-labs/centauri/v3/app/upgrade/reward"
custombankmodule "github.com/notional-labs/centauri/v3/custom/bank"
custombankmodule "github.com/notional-labs/centauri/v4/custom/bank"
"github.com/strangelove-ventures/packet-forward-middleware/v7/router"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v7/router/types"
alliancemodule "github.com/terra-money/alliance/x/alliance"
alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

"github.com/notional-labs/centauri/v3/app/ante"
transfermiddleware "github.com/notional-labs/centauri/v3/x/transfermiddleware"
transfermiddlewaretypes "github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
"github.com/notional-labs/centauri/v4/app/ante"
transfermiddleware "github.com/notional-labs/centauri/v4/x/transfermiddleware"
transfermiddlewaretypes "github.com/notional-labs/centauri/v4/x/transfermiddleware/types"

ratelimitmodule "github.com/notional-labs/centauri/v3/x/ratelimit"
ratelimitmoduletypes "github.com/notional-labs/centauri/v3/x/ratelimit/types"
ratelimitmodule "github.com/notional-labs/centauri/v4/x/ratelimit"
ratelimitmoduletypes "github.com/notional-labs/centauri/v4/x/ratelimit/types"

consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

"github.com/notional-labs/centauri/v3/x/mint"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
"github.com/notional-labs/centauri/v4/x/mint"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"

ibc_hooks "github.com/notional-labs/centauri/v3/x/ibc-hooks"
ibchookstypes "github.com/notional-labs/centauri/v3/x/ibc-hooks/types"
ibc_hooks "github.com/notional-labs/centauri/v4/x/ibc-hooks"
ibchookstypes "github.com/notional-labs/centauri/v4/x/ibc-hooks/types"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

upgrades "github.com/notional-labs/centauri/v4/app/upgrades"
)

const (
Expand All @@ -126,6 +129,8 @@
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v4.Upgrade}
)

// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
Expand Down Expand Up @@ -295,7 +300,7 @@
skipUpgradeHeights,
homePath,
)

app.setupUpgradeStoreLoaders()
app.InitNormalKeepers(
appCodec,
cdc,
Expand Down Expand Up @@ -463,6 +468,8 @@
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

app.setupUpgradeHandlers()

// create the simulation manager and define the order of the modules for deterministic simulations
// app.sm = module.NewSimulationManager(
// auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
Expand Down Expand Up @@ -523,9 +530,6 @@
}
}

// app.ScopedMonitoringKeeper = scopedMonitoringKeeper
app.UpgradeKeeper.SetUpgradeHandler(reward.UpgradeName, reward.CreateUpgradeHandler(app.mm, app.configurator, app.TransferMiddlewareKeeper, app.MintKeeper))

return app
}

Expand Down Expand Up @@ -664,3 +668,47 @@
func (app *CentauriApp) SimulationManager() *module.SimulationManager {
return app.sm
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
func (app *CentauriApp) setupUpgradeStoreLoaders() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}

currentHeight := app.CommitMultiStore().LastCommitID().Version

if upgradeInfo.Height == currentHeight+1 {
app.customPreUpgradeHandler(upgradeInfo)

Check warning

Code scanning / CodeQL

Expression has no effect Warning

This expression has no effect.
}

for _, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
}
}
}

func (app *CentauriApp) customPreUpgradeHandler(upgradeInfo upgradetypes.Plan) {
switch upgradeInfo.Name {
default:
}
}

func (app *CentauriApp) setupUpgradeHandlers() {
for _, upgrade := range Upgrades {
app.UpgradeKeeper.SetUpgradeHandler(
upgrade.UpgradeName,
upgrade.CreateUpgradeHandler(
app.mm,
app.configurator,
app.BaseApp,
&app.AppKeepers,
),
)
}
}
2 changes: 1 addition & 1 deletion app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/ibc-go/v7/testing/mock"
centauri "github.com/notional-labs/centauri/v3/app"
centauri "github.com/notional-labs/centauri/v4/app"
"github.com/stretchr/testify/require"
)

Expand Down
11 changes: 6 additions & 5 deletions app/ibctesting/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"testing"
"time"

ratelimitmodulekeeper "github.com/notional-labs/centauri/v4/x/ratelimit/keeper"

"cosmossdk.io/errors"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
Expand Down Expand Up @@ -49,10 +51,9 @@ import (
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/cosmos/ibc-go/v7/testing/mock"
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
centauri "github.com/notional-labs/centauri/v3/app"
"github.com/notional-labs/centauri/v3/app/ibctesting/simapp"
ratelimit "github.com/notional-labs/centauri/v3/x/ratelimit/keeper"
routerKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
centauri "github.com/notional-labs/centauri/v4/app"
"github.com/notional-labs/centauri/v4/app/ibctesting/simapp"
routerKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
Expand Down Expand Up @@ -617,7 +618,7 @@ func (chain *TestChain) TransferMiddleware() routerKeeper.Keeper {
return chain.GetTestSupport().TransferMiddleware()
}

func (chain *TestChain) RateLimit() ratelimit.Keeper {
func (chain *TestChain) RateLimit() ratelimitmodulekeeper.Keeper {
return chain.GetTestSupport().RateLimit()
}

Expand Down
20 changes: 10 additions & 10 deletions app/ibctesting/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ import (
"github.com/gorilla/mux"

// TODO: mint module not complete yet,
"github.com/notional-labs/centauri/v3/x/mint"
mintkeeper "github.com/notional-labs/centauri/v3/x/mint/keeper"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
"github.com/notional-labs/centauri/v4/x/mint"
mintkeeper "github.com/notional-labs/centauri/v4/x/mint/keeper"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand Down Expand Up @@ -123,13 +123,13 @@ import (
wasm08 "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/keeper"
ibcmock "github.com/cosmos/ibc-go/v7/testing/mock"
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
simappparams "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/params"
simappupgrades "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/upgrades"
v6 "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/upgrades/v6"
v7 "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/upgrades/v7"
transfermiddleware "github.com/notional-labs/centauri/v3/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
simappparams "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/params"
simappupgrades "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/upgrades"
v6 "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/upgrades/v6"
v7 "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/upgrades/v7"
transfermiddleware "github.com/notional-labs/centauri/v4/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/centauri/v4/x/transfermiddleware/types"
)

const appName = "SimApp"
Expand Down
2 changes: 1 addition & 1 deletion app/ibctesting/simapp/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package simapp
import (
"github.com/cosmos/cosmos-sdk/std"

simappparams "github.com/notional-labs/centauri/v3/app/ibctesting/simapp/params"
simappparams "github.com/notional-labs/centauri/v4/app/ibctesting/simapp/params"
)

// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
Expand Down
2 changes: 1 addition & 1 deletion app/ibctesting/simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/simulation"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"
"github.com/stretchr/testify/require"

ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand Down
24 changes: 12 additions & 12 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import (
icqkeeper "github.com/strangelove-ventures/async-icq/v7/keeper"
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"

custombankkeeper "github.com/notional-labs/centauri/v3/custom/bank/keeper"
custombankkeeper "github.com/notional-labs/centauri/v4/custom/bank/keeper"

"github.com/strangelove-ventures/packet-forward-middleware/v7/router"
routerkeeper "github.com/strangelove-ventures/packet-forward-middleware/v7/router/keeper"
Expand All @@ -73,29 +73,29 @@ import (
alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

transfermiddleware "github.com/notional-labs/centauri/v3/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
transfermiddleware "github.com/notional-labs/centauri/v4/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/centauri/v4/x/transfermiddleware/types"

ratelimitmodule "github.com/notional-labs/centauri/v3/x/ratelimit"
ratelimitmodulekeeper "github.com/notional-labs/centauri/v3/x/ratelimit/keeper"
ratelimitmoduletypes "github.com/notional-labs/centauri/v3/x/ratelimit/types"
ratelimitmodule "github.com/notional-labs/centauri/v4/x/ratelimit"
ratelimitmodulekeeper "github.com/notional-labs/centauri/v4/x/ratelimit/keeper"
ratelimitmoduletypes "github.com/notional-labs/centauri/v4/x/ratelimit/types"

consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

mintkeeper "github.com/notional-labs/centauri/v3/x/mint/keeper"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
mintkeeper "github.com/notional-labs/centauri/v4/x/mint/keeper"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

"github.com/CosmWasm/wasmd/x/wasm"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
wasm08Keeper "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/keeper"
wasmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"

ibc_hooks "github.com/notional-labs/centauri/v3/x/ibc-hooks"
ibchookskeeper "github.com/notional-labs/centauri/v3/x/ibc-hooks/keeper"
ibchookstypes "github.com/notional-labs/centauri/v3/x/ibc-hooks/types"
ibc_hooks "github.com/notional-labs/centauri/v4/x/ibc-hooks"
ibchookskeeper "github.com/notional-labs/centauri/v4/x/ibc-hooks/keeper"
ibchookstypes "github.com/notional-labs/centauri/v4/x/ibc-hooks/types"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v7/router/types"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

ibchookstypes "github.com/notional-labs/centauri/v3/x/ibc-hooks/types"
transfermiddlewaretypes "github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
ibchookstypes "github.com/notional-labs/centauri/v4/x/ibc-hooks/types"
ratelimitmoduletypes "github.com/notional-labs/centauri/v4/x/ratelimit/types"
transfermiddlewaretypes "github.com/notional-labs/centauri/v4/x/transfermiddleware/types"

consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
ratelimitmoduletypes "github.com/notional-labs/centauri/v3/x/ratelimit/types"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

"github.com/CosmWasm/wasmd/x/wasm"
wasm08types "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"
Expand Down
7 changes: 3 additions & 4 deletions app/test_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"

"github.com/cosmos/cosmos-sdk/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
Expand All @@ -16,8 +15,8 @@ import (
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
wasm08 "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/keeper"
ratelimitKeeper "github.com/notional-labs/centauri/v3/x/ratelimit/keeper"
tfmdKeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
ratelimitkeeper "github.com/notional-labs/centauri/v4/x/ratelimit/keeper"
tfmdKeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
)

type TestSupport struct {
Expand Down Expand Up @@ -86,6 +85,6 @@ func (s TestSupport) TransferMiddleware() tfmdKeeper.Keeper {
return s.app.TransferMiddlewareKeeper
}

func (s TestSupport) RateLimit() ratelimitKeeper.Keeper {
func (s TestSupport) RateLimit() ratelimitkeeper.Keeper {
return s.app.RatelimitKeeper
}
2 changes: 1 addition & 1 deletion app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
minttypes "github.com/notional-labs/centauri/v3/x/mint/types"
minttypes "github.com/notional-labs/centauri/v4/x/mint/types"

"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (

govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"

bech32authmigration "github.com/notional-labs/centauri/v3/bech32-migration/auth"
bech32govmigration "github.com/notional-labs/centauri/v3/bech32-migration/gov"
bech32slashingmigration "github.com/notional-labs/centauri/v3/bech32-migration/slashing"
bech32stakingmigration "github.com/notional-labs/centauri/v3/bech32-migration/staking"
bech32authmigration "github.com/notional-labs/centauri/v4/bech32-migration/auth"
bech32govmigration "github.com/notional-labs/centauri/v4/bech32-migration/gov"
bech32slashingmigration "github.com/notional-labs/centauri/v4/bech32-migration/slashing"
bech32stakingmigration "github.com/notional-labs/centauri/v4/bech32-migration/staking"
)

func CreateUpgradeHandler(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
mintkeeper "github.com/notional-labs/centauri/v3/x/mint/keeper"
tfmwkeeper "github.com/notional-labs/centauri/v3/x/transfermiddleware/keeper"
mintkeeper "github.com/notional-labs/centauri/v4/x/mint/keeper"
tfmwkeeper "github.com/notional-labs/centauri/v4/x/transfermiddleware/keeper"
)

var listAllowedRelayAddress = []string{
Expand Down
Loading
Loading