Skip to content

Commit

Permalink
Merge pull request #1886 from Sifchain/testnet
Browse files Browse the repository at this point in the history
[ChainOps] Latest merge to master
  • Loading branch information
intl-man authored Sep 17, 2021
2 parents 2fe84f1 + 571c3ad commit a54165b
Show file tree
Hide file tree
Showing 8 changed files with 610 additions and 17 deletions.
23 changes: 20 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package app

import (
tokenregistrykeeper "github.com/Sifchain/sifnode/x/tokenregistry/keeper"
tmos "github.com/tendermint/tendermint/libs/os"
"io"
"math/big"
"net/http"
"os"

tokenregistrykeeper "github.com/Sifchain/sifnode/x/tokenregistry/keeper"
tmos "github.com/tendermint/tendermint/libs/os"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand Down Expand Up @@ -55,6 +56,9 @@ import (
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/keeper"
ibcmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
Expand Down Expand Up @@ -107,6 +111,7 @@ var (
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler,
Expand All @@ -128,6 +133,7 @@ var (
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -173,6 +179,7 @@ type SifchainApp struct {
GovKeeper govkeeper.Keeper
StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
Expand Down Expand Up @@ -215,6 +222,7 @@ func NewSifApp(
paramstypes.StoreKey,
upgradetypes.StoreKey,
govtypes.StoreKey,
minttypes.StoreKey,
distrtypes.StoreKey,
slashingtypes.StoreKey,
evidencetypes.StoreKey,
Expand Down Expand Up @@ -271,6 +279,11 @@ func NewSifApp(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
)

app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName,
)

app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
Expand Down Expand Up @@ -375,6 +388,7 @@ func NewSifApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
Expand All @@ -395,9 +409,10 @@ func NewSifApp(
// CanWithdrawInvariant invariant.
app.mm.SetOrderBeginBlockers(
capabilitytypes.ModuleName,
upgradetypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
upgradetypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
ibchost.ModuleName,
Expand All @@ -419,6 +434,7 @@ func NewSifApp(
slashingtypes.ModuleName,
genutiltypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
evidencetypes.ModuleName,
ibchost.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -607,6 +623,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA
paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(clptypes.ModuleName)
Expand Down
26 changes: 15 additions & 11 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
package app

import (
tokenregistrymigrations "github.com/Sifchain/sifnode/x/tokenregistry/migrations"
tokenregistrytypes "github.com/Sifchain/sifnode/x/tokenregistry/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const upgradeNameV095 = "0.9.5"
const upgradeName = "0.9.7"

func SetupHandlers(app *SifchainApp) {
SetupHandlersForV095(app)
SetupHandlersForMint(app)
}

func SetupHandlersForV095(app *SifchainApp) {
app.UpgradeKeeper.SetUpgradeHandler("0.9.5", func(ctx sdk.Context, plan types.Plan) {
app.Logger().Info("Running upgrade handler for " + upgradeNameV095 + " with new store " + tokenregistrytypes.StoreKey)
// Install initial token registry entries for non-ibc tokens.
tokenregistrymigrations.Init(ctx, app.TokenRegistryKeeper)
func SetupHandlersForMint(app *SifchainApp) {
app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan types.Plan) {
app.Logger().Info("Running upgrade handler for " + upgradeName + " with new store " + minttypes.StoreKey)
// Install initial params and minter for mint module.
mintGenesis := minttypes.DefaultGenesisState()
// Replace default MintDenom with staking bond denom.
mintGenesis.Params.MintDenom = app.StakingKeeper.GetParams(ctx).BondDenom
mint.InitGenesis(ctx, app.MintKeeper, app.AccountKeeper, mintGenesis)

})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == upgradeNameV095 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{tokenregistrytypes.StoreKey},
Added: []string{minttypes.StoreKey},
}

// Use upgrade store loader for the initial loading of all stores when app starts,
Expand Down
2 changes: 1 addition & 1 deletion cmd/sifnoded/cmd/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestMigrateGenesisDataCmd(t *testing.T) {
cmd, _ := NewRootCmd()
migrateOutputBuf := new(bytes.Buffer)
cmd.SetOut(migrateOutputBuf)
// This test file has been run through sifnoded migrate, and IBC state added.
// This test file has been run through sifnoded migrate, and IBC and Mint state added.
cmd.SetArgs([]string{"migrate-data", "v0.9", "testdata/v039_exported_migrated_state.json"})

app.SetConfig(false)
Expand Down
Loading

0 comments on commit a54165b

Please sign in to comment.