From a296bdc79450be41666e1d235ffd5ed0269305dd Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 9 Aug 2022 18:13:51 -0400 Subject: [PATCH] feat!: add x/upgrade params (#290) --- baseapp/baseapp.go | 4 +- docs/core/proto-docs.md | 50 ++++ proto/cosmos/upgrade/v1beta1/genesis.proto | 13 + proto/cosmos/upgrade/v1beta1/upgrade.proto | 31 +- simapp/app.go | 3 +- store/rootmulti/store.go | 11 +- store/types/store.go | 3 +- store/types/version_manager.go | 8 + x/upgrade/exported/exported.go | 16 +- x/upgrade/keeper/keeper.go | 32 +- x/upgrade/keeper/keeper_test.go | 7 +- x/upgrade/keeper/migrator.go | 21 ++ x/upgrade/keeper/params.go | 17 ++ x/upgrade/migrations/v2/migrate.go | 21 ++ x/upgrade/migrations/v2/migrate_test.go | 32 ++ x/upgrade/module.go | 43 ++- x/upgrade/types/genesis.go | 14 + x/upgrade/types/genesis.pb.go | 324 +++++++++++++++++++++ x/upgrade/types/params.go | 54 ++++ x/upgrade/types/upgrade.pb.go | 228 ++++++++++++--- 20 files changed, 857 insertions(+), 75 deletions(-) create mode 100644 proto/cosmos/upgrade/v1beta1/genesis.proto create mode 100644 store/types/version_manager.go create mode 100644 x/upgrade/keeper/migrator.go create mode 100644 x/upgrade/keeper/params.go create mode 100644 x/upgrade/migrations/v2/migrate.go create mode 100644 x/upgrade/migrations/v2/migrate_test.go create mode 100644 x/upgrade/types/genesis.go create mode 100644 x/upgrade/types/genesis.pb.go create mode 100644 x/upgrade/types/params.go diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index b7f24aead3a3..1f5d1a32f032 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -16,10 +16,10 @@ import ( "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/store/rootmulti" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" - upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/exported" ) const ( @@ -129,7 +129,7 @@ type BaseApp struct { // nolint: maligned indexEvents map[string]struct{} } -var _ upgrade.AppVersionManager = (*BaseApp)(nil) +var _ storetypes.AppVersionManager = (*BaseApp)(nil) // NewBaseApp returns a reference to an initialized BaseApp. It accepts a // variadic number of option functions, which act on the BaseApp to set diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index f30ade8a7d93..2c75d03e1f87 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -563,9 +563,13 @@ - [cosmos/upgrade/v1beta1/upgrade.proto](#cosmos/upgrade/v1beta1/upgrade.proto) - [CancelSoftwareUpgradeProposal](#cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal) - [ModuleVersion](#cosmos.upgrade.v1beta1.ModuleVersion) + - [Params](#cosmos.upgrade.v1beta1.Params) - [Plan](#cosmos.upgrade.v1beta1.Plan) - [SoftwareUpgradeProposal](#cosmos.upgrade.v1beta1.SoftwareUpgradeProposal) +- [cosmos/upgrade/v1beta1/genesis.proto](#cosmos/upgrade/v1beta1/genesis.proto) + - [GenesisState](#cosmos.upgrade.v1beta1.GenesisState) + - [cosmos/upgrade/v1beta1/query.proto](#cosmos/upgrade/v1beta1/query.proto) - [QueryAppliedPlanRequest](#cosmos.upgrade.v1beta1.QueryAppliedPlanRequest) - [QueryAppliedPlanResponse](#cosmos.upgrade.v1beta1.QueryAppliedPlanResponse) @@ -8060,6 +8064,21 @@ Since: cosmos-sdk 0.43 + + +### Params +Params defines the x/upgrade parameters. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `is_mainnet` | [bool](#bool) | | | + + + + + + ### Plan @@ -8096,6 +8115,37 @@ upgrade. + + + + + + + + + + + +

Top

+ +## cosmos/upgrade/v1beta1/genesis.proto + + + + + +### GenesisState +GenesisState defines the x/upgrade module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#cosmos.upgrade.v1beta1.Params) | | params defines the x/upgrade parameters. | + + + + + diff --git a/proto/cosmos/upgrade/v1beta1/genesis.proto b/proto/cosmos/upgrade/v1beta1/genesis.proto new file mode 100644 index 000000000000..7851fec4f6c4 --- /dev/null +++ b/proto/cosmos/upgrade/v1beta1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cosmos.upgrade.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/upgrade/v1beta1/upgrade.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; + +// GenesisState defines the x/upgrade module's genesis state. +message GenesisState { + // params defines the x/upgrade parameters. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/cosmos/upgrade/v1beta1/upgrade.proto b/proto/cosmos/upgrade/v1beta1/upgrade.proto index e888b393d68a..9079d5ed0eb1 100644 --- a/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ b/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -5,7 +5,7 @@ import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; option (gogoproto.goproto_getters_all) = false; // Plan specifies information about a planned upgrade and when it should occur. @@ -22,10 +22,14 @@ message Plan { // reached and the software will exit. string name = 1; - // Deprecated: Time based upgrades have been deprecated. Time based upgrade logic - // has been removed from the SDK. - // If this field is not empty, an error will be thrown. - google.protobuf.Timestamp time = 2 [deprecated = true, (gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + // Deprecated: Time based upgrades have been deprecated. Time based upgrade + // logic has been removed from the SDK. If this field is not empty, an error + // will be thrown. + google.protobuf.Timestamp time = 2 [ + deprecated = true, + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; // The height at which the upgrade must be performed. // Only used if Time is not set. @@ -35,11 +39,13 @@ message Plan { // such as a git commit that validators could automatically upgrade to string info = 4; - // Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been - // moved to the IBC module in the sub module 02-client. - // If this field is not empty, an error will be thrown. - google.protobuf.Any upgraded_client_state = 5 - [deprecated = true, (gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; + // Deprecated: UpgradedClientState field has been deprecated. IBC upgrade + // logic has been moved to the IBC module in the sub module 02-client. If this + // field is not empty, an error will be thrown. + google.protobuf.Any upgraded_client_state = 5 [ + deprecated = true, + (gogoproto.moretags) = "yaml:\"upgraded_client_state\"" + ]; } // SoftwareUpgradeProposal is a gov Content type for initiating a software @@ -76,3 +82,8 @@ message ModuleVersion { // consensus version of the app module uint64 version = 2; } + +// Params defines the x/upgrade parameters. +message Params { + bool is_mainnet = 1; +} diff --git a/simapp/app.go b/simapp/app.go index d30301c14c8d..92a88d34e198 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -260,7 +260,7 @@ func NewSimApp( ) app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) + app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, app.GetSubspace(upgradetypes.ModuleName)) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks @@ -582,6 +582,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(upgradetypes.ModuleName) return paramsKeeper } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 233e24033825..e19fb2275be0 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -9,8 +9,6 @@ import ( "strings" "sync" - "github.com/cosmos/cosmos-sdk/pruning" - pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" iavltree "github.com/cosmos/iavl" protoio "github.com/gogo/protobuf/io" gogotypes "github.com/gogo/protobuf/types" @@ -20,6 +18,8 @@ import ( "github.com/tendermint/tendermint/proto/tendermint/crypto" dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/pruning" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/dbadapter" @@ -30,7 +30,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/transient" "github.com/cosmos/cosmos-sdk/store/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - vm "github.com/cosmos/cosmos-sdk/x/upgrade/exported" ) const ( @@ -73,9 +72,9 @@ type Store struct { } var ( - _ types.CommitMultiStore = (*Store)(nil) - _ vm.AppVersionManager = (*Store)(nil) - _ types.Queryable = (*Store)(nil) + _ types.CommitMultiStore = (*Store)(nil) + _ types.AppVersionManager = (*Store)(nil) + _ types.Queryable = (*Store)(nil) ) // NewStore returns a reference to a new Store object with the provided DB. The diff --git a/store/types/store.go b/store/types/store.go index a78ce355bf71..d8d006c652bb 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -11,7 +11,6 @@ import ( pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/types/kv" - vm "github.com/cosmos/cosmos-sdk/x/upgrade/exported" ) type Store interface { @@ -152,7 +151,7 @@ type CommitMultiStore interface { Committer MultiStore snapshottypes.Snapshotter - vm.AppVersionManager + AppVersionManager // Mount a store of type using the given db. // If db == nil, the new store will use the CommitMultiStore db. diff --git a/store/types/version_manager.go b/store/types/version_manager.go new file mode 100644 index 000000000000..4443142faa07 --- /dev/null +++ b/store/types/version_manager.go @@ -0,0 +1,8 @@ +package types + +// AppVersionManager defines the interface which allows managing the appVersion +// field. +type AppVersionManager interface { + GetAppVersion() (uint64, error) + SetAppVersion(version uint64) error +} diff --git a/x/upgrade/exported/exported.go b/x/upgrade/exported/exported.go index 5b5872c6f425..4cd0ef8363cc 100644 --- a/x/upgrade/exported/exported.go +++ b/x/upgrade/exported/exported.go @@ -1,7 +1,15 @@ package exported -// AppVersionManager defines the interface which allows managing the appVersion field. -type AppVersionManager interface { - GetAppVersion() (uint64, error) - SetAppVersion(version uint64) error +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// ParamSubspace defines the expected x/params Subspace interface. +type ParamSubspace interface { + HasKeyTable() bool + WithKeyTable(table paramtypes.KeyTable) paramtypes.Subspace + Get(ctx sdk.Context, key []byte, ptr interface{}) + GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) + SetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) } diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 4e73a7b33b65..4e9d4ee06513 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -18,7 +18,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" - vm "github.com/cosmos/cosmos-sdk/x/upgrade/exported" + "github.com/cosmos/cosmos-sdk/x/upgrade/exported" "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -31,7 +31,8 @@ type Keeper struct { storeKey sdk.StoreKey // key to access x/upgrade store cdc codec.BinaryCodec // App-wide binary codec upgradeHandlers map[string]types.UpgradeHandler // map of plan name to upgrade handler - versionManager vm.AppVersionManager // implements setting the app version field on BaseApp + versionManager store.AppVersionManager // implements setting the app version field on BaseApp + paramspace exported.ParamSubspace } // NewKeeper constructs an upgrade Keeper which requires the following arguments: @@ -40,7 +41,19 @@ type Keeper struct { // cdc - the app-wide binary codec // homePath - root directory of the application's config // vs - the interface implemented by baseapp which allows setting baseapp's app version field -func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey sdk.StoreKey, cdc codec.BinaryCodec, homePath string, vs vm.AppVersionManager) Keeper { +func NewKeeper( + skipUpgradeHeights map[int64]bool, + storeKey sdk.StoreKey, + cdc codec.BinaryCodec, + homePath string, + vs store.AppVersionManager, + paramspace exported.ParamSubspace, +) Keeper { + // set KeyTable if it has not already been set + if !paramspace.HasKeyTable() { + paramspace = paramspace.WithKeyTable(types.ParamKeyTable()) + } + return Keeper{ homePath: homePath, skipUpgradeHeights: skipUpgradeHeights, @@ -48,6 +61,19 @@ func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey sdk.StoreKey, cdc cod cdc: cdc, upgradeHandlers: map[string]types.UpgradeHandler{}, versionManager: vs, + paramspace: paramspace, + } +} + +// InitGenesis initializes the x/upgrade module's state based on GenesisState. +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the x/upgrade module's state in GenesisState. +func (k Keeper) ExportGenesis(ctx sdk.Context) types.GenesisState { + return types.GenesisState{ + Params: k.GetParams(ctx), } } diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index 08e49c7de07b..aa7b46d3accd 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -28,7 +28,12 @@ func (s *KeeperTestSuite) SetupTest() { app := simapp.Setup(false) homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test") app.UpgradeKeeper = keeper.NewKeeper( // recreate keeper in order to use a custom home path - make(map[int64]bool), app.GetKey(types.StoreKey), app.AppCodec(), homeDir, app.BaseApp, + make(map[int64]bool), + app.GetKey(types.StoreKey), + app.AppCodec(), + homeDir, + app.BaseApp, + app.GetSubspace(types.ModuleName), ) s.T().Log("home dir:", homeDir) s.homeDir = homeDir diff --git a/x/upgrade/keeper/migrator.go b/x/upgrade/keeper/migrator.go new file mode 100644 index 000000000000..7ddfe94c62b4 --- /dev/null +++ b/x/upgrade/keeper/migrator.go @@ -0,0 +1,21 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + v2 "github.com/cosmos/cosmos-sdk/x/upgrade/migrations/v2" +) + +// Migrator defines a wrapper around the x/upgrade keeper for performing consensus +// state migrations. +type Migrator struct { + Keeper +} + +func NewMigrator(k Keeper) Migrator { + return Migrator{Keeper: k} +} + +// Migrate1to2 migrates from consensus version 1 to version 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return v2.Migrate(ctx, m.paramspace) +} diff --git a/x/upgrade/keeper/params.go b/x/upgrade/keeper/params.go new file mode 100644 index 000000000000..2fe91fae438b --- /dev/null +++ b/x/upgrade/keeper/params.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// GetParams returns the module's parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramspace.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the module's parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramspace.SetParamSet(ctx, ¶ms) +} diff --git a/x/upgrade/migrations/v2/migrate.go b/x/upgrade/migrations/v2/migrate.go new file mode 100644 index 000000000000..f3bbe2ec7005 --- /dev/null +++ b/x/upgrade/migrations/v2/migrate.go @@ -0,0 +1,21 @@ +package v2 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/upgrade/exported" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// Migrate migrates the x/upgrade module state from the consensus version 1 to +// version 2, returning an error upon failure. +func Migrate(ctx sdk.Context, subspace exported.ParamSubspace) error { + // set KeyTable if it has not already been set + if !subspace.HasKeyTable() { + subspace = subspace.WithKeyTable(types.ParamKeyTable()) + } + + params := types.DefaultParams() + subspace.SetParamSet(ctx, ¶ms) + + return nil +} diff --git a/x/upgrade/migrations/v2/migrate_test.go b/x/upgrade/migrations/v2/migrate_test.go new file mode 100644 index 000000000000..1976cd9ff109 --- /dev/null +++ b/x/upgrade/migrations/v2/migrate_test.go @@ -0,0 +1,32 @@ +package v2_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + v2 "github.com/cosmos/cosmos-sdk/x/upgrade/migrations/v2" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func TestMigrate(t *testing.T) { + encCfg := simapp.MakeTestEncodingConfig() + key := sdk.NewKVStoreKey("upgrade") + tKey := sdk.NewTransientStoreKey("transient_test") + ctx := testutil.DefaultContext(key, tKey) + paramstore := paramtypes.NewSubspace(encCfg.Marshaler, encCfg.Amino, key, tKey, "upgrade") + + // Check no params + require.False(t, paramstore.Has(ctx, types.KeyIsMainnet)) + + err := v2.Migrate(ctx, paramstore) + require.NoError(t, err) + + var result bool + paramstore.Get(ctx, types.KeyIsMainnet, &result) + require.True(t, result) +} diff --git a/x/upgrade/module.go b/x/upgrade/module.go index b80b56f92a1f..e5208a7d0445 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -3,6 +3,7 @@ package upgrade import ( "context" "encoding/json" + "fmt" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -20,6 +21,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) +const ( + consensusVersion = 2 +) + func init() { types.RegisterLegacyAminoCodec(codec.NewLegacyAmino()) } @@ -98,30 +103,48 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { + panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", types.ModuleName, err)) + } } -// InitGenesis is ignored, no sense in serializing future upgrades -func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { +// InitGenesis initializes the x/upgrade module genesis state. It returns no +// validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + cdc.MustUnmarshalJSON(data, &genState) + + am.keeper.InitGenesis(ctx, genState) return []abci.ValidatorUpdate{} } -// DefaultGenesis is an empty object -func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { - return []byte("{}") +// DefaultGenesis returns the x/upgrade module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) } // ValidateGenesis is always successful, as we ignore the value -func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodingConfig, _ json.RawMessage) error { - return nil +func (amb AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, data json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(data, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genState.Params.Validate() } // ExportGenesis is always empty, as InitGenesis does nothing either -func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage { - return am.DefaultGenesis(cdc) +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(&genState) } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { + return consensusVersion +} // BeginBlock calls the upgrade module hooks // diff --git a/x/upgrade/types/genesis.go b/x/upgrade/types/genesis.go new file mode 100644 index 000000000000..ffeb68965356 --- /dev/null +++ b/x/upgrade/types/genesis.go @@ -0,0 +1,14 @@ +package types + +func NewGenesisState(params Params) GenesisState { + return GenesisState{ + Params: params, + } +} + +// DefaultGenesisState returns x/upgrade default genesis state. +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} diff --git a/x/upgrade/types/genesis.pb.go b/x/upgrade/types/genesis.pb.go new file mode 100644 index 000000000000..eaa9fde26568 --- /dev/null +++ b/x/upgrade/types/genesis.pb.go @@ -0,0 +1,324 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/upgrade/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the x/upgrade module's genesis state. +type GenesisState struct { + // params defines the x/upgrade parameters. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_2c4e5fcb49bcb8ab, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "cosmos.upgrade.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("cosmos/upgrade/v1beta1/genesis.proto", fileDescriptor_2c4e5fcb49bcb8ab) +} + +var fileDescriptor_2c4e5fcb49bcb8ab = []byte{ + // 202 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x2f, 0x2d, 0x48, 0x2f, 0x4a, 0x4c, 0x49, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, + 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x83, 0xa8, 0xd2, 0x83, 0xaa, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x70, 0x99, 0x09, 0xd3, 0x0d, 0x56, 0xa5, 0xe4, + 0xc3, 0xc5, 0xe3, 0x0e, 0xb1, 0x24, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x86, 0x8b, 0xad, 0x20, + 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4e, 0x0f, 0xbb, 0xa5, + 0x7a, 0x01, 0x60, 0x55, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x38, 0xb9, 0x9d, + 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, + 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x61, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, + 0xee, 0xca, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xe3, 0x8c, 0x01, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x10, 0x87, 0x77, 0x98, 0x18, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/upgrade/types/params.go b/x/upgrade/types/params.go new file mode 100644 index 000000000000..183e89561a0d --- /dev/null +++ b/x/upgrade/types/params.go @@ -0,0 +1,54 @@ +package types + +import ( + fmt "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Parameter store keys +var ( + KeyIsMainnet = []byte("IsMainnet") +) + +// ParamKeyTable returns a KeyTable for the x/upgrade module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewParams(isMainnet bool) Params { + return Params{ + IsMainnet: isMainnet, + } +} + +// DefaultParams returns the x/upgrade module's default parameters. +func DefaultParams() Params { + return NewParams(true) +} + +// ParamSetPairs returns the ParamSetPairs for the x/upgrade module. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyIsMainnet, &p.IsMainnet, validateIsMainnet), + } +} + +// Validate performs basic validation on the Params type returning an error upon +// validation failure. +func (p Params) Validate() error { + if err := validateIsMainnet(p.IsMainnet); err != nil { + return err + } + + return nil +} + +func validateIsMainnet(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/x/upgrade/types/upgrade.pb.go b/x/upgrade/types/upgrade.pb.go index 686389974b23..a3f49319ac7f 100644 --- a/x/upgrade/types/upgrade.pb.go +++ b/x/upgrade/types/upgrade.pb.go @@ -38,9 +38,9 @@ type Plan struct { // assumed that the software is out-of-date when the upgrade Time or Height is // reached and the software will exit. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // Deprecated: Time based upgrades have been deprecated. Time based upgrade logic - // has been removed from the SDK. - // If this field is not empty, an error will be thrown. + // Deprecated: Time based upgrades have been deprecated. Time based upgrade + // logic has been removed from the SDK. If this field is not empty, an error + // will be thrown. Time time.Time `protobuf:"bytes,2,opt,name=time,proto3,stdtime" json:"time"` // Deprecated: Do not use. // The height at which the upgrade must be performed. // Only used if Time is not set. @@ -48,9 +48,9 @@ type Plan struct { // Any application specific upgrade info to be included on-chain // such as a git commit that validators could automatically upgrade to Info string `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"` - // Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been - // moved to the IBC module in the sub module 02-client. - // If this field is not empty, an error will be thrown. + // Deprecated: UpgradedClientState field has been deprecated. IBC upgrade + // logic has been moved to the IBC module in the sub module 02-client. If this + // field is not empty, an error will be thrown. UpgradedClientState *types.Any `protobuf:"bytes,5,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"` // Deprecated: Do not use. } @@ -208,11 +208,50 @@ func (m *ModuleVersion) XXX_DiscardUnknown() { var xxx_messageInfo_ModuleVersion proto.InternalMessageInfo +// Params defines the x/upgrade parameters. +type Params struct { + IsMainnet bool `protobuf:"varint,1,opt,name=is_mainnet,json=isMainnet,proto3" json:"is_mainnet,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_ccf2a7d4d7b48dca, []int{4} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + func init() { proto.RegisterType((*Plan)(nil), "cosmos.upgrade.v1beta1.Plan") proto.RegisterType((*SoftwareUpgradeProposal)(nil), "cosmos.upgrade.v1beta1.SoftwareUpgradeProposal") proto.RegisterType((*CancelSoftwareUpgradeProposal)(nil), "cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal") proto.RegisterType((*ModuleVersion)(nil), "cosmos.upgrade.v1beta1.ModuleVersion") + proto.RegisterType((*Params)(nil), "cosmos.upgrade.v1beta1.Params") } func init() { @@ -220,36 +259,38 @@ func init() { } var fileDescriptor_ccf2a7d4d7b48dca = []byte{ - // 462 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xf6, 0x51, 0xb7, 0xd0, 0x8b, 0x58, 0x8e, 0x50, 0x4c, 0x54, 0xec, 0xc8, 0x62, 0xc8, 0x00, - 0x67, 0xb5, 0x48, 0x0c, 0xd9, 0x48, 0x07, 0x24, 0x24, 0xa4, 0xca, 0x05, 0x06, 0x96, 0xea, 0x62, - 0x5f, 0x9c, 0x13, 0xe7, 0x3b, 0xcb, 0x77, 0x29, 0xe4, 0x5f, 0x54, 0x62, 0x61, 0xec, 0xcf, 0xc9, - 0xd8, 0x91, 0x29, 0x40, 0xb2, 0x30, 0x33, 0x32, 0xa1, 0xbb, 0xb3, 0x51, 0x04, 0x19, 0x3b, 0xf9, - 0xfd, 0x78, 0xde, 0xe7, 0x79, 0x3f, 0x7c, 0xf0, 0x71, 0x26, 0x55, 0x29, 0x55, 0x32, 0xab, 0x8a, - 0x9a, 0xe4, 0x34, 0xb9, 0x38, 0x1a, 0x53, 0x4d, 0x8e, 0x5a, 0x1f, 0x57, 0xb5, 0xd4, 0x12, 0x1d, - 0x38, 0x14, 0x6e, 0xa3, 0x0d, 0xaa, 0xf7, 0xb0, 0x90, 0xb2, 0xe0, 0x34, 0xb1, 0xa8, 0xf1, 0x6c, - 0x92, 0x10, 0x31, 0x77, 0x25, 0xbd, 0x6e, 0x21, 0x0b, 0x69, 0xcd, 0xc4, 0x58, 0x4d, 0x34, 0xfa, - 0xb7, 0x40, 0xb3, 0x92, 0x2a, 0x4d, 0xca, 0xca, 0x01, 0xe2, 0xdf, 0x00, 0xfa, 0xa7, 0x9c, 0x08, - 0x84, 0xa0, 0x2f, 0x48, 0x49, 0x03, 0xd0, 0x07, 0x83, 0xfd, 0xd4, 0xda, 0x68, 0x08, 0x7d, 0x83, - 0x0f, 0x6e, 0xf5, 0xc1, 0xa0, 0x73, 0xdc, 0xc3, 0x8e, 0x0c, 0xb7, 0x64, 0xf8, 0x4d, 0x4b, 0x36, - 0x82, 0x8b, 0x65, 0xe4, 0x5d, 0x7e, 0x8b, 0x40, 0x00, 0x52, 0x5b, 0x83, 0x0e, 0xe0, 0xde, 0x94, - 0xb2, 0x62, 0xaa, 0x83, 0x9d, 0x3e, 0x18, 0xec, 0xa4, 0x8d, 0x67, 0x74, 0x98, 0x98, 0xc8, 0xc0, - 0x77, 0x3a, 0xc6, 0x46, 0x1c, 0xde, 0x6f, 0x26, 0xcd, 0xcf, 0x33, 0xce, 0xa8, 0xd0, 0xe7, 0x4a, - 0x13, 0x4d, 0x83, 0x5d, 0x2b, 0xdc, 0xfd, 0x4f, 0xf8, 0x85, 0x98, 0x8f, 0xe2, 0x5f, 0xcb, 0xe8, - 0x70, 0x4e, 0x4a, 0x3e, 0x8c, 0xb7, 0x16, 0xc7, 0x01, 0x48, 0xef, 0xb5, 0x99, 0x13, 0x9b, 0x38, - 0x33, 0xf1, 0xe1, 0x9d, 0x2f, 0x57, 0x91, 0xf7, 0xf3, 0x2a, 0x02, 0xf1, 0x67, 0x00, 0x1f, 0x9c, - 0xc9, 0x89, 0xfe, 0x48, 0x6a, 0xfa, 0xd6, 0x21, 0x4f, 0x6b, 0x59, 0x49, 0x45, 0x38, 0xea, 0xc2, - 0x5d, 0xcd, 0x34, 0x6f, 0x17, 0xe2, 0x1c, 0xd4, 0x87, 0x9d, 0x9c, 0xaa, 0xac, 0x66, 0x95, 0x66, - 0x52, 0xd8, 0xc5, 0xec, 0xa7, 0x9b, 0x21, 0xf4, 0x1c, 0xfa, 0x15, 0x27, 0xc2, 0x4e, 0xdd, 0x39, - 0x3e, 0xc4, 0xdb, 0x2f, 0x89, 0xcd, 0xce, 0x47, 0xbe, 0xd9, 0x5a, 0x6a, 0xf1, 0x1b, 0x5d, 0x11, - 0xf8, 0xe8, 0x84, 0x88, 0x8c, 0xf2, 0x1b, 0x6e, 0x6d, 0x43, 0xe2, 0x25, 0xbc, 0xfb, 0x5a, 0xe6, - 0x33, 0x4e, 0xdf, 0xd1, 0x5a, 0x99, 0xae, 0xb7, 0x5d, 0x3f, 0x80, 0xb7, 0x2f, 0x5c, 0xda, 0x92, - 0xf9, 0x69, 0xeb, 0x5a, 0x22, 0x60, 0x88, 0x46, 0xaf, 0x16, 0x3f, 0x42, 0x6f, 0xb1, 0x0a, 0xc1, - 0xf5, 0x2a, 0x04, 0xdf, 0x57, 0x21, 0xb8, 0x5c, 0x87, 0xde, 0xf5, 0x3a, 0xf4, 0xbe, 0xae, 0x43, - 0xef, 0xfd, 0x93, 0x82, 0xe9, 0xe9, 0x6c, 0x8c, 0x33, 0x59, 0x26, 0xcd, 0x7f, 0xef, 0x3e, 0x4f, - 0x55, 0xfe, 0x21, 0xf9, 0xf4, 0xf7, 0x11, 0xe8, 0x79, 0x45, 0xd5, 0x78, 0xcf, 0x9e, 0xf7, 0xd9, - 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x67, 0xe1, 0x07, 0x23, 0x03, 0x00, 0x00, + // 488 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xf6, 0x51, 0x37, 0x34, 0x17, 0xb1, 0x1c, 0xa1, 0x98, 0xa8, 0xb5, 0x23, 0x0b, 0x89, 0x0c, + 0x60, 0xab, 0x45, 0x62, 0xc8, 0x46, 0x3a, 0x20, 0x21, 0x55, 0x8a, 0x5c, 0x60, 0x60, 0x89, 0x2e, + 0xf6, 0xc5, 0x39, 0x71, 0xbe, 0xb3, 0x7c, 0x97, 0x82, 0xff, 0x45, 0x25, 0x16, 0xc6, 0xfe, 0x9c, + 0x8c, 0x1d, 0x99, 0x02, 0x24, 0x0b, 0x33, 0x23, 0x13, 0xf2, 0x9d, 0x8d, 0x22, 0xc8, 0xd8, 0xc9, + 0xef, 0x7d, 0xef, 0x7b, 0xdf, 0xf7, 0xee, 0x9d, 0x0f, 0x3e, 0x8e, 0x85, 0xcc, 0x84, 0x0c, 0x17, + 0x79, 0x5a, 0xe0, 0x84, 0x84, 0x97, 0x27, 0x53, 0xa2, 0xf0, 0x49, 0x93, 0x07, 0x79, 0x21, 0x94, + 0x40, 0x87, 0x86, 0x15, 0x34, 0x68, 0xcd, 0xea, 0x3d, 0x4a, 0x85, 0x48, 0x19, 0x09, 0x35, 0x6b, + 0xba, 0x98, 0x85, 0x98, 0x97, 0xa6, 0xa5, 0xd7, 0x4d, 0x45, 0x2a, 0x74, 0x18, 0x56, 0x51, 0x8d, + 0x7a, 0xff, 0x36, 0x28, 0x9a, 0x11, 0xa9, 0x70, 0x96, 0x1b, 0x82, 0xff, 0x1b, 0x40, 0x7b, 0xcc, + 0x30, 0x47, 0x08, 0xda, 0x1c, 0x67, 0xc4, 0x01, 0x7d, 0x30, 0x68, 0x47, 0x3a, 0x46, 0x43, 0x68, + 0x57, 0x7c, 0xe7, 0x4e, 0x1f, 0x0c, 0x3a, 0xa7, 0xbd, 0xc0, 0x88, 0x05, 0x8d, 0x58, 0xf0, 0xa6, + 0x11, 0x1b, 0xc1, 0xe5, 0xca, 0xb3, 0xae, 0xbe, 0x79, 0xc0, 0x01, 0x91, 0xee, 0x41, 0x87, 0xb0, + 0x35, 0x27, 0x34, 0x9d, 0x2b, 0x67, 0xaf, 0x0f, 0x06, 0x7b, 0x51, 0x9d, 0x55, 0x3e, 0x94, 0xcf, + 0x84, 0x63, 0x1b, 0x9f, 0x2a, 0x46, 0x0c, 0x3e, 0xa8, 0x4f, 0x9a, 0x4c, 0x62, 0x46, 0x09, 0x57, + 0x13, 0xa9, 0xb0, 0x22, 0xce, 0xbe, 0x36, 0xee, 0xfe, 0x67, 0xfc, 0x92, 0x97, 0x23, 0xff, 0xd7, + 0xca, 0x3b, 0x2a, 0x71, 0xc6, 0x86, 0xfe, 0xce, 0x66, 0xdf, 0x01, 0xd1, 0xfd, 0xa6, 0x72, 0xa6, + 0x0b, 0x17, 0x15, 0x3e, 0x3c, 0xf8, 0x72, 0xed, 0x59, 0x3f, 0xaf, 0x3d, 0xe0, 0x7f, 0x06, 0xf0, + 0xe1, 0x85, 0x98, 0xa9, 0x8f, 0xb8, 0x20, 0x6f, 0x0d, 0x73, 0x5c, 0x88, 0x5c, 0x48, 0xcc, 0x50, + 0x17, 0xee, 0x2b, 0xaa, 0x58, 0xb3, 0x10, 0x93, 0xa0, 0x3e, 0xec, 0x24, 0x44, 0xc6, 0x05, 0xcd, + 0x15, 0x15, 0x5c, 0x2f, 0xa6, 0x1d, 0x6d, 0x43, 0xe8, 0x05, 0xb4, 0x73, 0x86, 0xb9, 0x3e, 0x75, + 0xe7, 0xf4, 0x28, 0xd8, 0x7d, 0x93, 0x41, 0xb5, 0xf3, 0x91, 0x5d, 0x6d, 0x2d, 0xd2, 0xfc, 0xad, + 0xa9, 0x30, 0x3c, 0x3e, 0xc3, 0x3c, 0x26, 0xec, 0x96, 0x47, 0xdb, 0xb2, 0x78, 0x05, 0xef, 0x9d, + 0x8b, 0x64, 0xc1, 0xc8, 0x3b, 0x52, 0xc8, 0x6a, 0xea, 0x5d, 0xb7, 0xef, 0xc0, 0xbb, 0x97, 0xa6, + 0xac, 0xc5, 0xec, 0xa8, 0x49, 0xb5, 0x10, 0xd0, 0x42, 0x4f, 0x60, 0x6b, 0x8c, 0x0b, 0x9c, 0x49, + 0x74, 0x0c, 0x21, 0x95, 0x93, 0x0c, 0x53, 0xce, 0x89, 0xd2, 0x3a, 0x07, 0x51, 0x9b, 0xca, 0x73, + 0x03, 0x8c, 0x5e, 0x2f, 0x7f, 0xb8, 0xd6, 0x72, 0xed, 0x82, 0x9b, 0xb5, 0x0b, 0xbe, 0xaf, 0x5d, + 0x70, 0xb5, 0x71, 0xad, 0x9b, 0x8d, 0x6b, 0x7d, 0xdd, 0xb8, 0xd6, 0xfb, 0xa7, 0x29, 0x55, 0xf3, + 0xc5, 0x34, 0x88, 0x45, 0x16, 0xd6, 0x0f, 0xc4, 0x7c, 0x9e, 0xc9, 0xe4, 0x43, 0xf8, 0xe9, 0xef, + 0x6b, 0x51, 0x65, 0x4e, 0xe4, 0xb4, 0xa5, 0xff, 0x83, 0xe7, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x41, 0x30, 0x5f, 0x66, 0x4c, 0x03, 0x00, 0x00, } func (this *Plan) Equal(that interface{}) bool { @@ -553,6 +594,39 @@ func (m *ModuleVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsMainnet { + i-- + if m.IsMainnet { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintUpgrade(dAtA []byte, offset int, v uint64) int { offset -= sovUpgrade(v) base := offset @@ -642,6 +716,18 @@ func (m *ModuleVersion) Size() (n int) { return n } +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsMainnet { + n += 2 + } + return n +} + func sovUpgrade(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1212,6 +1298,76 @@ func (m *ModuleVersion) Unmarshal(dAtA []byte) error { } return nil } +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUpgrade + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsMainnet", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUpgrade + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsMainnet = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipUpgrade(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthUpgrade + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipUpgrade(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0