feat: remove x/params dependency in x/crisis (#12491)

## Description

Closes: #12445 



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
This commit is contained in:
atheeshp 2022-07-12 11:45:50 +05:30 committed by GitHub
parent 8090177144
commit 7c1d743499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 1923 additions and 76 deletions

View File

@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/slashing) [#12399](https://github.com/cosmos/cosmos-sdk/pull/12399) Migrate `x/slashing` to self-managed parameters and deprecate its usage of `x/params`.
* (x/mint) [#12363](https://github.com/cosmos/cosmos-sdk/pull/12363) Migrate `x/mint` to self-managed parameters and deprecate it's usage of `x/params`.
* (x/distribution) [#12434](https://github.com/cosmos/cosmos-sdk/pull/12434) Migrate `x/distribution` to self-managed parameters and deprecate it's usage of `x/params`.
* (x/crisis) [#12445](https://github.com/cosmos/cosmos-sdk/pull/12445) Migrate `x/crisis` to self-managed parameters and deprecate it's usage of `x/params`.
### API Breaking Changes
@ -73,6 +74,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/staking) [#12102](https://github.com/cosmos/cosmos-sdk/pull/12102) Staking keeper now is passed by reference instead of copy. Keeper's SetHooks no longer returns keeper. It updates the keeper in place instead.
* (linting) [#12141](https://github.com/cosmos/cosmos-sdk/pull/12141) Fix usability related linting for database. This means removing the infix Prefix from `prefix.NewPrefixWriter` and such so that it is `prefix.NewWriter` and making `db.DBConnection` and such into `db.Connection`
* (x/distribution) [#12434](https://github.com/cosmos/cosmos-sdk/pull/12434) `x/distribution` module `SetParams` keeper method definition is now updated to return `error`.
* (x/crisis) [#12445](https://github.com/cosmos/cosmos-sdk/pull/12445) `x/crisis` module `SetConstantFee` keeper method definition is now updated to return `error`.
### Bug Fixes

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,11 @@ const _ = grpc.SupportPackageIsVersion7
type MsgClient interface {
// VerifyInvariant defines a method to verify a particular invariance.
VerifyInvariant(ctx context.Context, in *MsgVerifyInvariant, opts ...grpc.CallOption) (*MsgVerifyInvariantResponse, error)
// UpdateParams defines a governance operation for updating the x/crisis module
// parameters. The authority is defined in the keeper.
//
// Since: cosmos-sdk 0.47
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
type msgClient struct {
@ -43,12 +48,26 @@ func (c *msgClient) VerifyInvariant(ctx context.Context, in *MsgVerifyInvariant,
return out, nil
}
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
out := new(MsgUpdateParamsResponse)
err := c.cc.Invoke(ctx, "/cosmos.crisis.v1beta1.Msg/UpdateParams", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
// All implementations must embed UnimplementedMsgServer
// for forward compatibility
type MsgServer interface {
// VerifyInvariant defines a method to verify a particular invariance.
VerifyInvariant(context.Context, *MsgVerifyInvariant) (*MsgVerifyInvariantResponse, error)
// UpdateParams defines a governance operation for updating the x/crisis module
// parameters. The authority is defined in the keeper.
//
// Since: cosmos-sdk 0.47
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
mustEmbedUnimplementedMsgServer()
}
@ -59,6 +78,9 @@ type UnimplementedMsgServer struct {
func (UnimplementedMsgServer) VerifyInvariant(context.Context, *MsgVerifyInvariant) (*MsgVerifyInvariantResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method VerifyInvariant not implemented")
}
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
}
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
@ -90,6 +112,24 @@ func _Msg_VerifyInvariant_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).UpdateParams(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.crisis.v1beta1.Msg/UpdateParams",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
}
return interceptor(ctx, in, info, handler)
}
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -101,6 +141,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
MethodName: "VerifyInvariant",
Handler: _Msg_VerifyInvariant_Handler,
},
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/crisis/v1beta1/tx.proto",

View File

@ -6,11 +6,18 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/base/v1beta1/coin.proto";
// Msg defines the bank Msg service.
service Msg {
// VerifyInvariant defines a method to verify a particular invariance.
rpc VerifyInvariant(MsgVerifyInvariant) returns (MsgVerifyInvariantResponse);
// UpdateParams defines a governance operation for updating the x/crisis module
// parameters. The authority is defined in the keeper.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgVerifyInvariant represents a message to verify a particular invariance.
@ -27,3 +34,22 @@ message MsgVerifyInvariant {
// MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type.
message MsgVerifyInvariantResponse {}
// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// constant_fee defines the x/crisis parameter.
cosmos.base.v1beta1.Coin constant_fee = 2 [(gogoproto.nullable) = false];
}
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {}

View File

@ -0,0 +1,19 @@
package exported
import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
type (
ParamSet = paramtypes.ParamSet
// Subspace defines an interface that implements the legacy x/params Subspace
// type.
//
// NOTE: This is used solely for migration of x/params managed parameters.
Subspace interface {
// GetParamSet(ctx sdk.Context, ps ParamSet)
Get(ctx sdk.Context, key []byte, ptr interface{})
}
)

View File

@ -7,7 +7,9 @@ import (
// new crisis genesis
func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) {
k.SetConstantFee(ctx, data.ConstantFee)
if err := k.SetConstantFee(ctx, data.ConstantFee); err != nil {
panic(err)
}
}
// ExportGenesis returns a GenesisState for a given context and keeper.

View File

@ -6,38 +6,46 @@ import (
"github.com/tendermint/tendermint/libs/log"
"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/x/crisis/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Keeper - crisis keeper
type Keeper struct {
routes []types.InvarRoute
paramSpace paramtypes.Subspace
invCheckPeriod uint
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
// the address capable of executing a MsgUpdateParams message. Typically, this
// should be the x/gov module account.
authority string
supplyKeeper types.SupplyKeeper
feeCollectorName string // name of the FeeCollector ModuleAccount
}
func (k *Keeper) GetAuthority() string {
return k.authority
}
// NewKeeper creates a new Keeper object
func NewKeeper(
paramSpace paramtypes.Subspace, invCheckPeriod uint, supplyKeeper types.SupplyKeeper,
feeCollectorName string,
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, invCheckPeriod uint,
supplyKeeper types.SupplyKeeper, feeCollectorName string, authority string,
) *Keeper {
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
}
return &Keeper{
storeKey: storeKey,
cdc: cdc,
routes: make([]types.InvarRoute, 0),
paramSpace: paramSpace,
invCheckPeriod: invCheckPeriod,
supplyKeeper: supplyKeeper,
feeCollectorName: feeCollectorName,
authority: authority,
}
}

View File

@ -0,0 +1,28 @@
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/crisis/exported"
v046 "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v046"
)
// Migrator is a struct for handling in-place state migrations.
type Migrator struct {
keeper *Keeper
legacySubspace exported.Subspace
}
func NewMigrator(k *Keeper, ss exported.Subspace) Migrator {
return Migrator{
keeper: k,
legacySubspace: ss,
}
}
// Migrate1to2 migrates the x/mint module state from the consensus version 1 to
// version 2. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/mint
// module state.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v046.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}

View File

@ -4,7 +4,9 @@ import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/crisis/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
var _ types.MsgServer = &Keeper{}
@ -64,3 +66,16 @@ func (k *Keeper) VerifyInvariant(goCtx context.Context, msg *types.MsgVerifyInva
return &types.MsgVerifyInvariantResponse{}, nil
}
func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if k.authority != req.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority)
}
ctx := sdk.UnwrapSDKContext(goCtx)
if err := k.SetConstantFee(ctx, req.ConstantFee); err != nil {
return nil, err
}
return &types.MsgUpdateParamsResponse{}, nil
}

View File

@ -0,0 +1,94 @@
package keeper_test
import (
"testing"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/crisis/keeper"
"github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
type KeeperTestSuite struct {
suite.Suite
ctx sdk.Context
keeper *keeper.Keeper
}
func (s *KeeperTestSuite) SetupTest() {
app := simapp.Setup(s.T(), false)
app.Commit()
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}})
ctx := app.NewContext(true, tmproto.Header{})
s.ctx = ctx
s.keeper = app.CrisisKeeper
}
func (s *KeeperTestSuite) TestMsgUpdateParams() {
// default params
constantFee := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000))
testCases := []struct {
name string
input *types.MsgUpdateParams
expErr bool
expErrMsg string
}{
{
name: "invalid authority",
input: &types.MsgUpdateParams{
Authority: "invalid",
ConstantFee: constantFee,
},
expErr: true,
expErrMsg: "invalid authority",
},
{
name: "invalid constant fee",
input: &types.MsgUpdateParams{
Authority: s.keeper.GetAuthority(),
ConstantFee: sdk.Coin{},
},
expErr: true,
},
{
name: "negative constant fee",
input: &types.MsgUpdateParams{
Authority: s.keeper.GetAuthority(),
ConstantFee: sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(-1000)},
},
expErr: true,
},
{
name: "all good",
input: &types.MsgUpdateParams{
Authority: s.keeper.GetAuthority(),
ConstantFee: constantFee,
},
expErr: false,
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
_, err := s.keeper.UpdateParams(s.ctx, tc.input)
if tc.expErr {
s.Require().Error(err)
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
s.Require().NoError(err)
}
})
}
}
func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(KeeperTestSuite))
}

View File

@ -2,16 +2,33 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/crisis/types"
)
// GetConstantFee get's the constant fee from the paramSpace
// GetConstantFee get's the constant fee from the store
func (k *Keeper) GetConstantFee(ctx sdk.Context) (constantFee sdk.Coin) {
k.paramSpace.Get(ctx, types.ParamStoreKeyConstantFee, &constantFee)
return
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.ConstantFeeKey)
if bz == nil {
return constantFee
}
k.cdc.MustUnmarshal(bz, &constantFee)
return constantFee
}
// GetConstantFee set's the constant fee in the paramSpace
func (k *Keeper) SetConstantFee(ctx sdk.Context, constantFee sdk.Coin) {
k.paramSpace.Set(ctx, types.ParamStoreKeyConstantFee, constantFee)
// GetConstantFee set's the constant fee in the store
func (k *Keeper) SetConstantFee(ctx sdk.Context, constantFee sdk.Coin) error {
if !constantFee.IsValid() || constantFee.IsNegative() {
return errors.Wrapf(errors.ErrInvalidCoins, "negative or invalid constant fee: %s", constantFee)
}
store := ctx.KVStore(k.storeKey)
bz, err := k.cdc.Marshal(&constantFee)
if err != nil {
return err
}
store.Set(types.ConstantFeeKey, bz)
return nil
}

View File

@ -0,0 +1,52 @@
package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (s *KeeperTestSuite) TestParams() {
// default params
constantFee := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000))
testCases := []struct {
name string
constantFee sdk.Coin
expErr bool
expErrMsg string
}{
{
name: "invalid constant fee",
constantFee: sdk.Coin{},
expErr: true,
},
{
name: "negative constant fee",
constantFee: sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(-1000)},
expErr: true,
},
{
name: "all good",
constantFee: constantFee,
expErr: false,
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
expected := s.keeper.GetConstantFee(s.ctx)
err := s.keeper.SetConstantFee(s.ctx, tc.constantFee)
if tc.expErr {
s.Require().Error(err)
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
expected = tc.constantFee
s.Require().NoError(err)
}
params := s.keeper.GetConstantFee(s.ctx)
s.Require().Equal(expected, params)
})
}
}

View File

@ -0,0 +1,41 @@
package v046
import (
"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/errors"
"github.com/cosmos/cosmos-sdk/x/crisis/exported"
)
const (
ModuleName = "crisis"
)
var (
ConstantFee = []byte("ConstantFee")
ConstantFeeKey = []byte{0x01}
)
// MigrateStore migrates the x/crisis module state from the consensus version 1 to
// version 2. Specifically, it takes the `ConstantFee` parameter that is currently stored
// and managed by the x/params module and stores it directly into the x/crisis
// module state.
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
store := ctx.KVStore(storeKey)
var currConstantFee sdk.Coin
legacySubspace.Get(ctx, ConstantFee, &currConstantFee)
if !currConstantFee.IsValid() {
return errors.ErrInvalidCoins.Wrap("constant fee")
}
bz, err := cdc.Marshal(&currConstantFee)
if err != nil {
return err
}
store.Set(ConstantFeeKey, bz)
return nil
}

View File

@ -0,0 +1,44 @@
package v046_test
import (
"testing"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
v046 "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v046"
"github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/stretchr/testify/require"
)
type mockSubspace struct {
constantFee sdk.Coin
}
func newMockSubspace(fee sdk.Coin) mockSubspace {
return mockSubspace{constantFee: fee}
}
func (ms mockSubspace) Get(ctx sdk.Context, key []byte, ptr interface{}) {
*ptr.(*sdk.Coin) = ms.constantFee
}
func TestMigrate(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v046.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
legacySubspace := newMockSubspace(types.DefaultGenesisState().ConstantFee)
require.NoError(t, v046.MigrateStore(ctx, storeKey, legacySubspace, cdc))
var res sdk.Coin
bz := store.Get(v046.ConstantFeeKey)
require.NoError(t, cdc.Unmarshal(bz, &res))
require.NotNil(t, res)
require.Equal(t, legacySubspace.constantFee, res)
}

View File

@ -19,16 +19,22 @@ import (
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/crisis/client/cli"
"github.com/cosmos/cosmos-sdk/x/crisis/exported"
"github.com/cosmos/cosmos-sdk/x/crisis/keeper"
"github.com/cosmos/cosmos-sdk/x/crisis/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// ConsensusVersion defines the current x/params module consensus version.
const ConsensusVersion = 2
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
@ -94,6 +100,9 @@ type AppModule struct {
// executed.
keeper *keeper.Keeper
// legacySubspace is used solely for migration of x/params managed parameters
legacySubspace exported.Subspace
skipGenesisInvariants bool
}
@ -101,10 +110,11 @@ type AppModule struct {
// we will call keeper.AssertInvariants during InitGenesis (it may take a significant time)
// - which doesn't impact the chain security unless 66+% of validators have a wrongly
// modified genesis file.
func NewAppModule(keeper *keeper.Keeper, skipGenesisInvariants bool) AppModule {
func NewAppModule(keeper *keeper.Keeper, skipGenesisInvariants bool, ss exported.Subspace) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
legacySubspace: ss,
skipGenesisInvariants: skipGenesisInvariants,
}
@ -137,6 +147,11 @@ func (AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { return n
// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
m := keeper.NewMigrator(am.keeper, am.legacySubspace)
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 performs genesis initialization for the crisis module. It returns
@ -162,7 +177,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// BeginBlock performs a no-op.
func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
@ -187,6 +202,8 @@ type crisisInputs struct {
depinject.In
Config *modulev1.Module
Key *store.KVStoreKey
Cdc codec.Codec
AppOpts servertypes.AppOptions `optional:"true"`
Subspace paramstypes.Subspace
BankKeeper types.SupplyKeeper
@ -212,15 +229,17 @@ func provideModule(in crisisInputs) crisisOutputs {
}
k := keeper.NewKeeper(
in.Subspace,
in.Cdc,
in.Key,
invalidCheckPeriod,
in.BankKeeper,
feeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants))
m := NewAppModule(k, skipGenesisInvariants)
m := NewAppModule(k, skipGenesisInvariants, in.Subspace)
return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)}
}

View File

@ -14,11 +14,13 @@ import (
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/crisis/MsgUpdateParams")
}
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgVerifyInvariant{},
&MsgUpdateParams{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)

View File

@ -3,4 +3,10 @@ package types
const (
// module name
ModuleName = "crisis"
StoreKey = ModuleName
)
var (
ConstantFeeKey = []byte{0x01}
)

View File

@ -5,8 +5,13 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
const (
TypeMsgVerifyInvariant = "verify_invariant"
TypeMsgUpdateParams = "update_params"
)
// ensure Msg interface compliance at compile time
var _ sdk.Msg = &MsgVerifyInvariant{}
var _, _ sdk.Msg = &MsgVerifyInvariant{}, &MsgUpdateParams{}
// NewMsgVerifyInvariant creates a new MsgVerifyInvariant object
//nolint:interfacer
@ -19,7 +24,7 @@ func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string)
}
func (msg MsgVerifyInvariant) Route() string { return ModuleName }
func (msg MsgVerifyInvariant) Type() string { return "verify_invariant" }
func (msg MsgVerifyInvariant) Type() string { return TypeMsgVerifyInvariant }
// get the bytes for the message signer to sign on
func (msg MsgVerifyInvariant) GetSigners() []sdk.AccAddress {
@ -45,3 +50,37 @@ func (msg MsgVerifyInvariant) ValidateBasic() error {
func (msg MsgVerifyInvariant) FullInvariantRoute() string {
return msg.InvariantModuleName + "/" + msg.InvariantRoute
}
func (msg MsgUpdateParams) Route() string { return ModuleName }
func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams }
// GetSigners returns the signer addresses that are expected to sign the result
// of GetSignBytes.
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {
authority, _ := sdk.AccAddressFromBech32(msg.Authority)
return []sdk.AccAddress{authority}
}
// GetSignBytes returns the raw bytes for a MsgUpdateParams message that
// the expected signer needs to sign.
func (msg MsgUpdateParams) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// ValidateBasic performs basic MsgUpdateParams message validation.
func (msg MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return sdkerrors.Wrap(err, "invalid authority address")
}
if !msg.ConstantFee.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "invalid costant fee")
}
if msg.ConstantFee.IsNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "negative costant fee")
}
return nil
}

View File

@ -7,6 +7,7 @@ import (
context "context"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
types "github.com/cosmos/cosmos-sdk/types"
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
@ -107,37 +108,144 @@ func (m *MsgVerifyInvariantResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgVerifyInvariantResponse proto.InternalMessageInfo
// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
type MsgUpdateParams struct {
// authority is the address of the governance account.
Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
// constant_fee defines the x/crisis parameter.
ConstantFee types.Coin `protobuf:"bytes,2,opt,name=constant_fee,json=constantFee,proto3" json:"constant_fee"`
}
func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} }
func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateParams) ProtoMessage() {}
func (*MsgUpdateParams) Descriptor() ([]byte, []int) {
return fileDescriptor_61276163172fe867, []int{2}
}
func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgUpdateParams.Merge(m, src)
}
func (m *MsgUpdateParams) XXX_Size() int {
return m.Size()
}
func (m *MsgUpdateParams) XXX_DiscardUnknown() {
xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m)
}
var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo
func (m *MsgUpdateParams) GetAuthority() string {
if m != nil {
return m.Authority
}
return ""
}
func (m *MsgUpdateParams) GetConstantFee() types.Coin {
if m != nil {
return m.ConstantFee
}
return types.Coin{}
}
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
type MsgUpdateParamsResponse struct {
}
func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} }
func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateParamsResponse) ProtoMessage() {}
func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_61276163172fe867, []int{3}
}
func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src)
}
func (m *MsgUpdateParamsResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgVerifyInvariant)(nil), "cosmos.crisis.v1beta1.MsgVerifyInvariant")
proto.RegisterType((*MsgVerifyInvariantResponse)(nil), "cosmos.crisis.v1beta1.MsgVerifyInvariantResponse")
proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.crisis.v1beta1.MsgUpdateParams")
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.crisis.v1beta1.MsgUpdateParamsResponse")
}
func init() { proto.RegisterFile("cosmos/crisis/v1beta1/tx.proto", fileDescriptor_61276163172fe867) }
var fileDescriptor_61276163172fe867 = []byte{
// 342 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0x2f, 0xce,
0xcd, 0x2f, 0xd6, 0x4f, 0x2e, 0xca, 0x2c, 0xce, 0x2c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49,
0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x85, 0xc8, 0xeb, 0x41,
0xe4, 0xf5, 0xa0, 0xf2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x15, 0xfa, 0x20, 0x16, 0x44,
0xb1, 0x94, 0x24, 0x44, 0x71, 0x3c, 0x44, 0x02, 0xaa, 0x13, 0x22, 0x25, 0x0e, 0xb5, 0x27, 0xb7,
0x38, 0x5d, 0xbf, 0xcc, 0x10, 0x44, 0x41, 0x24, 0x94, 0x76, 0x30, 0x72, 0x09, 0xf9, 0x16, 0xa7,
0x87, 0xa5, 0x16, 0x65, 0xa6, 0x55, 0x7a, 0xe6, 0x95, 0x25, 0x16, 0x65, 0x26, 0xe6, 0x95, 0x08,
0x19, 0x70, 0xb1, 0x15, 0xa7, 0xe6, 0xa5, 0xa4, 0x16, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a,
0x49, 0x5c, 0xda, 0xa2, 0x2b, 0x02, 0x35, 0xd1, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb8,
0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x08, 0xaa, 0x4e, 0xc8, 0x88, 0x4b, 0x34, 0x13, 0xa6, 0x3d, 0x3e,
0x37, 0x3f, 0xa5, 0x34, 0x27, 0x35, 0x3e, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x09, 0x64, 0x40, 0x90,
0x30, 0x5c, 0xd2, 0x17, 0x2c, 0xe7, 0x97, 0x98, 0x9b, 0x2a, 0xa4, 0xce, 0xc5, 0x8f, 0xd0, 0x53,
0x94, 0x5f, 0x5a, 0x92, 0x2a, 0xc1, 0x0c, 0x56, 0xcd, 0x07, 0x17, 0x0e, 0x02, 0x89, 0x5a, 0x09,
0x77, 0x2c, 0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0xa1, 0xe9, 0xf9, 0x06, 0x2d, 0xa8, 0x8d, 0x4a,
0x32, 0x5c, 0x52, 0x98, 0x2e, 0x0f, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0x2a, 0xe3,
0x62, 0xf6, 0x2d, 0x4e, 0x17, 0xca, 0xe7, 0xe2, 0x47, 0xf7, 0x9b, 0xa6, 0x1e, 0xd6, 0x40, 0xd5,
0xc3, 0x34, 0x4c, 0xca, 0x90, 0x68, 0xa5, 0x30, 0x7b, 0x9d, 0x5c, 0x4f, 0x3c, 0x92, 0x63, 0xbc,
0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63,
0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3b, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f,
0x57, 0x1f, 0x16, 0xed, 0x60, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x96, 0x06, 0x4a, 0x2a,
0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xd1, 0x63, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x69, 0x76,
0x6c, 0x9d, 0x21, 0x02, 0x00, 0x00,
// 467 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbf, 0x6f, 0x13, 0x31,
0x14, 0xbe, 0xa3, 0xa8, 0x52, 0xdd, 0xaa, 0x91, 0xdc, 0x56, 0x4d, 0x4e, 0xe8, 0x82, 0x32, 0xf0,
0x53, 0xf5, 0x91, 0x20, 0x31, 0x74, 0x23, 0x08, 0x24, 0x86, 0x20, 0x74, 0x08, 0x06, 0x96, 0xc8,
0xb9, 0x7b, 0xb9, 0x5a, 0x70, 0x76, 0xe4, 0xe7, 0x44, 0xcd, 0xca, 0xc4, 0xc8, 0x3f, 0x80, 0xd4,
0x3f, 0x81, 0x81, 0x81, 0x3f, 0xa1, 0x63, 0xc5, 0xc4, 0x54, 0xa1, 0x64, 0x80, 0x3f, 0x03, 0xdd,
0x9d, 0x9d, 0x40, 0x0b, 0x22, 0x93, 0x2d, 0x7f, 0xdf, 0xf7, 0xbe, 0xcf, 0xcf, 0x7e, 0x24, 0x4c,
0x14, 0xe6, 0x0a, 0xa3, 0x44, 0x0b, 0x14, 0x18, 0x4d, 0xda, 0x03, 0x30, 0xbc, 0x1d, 0x99, 0x63,
0x36, 0xd2, 0xca, 0x28, 0xba, 0x57, 0xe1, 0xac, 0xc2, 0x99, 0xc5, 0x83, 0xdd, 0x4c, 0x65, 0xaa,
0x64, 0x44, 0xc5, 0xae, 0x22, 0x07, 0x8d, 0x8a, 0xdc, 0xaf, 0x00, 0xab, 0xac, 0xa0, 0x7d, 0xeb,
0x93, 0x63, 0x16, 0x4d, 0xda, 0xc5, 0x62, 0x01, 0x17, 0x60, 0xc0, 0x11, 0x16, 0xf6, 0x89, 0x12,
0xb2, 0xc2, 0x5b, 0x5f, 0x7c, 0x42, 0x7b, 0x98, 0xbd, 0x02, 0x2d, 0x86, 0xd3, 0xa7, 0x72, 0xc2,
0xb5, 0xe0, 0xd2, 0xd0, 0x7b, 0x64, 0x1d, 0x41, 0xa6, 0xa0, 0xeb, 0xfe, 0x75, 0xff, 0xd6, 0x46,
0xb7, 0xfe, 0xf5, 0xf3, 0xc1, 0xae, 0x75, 0x7c, 0x98, 0xa6, 0x1a, 0x10, 0x5f, 0x18, 0x2d, 0x64,
0x16, 0x5b, 0x1e, 0xed, 0x90, 0x3d, 0xe1, 0xe4, 0xfd, 0x5c, 0xa5, 0xe3, 0xb7, 0xd0, 0x97, 0x3c,
0x87, 0xfa, 0x95, 0xa2, 0x40, 0xbc, 0xb3, 0x00, 0x7b, 0x25, 0xf6, 0x8c, 0xe7, 0x40, 0x6f, 0x92,
0xda, 0x52, 0xa3, 0xd5, 0xd8, 0x40, 0x7d, 0xad, 0x64, 0x6f, 0x2f, 0x8e, 0xe3, 0xe2, 0xf4, 0x70,
0xe7, 0xfd, 0x49, 0xd3, 0xfb, 0x79, 0xd2, 0xf4, 0xde, 0xfd, 0xf8, 0x74, 0xc7, 0x3a, 0xb6, 0xae,
0x91, 0xe0, 0x72, 0xf2, 0x18, 0x70, 0xa4, 0x24, 0x42, 0xeb, 0xa3, 0x4f, 0x6a, 0x3d, 0xcc, 0x5e,
0x8e, 0x52, 0x6e, 0xe0, 0x39, 0xd7, 0x3c, 0x47, 0xfa, 0x80, 0x6c, 0xf0, 0xb1, 0x39, 0x52, 0x5a,
0x98, 0xe9, 0x7f, 0x2f, 0xb6, 0xa4, 0xd2, 0x2e, 0xd9, 0x4a, 0x94, 0x44, 0x53, 0xc4, 0x1c, 0x42,
0x75, 0xa5, 0xcd, 0x4e, 0x83, 0x59, 0x5d, 0xd1, 0x5b, 0xf7, 0x74, 0xec, 0x91, 0x12, 0xb2, 0x7b,
0xf5, 0xf4, 0xbc, 0xe9, 0xc5, 0x9b, 0x4e, 0xf4, 0x04, 0xe0, 0x70, 0xbb, 0x88, 0xbe, 0xac, 0xd9,
0x6a, 0x90, 0xfd, 0x0b, 0xf1, 0x5c, 0xf4, 0xce, 0xb9, 0x4f, 0xd6, 0x7a, 0x98, 0x51, 0x45, 0x6a,
0x17, 0xdf, 0xe5, 0x36, 0xfb, 0xeb, 0x87, 0x61, 0x97, 0x1b, 0x11, 0xb4, 0x57, 0xa6, 0x3a, 0x63,
0x3a, 0x24, 0x5b, 0x7f, 0xf4, 0xeb, 0xc6, 0xbf, 0x4b, 0xfc, 0xce, 0x0b, 0xd8, 0x6a, 0x3c, 0xe7,
0xd3, 0x7d, 0x7c, 0x3a, 0x0b, 0xfd, 0xb3, 0x59, 0xe8, 0x7f, 0x9f, 0x85, 0xfe, 0x87, 0x79, 0xe8,
0x9d, 0xcd, 0x43, 0xef, 0xdb, 0x3c, 0xf4, 0x5e, 0xdf, 0xcd, 0x84, 0x39, 0x1a, 0x0f, 0x58, 0xa2,
0xf2, 0xc8, 0x8d, 0x4e, 0xb9, 0x1c, 0x60, 0xfa, 0x26, 0x3a, 0x76, 0x73, 0x64, 0xa6, 0x23, 0xc0,
0xc1, 0x7a, 0xf9, 0x85, 0xef, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x34, 0x0c, 0xab, 0x77, 0x65,
0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -154,6 +262,11 @@ const _ = grpc.SupportPackageIsVersion4
type MsgClient interface {
// VerifyInvariant defines a method to verify a particular invariance.
VerifyInvariant(ctx context.Context, in *MsgVerifyInvariant, opts ...grpc.CallOption) (*MsgVerifyInvariantResponse, error)
// UpdateParams defines a governance operation for updating the x/crisis module
// parameters. The authority is defined in the keeper.
//
// Since: cosmos-sdk 0.47
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
type msgClient struct {
@ -173,10 +286,24 @@ func (c *msgClient) VerifyInvariant(ctx context.Context, in *MsgVerifyInvariant,
return out, nil
}
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
out := new(MsgUpdateParamsResponse)
err := c.cc.Invoke(ctx, "/cosmos.crisis.v1beta1.Msg/UpdateParams", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
// VerifyInvariant defines a method to verify a particular invariance.
VerifyInvariant(context.Context, *MsgVerifyInvariant) (*MsgVerifyInvariantResponse, error)
// UpdateParams defines a governance operation for updating the x/crisis module
// parameters. The authority is defined in the keeper.
//
// Since: cosmos-sdk 0.47
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
@ -186,6 +313,9 @@ type UnimplementedMsgServer struct {
func (*UnimplementedMsgServer) VerifyInvariant(ctx context.Context, req *MsgVerifyInvariant) (*MsgVerifyInvariantResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method VerifyInvariant not implemented")
}
func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
@ -209,6 +339,24 @@ func _Msg_VerifyInvariant_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).UpdateParams(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.crisis.v1beta1.Msg/UpdateParams",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
}
return interceptor(ctx, in, info, handler)
}
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.crisis.v1beta1.Msg",
HandlerType: (*MsgServer)(nil),
@ -217,6 +365,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
MethodName: "VerifyInvariant",
Handler: _Msg_VerifyInvariant_Handler,
},
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/crisis/v1beta1/tx.proto",
@ -289,6 +441,69 @@ func (m *MsgVerifyInvariantResponse) MarshalToSizedBuffer(dAtA []byte) (int, err
return len(dAtA) - i, nil
}
func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size, err := m.ConstantFee.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if len(m.Authority) > 0 {
i -= len(m.Authority)
copy(dAtA[i:], m.Authority)
i = encodeVarintTx(dAtA, i, uint64(len(m.Authority)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
offset -= sovTx(v)
base := offset
@ -330,6 +545,30 @@ func (m *MsgVerifyInvariantResponse) Size() (n int) {
return n
}
func (m *MsgUpdateParams) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Authority)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
l = m.ConstantFee.Size()
n += 1 + l + sovTx(uint64(l))
return n
}
func (m *MsgUpdateParamsResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func sovTx(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -532,6 +771,171 @@ func (m *MsgVerifyInvariantResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *MsgUpdateParams) 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 ErrIntOverflowTx
}
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: MsgUpdateParams: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Authority = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ConstantFee", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.ConstantFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx
}
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: MsgUpdateParamsResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipTx(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0