-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "keep behavior of random opcode"
This reverts commit a96519d.
- Loading branch information
Showing
11 changed files
with
275 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,151 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" | ||
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" | ||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" | ||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" | ||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" | ||
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" | ||
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" | ||
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" | ||
clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" | ||
"github.com/cosmos/ibc-go/v7/modules/core/exported" | ||
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" | ||
cronostypes "github.com/crypto-org-chain/cronos/v2/x/cronos/types" | ||
icaauthtypes "github.com/crypto-org-chain/cronos/v2/x/icaauth/types" | ||
v0evmtypes "github.com/evmos/ethermint/x/evm/migrations/v0/types" | ||
evmtypes "github.com/evmos/ethermint/x/evm/types" | ||
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" | ||
) | ||
|
||
func (app *App) RegisterUpgradeHandlers(cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) { | ||
planName := "v1.1" | ||
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
planName := "v1.1.0" | ||
// Set param key table for params module migration | ||
for _, subspace := range app.ParamsKeeper.GetSubspaces() { | ||
var keyTable paramstypes.KeyTable | ||
switch subspace.Name() { | ||
case authtypes.ModuleName: | ||
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck | ||
case banktypes.ModuleName: | ||
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck | ||
case stakingtypes.ModuleName: | ||
keyTable = stakingtypes.ParamKeyTable() | ||
case minttypes.ModuleName: | ||
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck | ||
case distrtypes.ModuleName: | ||
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck | ||
case slashingtypes.ModuleName: | ||
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck | ||
case govtypes.ModuleName: | ||
keyTable = govv1.ParamKeyTable() //nolint:staticcheck | ||
case crisistypes.ModuleName: | ||
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck | ||
case ibctransfertypes.ModuleName: | ||
keyTable = ibctransfertypes.ParamKeyTable() | ||
case icacontrollertypes.SubModuleName: | ||
keyTable = icacontrollertypes.ParamKeyTable() | ||
case icaauthtypes.ModuleName: | ||
keyTable = icaauthtypes.ParamKeyTable() | ||
case evmtypes.ModuleName: | ||
keyTable = v0evmtypes.ParamKeyTable() //nolint:staticcheck | ||
case feemarkettypes.ModuleName: | ||
keyTable = feemarkettypes.ParamKeyTable() | ||
case cronostypes.ModuleName: | ||
keyTable = cronostypes.ParamKeyTable() | ||
default: | ||
continue | ||
} | ||
if !subspace.HasKeyTable() { | ||
subspace.WithKeyTable(keyTable) | ||
} | ||
} | ||
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) | ||
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
// OPTIONAL: prune expired tendermint consensus states to save storage space | ||
if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, cdc, clientKeeper); err != nil { | ||
return nil, err | ||
} | ||
// explicitly update the IBC 02-client params, adding the localhost client type | ||
params := clientKeeper.GetParams(ctx) | ||
params.AllowedClients = append(params.AllowedClients, exported.Localhost) | ||
clientKeeper.SetParams(ctx, params) | ||
|
||
// Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module. | ||
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper) | ||
if icaModule, ok := app.mm.Modules[icatypes.ModuleName].(ica.AppModule); ok { | ||
// set the ICS27 consensus version so InitGenesis is not run | ||
version := icaModule.ConsensusVersion() | ||
fromVM[icatypes.ModuleName] = version | ||
|
||
// create ICS27 Controller submodule params | ||
controllerParams := icacontrollertypes.Params{ | ||
ControllerEnabled: true, | ||
} | ||
|
||
// initialize ICS27 module | ||
icaModule.InitModule(ctx, controllerParams, icahosttypes.Params{}) | ||
} | ||
|
||
m, err := app.mm.RunMigrations(ctx, app.configurator, fromVM) | ||
if err != nil { | ||
return m, err | ||
} | ||
|
||
// enlarge block gas limit | ||
consParams, err := app.ConsensusParamsKeeper.Get(ctx) | ||
if err != nil { | ||
return m, err | ||
} | ||
consParams.Block.MaxGas = 60_000_000 | ||
app.ConsensusParamsKeeper.Set(ctx, consParams) | ||
return m, nil | ||
}) | ||
|
||
testnetPlanName := "v1.1.0-testnet-1" | ||
app.UpgradeKeeper.SetUpgradeHandler(testnetPlanName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
m, err := app.mm.RunMigrations(ctx, app.configurator, fromVM) | ||
if err != nil { | ||
return m, err | ||
} | ||
return m, nil | ||
}) | ||
|
||
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) { | ||
if upgradeInfo.Name == planName { | ||
storeUpgrades := storetypes.StoreUpgrades{ | ||
Added: []string{ | ||
consensusparamtypes.StoreKey, | ||
crisistypes.StoreKey, | ||
icacontrollertypes.StoreKey, | ||
icaauthtypes.StoreKey, | ||
}, | ||
Deleted: []string{ | ||
authzkeeper.StoreKey, | ||
}, | ||
} | ||
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
local config = import 'default.jsonnet'; | ||
|
||
config { | ||
'cronos_777-1'+: { | ||
'app-config'+: { | ||
'app-db-backend': 'rocksdb', | ||
'minimum-gas-prices': '100000000000basetcro', | ||
'iavl-lazy-loading':: super['iavl-lazy-loading'], | ||
}, | ||
genesis+: { | ||
consensus_params+: { | ||
block+: { | ||
max_gas: '60000000', | ||
}, | ||
}, | ||
app_state+: { | ||
bank+: { | ||
send_enabled+: [ | ||
{ | ||
denom: 'stake', | ||
enabled: true, | ||
}, | ||
{ | ||
denom: 'basetcro', | ||
enabled: false, | ||
}, | ||
], | ||
}, | ||
feemarket+: { | ||
params+: { | ||
no_base_fee: false, | ||
base_fee:: super.base_fee, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
integration_tests/configs/upgrade-testnet-test-package.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let | ||
pkgs = import ../../nix { }; | ||
fetchFlake = repo: rev: (pkgs.flake-compat { | ||
src = { | ||
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; | ||
inherit rev; | ||
shortRev = builtins.substring 0 7 rev; | ||
}; | ||
}).defaultNix; | ||
# v1.1.0-rc3 | ||
released = (fetchFlake "crypto-org-chain/cronos" "b7b261a3652cdf3ee2e224e777a40ce6dbbb0da5").default; | ||
current = pkgs.callPackage ../../. { }; | ||
in | ||
pkgs.linkFarm "upgrade-test-package" [ | ||
{ name = "genesis"; path = released; } | ||
{ name = "v1.1.0-testnet-1"; path = current; } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.