-
Notifications
You must be signed in to change notification settings - Fork 626
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: simapp and upgrade configuration for e2e v7 upgrade #3136
Changes from 18 commits
8262756
2442711
47d6f74
6ed71d8
ae4ceb1
b665d3f
44c7ece
4d1cf73
d8e3e05
889f0c1
e7203d0
306a935
fe6ad84
14f19d7
82594a1
dc9907d
9f0565a
641b25e
287c9dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,22 @@ package simapp | |
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"os" | ||
"path/filepath" | ||
|
||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" | ||
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" | ||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
_ "github.com/cosmos/cosmos-sdk/client/docs/statik" // this is used for serving docs | ||
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" | ||
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" | ||
"github.com/cosmos/cosmos-sdk/server/api" | ||
"github.com/cosmos/cosmos-sdk/server/config" | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
|
@@ -305,7 +309,7 @@ func NewSimApp( | |
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) | ||
|
||
// set the BaseApp's parameter store | ||
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) | ||
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a misconfiguration in #2672 |
||
bApp.SetParamStore(&app.ConsensusParamsKeeper) | ||
|
||
// add capability keeper and ScopeToModule for ibc module | ||
|
@@ -602,6 +606,14 @@ func NewSimApp( | |
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) | ||
app.mm.RegisterServices(app.configurator) | ||
|
||
autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules)) | ||
|
||
reflectionSvc, err := runtimeservices.NewReflectionService() | ||
if err != nil { | ||
panic(err) | ||
} | ||
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) | ||
|
||
// add test gRPC service for testing gRPC queries in isolation | ||
testdata.RegisterQueryServer(app.GRPCQueryRouter(), testdata.QueryImpl{}) | ||
|
||
|
@@ -658,6 +670,7 @@ func NewSimApp( | |
app.SetEndBlocker(app.EndBlocker) | ||
|
||
app.setupUpgradeHandlers() | ||
app.setupUpgradeStoreLoaders() | ||
|
||
if loadLatest { | ||
if err := app.LoadLatestVersion(); err != nil { | ||
|
@@ -823,6 +836,9 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon | |
// Register legacy and grpc-gateway routes for all modules. | ||
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) | ||
|
||
// Register nodeservice grpc-gateway routes. | ||
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) | ||
|
||
// register swagger API from root so that other applications can override easily | ||
if apiConfig.Swagger { | ||
RegisterSwaggerAPI(clientCtx, apiSvr.Router) | ||
|
@@ -892,14 +908,14 @@ func BlockedAddresses() map[string]bool { | |
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { | ||
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) | ||
|
||
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(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) | ||
paramsKeeper.Subspace(crisistypes.ModuleName) | ||
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) | ||
Comment on lines
+911
to
+918
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding This registration was previously done in each if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
} The param set pair types need to be registered in order to perform the migrations for modules maintaining their own params, otherwise we fail here. Essentially, the key-value attributes are maintained in memory in this map. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice find. Will this be removable in the future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we can remove this post v7. We will have to do something similar when we migrate params for ibc-go modules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Should we have an issue for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #3141 |
||
paramsKeeper.Subspace(ibctransfertypes.ModuleName) | ||
paramsKeeper.Subspace(ibcexported.ModuleName) | ||
paramsKeeper.Subspace(icacontrollertypes.SubModuleName) | ||
|
@@ -938,6 +954,28 @@ func (app *SimApp) setupUpgradeHandlers() { | |
app.configurator, | ||
app.appCodec, | ||
app.IBCKeeper.ClientKeeper, | ||
app.ConsensusParamsKeeper, | ||
app.ParamsKeeper, | ||
), | ||
) | ||
} | ||
|
||
// setupUpgradeStoreLoaders sets all necessary store loaders required by upgrades. | ||
func (app *SimApp) setupUpgradeStoreLoaders() { | ||
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() | ||
if err != nil { | ||
tmos.Exit(fmt.Sprintf("failed to read upgrade info from disk %s", err)) | ||
} | ||
|
||
if upgradeInfo.Name == v7.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { | ||
storeUpgrades := storetypes.StoreUpgrades{ | ||
Added: []string{ | ||
consensusparamtypes.StoreKey, | ||
crisistypes.StoreKey, | ||
Comment on lines
+973
to
+974
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds store keys for The new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this logic is repeated for every new module. If we need to do it again for a new module, it'd probably make sense to turn into a helper function. Looks great to me as is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I agree. We could possible adopt the osmosis upgrade structure, but may require some refactoring of app.go. |
||
}, | ||
} | ||
|
||
// configure store loader that checks if version == upgradeHeight and applies store upgrades | ||
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will essentially need to be
v7.0.0-rc1
when this PR is merged, backported and tagged in rc1.