feat: deprecate x/params usage in x/slashing (#12399)
This commit is contained in:
@@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### State Machine Breaking
|
||||
|
||||
* (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`.
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
@@ -2259,7 +2259,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 the module.
|
||||
Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"`
|
||||
// signing_infos represents a map between validator addresses and their
|
||||
// signing infos.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,11 @@ type MsgClient interface {
|
||||
// them into the bonded validator set, so they can begin receiving provisions
|
||||
// and rewards again.
|
||||
Unjail(ctx context.Context, in *MsgUnjail, opts ...grpc.CallOption) (*MsgUnjailResponse, error)
|
||||
// UpdateParams defines a governance operation for updating the x/slashing module
|
||||
// parameters. The authority is hard-coded to the x/gov module account.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@@ -45,6 +50,15 @@ func (c *msgClient) Unjail(ctx context.Context, in *MsgUnjail, opts ...grpc.Call
|
||||
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.slashing.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
|
||||
@@ -53,6 +67,11 @@ type MsgServer interface {
|
||||
// them into the bonded validator set, so they can begin receiving provisions
|
||||
// and rewards again.
|
||||
Unjail(context.Context, *MsgUnjail) (*MsgUnjailResponse, error)
|
||||
// UpdateParams defines a governance operation for updating the x/slashing module
|
||||
// parameters. The authority is hard-coded to the x/gov module account.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||
mustEmbedUnimplementedMsgServer()
|
||||
}
|
||||
|
||||
@@ -63,6 +82,9 @@ type UnimplementedMsgServer struct {
|
||||
func (UnimplementedMsgServer) Unjail(context.Context, *MsgUnjail) (*MsgUnjailResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Unjail 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.
|
||||
@@ -94,6 +116,24 @@ func _Msg_Unjail_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
||||
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.slashing.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)
|
||||
@@ -105,6 +145,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "Unjail",
|
||||
Handler: _Msg_Unjail_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/slashing/v1beta1/tx.proto",
|
||||
|
||||
@@ -9,7 +9,7 @@ import "cosmos_proto/cosmos.proto";
|
||||
|
||||
// GenesisState defines the slashing module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the paramaters of related to deposit.
|
||||
// params defines all the parameters of the module.
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// signing_infos represents a map between validator addresses and their
|
||||
|
||||
@@ -5,6 +5,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/slashing/v1beta1/slashing.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
|
||||
@@ -14,6 +15,12 @@ service Msg {
|
||||
// them into the bonded validator set, so they can begin receiving provisions
|
||||
// and rewards again.
|
||||
rpc Unjail(MsgUnjail) returns (MsgUnjailResponse);
|
||||
|
||||
// UpdateParams defines a governance operation for updating the x/slashing module
|
||||
// parameters. The authority is hard-coded to the x/gov module account.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
||||
}
|
||||
|
||||
// MsgUnjail defines the Msg/Unjail request type
|
||||
@@ -28,3 +35,24 @@ message MsgUnjail {
|
||||
|
||||
// MsgUnjailResponse defines the Msg/Unjail response type
|
||||
message MsgUnjailResponse {}
|
||||
|
||||
// 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/slashing 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 {}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
)
|
||||
+19
-13
@@ -14,27 +14,33 @@ import (
|
||||
|
||||
// Keeper of the slashing store
|
||||
type Keeper struct {
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
sk types.StakingKeeper
|
||||
paramspace types.ParamSubspace
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
legacyAmino *codec.LegacyAmino
|
||||
sk types.StakingKeeper
|
||||
|
||||
// the address capable of executing a MsgUpdateParams message. Typically, this
|
||||
// should be the x/gov module account.
|
||||
authority string
|
||||
}
|
||||
|
||||
// NewKeeper creates a slashing keeper
|
||||
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, sk types.StakingKeeper, paramspace types.ParamSubspace) Keeper {
|
||||
// set KeyTable if it has not already been set
|
||||
if !paramspace.HasKeyTable() {
|
||||
paramspace = paramspace.WithKeyTable(types.ParamKeyTable())
|
||||
}
|
||||
func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key storetypes.StoreKey, sk types.StakingKeeper, authority string) Keeper {
|
||||
|
||||
return Keeper{
|
||||
storeKey: key,
|
||||
cdc: cdc,
|
||||
sk: sk,
|
||||
paramspace: paramspace,
|
||||
storeKey: key,
|
||||
cdc: cdc,
|
||||
legacyAmino: legacyAmino,
|
||||
sk: sk,
|
||||
authority: authority,
|
||||
}
|
||||
}
|
||||
|
||||
// GetAuthority returns the x/slashing module's authority.
|
||||
func (k Keeper) GetAuthority() string {
|
||||
return k.authority
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", "x/"+types.ModuleName)
|
||||
|
||||
@@ -37,6 +37,7 @@ type KeeperTestSuite struct {
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
addrDels []sdk.AccAddress
|
||||
queryClient slashingtypes.QueryClient
|
||||
msgServer types.MsgServer
|
||||
}
|
||||
|
||||
func (s *KeeperTestSuite) SetupTest() {
|
||||
@@ -49,6 +50,7 @@ func (s *KeeperTestSuite) SetupTest() {
|
||||
&s.interfaceRegistry,
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
s.accountKeeper.SetParams(ctx, authtypes.DefaultParams())
|
||||
@@ -72,6 +74,7 @@ func (s *KeeperTestSuite) SetupTest() {
|
||||
|
||||
s.addrDels = addrDels
|
||||
s.ctx = ctx
|
||||
s.msgServer = slashingkeeper.NewMsgServerImpl(s.slashingKeeper)
|
||||
}
|
||||
|
||||
func (s *KeeperTestSuite) TestUnJailNotBonded() {
|
||||
|
||||
@@ -2,20 +2,31 @@ package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/exported"
|
||||
v043 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v043"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v2"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
return Migrator{keeper: keeper}
|
||||
func NewMigrator(keeper Keeper, ss exported.Subspace) Migrator {
|
||||
return Migrator{keeper: keeper, legacySubspace: ss}
|
||||
}
|
||||
|
||||
// Migrate1to2 migrates from version 1 to 2.
|
||||
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
||||
return v043.MigrateStore(ctx, m.keeper.storeKey)
|
||||
}
|
||||
|
||||
// Migrate2to3 migrates the x/slashing module state from the consensus
|
||||
// version 2 to version 3. Specifically, it takes the parameters that are currently stored
|
||||
// and managed by the x/params modules and stores them directly into the x/slashing
|
||||
// module state.
|
||||
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
|
||||
return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
|
||||
type msgServer struct {
|
||||
Keeper
|
||||
}
|
||||
@@ -17,7 +21,17 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{Keeper: keeper}
|
||||
}
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
func (k msgServer) 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.SetParams(ctx, req.Params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgUpdateParamsResponse{}, nil
|
||||
}
|
||||
|
||||
// Unjail implements MsgServer.Unjail method.
|
||||
// Validators must submit a transaction to unjail itself after
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
func (s *KeeperTestSuite) TestUpdateParams() {
|
||||
minSignedPerWindow, err := sdk.NewDecFromStr("0.60")
|
||||
s.Require().NoError(err)
|
||||
|
||||
slashFractionDoubleSign, err := sdk.NewDecFromStr("0.022")
|
||||
s.Require().NoError(err)
|
||||
|
||||
slashFractionDowntime, err := sdk.NewDecFromStr("0.0089")
|
||||
s.Require().NoError(err)
|
||||
|
||||
invalidVal, err := sdk.NewDecFromStr("-1")
|
||||
s.Require().NoError(err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
request *types.MsgUpdateParams
|
||||
expectErr bool
|
||||
expErrMsg string
|
||||
}{
|
||||
{
|
||||
name: "set invalid authority",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: "foo",
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "invalid authority",
|
||||
},
|
||||
{
|
||||
name: "set invalid signed blocks window",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.slashingKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
SignedBlocksWindow: 0,
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(34800000000000),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "signed blocks window must be positive",
|
||||
},
|
||||
{
|
||||
name: "set invalid min signed per window",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.slashingKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: invalidVal,
|
||||
DowntimeJailDuration: time.Duration(34800000000000),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "min signed per window cannot be negative",
|
||||
},
|
||||
{
|
||||
name: "set invalid downtime jail duration",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.slashingKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(0),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "downtime jail duration must be positive",
|
||||
},
|
||||
{
|
||||
name: "set invalid slash fraction double sign",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.slashingKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(10),
|
||||
SlashFractionDoubleSign: invalidVal,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "double sign slash fraction cannot be negative",
|
||||
},
|
||||
{
|
||||
name: "set invalid slash fraction downtime",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.slashingKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(10),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: invalidVal,
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "downtime slash fraction cannot be negative",
|
||||
},
|
||||
{
|
||||
name: "set full valid params",
|
||||
request: &types.MsgUpdateParams{
|
||||
Authority: s.slashingKeeper.GetAuthority(),
|
||||
Params: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(34800000000000),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
s.Run(tc.name, func() {
|
||||
_, err := s.msgServer.UpdateParams(s.ctx, tc.request)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.expErrMsg)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+24
-16
@@ -9,46 +9,54 @@ import (
|
||||
|
||||
// SignedBlocksWindow - sliding window for downtime slashing
|
||||
func (k Keeper) SignedBlocksWindow(ctx sdk.Context) (res int64) {
|
||||
k.paramspace.Get(ctx, types.KeySignedBlocksWindow, &res)
|
||||
return
|
||||
return k.GetParams(ctx).SignedBlocksWindow
|
||||
}
|
||||
|
||||
// MinSignedPerWindow - minimum blocks signed per window
|
||||
func (k Keeper) MinSignedPerWindow(ctx sdk.Context) int64 {
|
||||
var minSignedPerWindow sdk.Dec
|
||||
k.paramspace.Get(ctx, types.KeyMinSignedPerWindow, &minSignedPerWindow)
|
||||
params := k.GetParams(ctx)
|
||||
signedBlocksWindow := k.SignedBlocksWindow(ctx)
|
||||
|
||||
// NOTE: RoundInt64 will never panic as minSignedPerWindow is
|
||||
// less than 1.
|
||||
return minSignedPerWindow.MulInt64(signedBlocksWindow).RoundInt64()
|
||||
return params.MinSignedPerWindow.MulInt64(signedBlocksWindow).RoundInt64()
|
||||
}
|
||||
|
||||
// DowntimeJailDuration - Downtime unbond duration
|
||||
func (k Keeper) DowntimeJailDuration(ctx sdk.Context) (res time.Duration) {
|
||||
k.paramspace.Get(ctx, types.KeyDowntimeJailDuration, &res)
|
||||
return
|
||||
return k.GetParams(ctx).DowntimeJailDuration
|
||||
}
|
||||
|
||||
// SlashFractionDoubleSign - fraction of power slashed in case of double sign
|
||||
func (k Keeper) SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec) {
|
||||
k.paramspace.Get(ctx, types.KeySlashFractionDoubleSign, &res)
|
||||
return
|
||||
return k.GetParams(ctx).SlashFractionDoubleSign
|
||||
}
|
||||
|
||||
// SlashFractionDowntime - fraction of power slashed for downtime
|
||||
func (k Keeper) SlashFractionDowntime(ctx sdk.Context) (res sdk.Dec) {
|
||||
k.paramspace.Get(ctx, types.KeySlashFractionDowntime, &res)
|
||||
return
|
||||
return k.GetParams(ctx).SlashFractionDowntime
|
||||
}
|
||||
|
||||
// GetParams returns the total set of slashing parameters.
|
||||
// GetParams returns the current x/slashing module parameters.
|
||||
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
||||
k.paramspace.GetParamSet(ctx, ¶ms)
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.ParamsKey)
|
||||
if bz == nil {
|
||||
return params
|
||||
}
|
||||
k.cdc.MustUnmarshal(bz, ¶ms)
|
||||
return params
|
||||
}
|
||||
|
||||
// SetParams sets the slashing parameters to the param space.
|
||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||
k.paramspace.SetParamSet(ctx, ¶ms)
|
||||
// SetParams sets the x/slashing 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 := k.cdc.MustMarshal(¶ms)
|
||||
store.Set(types.ParamsKey, bz)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
func (s *KeeperTestSuite) TestParams() {
|
||||
minSignedPerWindow, err := sdk.NewDecFromStr("0.60")
|
||||
s.Require().NoError(err)
|
||||
|
||||
slashFractionDoubleSign, err := sdk.NewDecFromStr("0.022")
|
||||
s.Require().NoError(err)
|
||||
|
||||
slashFractionDowntime, err := sdk.NewDecFromStr("0.0089")
|
||||
s.Require().NoError(err)
|
||||
|
||||
invalidVal, err := sdk.NewDecFromStr("-1")
|
||||
s.Require().NoError(err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
input types.Params
|
||||
expectErr bool
|
||||
expErrMsg string
|
||||
}{
|
||||
{
|
||||
name: "set invalid signed blocks window",
|
||||
input: types.Params{
|
||||
SignedBlocksWindow: 0,
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(34800000000000),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "signed blocks window must be positive",
|
||||
},
|
||||
{
|
||||
name: "set invalid min signed per window",
|
||||
input: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: invalidVal,
|
||||
DowntimeJailDuration: time.Duration(34800000000000),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "min signed per window cannot be negative",
|
||||
},
|
||||
{
|
||||
name: "set invalid downtime jail duration",
|
||||
input: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(0),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "downtime jail duration must be positive",
|
||||
},
|
||||
{
|
||||
name: "set invalid slash fraction double sign",
|
||||
input: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(10),
|
||||
SlashFractionDoubleSign: invalidVal,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "double sign slash fraction cannot be negative",
|
||||
},
|
||||
{
|
||||
name: "set invalid slash fraction downtime",
|
||||
input: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(10),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: invalidVal,
|
||||
},
|
||||
expectErr: true,
|
||||
expErrMsg: "downtime slash fraction cannot be negative",
|
||||
},
|
||||
{
|
||||
name: "set all valid params",
|
||||
input: types.Params{
|
||||
SignedBlocksWindow: int64(750),
|
||||
MinSignedPerWindow: minSignedPerWindow,
|
||||
DowntimeJailDuration: time.Duration(34800000000000),
|
||||
SlashFractionDoubleSign: slashFractionDoubleSign,
|
||||
SlashFractionDowntime: slashFractionDowntime,
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
s.Run(tc.name, func() {
|
||||
expected := s.slashingKeeper.GetParams(s.ctx)
|
||||
err := s.slashingKeeper.SetParams(s.ctx, tc.input)
|
||||
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.expErrMsg)
|
||||
} else {
|
||||
expected = tc.input
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
params := s.slashingKeeper.GetParams(s.ctx)
|
||||
s.Require().Equal(expected, params)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package v2
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
const (
|
||||
ModuleName = "slashing"
|
||||
)
|
||||
|
||||
var (
|
||||
ParamsKey = []byte{0x00}
|
||||
)
|
||||
|
||||
// Migrate migrates the x/slashing module state from the consensus version 2 to
|
||||
// version 3. Specifically, it takes the parameters that are currently stored
|
||||
// and managed by the x/params modules and stores them directly into the x/slashing
|
||||
// module state.
|
||||
func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
|
||||
var currParams types.Params
|
||||
legacySubspace.GetParamSet(ctx, &currParams)
|
||||
|
||||
if err := currParams.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bz := cdc.MustMarshal(&currParams)
|
||||
store.Set(ParamsKey, bz)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package v2_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/slashing"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/exported"
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v2"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/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 exported.ParamSet) {
|
||||
*ps.(*types.Params) = ms.ps
|
||||
}
|
||||
|
||||
func TestMigrate(t *testing.T) {
|
||||
encCfg := moduletestutil.MakeTestEncodingConfig(slashing.AppModuleBasic{})
|
||||
cdc := encCfg.Codec
|
||||
|
||||
storeKey := sdk.NewKVStoreKey(v2.ModuleName)
|
||||
tKey := sdk.NewTransientStoreKey("transient_test")
|
||||
ctx := testutil.DefaultContext(storeKey, tKey)
|
||||
store := ctx.KVStore(storeKey)
|
||||
|
||||
legacySubspace := newMockSubspace(types.DefaultParams())
|
||||
require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc))
|
||||
|
||||
var res types.Params
|
||||
bz := store.Get(v2.ParamsKey)
|
||||
require.NoError(t, cdc.Unmarshal(bz, &res))
|
||||
require.Equal(t, legacySubspace.ps, res)
|
||||
}
|
||||
+31
-12
@@ -20,16 +20,22 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
store "github.com/cosmos/cosmos-sdk/store/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
||||
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"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||
)
|
||||
|
||||
// ConsensusVersion defines the current x/slashing module consensus version.
|
||||
const ConsensusVersion = 3
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
@@ -99,16 +105,20 @@ type AppModule struct {
|
||||
accountKeeper types.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
stakingKeeper types.StakingKeeper
|
||||
|
||||
// legacySubspace is used solely for migration of x/slashing 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, sk types.StakingKeeper) AppModule {
|
||||
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, ss exported.Subspace) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
||||
keeper: keeper,
|
||||
accountKeeper: ak,
|
||||
bankKeeper: bk,
|
||||
stakingKeeper: sk,
|
||||
legacySubspace: ss,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +150,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
|
||||
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
||||
|
||||
m := keeper.NewMigrator(am.keeper)
|
||||
cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the slashing module. It returns
|
||||
@@ -161,7 +177,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
|
||||
}
|
||||
|
||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
||||
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||
|
||||
// BeginBlock returns the begin blocker for the slashing module.
|
||||
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
||||
@@ -195,10 +211,13 @@ type slashingInputs struct {
|
||||
|
||||
Key *store.KVStoreKey
|
||||
Cdc codec.Codec
|
||||
AccountKeeper types.AccountKeeper
|
||||
BankKeeper types.BankKeeper
|
||||
StakingKeeper types.StakingKeeper
|
||||
Subspace paramstypes.Subspace
|
||||
LegacyAmino *codec.LegacyAmino
|
||||
AccountKeeper types.AccountKeeper `key:"cosmos.auth.v1.AccountKeeper"`
|
||||
BankKeeper types.BankKeeper `key:"cosmos.bank.v1.Keeper"`
|
||||
StakingKeeper types.StakingKeeper `key:"cosmos.staking.v1.Keeper"`
|
||||
|
||||
// LegacySubspace is used solely for migration of x/params managed parameters
|
||||
LegacySubspace exported.Subspace
|
||||
}
|
||||
|
||||
type slashingOutputs struct {
|
||||
@@ -210,8 +229,8 @@ type slashingOutputs struct {
|
||||
}
|
||||
|
||||
func provideModule(in slashingInputs) slashingOutputs {
|
||||
k := keeper.NewKeeper(in.Cdc, in.Key, in.StakingKeeper, in.Subspace)
|
||||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper)
|
||||
k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.Key, in.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
||||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.LegacySubspace)
|
||||
return slashingOutputs{
|
||||
Keeper: k,
|
||||
Module: runtime.WrapAppModule(m),
|
||||
@@ -235,7 +254,7 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
|
||||
|
||||
// RandomizedParams creates randomized slashing 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 slashing module's types
|
||||
|
||||
@@ -12,12 +12,15 @@ import (
|
||||
|
||||
// RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params", nil)
|
||||
legacy.RegisterAminoMsg(cdc, &MsgUnjail{}, "cosmos-sdk/MsgUnjail")
|
||||
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/MsgUpdateParams")
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgUnjail{},
|
||||
&MsgUpdateParams{},
|
||||
)
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
|
||||
@@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the slashing module's genesis state.
|
||||
type GenesisState struct {
|
||||
// params defines all the paramaters of related to deposit.
|
||||
// params defines all the parameters of the module.
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
// signing_infos represents a map between validator addresses and their
|
||||
// signing infos.
|
||||
|
||||
@@ -30,7 +30,9 @@ const (
|
||||
// - 0x02<consAddrLen (1 Byte)><consAddress_Bytes><period_Bytes>: bool
|
||||
//
|
||||
// - 0x03<accAddrLen (1 Byte)><accAddr_Bytes>: cryptotypes.PubKey
|
||||
|
||||
var (
|
||||
ParamsKey = []byte{0x00} // Prefix for params key
|
||||
ValidatorSigningInfoKeyPrefix = []byte{0x01} // Prefix for signing info
|
||||
ValidatorMissedBlockBitArrayKeyPrefix = []byte{0x02} // Prefix for missed block bit array
|
||||
AddrPubkeyRelationKeyPrefix = []byte{0x03} // Prefix for address-pubkey relation
|
||||
|
||||
+28
-1
@@ -11,7 +11,10 @@ const (
|
||||
)
|
||||
|
||||
// verify interface at compile time
|
||||
var _ sdk.Msg = &MsgUnjail{}
|
||||
var (
|
||||
_ sdk.Msg = &MsgUnjail{}
|
||||
_ sdk.Msg = &MsgUpdateParams{}
|
||||
)
|
||||
|
||||
// NewMsgUnjail creates a new MsgUnjail instance
|
||||
//nolint:interfacer
|
||||
@@ -41,3 +44,27 @@ func (msg MsgUnjail) ValidateBasic() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (msg MsgUpdateParams) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners returns the expected signers for a MsgUpdateParams message.
|
||||
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
// ValidateBasic does a sanity check on the provided data.
|
||||
func (msg *MsgUpdateParams) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid authority address")
|
||||
}
|
||||
|
||||
if err := msg.Params.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+25
-28
@@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Default parameter namespace
|
||||
@@ -20,20 +19,6 @@ var (
|
||||
DefaultSlashFractionDowntime = sdk.NewDec(1).Quo(sdk.NewDec(100))
|
||||
)
|
||||
|
||||
// Parameter store keys
|
||||
var (
|
||||
KeySignedBlocksWindow = []byte("SignedBlocksWindow")
|
||||
KeyMinSignedPerWindow = []byte("MinSignedPerWindow")
|
||||
KeyDowntimeJailDuration = []byte("DowntimeJailDuration")
|
||||
KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign")
|
||||
KeySlashFractionDowntime = []byte("SlashFractionDowntime")
|
||||
)
|
||||
|
||||
// ParamKeyTable for slashing module
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// NewParams creates a new Params object
|
||||
func NewParams(
|
||||
signedBlocksWindow int64, minSignedPerWindow sdk.Dec, downtimeJailDuration time.Duration,
|
||||
@@ -48,25 +33,37 @@ func NewParams(
|
||||
}
|
||||
}
|
||||
|
||||
// ParamSetPairs - Implements params.ParamSet
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeySignedBlocksWindow, &p.SignedBlocksWindow, validateSignedBlocksWindow),
|
||||
paramtypes.NewParamSetPair(KeyMinSignedPerWindow, &p.MinSignedPerWindow, validateMinSignedPerWindow),
|
||||
paramtypes.NewParamSetPair(KeyDowntimeJailDuration, &p.DowntimeJailDuration, validateDowntimeJailDuration),
|
||||
paramtypes.NewParamSetPair(KeySlashFractionDoubleSign, &p.SlashFractionDoubleSign, validateSlashFractionDoubleSign),
|
||||
paramtypes.NewParamSetPair(KeySlashFractionDowntime, &p.SlashFractionDowntime, validateSlashFractionDowntime),
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultParams defines the parameters for this module
|
||||
func DefaultParams() Params {
|
||||
return NewParams(
|
||||
DefaultSignedBlocksWindow, DefaultMinSignedPerWindow, DefaultDowntimeJailDuration,
|
||||
DefaultSlashFractionDoubleSign, DefaultSlashFractionDowntime,
|
||||
DefaultSignedBlocksWindow,
|
||||
DefaultMinSignedPerWindow,
|
||||
DefaultDowntimeJailDuration,
|
||||
DefaultSlashFractionDoubleSign,
|
||||
DefaultSlashFractionDowntime,
|
||||
)
|
||||
}
|
||||
|
||||
// validate params
|
||||
func (p Params) Validate() error {
|
||||
if err := validateSignedBlocksWindow(p.SignedBlocksWindow); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateMinSignedPerWindow(p.MinSignedPerWindow); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateDowntimeJailDuration(p.DowntimeJailDuration); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateSlashFractionDoubleSign(p.SlashFractionDoubleSign); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateSlashFractionDowntime(p.SlashFractionDowntime); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateSignedBlocksWindow(i interface{}) error {
|
||||
v, ok := i.(int64)
|
||||
if !ok {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov
|
||||
controlled execution of MsgUpdateParams messages. These types remains solely
|
||||
for migration purposes and will be removed in a future release.
|
||||
*/
|
||||
package types
|
||||
|
||||
import (
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Parameter store keys
|
||||
var (
|
||||
KeySignedBlocksWindow = []byte("SignedBlocksWindow")
|
||||
KeyMinSignedPerWindow = []byte("MinSignedPerWindow")
|
||||
KeyDowntimeJailDuration = []byte("DowntimeJailDuration")
|
||||
KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign")
|
||||
KeySlashFractionDowntime = []byte("SlashFractionDowntime")
|
||||
)
|
||||
|
||||
// ParamKeyTable for slashing module
|
||||
//
|
||||
// NOTE: Deprecated.
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// ParamSetPairs - Implements params.ParamSet
|
||||
//
|
||||
// NOTE: Deprecated.
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{
|
||||
paramtypes.NewParamSetPair(KeySignedBlocksWindow, &p.SignedBlocksWindow, validateSignedBlocksWindow),
|
||||
paramtypes.NewParamSetPair(KeyMinSignedPerWindow, &p.MinSignedPerWindow, validateMinSignedPerWindow),
|
||||
paramtypes.NewParamSetPair(KeyDowntimeJailDuration, &p.DowntimeJailDuration, validateDowntimeJailDuration),
|
||||
paramtypes.NewParamSetPair(KeySlashFractionDoubleSign, &p.SlashFractionDoubleSign, validateSlashFractionDoubleSign),
|
||||
paramtypes.NewParamSetPair(KeySlashFractionDowntime, &p.SlashFractionDowntime, validateSlashFractionDowntime),
|
||||
}
|
||||
}
|
||||
+468
-16
@@ -105,34 +105,142 @@ func (m *MsgUnjailResponse) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgUnjailResponse 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/slashing 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_3c5611c0c4a59d9d, []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) 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_3c5611c0c4a59d9d, []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((*MsgUnjail)(nil), "cosmos.slashing.v1beta1.MsgUnjail")
|
||||
proto.RegisterType((*MsgUnjailResponse)(nil), "cosmos.slashing.v1beta1.MsgUnjailResponse")
|
||||
proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.slashing.v1beta1.MsgUpdateParams")
|
||||
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.slashing.v1beta1.MsgUpdateParamsResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/slashing/v1beta1/tx.proto", fileDescriptor_3c5611c0c4a59d9d) }
|
||||
|
||||
var fileDescriptor_3c5611c0c4a59d9d = []byte{
|
||||
// 296 bytes of a gzipped FileDescriptorProto
|
||||
// 407 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0xd6, 0x2f, 0xce, 0x49, 0x2c, 0xce, 0xc8, 0xcc, 0x4b, 0xd7, 0x2f, 0x33, 0x4c, 0x4a,
|
||||
0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8,
|
||||
0xd0, 0x83, 0xa9, 0xd0, 0x83, 0xaa, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd1, 0x07,
|
||||
0xb1, 0x20, 0xca, 0xa5, 0x24, 0x21, 0xca, 0xe3, 0x21, 0x12, 0x50, 0xbd, 0x10, 0x29, 0xa8, 0x49,
|
||||
0xfa, 0xb9, 0xc5, 0x20, 0x6b, 0x40, 0x14, 0x44, 0x42, 0xa9, 0x84, 0x8b, 0xd3, 0xb7, 0x38, 0x3d,
|
||||
0x34, 0x2f, 0x2b, 0x31, 0x33, 0x47, 0xc8, 0x8b, 0x8b, 0xaf, 0x2c, 0x31, 0x27, 0x33, 0x25, 0xb1,
|
||||
0x24, 0xbf, 0x28, 0x3e, 0x31, 0x25, 0xa5, 0x48, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, 0x49, 0xf9,
|
||||
0xd5, 0x3d, 0x79, 0x76, 0x10, 0x3f, 0xb5, 0xb8, 0xf8, 0xd2, 0x16, 0x5d, 0x11, 0xa8, 0xd1, 0x8e,
|
||||
0x10, 0x91, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x5e, 0xb8, 0x56, 0x90, 0xb8, 0x95, 0x74,
|
||||
0xc7, 0x02, 0x79, 0x86, 0x19, 0x0b, 0xe4, 0x19, 0x9b, 0x9e, 0x6f, 0xd0, 0x42, 0x33, 0x56, 0x49,
|
||||
0x98, 0x4b, 0x10, 0x6e, 0x6b, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x51, 0x3c, 0x17,
|
||||
0xb3, 0x6f, 0x71, 0xba, 0x50, 0x04, 0x17, 0x1b, 0xd4, 0x39, 0x4a, 0x7a, 0x38, 0xfc, 0xaf, 0x07,
|
||||
0xd7, 0x2c, 0xa5, 0x45, 0x58, 0x0d, 0xcc, 0x02, 0x27, 0xef, 0x15, 0x8f, 0xe4, 0x18, 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, 0x37, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49,
|
||||
0x2f, 0x39, 0x3f, 0x17, 0x1a, 0x76, 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x11, 0x4d,
|
||||
0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0xf0, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff,
|
||||
0xc5, 0xe4, 0xf3, 0x05, 0xc6, 0x01, 0x00, 0x00,
|
||||
0xb1, 0x20, 0xca, 0xa5, 0xd4, 0x70, 0x19, 0x08, 0xd7, 0x0f, 0x51, 0x27, 0x09, 0x51, 0x17, 0x0f,
|
||||
0x31, 0x00, 0x6a, 0x07, 0x44, 0x0a, 0x6a, 0xa3, 0x7e, 0x6e, 0x31, 0x48, 0x37, 0x88, 0x82, 0x48,
|
||||
0x28, 0x95, 0x70, 0x71, 0xfa, 0x16, 0xa7, 0x87, 0xe6, 0x65, 0x25, 0x66, 0xe6, 0x08, 0x79, 0x71,
|
||||
0xf1, 0x95, 0x25, 0xe6, 0x64, 0xa6, 0x24, 0x96, 0xe4, 0x17, 0xc5, 0x27, 0xa6, 0xa4, 0x14, 0x49,
|
||||
0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0x29, 0xbf, 0xba, 0x27, 0xcf, 0x0e, 0xe2, 0xa7, 0x16, 0x17,
|
||||
0x5f, 0xda, 0xa2, 0x2b, 0x02, 0x35, 0xda, 0x11, 0x22, 0x12, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x1e,
|
||||
0xc4, 0x0b, 0xd7, 0x0a, 0x12, 0xb7, 0x92, 0xee, 0x58, 0x20, 0xcf, 0x30, 0x63, 0x81, 0x3c, 0x63,
|
||||
0xd3, 0xf3, 0x0d, 0x5a, 0x68, 0xc6, 0x2a, 0x09, 0x73, 0x09, 0xc2, 0x6d, 0x0d, 0x4a, 0x2d, 0x2e,
|
||||
0xc8, 0xcf, 0x2b, 0x4e, 0x55, 0x9a, 0xc1, 0xc8, 0xc5, 0x0f, 0x12, 0x2d, 0x48, 0x49, 0x2c, 0x49,
|
||||
0x0d, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0x16, 0x32, 0xe3, 0xe2, 0x4c, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f,
|
||||
0xca, 0x2c, 0xa9, 0x84, 0x3a, 0x46, 0x02, 0xa7, 0x0b, 0x10, 0x4a, 0x85, 0x6c, 0xb9, 0xd8, 0x0a,
|
||||
0xc0, 0x26, 0x48, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0xc9, 0xeb, 0xe1, 0x08, 0x72, 0x3d, 0x88,
|
||||
0x45, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x35, 0x59, 0xf1, 0x81, 0x1c, 0x8d, 0x30,
|
||||
0x4e, 0x49, 0x92, 0x4b, 0x1c, 0xcd, 0x65, 0x30, 0x57, 0x1b, 0x9d, 0x66, 0xe4, 0x62, 0xf6, 0x2d,
|
||||
0x4e, 0x17, 0x8a, 0xe0, 0x62, 0x83, 0x86, 0xa2, 0x12, 0x4e, 0xbb, 0xe0, 0x7e, 0x96, 0xd2, 0x22,
|
||||
0xac, 0x06, 0x66, 0x83, 0x50, 0x16, 0x17, 0x0f, 0x4a, 0x98, 0x68, 0xe0, 0xd5, 0x8b, 0xa4, 0x52,
|
||||
0xca, 0x80, 0x58, 0x95, 0x30, 0xbb, 0x9c, 0xbc, 0x57, 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e,
|
||||
0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58,
|
||||
0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4,
|
||||
0xfc, 0x5c, 0x68, 0xf2, 0x82, 0x52, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x88, 0x04, 0x5a, 0x52,
|
||||
0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x62, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x61,
|
||||
0xd5, 0x7a, 0xbc, 0x11, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *MsgUnjail) Equal(that interface{}) bool {
|
||||
@@ -180,6 +288,54 @@ func (this *MsgUnjailResponse) Equal(that interface{}) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *MsgUpdateParams) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*MsgUpdateParams)
|
||||
if !ok {
|
||||
that2, ok := that.(MsgUpdateParams)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.Authority != that1.Authority {
|
||||
return false
|
||||
}
|
||||
if !this.Params.Equal(&that1.Params) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *MsgUpdateParamsResponse) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*MsgUpdateParamsResponse)
|
||||
if !ok {
|
||||
that2, ok := that.(MsgUpdateParamsResponse)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
@@ -197,6 +353,11 @@ type MsgClient interface {
|
||||
// them into the bonded validator set, so they can begin receiving provisions
|
||||
// and rewards again.
|
||||
Unjail(ctx context.Context, in *MsgUnjail, opts ...grpc.CallOption) (*MsgUnjailResponse, error)
|
||||
// UpdateParams defines a governance operation for updating the x/slashing module
|
||||
// parameters. The authority is hard-coded to the x/gov module account.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@@ -216,12 +377,26 @@ func (c *msgClient) Unjail(ctx context.Context, in *MsgUnjail, opts ...grpc.Call
|
||||
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.slashing.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 {
|
||||
// Unjail defines a method for unjailing a jailed validator, thus returning
|
||||
// them into the bonded validator set, so they can begin receiving provisions
|
||||
// and rewards again.
|
||||
Unjail(context.Context, *MsgUnjail) (*MsgUnjailResponse, error)
|
||||
// UpdateParams defines a governance operation for updating the x/slashing module
|
||||
// parameters. The authority is hard-coded to the x/gov module account.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
@@ -231,6 +406,9 @@ type UnimplementedMsgServer struct {
|
||||
func (*UnimplementedMsgServer) Unjail(ctx context.Context, req *MsgUnjail) (*MsgUnjailResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Unjail 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)
|
||||
@@ -254,6 +432,24 @@ func _Msg_Unjail_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
||||
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.slashing.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.slashing.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
@@ -262,6 +458,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "Unjail",
|
||||
Handler: _Msg_Unjail_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateParams",
|
||||
Handler: _Msg_UpdateParams_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/slashing/v1beta1/tx.proto",
|
||||
@@ -320,6 +520,69 @@ func (m *MsgUnjailResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
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
|
||||
@@ -353,6 +616,30 @@ func (m *MsgUnjailResponse) 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
|
||||
}
|
||||
@@ -491,6 +778,171 @@ func (m *MsgUnjailResponse) 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
|
||||
|
||||
Reference in New Issue
Block a user