-
Notifications
You must be signed in to change notification settings - Fork 273
Problem: can't support prevrando opcode #1366
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,151 +1,20 @@ | ||
| 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.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) { | ||
| planName := "v1.2" | ||
| app.UpgradeKeeper.SetUpgradeHandler(planName, 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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: 0 additions & 17 deletions
17
integration_tests/configs/upgrade-testnet-test-package.nix
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,8 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.15; | ||
|
|
||
| contract Random { | ||
| function randomTokenId() public returns (uint256) { | ||
| return uint256(keccak256(abi.encodePacked(block.prevrandao))); | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.