feat(staking): migrate x/params away from x/staking (#12409)

## Description
Deprecate the usage of the now legacy x/params module within x/staking.

Closes: #12285



---

### 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:
Jeancarlo Barrios 2022-07-21 08:50:25 -06:00 committed by GitHub
parent f02c28a72e
commit fc2897d3a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 2366 additions and 355 deletions

View File

@ -68,6 +68,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (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`.
* (x/staking) [#12409](https://github.com/cosmos/cosmos-sdk/pull/12409) Migrate `x/staking` to self-managed parameters and deprecate it's usage of `x/params`.
### API Breaking Changes
@ -84,6 +86,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/staking) [#12409](https://github.com/cosmos/cosmos-sdk/pull/12409) `x/staking` 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`.
### CLI Breaking Changes

View File

@ -1746,7 +1746,7 @@ type GenesisState struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// params defines all the paramaters of related to deposit.
// params defines all the parameters of related to deposit.
Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"`
// last_total_power tracks the total amounts of bonded tokens recorded during
// the previous end block.

View File

@ -12706,7 +12706,7 @@ func (x *Redelegation) GetEntries() []*RedelegationEntry {
return nil
}
// Params defines the parameters for the staking module.
// Params defines the parameters for the x/staking module.
type Params struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,10 @@ type MsgClient interface {
//
// Since: cosmos-sdk 0.46
CancelUnbondingDelegation(ctx context.Context, in *MsgCancelUnbondingDelegation, opts ...grpc.CallOption) (*MsgCancelUnbondingDelegationResponse, error)
// UpdateParams defines a operation for updating the x/staking module
// parameters.
// Since: cosmos-sdk 0.47
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
type msgClient struct {
@ -104,6 +108,15 @@ func (c *msgClient) CancelUnbondingDelegation(ctx context.Context, in *MsgCancel
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.staking.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
@ -126,6 +139,10 @@ type MsgServer interface {
//
// Since: cosmos-sdk 0.46
CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error)
// UpdateParams defines a operation for updating the x/staking module
// parameters.
// Since: cosmos-sdk 0.47
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
mustEmbedUnimplementedMsgServer()
}
@ -151,6 +168,9 @@ func (UnimplementedMsgServer) Undelegate(context.Context, *MsgUndelegate) (*MsgU
func (UnimplementedMsgServer) CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CancelUnbondingDelegation 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.
@ -272,6 +292,24 @@ func _Msg_CancelUnbondingDelegation_Handler(srv interface{}, ctx context.Context
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.staking.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)
@ -303,6 +341,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
MethodName: "CancelUnbondingDelegation",
Handler: _Msg_CancelUnbondingDelegation_Handler,
},
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/staking/v1beta1/tx.proto",

View File

@ -9,7 +9,7 @@ import "cosmos_proto/cosmos.proto";
// GenesisState defines the staking module's genesis state.
message GenesisState {
// params defines all the paramaters of related to deposit.
// params defines all the parameters of related to deposit.
Params params = 1 [(gogoproto.nullable) = false];
// last_total_power tracks the total amounts of bonded tokens recorded during

View File

@ -282,7 +282,7 @@ message Redelegation {
repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries
}
// Params defines the parameters for the staking module.
// Params defines the parameters for the x/staking module.
message Params {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;

View File

@ -38,6 +38,11 @@ service Msg {
//
// Since: cosmos-sdk 0.46
rpc CancelUnbondingDelegation(MsgCancelUnbondingDelegation) returns (MsgCancelUnbondingDelegationResponse);
// UpdateParams defines an operation for updating the x/staking module
// parameters.
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgCreateValidator defines a SDK message for creating a new validator.
@ -163,3 +168,23 @@ message MsgCancelUnbondingDelegation {
//
// Since: cosmos-sdk 0.46
message MsgCancelUnbondingDelegationResponse {}
// 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"];
// params defines the x/staking parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
};
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {};

View File

@ -261,7 +261,7 @@ func NewSimApp(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.ModuleAccountAddrs(), authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.MintKeeper = mintkeeper.NewKeeper(appCodec, keys[minttypes.StoreKey], app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
@ -361,7 +361,7 @@ func NewSimApp(
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
params.NewAppModule(app.ParamsKeeper),
@ -427,7 +427,7 @@ func NewSimApp(
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)),
params.NewAppModule(app.ParamsKeeper),

View File

@ -6,8 +6,8 @@ import (
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
v046gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
v043staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v043"
v046staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v046"
stakingv2 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2"
stakingv3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -32,21 +32,21 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {
}
// Migrate x/staking.
if appState[v043staking.ModuleName] != nil {
if appState[stakingv2.ModuleName] != nil {
// unmarshal relative source genesis application state
var old stakingtypes.GenesisState
clientCtx.Codec.MustUnmarshalJSON(appState[v043staking.ModuleName], &old)
clientCtx.Codec.MustUnmarshalJSON(appState[stakingv2.ModuleName], &old)
// delete deprecated x/staking genesis state
delete(appState, v043staking.ModuleName)
delete(appState, stakingv2.ModuleName)
// Migrate relative source genesis application state and marshal it into
// the respective key.
new, err := v046staking.MigrateJSON(old)
new, err := stakingv3.MigrateJSON(old)
if err != nil {
panic(err)
}
appState[v046staking.ModuleName] = clientCtx.Codec.MustMarshalJSON(&new)
appState[stakingv3.ModuleName] = clientCtx.Codec.MustMarshalJSON(&new)
}
return appState

View File

@ -48,7 +48,7 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
app.GetKey(stakingtypes.StoreKey),
app.AccountKeeper,
app.BankKeeper,
app.GetSubspace(stakingtypes.ModuleName),
authtypes.NewModuleAddress(types.ModuleName).String(),
)
val1, err := stakingtypes.NewValidator(valAddrs[0], pks[0], stakingtypes.Description{})

View File

@ -27,53 +27,40 @@ func (s *IntegrationTestSuite) TestQueryParamsGRPC() {
map[string]string{},
true,
&proposal.QueryParamsResponse{},
&proposal.QueryParamsResponse{
Param: proposal.ParamChange{
Subspace: "staking",
Key: "MaxValidators",
Value: "100",
},
},
nil,
},
{
"with wrong subspace",
fmt.Sprintf("%s/cosmos/params/v1beta1/params?subspace=%s&key=%s", baseURL, "wrongSubspace", "MaxValidators"),
fmt.Sprintf("%s/cosmos/params/v1beta1/params?subspace=%s&key=%s", baseURL, "wrongSubspace", "foo"),
map[string]string{},
true,
&proposal.QueryParamsResponse{},
&proposal.QueryParamsResponse{
Param: proposal.ParamChange{
Subspace: "staking",
Key: "MaxValidators",
Value: "100",
},
},
nil,
},
{
"with wrong key",
fmt.Sprintf("%s/cosmos/params/v1beta1/params?subspace=%s&key=%s", baseURL, "staking", "wrongKey"),
fmt.Sprintf("%s/cosmos/params/v1beta1/params?subspace=%s&key=%s", baseURL, mySubspace, "wrongKey"),
map[string]string{},
false,
&proposal.QueryParamsResponse{},
&proposal.QueryParamsResponse{
Param: proposal.ParamChange{
Subspace: "staking",
Subspace: mySubspace,
Key: "wrongKey",
Value: "",
},
},
},
{
"params",
fmt.Sprintf("%s/cosmos/params/v1beta1/params?subspace=%s&key=%s", baseURL, "staking", "MaxValidators"),
fmt.Sprintf("%s/cosmos/params/v1beta1/params?subspace=%s&key=%s", baseURL, mySubspace, "bar"),
map[string]string{},
false,
&proposal.QueryParamsResponse{},
&proposal.QueryParamsResponse{
Param: proposal.ParamChange{
Subspace: "staking",
Key: "MaxValidators",
Value: "100",
Subspace: mySubspace,
Key: "bar",
Value: `"1234"`,
},
},
},

View File

@ -5,13 +5,40 @@ import (
"strings"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmcli "github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tm-db"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/baseapp"
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/cosmos/cosmos-sdk/runtime"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/params/client/cli"
"github.com/cosmos/cosmos-sdk/x/params/keeper"
"github.com/cosmos/cosmos-sdk/x/params/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// mySubspace is a x/params subspace created for the purpose of this
// test suite.
const (
mySubspace = "foo"
)
// myParams defines some params in the `mySubspace` subspace.
type myParams struct{}
func (p *myParams) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair([]byte("bar"), 1234, func(value interface{}) error { return nil }),
}
}
type IntegrationTestSuite struct {
suite.Suite
@ -26,6 +53,44 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
// Create a new AppConstructor for this test suite, where we manually
// add a subspace and `myParams` to the x/params store.
s.cfg.AppConstructor = func(val moduletestutil.Validator) servertypes.Application {
var (
appBuilder *runtime.AppBuilder
paramsKeeper keeper.Keeper
)
if err := depinject.Inject(testutil.AppConfig, &appBuilder, &paramsKeeper); err != nil {
panic(err)
}
// Add this test's `myParams` to the x/params store.
paramSet := myParams{}
subspace := paramsKeeper.Subspace(mySubspace).WithKeyTable(paramtypes.NewKeyTable().RegisterParamSet(&paramSet))
app := appBuilder.Build(
val.GetCtx().Logger,
dbm.NewMemDB(),
nil,
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
)
s.Require().NoError(app.Load(false))
// Make sure not to forget to persist `myParams` into the actual store,
// this is done in InitChain.
app.SetInitChainer(func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
subspace.SetParamSet(ctx, &paramSet)
return app.InitChainer(ctx, req)
})
s.Require().NoError(app.LoadLatestVersion())
return app
}
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
@ -50,20 +115,20 @@ func (s *IntegrationTestSuite) TestNewQuerySubspaceParamsCmd() {
{
"json output",
[]string{
"staking", "MaxValidators",
"foo", "bar",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
`{"subspace":"staking","key":"MaxValidators","value":"100"}`,
`{"subspace":"foo","key":"bar","value":"\"1234\""}`,
},
{
"text output",
[]string{
"staking", "MaxValidators",
"foo", "bar",
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
},
`key: MaxValidators
subspace: staking
value: "100"`,
`key: bar
subspace: foo
value: '"1234"'`,
},
}

View File

@ -1,6 +1,7 @@
package params_test
import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"testing"
"github.com/golang/mock/gomock"
@ -15,7 +16,6 @@ import (
paramstestutil "github.com/cosmos/cosmos-sdk/x/params/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
// StakingKeeper defines the expected staking keeper
@ -78,23 +78,23 @@ func (suite *HandlerTestSuite) TestProposalHandler() {
func() {},
true,
},
// {
// "omit empty fields",
// testProposal(proposal.ParamChange{
// Subspace: govtypes.ModuleName,
// Key: string(govv1.ParamStoreKeyDepositParams),
// Value: `{"min_deposit": [{"denom": "uatom","amount": "64000000"}], "max_deposit_period": "172800000000000"}`,
// }),
// func() {
// depositParams := suite.app.GovKeeper.GetDepositParams(suite.ctx)
// defaultPeriod := govv1.DefaultPeriod
// suite.Require().Equal(govv1.DepositParams{
// MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(64000000))),
// MaxDepositPeriod: &defaultPeriod,
// }, depositParams)
// },
// false,
// },
//{
// "omit empty fields",
// testProposal(proposal.ParamChange{
// Subspace: govtypes.ModuleName,
// Key: string(govv1.ParamStoreKeyDepositParams),
// Value: `{"min_deposit": [{"denom": "uatom","amount": "64000000"}], "max_deposit_period": "172800000000000"}`,
// }),
// func() {
// depositParams := suite.app.GovKeeper.GetDepositParams(suite.ctx)
// defaultPeriod := govv1.DefaultPeriod
// suite.Require().Equal(govv1.DepositParams{
// MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(64000000))),
// MaxDepositPeriod: &defaultPeriod,
// }, depositParams)
// },
// false,
//},
}
for _, tc := range testCases {

View File

@ -1,6 +1,8 @@
package staking_test
import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"math/big"
"testing"
@ -48,7 +50,7 @@ func getBaseSimappWithCustomKeeper(t *testing.T) (*codec.LegacyAmino, *simapp.Si
app.GetKey(types.StoreKey),
app.AccountKeeper,
app.BankKeeper,
app.GetSubspace(types.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.StakingKeeper.SetParams(ctx, types.DefaultParams())

View File

@ -0,0 +1,16 @@
package exported
import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
type (
// 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 paramtypes.ParamSet)
}
)

View File

@ -1,6 +1,8 @@
package keeper_test
import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"math/big"
"testing"
@ -31,7 +33,7 @@ func createTestInput(t *testing.T) (*codec.LegacyAmino, *simapp.SimApp, sdk.Cont
app.GetKey(types.StoreKey),
app.AccountKeeper,
app.BankKeeper,
app.GetSubspace(types.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
return app.LegacyAmino(), app, ctx
}

View File

@ -106,6 +106,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []ab
}
// TODO: remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
bondedBalance := k.bankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())
if bondedBalance.IsZero() {
k.authKeeper.SetModuleAccount(ctx, bondedPool)

View File

@ -3,6 +3,8 @@ package keeper_test
import (
gocontext "context"
"fmt"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"testing"
"github.com/stretchr/testify/require"
@ -796,7 +798,7 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
app.GetKey(types.StoreKey),
app.AccountKeeper,
app.BankKeeper,
app.GetSubspace(types.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
val1 := teststaking.NewValidator(t, valAddrs[0], pks[0])

View File

@ -1,16 +1,14 @@
package keeper
import (
"fmt"
"cosmossdk.io/math"
"fmt"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -20,26 +18,24 @@ var _ types.ValidatorSet = Keeper{}
// Implements DelegationSet interface
var _ types.DelegationSet = Keeper{}
// keeper of the staking store
// Keeper of the x/staking store
type Keeper struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
authKeeper types.AccountKeeper
bankKeeper types.BankKeeper
hooks types.StakingHooks
paramstore paramtypes.Subspace
authority string
}
// NewKeeper creates a new staking Keeper instance
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, ak types.AccountKeeper, bk types.BankKeeper,
ps paramtypes.Subspace,
cdc codec.BinaryCodec,
key storetypes.StoreKey,
ak types.AccountKeeper,
bk types.BankKeeper,
authority string,
) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}
// ensure bonded and not bonded module accounts are set
if addr := ak.GetModuleAddress(types.BondedPoolName); addr == nil {
panic(fmt.Sprintf("%s module account has not been set", types.BondedPoolName))
@ -49,13 +45,18 @@ func NewKeeper(
panic(fmt.Sprintf("%s module account has not been set", types.NotBondedPoolName))
}
// ensure that authority is a valid AccAddress
if _, err := sdk.AccAddressFromBech32(authority); err != nil {
panic(fmt.Sprintf("authority is not a valid acc address"))
}
return &Keeper{
storeKey: key,
cdc: cdc,
authKeeper: ak,
bankKeeper: bk,
paramstore: ps,
hooks: nil,
authority: authority,
}
}
@ -64,7 +65,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", "x/"+types.ModuleName)
}
// Set the validator hooks
// SetHooks Set the validator hooks
func (k *Keeper) SetHooks(sh types.StakingHooks) {
if k.hooks != nil {
panic("cannot set validator hooks twice")
@ -73,7 +74,7 @@ func (k *Keeper) SetHooks(sh types.StakingHooks) {
k.hooks = sh
}
// Load the last total validator power.
// GetLastTotalPower Load the last total validator power.
func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.LastTotalPowerKey)
@ -88,9 +89,14 @@ func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int {
return ip.Int
}
// Set the last total validator power.
// SetLastTotalPower Set the last total validator power.
func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
store.Set(types.LastTotalPowerKey, bz)
}
// GetAuthority returns the x/staking module's authority.
func (k Keeper) GetAuthority() string {
return k.authority
}

View File

@ -2,28 +2,37 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
v043 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v043"
v046 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v046"
"github.com/cosmos/cosmos-sdk/x/staking/exported"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
v4 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v4"
)
// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper *Keeper
keeper *Keeper
legacySubspace exported.Subspace
}
// NewMigrator returns a new Migrator.
func NewMigrator(keeper *Keeper) Migrator {
func NewMigrator(keeper *Keeper, legacySubspace exported.Subspace) Migrator {
return Migrator{
keeper: keeper,
keeper: keeper,
legacySubspace: legacySubspace,
}
}
// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v043.MigrateStore(ctx, m.keeper.storeKey)
return v2.MigrateStore(ctx, m.keeper.storeKey)
}
// Migrate2to3 migrates x/staking state from consensus version 2 to 3.
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v046.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.keeper.paramstore)
return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.legacySubspace)
}
// Migrate3to4 migrates x/staking state from consensus version 3 to 4.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.legacySubspace)
}

View File

@ -2,6 +2,7 @@ package keeper
import (
"context"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"strconv"
"time"
@ -499,3 +500,18 @@ func (k msgServer) CancelUnbondingDelegation(goCtx context.Context, msg *types.M
return &types.MsgCancelUnbondingDelegationResponse{}, nil
}
func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
if ms.authority != msg.Authority {
return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, msg.Authority)
}
// store params
if err := ms.SetParams(ctx, msg.Params); err != nil {
return nil, err
}
return &types.MsgUpdateParamsResponse{}, nil
}

View File

@ -144,3 +144,127 @@ func TestCancelUnbondingDelegation(t *testing.T) {
})
}
}
func TestMsgUpdateParams(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
msgServer := keeper.NewMsgServerImpl(app.StakingKeeper)
testCases := []struct {
name string
input *types.MsgUpdateParams
expErr bool
expErrMsg string
}{
{
name: "valid params",
input: &types.MsgUpdateParams{
Authority: app.StakingKeeper.GetAuthority(),
Params: types.DefaultParams(),
},
expErr: false,
},
{
name: "invalid authority",
input: &types.MsgUpdateParams{
Authority: "invalid",
Params: types.DefaultParams(),
},
expErr: true,
expErrMsg: "invalid authority",
},
{
name: "negative commission rate",
input: &types.MsgUpdateParams{
Authority: app.StakingKeeper.GetAuthority(),
Params: types.Params{
MinCommissionRate: sdk.NewDec(-10),
UnbondingTime: types.DefaultUnbondingTime,
MaxValidators: types.DefaultMaxValidators,
MaxEntries: types.DefaultMaxEntries,
HistoricalEntries: types.DefaultHistoricalEntries,
BondDenom: types.BondStatusBonded,
},
},
expErr: true,
expErrMsg: "minimum commission rate cannot be negative",
},
{
name: "commission rate cannot be bigger than 100",
input: &types.MsgUpdateParams{
Authority: app.StakingKeeper.GetAuthority(),
Params: types.Params{
MinCommissionRate: sdk.NewDec(2),
UnbondingTime: types.DefaultUnbondingTime,
MaxValidators: types.DefaultMaxValidators,
MaxEntries: types.DefaultMaxEntries,
HistoricalEntries: types.DefaultHistoricalEntries,
BondDenom: types.BondStatusBonded,
},
},
expErr: true,
expErrMsg: "minimum commission rate cannot be greater than 100%",
},
{
name: "invalid bond denom",
input: &types.MsgUpdateParams{
Authority: app.StakingKeeper.GetAuthority(),
Params: types.Params{
MinCommissionRate: types.DefaultMinCommissionRate,
UnbondingTime: types.DefaultUnbondingTime,
MaxValidators: types.DefaultMaxValidators,
MaxEntries: types.DefaultMaxEntries,
HistoricalEntries: types.DefaultHistoricalEntries,
BondDenom: "",
},
},
expErr: true,
expErrMsg: "bond denom cannot be blank",
},
{
name: "max validators most be positive",
input: &types.MsgUpdateParams{
Authority: app.StakingKeeper.GetAuthority(),
Params: types.Params{
MinCommissionRate: types.DefaultMinCommissionRate,
UnbondingTime: types.DefaultUnbondingTime,
MaxValidators: 0,
MaxEntries: types.DefaultMaxEntries,
HistoricalEntries: types.DefaultHistoricalEntries,
BondDenom: types.BondStatusBonded,
},
},
expErr: true,
expErrMsg: "max validators must be positive",
},
{
name: "max entries most be positive",
input: &types.MsgUpdateParams{
Authority: app.StakingKeeper.GetAuthority(),
Params: types.Params{
MinCommissionRate: types.DefaultMinCommissionRate,
UnbondingTime: types.DefaultUnbondingTime,
MaxValidators: types.DefaultMaxValidators,
MaxEntries: 0,
HistoricalEntries: types.DefaultHistoricalEntries,
BondDenom: types.BondStatusBonded,
},
},
expErr: true,
expErrMsg: "max entries must be positive",
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
_, err := msgServer.UpdateParams(ctx, tc.input)
if tc.expErr {
require.Error(t, err)
require.Contains(t, err.Error(), tc.expErrMsg)
} else {
require.NoError(t, err)
}
})
}
}

View File

@ -10,35 +10,30 @@ import (
)
// UnbondingTime
func (k Keeper) UnbondingTime(ctx sdk.Context) (res time.Duration) {
k.paramstore.Get(ctx, types.KeyUnbondingTime, &res)
return
func (k Keeper) UnbondingTime(ctx sdk.Context) time.Duration {
return k.GetParams(ctx).UnbondingTime
}
// MaxValidators - Maximum number of validators
func (k Keeper) MaxValidators(ctx sdk.Context) (res uint32) {
k.paramstore.Get(ctx, types.KeyMaxValidators, &res)
return
func (k Keeper) MaxValidators(ctx sdk.Context) uint32 {
return k.GetParams(ctx).MaxValidators
}
// MaxEntries - Maximum number of simultaneous unbonding
// delegations or redelegations (per pair/trio)
func (k Keeper) MaxEntries(ctx sdk.Context) (res uint32) {
k.paramstore.Get(ctx, types.KeyMaxEntries, &res)
return
func (k Keeper) MaxEntries(ctx sdk.Context) uint32 {
return k.GetParams(ctx).MaxEntries
}
// HistoricalEntries = number of historical info entries
// to persist in store
func (k Keeper) HistoricalEntries(ctx sdk.Context) (res uint32) {
k.paramstore.Get(ctx, types.KeyHistoricalEntries, &res)
return
return k.GetParams(ctx).HistoricalEntries
}
// BondDenom - Bondable coin denomination
func (k Keeper) BondDenom(ctx sdk.Context) (res string) {
k.paramstore.Get(ctx, types.KeyBondDenom, &res)
return
return k.GetParams(ctx).BondDenom
}
// PowerReduction - is the amount of staking tokens required for 1 unit of consensus-engine power.
@ -50,24 +45,34 @@ func (k Keeper) PowerReduction(ctx sdk.Context) math.Int {
}
// MinCommissionRate - Minimum validator commission rate
func (k Keeper) MinCommissionRate(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeyMinCommissionRate, &res)
return
func (k Keeper) MinCommissionRate(ctx sdk.Context) sdk.Dec {
return k.GetParams(ctx).MinCommissionRate
}
// Get all parameters as types.Params
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.UnbondingTime(ctx),
k.MaxValidators(ctx),
k.MaxEntries(ctx),
k.HistoricalEntries(ctx),
k.BondDenom(ctx),
k.MinCommissionRate(ctx),
)
// SetParams sets the x/staking module parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
if err := params.Validate(); err != nil {
return err
}
store := ctx.KVStore(k.storeKey)
bz, err := k.cdc.Marshal(&params)
if err != nil {
return err
}
store.Set(types.ParamsKey, bz)
return nil
}
// set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, &params)
// GetParams sets the x/staking module parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.ParamsKey)
if bz == nil {
return params
}
k.cdc.MustUnmarshal(bz, &params)
return params
}

View File

@ -1,4 +1,4 @@
package v042
package v1
import (
"bytes"

View File

@ -1,4 +1,4 @@
package v043
package v2
const (
// ModuleName is the name of the module

View File

@ -1,4 +1,4 @@
package v043
package v2
import (
"github.com/cosmos/cosmos-sdk/store/prefix"
@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/address"
v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042"
v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043"
v040staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v042"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v1"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -39,7 +39,7 @@ func migratePrefixAddressAddressAddress(store sdk.KVStore, prefixBz []byte) {
const powerBytesLen = 8
func migrateValidatorsByPowerIndexKey(store sdk.KVStore) {
oldStore := prefix.NewStore(store, v040staking.ValidatorsByPowerIndexKey)
oldStore := prefix.NewStore(store, v1.ValidatorsByPowerIndexKey)
oldStoreIter := oldStore.Iterator(nil, nil)
defer oldStoreIter.Close()
@ -62,18 +62,18 @@ func migrateValidatorsByPowerIndexKey(store sdk.KVStore) {
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error {
store := ctx.KVStore(storeKey)
v043distribution.MigratePrefixAddress(store, v040staking.LastValidatorPowerKey)
v043distribution.MigratePrefixAddress(store, v1.LastValidatorPowerKey)
v043distribution.MigratePrefixAddress(store, v040staking.ValidatorsKey)
v043distribution.MigratePrefixAddress(store, v040staking.ValidatorsByConsAddrKey)
v043distribution.MigratePrefixAddress(store, v1.ValidatorsKey)
v043distribution.MigratePrefixAddress(store, v1.ValidatorsByConsAddrKey)
migrateValidatorsByPowerIndexKey(store)
v043distribution.MigratePrefixAddressAddress(store, v040staking.DelegationKey)
v043distribution.MigratePrefixAddressAddress(store, v040staking.UnbondingDelegationKey)
v043distribution.MigratePrefixAddressAddress(store, v040staking.UnbondingDelegationByValIndexKey)
migratePrefixAddressAddressAddress(store, v040staking.RedelegationKey)
migratePrefixAddressAddressAddress(store, v040staking.RedelegationByValSrcIndexKey)
migratePrefixAddressAddressAddress(store, v040staking.RedelegationByValDstIndexKey)
v043distribution.MigratePrefixAddressAddress(store, v1.DelegationKey)
v043distribution.MigratePrefixAddressAddress(store, v1.UnbondingDelegationKey)
v043distribution.MigratePrefixAddressAddress(store, v1.UnbondingDelegationByValIndexKey)
migratePrefixAddressAddressAddress(store, v1.RedelegationKey)
migratePrefixAddressAddressAddress(store, v1.RedelegationByValSrcIndexKey)
migratePrefixAddressAddressAddress(store, v1.RedelegationByValDstIndexKey)
return nil
}

View File

@ -1,4 +1,4 @@
package v043_test
package v2_test
import (
"bytes"
@ -10,8 +10,8 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
v042staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v042"
v043staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v043"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v1"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -41,77 +41,77 @@ func TestStoreMigration(t *testing.T) {
}{
{
"LastValidatorPowerKey",
v042staking.GetLastValidatorPowerKey(valAddr1),
v1.GetLastValidatorPowerKey(valAddr1),
types.GetLastValidatorPowerKey(valAddr1),
},
{
"LastTotalPowerKey",
v042staking.LastTotalPowerKey,
v1.LastTotalPowerKey,
types.LastTotalPowerKey,
},
{
"ValidatorsKey",
v042staking.GetValidatorKey(valAddr1),
v1.GetValidatorKey(valAddr1),
types.GetValidatorKey(valAddr1),
},
{
"ValidatorsByConsAddrKey",
v042staking.GetValidatorByConsAddrKey(consAddr),
v1.GetValidatorByConsAddrKey(consAddr),
types.GetValidatorByConsAddrKey(consAddr),
},
{
"ValidatorsByPowerIndexKey",
v042staking.GetValidatorsByPowerIndexKey(val),
v1.GetValidatorsByPowerIndexKey(val),
types.GetValidatorsByPowerIndexKey(val, sdk.DefaultPowerReduction),
},
{
"DelegationKey",
v042staking.GetDelegationKey(addr4, valAddr1),
v1.GetDelegationKey(addr4, valAddr1),
types.GetDelegationKey(addr4, valAddr1),
},
{
"UnbondingDelegationKey",
v042staking.GetUBDKey(addr4, valAddr1),
v1.GetUBDKey(addr4, valAddr1),
types.GetUBDKey(addr4, valAddr1),
},
{
"UnbondingDelegationByValIndexKey",
v042staking.GetUBDByValIndexKey(addr4, valAddr1),
v1.GetUBDByValIndexKey(addr4, valAddr1),
types.GetUBDByValIndexKey(addr4, valAddr1),
},
{
"RedelegationKey",
v042staking.GetREDKey(addr4, valAddr1, valAddr2),
v1.GetREDKey(addr4, valAddr1, valAddr2),
types.GetREDKey(addr4, valAddr1, valAddr2),
},
{
"RedelegationByValSrcIndexKey",
v042staking.GetREDByValSrcIndexKey(addr4, valAddr1, valAddr2),
v1.GetREDByValSrcIndexKey(addr4, valAddr1, valAddr2),
types.GetREDByValSrcIndexKey(addr4, valAddr1, valAddr2),
},
{
"RedelegationByValDstIndexKey",
v042staking.GetREDByValDstIndexKey(addr4, valAddr1, valAddr2),
v1.GetREDByValDstIndexKey(addr4, valAddr1, valAddr2),
types.GetREDByValDstIndexKey(addr4, valAddr1, valAddr2),
},
{
"UnbondingQueueKey",
v042staking.GetUnbondingDelegationTimeKey(now),
v1.GetUnbondingDelegationTimeKey(now),
types.GetUnbondingDelegationTimeKey(now),
},
{
"RedelegationQueueKey",
v042staking.GetRedelegationTimeKey(now),
v1.GetRedelegationTimeKey(now),
types.GetRedelegationTimeKey(now),
},
{
"ValidatorQueueKey",
v042staking.GetValidatorQueueKey(now, 4),
v1.GetValidatorQueueKey(now, 4),
types.GetValidatorQueueKey(now, 4),
},
{
"HistoricalInfoKey",
v042staking.GetHistoricalInfoKey(4),
v1.GetHistoricalInfoKey(4),
types.GetHistoricalInfoKey(4),
},
}
@ -122,7 +122,7 @@ func TestStoreMigration(t *testing.T) {
}
// Run migrations.
err := v043staking.MigrateStore(ctx, stakingKey)
err := v2.MigrateStore(ctx, stakingKey)
require.NoError(t, err)
// Make sure the new keys are set and old keys are deleted.

View File

@ -1,4 +1,4 @@
package v046
package v3
import "github.com/cosmos/cosmos-sdk/x/staking/types"

View File

@ -1,4 +1,4 @@
package v046_test
package v3_test
import (
"encoding/json"
@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/simapp"
v046 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v046"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -21,7 +21,7 @@ func TestMigrateJSON(t *testing.T) {
oldState := types.DefaultGenesisState()
newState, err := v046.MigrateJSON(*oldState)
newState, err := v3.MigrateJSON(*oldState)
require.NoError(t, err)
bz, err := clientCtx.Codec.MarshalJSON(&newState)

View File

@ -1,4 +1,4 @@
package v046
package v3
const (
// ModuleName is the name of the module

View File

@ -1,24 +1,34 @@
package v046
package v3
import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/staking/exported"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
// subspace contains the method needed for migrations of the
// legacy Params subspace
type subspace interface {
GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet)
HasKeyTable() bool
WithKeyTable(paramtypes.KeyTable) paramtypes.Subspace
Set(ctx sdk.Context, key []byte, value interface{})
}
// MigrateStore performs in-place store migrations from v0.43/v0.44/v0.45 to v0.46.
// The migration includes:
//
// - Setting the MinCommissionRate param in the paramstore
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, paramstore paramtypes.Subspace) error {
migrateParamsStore(ctx, paramstore)
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, paramstore exported.Subspace) error {
migrateParamsStore(ctx, paramstore.(subspace))
return nil
}
func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) {
func migrateParamsStore(ctx sdk.Context, paramstore subspace) {
if paramstore.HasKeyTable() {
paramstore.Set(ctx, types.KeyMinCommissionRate, types.DefaultMinCommissionRate)
} else {

View File

@ -1,4 +1,4 @@
package v046_test
package v3_test
import (
"testing"
@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
v046staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v046"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -24,7 +24,7 @@ func TestStoreMigration(t *testing.T) {
require.False(t, paramstore.Has(ctx, types.KeyMinCommissionRate))
// Run migrations.
err := v046staking.MigrateStore(ctx, stakingKey, encCfg.Codec, paramstore)
err := v3.MigrateStore(ctx, stakingKey, encCfg.Codec, paramstore)
require.NoError(t, err)
// Make sure the new params are set.

View File

@ -0,0 +1,8 @@
package v4
const (
// ModuleName is the name of the module
ModuleName = "staking"
)
var ParamsKey = []byte{0x51} // prefix for parameters for module x/staking

View File

@ -0,0 +1,45 @@
package v4_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/distribution"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/staking/migrations/v4"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
type mockSubspace struct {
ps types.Params
}
func newMockSubspace(ps types.Params) mockSubspace {
return mockSubspace{ps: ps}
}
func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet) {
*ps.(*types.Params) = ms.ps
}
func TestMigrate(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(distribution.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v4.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
legacySubspace := newMockSubspace(types.DefaultParams())
require.NoError(t, v4.MigrateStore(ctx, storeKey, cdc, legacySubspace))
var res types.Params
bz := store.Get(v4.ParamsKey)
require.NoError(t, cdc.Unmarshal(bz, &res))
require.Equal(t, legacySubspace.ps, res)
}

View File

@ -0,0 +1,25 @@
package v4
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/x/staking/exported"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
// MigrateStore performs in-place store migrations from v3 to v4.
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, legacySubspace exported.Subspace) error {
store := ctx.KVStore(storeKey)
var legacyParams types.Params
legacySubspace.GetParamSet(ctx, &legacyParams)
if err := legacyParams.Validate(); err != nil {
return err
}
bz := cdc.MustMarshal(&legacyParams)
store.Set(types.ParamsKey, bz)
return nil
}

View File

@ -4,6 +4,9 @@ import (
"context"
"encoding/json"
"fmt"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/staking/exported"
"math/rand"
"sort"
@ -23,7 +26,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/staking/client/cli"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/simulation"
@ -31,7 +33,7 @@ import (
)
const (
consensusVersion uint64 = 3
consensusVersion uint64 = 4
)
var (
@ -102,15 +104,25 @@ type AppModule struct {
keeper *keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
// legacySubspace is used solely for migration of x/params managed parameters
legacySubspace exported.Subspace
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule {
func NewAppModule(
cdc codec.Codec,
keeper *keeper.Keeper,
ak types.AccountKeeper,
bk types.BankKeeper,
ls exported.Subspace,
) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
keeper: keeper,
accountKeeper: ak,
bankKeeper: bk,
legacySubspace: ls,
}
}
@ -145,9 +157,18 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
querier := keeper.Querier{Keeper: am.keeper}
types.RegisterQueryServer(cfg.QueryServer(), querier)
m := keeper.NewMigrator(am.keeper)
cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
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))
}
if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", types.ModuleName, err))
}
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 3 to 4: %v", types.ModuleName, err))
}
}
// InitGenesis performs genesis initialization for the staking module. It returns
@ -199,8 +220,11 @@ type stakingInputs struct {
AccountKeeper types.AccountKeeper
BankKeeper types.BankKeeper
Cdc codec.Codec
Subspace paramstypes.Subspace
Key *store.KVStoreKey
ModuleKey depinject.OwnModuleKey
Authority map[string]sdk.AccAddress `optional:"true"`
// LegacySubspace is used solely for migration of x/params managed parameters
LegacySubspace exported.Subspace
}
// Dependency Injection Outputs
@ -212,8 +236,20 @@ type stakingOutputs struct {
}
func provideModule(in stakingInputs) stakingOutputs {
k := keeper.NewKeeper(in.Cdc, in.Key, in.AccountKeeper, in.BankKeeper, in.Subspace)
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper)
authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()]
if !ok {
// default to governance authority if not provided
authority = authtypes.NewModuleAddress(govtypes.ModuleName)
}
k := keeper.NewKeeper(
in.Cdc,
in.Key,
in.AccountKeeper,
in.BankKeeper,
authority.String(),
)
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace)
return stakingOutputs{StakingKeeper: k, Module: runtime.WrapAppModule(m)}
}
@ -270,7 +306,7 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
// RandomizedParams creates randomized staking param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return simulation.ParamChanges(r)
return []simtypes.ParamChange{}
}
// RegisterStoreDecoder registers a decoder for staking module's types

View File

@ -17,8 +17,10 @@ Store entries prefixed with "Last" must remain unchanged until EndBlock.
## Params
Params is a module-wide configuration structure that stores system parameters
and defines overall functioning of the staking module.
staking module stores it's params in state with the prefix of `0x51`,
it can only be updated with governance.
* Params: `0x51 | ProtocolBuffer(Params)`
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/proto/cosmos/staking/v1beta1/staking.proto#L285-L306

View File

@ -173,3 +173,15 @@ When this message is processed the following actions occur:
* under this situation if the delegation is the validator's self-delegation then also jail the validator.
![Begin redelegation sequence](../../../docs/uml/svg/begin_redelegation_sequence.svg)
## MsgUpdateParams
The `MsgUpdateParams` update the staking module parameters.
The params are updated through a governance proposal where the signer is the gov module account address.
+++ https://github.com/cosmos/cosmos-sdk/blob/e412ce990251768579d49947991be76a87564f7d/proto/cosmos/staking/v1beta1/tx.proto#L172-L190
The message handling can fail if:
* signer is not the authority defined in the staking keeper (usually the gov module account).

View File

@ -20,11 +20,13 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgUndelegate{}, "cosmos-sdk/MsgUndelegate")
legacy.RegisterAminoMsg(cdc, &MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate")
legacy.RegisterAminoMsg(cdc, &MsgCancelUnbondingDelegation{}, "cosmos-sdk/MsgCancelUnbondingDelegation")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/staking/MsgUpdateParams")
cdc.RegisterInterface((*isStakeAuthorization_Validators)(nil), nil)
cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList", nil)
cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList", nil)
cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization", nil)
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params", nil)
}
// RegisterInterfaces registers the x/staking interfaces types with the interface registry
@ -36,6 +38,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&MsgUndelegate{},
&MsgBeginRedelegate{},
&MsgCancelUnbondingDelegation{},
&MsgUpdateParams{},
)
registry.RegisterImplementations(
(*authz.Authorization)(nil),

View File

@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the staking module's genesis state.
type GenesisState struct {
// params defines all the paramaters of related to deposit.
// params defines all the parameters of related to deposit.
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// last_total_power tracks the total amounts of bonded tokens recorded during
// the previous end block.

View File

@ -50,6 +50,8 @@ var (
ValidatorQueueKey = []byte{0x43} // prefix for the timestamps in validator queue
HistoricalInfoKey = []byte{0x50} // prefix for the historical info
ParamsKey = []byte{0x51} // prefix for parameters for module x/staking
)
// GetValidatorKey creates the key for the validator with address

View File

@ -16,6 +16,7 @@ const (
TypeMsgCreateValidator = "create_validator"
TypeMsgDelegate = "delegate"
TypeMsgBeginRedelegate = "begin_redelegate"
TypeMsgUpdateParams = "update_params"
)
var (
@ -27,6 +28,7 @@ var (
_ sdk.Msg = &MsgUndelegate{}
_ sdk.Msg = &MsgBeginRedelegate{}
_ sdk.Msg = &MsgCancelUnbondingDelegation{}
_ sdk.Msg = &MsgUpdateParams{}
)
// NewMsgCreateValidator creates a new MsgCreateValidator instance.
@ -393,3 +395,24 @@ func (msg MsgCancelUnbondingDelegation) ValidateBasic() error {
return nil
}
// GetSignBytes returns the raw bytes for a MsgUpdateParams message that
// the expected signer needs to sign.
func (m MsgUpdateParams) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
// ValidateBasic executes sanity validation on the provided data
func (m *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return sdkerrors.Wrap(err, "invalid authority address")
}
return m.Params.Validate()
}
// GetSigners returns the expected signers for a MsgUpdateParams message
func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Authority)
return []sdk.AccAddress{addr}
}

View File

@ -1,7 +1,10 @@
package types_test
import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"testing"
"time"
"github.com/stretchr/testify/require"
@ -197,3 +200,153 @@ func TestMsgUndelegate(t *testing.T) {
}
}
}
func TestMsgUpdateParams(t *testing.T) {
msg := types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.DefaultParams(),
}
require.Equal(t, []sdk.AccAddress{authtypes.NewModuleAddress(govtypes.ModuleName)}, msg.GetSigners())
}
func TestMsgUpdateParamsValidateBasic(t *testing.T) {
tests := []struct {
name string
msgUpdateParams types.MsgUpdateParams
expFail bool
expError string
}{
{
"valid msg",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.DefaultParams(),
},
false,
"",
},
{
"negative unbounding time",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3 * -1,
MaxEntries: types.DefaultMaxEntries,
MaxValidators: types.DefaultMaxValidators,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: types.DefaultMinCommissionRate,
BondDenom: "denom",
},
},
true,
"unbonding time must be positive:",
},
{
"cero value max validator",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3,
MaxEntries: types.DefaultMaxEntries,
MaxValidators: 0,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: types.DefaultMinCommissionRate,
BondDenom: "denom",
},
},
true,
"max validators must be positive:",
},
{
"cero value max validator",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3,
MaxEntries: 0,
MaxValidators: types.DefaultMaxValidators,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: types.DefaultMinCommissionRate,
BondDenom: "denom",
},
},
true,
"max entries must be positive:",
},
{
"negative commission rate",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3,
MaxEntries: types.DefaultMaxEntries,
MaxValidators: types.DefaultMaxValidators,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: sdk.NewDec(-1),
BondDenom: "denom",
},
},
true,
"minimum commission rate cannot be negative:",
},
{
"negative commission rate",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3,
MaxEntries: types.DefaultMaxEntries,
MaxValidators: types.DefaultMaxValidators,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: sdk.NewDec(2),
BondDenom: "denom",
},
},
true,
"minimum commission rate cannot be greater than 100",
},
{
"blank bonddenom",
types.MsgUpdateParams{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3,
MaxEntries: types.DefaultMaxEntries,
MaxValidators: types.DefaultMaxValidators,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: types.DefaultMinCommissionRate,
BondDenom: "",
},
},
true,
"bond denom cannot be blank",
},
{
"Invalid authority",
types.MsgUpdateParams{
Authority: "invalid",
Params: types.Params{
UnbondingTime: time.Hour * 24 * 7 * 3,
MaxEntries: types.DefaultMaxEntries,
MaxValidators: types.DefaultMaxValidators,
HistoricalEntries: types.DefaultHistoricalEntries,
MinCommissionRate: types.DefaultMinCommissionRate,
BondDenom: "denom",
},
},
true,
"invalid authority address",
},
}
for _, tc := range tests {
err := tc.msgUpdateParams.ValidateBasic()
if tc.expFail {
require.Error(t, err)
require.Contains(t, err.Error(), tc.expError)
} else {
require.NoError(t, err)
}
}
}

View File

@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Staking params default values
@ -36,22 +35,6 @@ const (
// DefaultMinCommissionRate is set to 0%
var DefaultMinCommissionRate = sdk.ZeroDec()
var (
KeyUnbondingTime = []byte("UnbondingTime")
KeyMaxValidators = []byte("MaxValidators")
KeyMaxEntries = []byte("MaxEntries")
KeyBondDenom = []byte("BondDenom")
KeyHistoricalEntries = []byte("HistoricalEntries")
KeyMinCommissionRate = []byte("MinCommissionRate")
)
var _ paramtypes.ParamSet = (*Params)(nil)
// ParamTable for staking module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// NewParams creates a new Params instance
func NewParams(unbondingTime time.Duration, maxValidators, maxEntries, historicalEntries uint32, bondDenom string, minCommissionRate sdk.Dec) Params {
return Params{
@ -64,18 +47,6 @@ func NewParams(unbondingTime time.Duration, maxValidators, maxEntries, historica
}
}
// Implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime),
paramtypes.NewParamSetPair(KeyMaxValidators, &p.MaxValidators, validateMaxValidators),
paramtypes.NewParamSetPair(KeyMaxEntries, &p.MaxEntries, validateMaxEntries),
paramtypes.NewParamSetPair(KeyHistoricalEntries, &p.HistoricalEntries, validateHistoricalEntries),
paramtypes.NewParamSetPair(KeyBondDenom, &p.BondDenom, validateBondDenom),
paramtypes.NewParamSetPair(KeyMinCommissionRate, &p.MinCommissionRate, validateMinCommissionRate),
}
}
// DefaultParams returns a default set of parameters.
func DefaultParams() Params {
return NewParams(

View File

@ -0,0 +1,33 @@
package types
import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
var (
KeyUnbondingTime = []byte("UnbondingTime")
KeyMaxValidators = []byte("MaxValidators")
KeyMaxEntries = []byte("MaxEntries")
KeyBondDenom = []byte("BondDenom")
KeyHistoricalEntries = []byte("HistoricalEntries")
KeyMinCommissionRate = []byte("MinCommissionRate")
)
var _ paramtypes.ParamSet = (*Params)(nil)
// ParamTable for staking module
// NOTE: Deprecated now params can be accesed on key `0x51` on the staking store.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// Implements params.ParamSet
// NOTE: Deprecated.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime),
paramtypes.NewParamSetPair(KeyMaxValidators, &p.MaxValidators, validateMaxValidators),
paramtypes.NewParamSetPair(KeyMaxEntries, &p.MaxEntries, validateMaxEntries),
paramtypes.NewParamSetPair(KeyHistoricalEntries, &p.HistoricalEntries, validateHistoricalEntries),
paramtypes.NewParamSetPair(KeyBondDenom, &p.BondDenom, validateBondDenom),
paramtypes.NewParamSetPair(KeyMinCommissionRate, &p.MinCommissionRate, validateMinCommissionRate),
}
}

View File

@ -834,7 +834,7 @@ func (m *Redelegation) XXX_DiscardUnknown() {
var xxx_messageInfo_Redelegation proto.InternalMessageInfo
// Params defines the parameters for the staking module.
// Params defines the parameters for the x/staking module.
type Params struct {
// unbonding_time is the time duration of unbonding.
UnbondingTime time.Duration `protobuf:"bytes,1,opt,name=unbonding_time,json=unbondingTime,proto3,stdduration" json:"unbonding_time"`

View File

@ -535,6 +535,105 @@ func (m *MsgCancelUnbondingDelegationResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgCancelUnbondingDelegationResponse 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"`
// params defines the x/staking parameters to update.
//
// NOTE: All parameters must be supplied.
Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
}
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_0926ef28816b35ab, []int{12}
}
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) GetParams() Params {
if m != nil {
return m.Params
}
return Params{}
}
// 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_0926ef28816b35ab, []int{13}
}
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((*MsgCreateValidator)(nil), "cosmos.staking.v1beta1.MsgCreateValidator")
proto.RegisterType((*MsgCreateValidatorResponse)(nil), "cosmos.staking.v1beta1.MsgCreateValidatorResponse")
@ -548,71 +647,78 @@ func init() {
proto.RegisterType((*MsgUndelegateResponse)(nil), "cosmos.staking.v1beta1.MsgUndelegateResponse")
proto.RegisterType((*MsgCancelUnbondingDelegation)(nil), "cosmos.staking.v1beta1.MsgCancelUnbondingDelegation")
proto.RegisterType((*MsgCancelUnbondingDelegationResponse)(nil), "cosmos.staking.v1beta1.MsgCancelUnbondingDelegationResponse")
proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.staking.v1beta1.MsgUpdateParams")
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.staking.v1beta1.MsgUpdateParamsResponse")
}
func init() { proto.RegisterFile("cosmos/staking/v1beta1/tx.proto", fileDescriptor_0926ef28816b35ab) }
var fileDescriptor_0926ef28816b35ab = []byte{
// 937 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x57, 0x4d, 0x6f, 0x1b, 0x45,
0x18, 0xf6, 0xc6, 0x4e, 0x28, 0x13, 0xb5, 0x69, 0x37, 0x09, 0x38, 0xab, 0xca, 0xae, 0xdc, 0xd2,
0x46, 0x85, 0xac, 0x69, 0x28, 0x02, 0x55, 0xbd, 0xd4, 0x75, 0x2b, 0xaa, 0x62, 0x09, 0x6d, 0x28,
0x07, 0x84, 0x64, 0xcd, 0xee, 0x4e, 0x26, 0x23, 0xef, 0xce, 0xb8, 0x3b, 0xe3, 0xa8, 0xbe, 0x72,
0xe2, 0x46, 0x25, 0xfe, 0x40, 0x7f, 0x00, 0x42, 0x1c, 0xfa, 0x23, 0x2a, 0x4e, 0x51, 0x4f, 0x88,
0x43, 0x81, 0xe4, 0x00, 0x3f, 0x00, 0x71, 0x46, 0x3b, 0x3b, 0x3b, 0xfe, 0x58, 0x7b, 0xb3, 0x41,
0xe9, 0x01, 0x71, 0xf2, 0x6a, 0xe6, 0x79, 0x9f, 0x99, 0x79, 0xde, 0x67, 0xde, 0x77, 0x0c, 0xea,
0x1e, 0xe3, 0x21, 0xe3, 0x4d, 0x2e, 0x60, 0x8f, 0x50, 0xdc, 0xdc, 0xbf, 0xe1, 0x22, 0x01, 0x6f,
0x34, 0xc5, 0x13, 0xbb, 0x1f, 0x31, 0xc1, 0xcc, 0xb7, 0x12, 0x80, 0xad, 0x00, 0xb6, 0x02, 0x58,
0x1b, 0x98, 0x31, 0x1c, 0xa0, 0xa6, 0x44, 0xb9, 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xfc, 0x76, 0x58, 0x33, 0x9e, 0x1e,
0xd5, 0x4a, 0x07, 0x47, 0xb5, 0xd2, 0xcf, 0x47, 0xb5, 0xd2, 0x97, 0xef, 0xe5, 0xbe, 0x6a, 0x9e,
0xe8, 0xff, 0x36, 0xf2, 0x7d, 0xe3, 0x2e, 0xc9, 0xea, 0xf3, 0xc1, 0x3f, 0x01, 0x00, 0x00, 0xff,
0xff, 0x48, 0x6a, 0x50, 0xaf, 0xc0, 0x0d, 0x00, 0x00,
// 1012 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x57, 0x4f, 0x6f, 0x1b, 0x45,
0x14, 0xf7, 0x26, 0xae, 0x69, 0x5f, 0x68, 0xdc, 0x6e, 0x12, 0x6a, 0xaf, 0x2a, 0xbb, 0x72, 0x4b,
0x13, 0x15, 0xb2, 0xa6, 0xa1, 0xfc, 0x51, 0x94, 0x4b, 0x5d, 0xb7, 0xa2, 0x2a, 0x96, 0x2a, 0x87,
0x72, 0x40, 0x48, 0xd6, 0xec, 0xee, 0x64, 0xbd, 0xf2, 0xee, 0xcc, 0x76, 0x67, 0x1c, 0xd5, 0x57,
0x4e, 0xdc, 0xa8, 0x84, 0x04, 0xd7, 0x7e, 0x02, 0xc4, 0xa1, 0x1f, 0xa2, 0xe2, 0x14, 0xf5, 0x84,
0x38, 0x14, 0x48, 0x0e, 0xf0, 0x01, 0x10, 0x67, 0xb4, 0xbb, 0xb3, 0xe3, 0xff, 0x9b, 0x0d, 0x4a,
0x0f, 0x88, 0x93, 0x57, 0x33, 0xbf, 0xf7, 0x7b, 0xef, 0xfd, 0xde, 0x9b, 0x37, 0x63, 0xa8, 0x9a,
0x94, 0x79, 0x94, 0xd5, 0x19, 0x47, 0x3d, 0x87, 0xd8, 0xf5, 0xfd, 0x9b, 0x06, 0xe6, 0xe8, 0x66,
0x9d, 0x3f, 0xd1, 0xfd, 0x80, 0x72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 0x32, 0x86, 0xd4, 0xde, 0xcb, 0x8a, 0x94, 0xce, 0xbe, 0x84, 0xb3,
0xf2, 0x82, 0xbc, 0x9a, 0x62, 0x9d, 0x80, 0xb4, 0x77, 0x32, 0x80, 0x24, 0xfb, 0x63, 0x28, 0x4e,
0x5e, 0x38, 0x69, 0xea, 0x4d, 0x60, 0x53, 0xd5, 0x9b, 0x37, 0x76, 0x0d, 0x80, 0x91, 0x19, 0xf9,
0x76, 0x0a, 0xc3, 0x10, 0xa6, 0x6d, 0x66, 0x82, 0x49, 0x1f, 0xdf, 0x28, 0x50, 0x9e, 0x3f, 0x27,
0x6e, 0xa5, 0xd5, 0x7c, 0x9e, 0x95, 0xb6, 0xf3, 0x6f, 0xac, 0x64, 0x44, 0x5d, 0x78, 0x73, 0xec,
0x7c, 0xad, 0xa7, 0x25, 0x34, 0x02, 0xd4, 0xea, 0x19, 0x81, 0x89, 0xa7, 0xc6, 0xbd, 0x17, 0x87,
0x15, 0xe5, 0xe0, 0xb0, 0xa2, 0xfc, 0x76, 0x58, 0x51, 0x9e, 0x1e, 0x55, 0x72, 0x07, 0x47, 0x95,
0xdc, 0xcf, 0x47, 0x95, 0xdc, 0x17, 0xef, 0xa6, 0x3e, 0xfa, 0x9e, 0xc8, 0xbf, 0x7e, 0xd1, 0xf3,
0xcf, 0x28, 0x44, 0xc3, 0xf9, 0xfd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x69, 0xfd, 0x9c, 0x84,
0xdf, 0x0e, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -645,6 +751,10 @@ type MsgClient interface {
//
// Since: cosmos-sdk 0.46
CancelUnbondingDelegation(ctx context.Context, in *MsgCancelUnbondingDelegation, opts ...grpc.CallOption) (*MsgCancelUnbondingDelegationResponse, error)
// UpdateParams defines a operation for updating the x/staking module
// parameters.
// Since: cosmos-sdk 0.47
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
type msgClient struct {
@ -709,6 +819,15 @@ func (c *msgClient) CancelUnbondingDelegation(ctx context.Context, in *MsgCancel
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.staking.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 {
// CreateValidator defines a method for creating a new validator.
@ -729,6 +848,10 @@ type MsgServer interface {
//
// Since: cosmos-sdk 0.46
CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error)
// UpdateParams defines a operation for updating the x/staking module
// parameters.
// Since: cosmos-sdk 0.47
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
@ -753,6 +876,9 @@ func (*UnimplementedMsgServer) Undelegate(ctx context.Context, req *MsgUndelegat
func (*UnimplementedMsgServer) CancelUnbondingDelegation(ctx context.Context, req *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CancelUnbondingDelegation 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)
@ -866,6 +992,24 @@ func _Msg_CancelUnbondingDelegation_Handler(srv interface{}, ctx context.Context
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.staking.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.staking.v1beta1.Msg",
HandlerType: (*MsgServer)(nil),
@ -894,6 +1038,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
MethodName: "CancelUnbondingDelegation",
Handler: _Msg_CancelUnbondingDelegation_Handler,
},
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/staking/v1beta1/tx.proto",
@ -1406,6 +1554,69 @@ func (m *MsgCancelUnbondingDelegationResponse) MarshalToSizedBuffer(dAtA []byte)
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.Params.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
@ -1610,6 +1821,30 @@ func (m *MsgCancelUnbondingDelegationResponse) 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.Params.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
}
@ -3091,6 +3326,171 @@ func (m *MsgCancelUnbondingDelegationResponse) 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 Params", 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.Params.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