From 549de1fce92a9554085116210d51d6b57532fe9f Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 15 Oct 2020 13:46:33 +0530 Subject: [PATCH 1/5] Refactor x/staking according to ADR 031 --- proto/cosmos/staking/v1beta1/tx.proto | 52 +- x/staking/handler.go | 353 +------- x/staking/handler_test.go | 45 +- x/staking/keeper/msg_server.go | 363 +++++++++ x/staking/types/tx.pb.go | 1074 +++++++++++++++++++++++-- 5 files changed, 1482 insertions(+), 405 deletions(-) create mode 100644 x/staking/keeper/msg_server.go diff --git a/proto/cosmos/staking/v1beta1/tx.proto b/proto/cosmos/staking/v1beta1/tx.proto index 4eb3c8418a4b..d253207fb51b 100644 --- a/proto/cosmos/staking/v1beta1/tx.proto +++ b/proto/cosmos/staking/v1beta1/tx.proto @@ -7,7 +7,28 @@ import "cosmos/staking/v1beta1/staking.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; -// MsgCreateValidator defines an SDK message for creating a new validator. +// Msg defines the bank Msg service. +service Msg { + // CreateValidator defines a method for creating a new validator. + rpc CreateValidator(MsgCreateValidator) returns (MsgCreateValidatorResponse); + + // EditValidator defines a method for editing an existing validator. + rpc EditValidator(MsgEditValidator) returns (MsgEditValidatorResponse); + + // Delegate defines a method for performing a delegation of coins + // from a delegator to a validator. + rpc Delegate(MsgDelegate) returns (MsgDelegateResponse); + + // BeginRedelegate defines a method for performing a redelegation + // of coins from a delegator and source validator to a destination validator. + rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse); + + // Undelegate defines a method for performing an undelegation from a + // delegate and a validator. + rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse); +} + +// MsgCreateValidator defines a SDK message for creating a new validator. message MsgCreateValidator { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -25,7 +46,10 @@ message MsgCreateValidator { cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false]; } -// MsgEditValidator defines an SDK message for editing an existing validator. +// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. +message MsgCreateValidatorResponse { } + +// MsgEditValidator defines a SDK message for editing an existing validator. message MsgEditValidator { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -48,7 +72,10 @@ message MsgEditValidator { ]; } -// MsgDelegate defines an SDK message for performing a delegation of coins +// MsgEditValidatorResponse defines the Msg/EditValidator response type. +message MsgEditValidatorResponse { } + +// MsgDelegate defines a SDK message for performing a delegation of coins // from a delegator to a validator. message MsgDelegate { option (gogoproto.equal) = false; @@ -59,7 +86,10 @@ message MsgDelegate { cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; } -// MsgBeginRedelegate defines an SDK message for performing a redelegation +// MsgDelegateResponse defines the Msg/Delegate response type. +message MsgDelegateResponse { } + +// MsgBeginRedelegate defines a SDK message for performing a redelegation // of coins from a delegator and source validator to a destination validator. message MsgBeginRedelegate { option (gogoproto.equal) = false; @@ -71,7 +101,12 @@ message MsgBeginRedelegate { cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; } -// MsgUndelegate defines an SDK message for performing an undelegation from a +// MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. +message MsgBeginRedelegateResponse { + bytes completionTime = 1; +} + +// MsgUndelegate defines a SDK message for performing an undelegation from a // delegate and a validator. message MsgUndelegate { option (gogoproto.equal) = false; @@ -80,4 +115,9 @@ message MsgUndelegate { string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; -} \ No newline at end of file +} + +// MsgUndelegateResponse defines the Msg/Undelegate response type. +message MsgUndelegateResponse { + bytes completionTime = 1; +} diff --git a/x/staking/handler.go b/x/staking/handler.go index 4da6b05a6654..e60568aca689 100644 --- a/x/staking/handler.go +++ b/x/staking/handler.go @@ -1,13 +1,6 @@ package staking import ( - "time" - - metrics "github.com/armon/go-metrics" - gogotypes "github.com/gogo/protobuf/types" - tmstrings "github.com/tendermint/tendermint/libs/strings" - - "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -18,353 +11,31 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) + msgServer := keeper.NewMsgServerImpl(k) + switch msg := msg.(type) { case *types.MsgCreateValidator: - return handleMsgCreateValidator(ctx, msg, k) + res, err := msgServer.CreateValidator(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgEditValidator: - return handleMsgEditValidator(ctx, msg, k) + res, err := msgServer.EditValidator(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgDelegate: - return handleMsgDelegate(ctx, msg, k) + res, err := msgServer.Delegate(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgBeginRedelegate: - return handleMsgBeginRedelegate(ctx, msg, k) + res, err := msgServer.BeginRedelegate(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgUndelegate: - return handleMsgUndelegate(ctx, msg, k) + res, err := msgServer.Undelegate(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } - -// These functions assume everything has been authenticated, -// now we just perform action and save - -func handleMsgCreateValidator(ctx sdk.Context, msg *types.MsgCreateValidator, k keeper.Keeper) (*sdk.Result, error) { - - valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) - if err != nil { - return nil, err - } - - // check to see if the pubkey or sender has been registered before - if _, found := k.GetValidator(ctx, valAddr); found { - return nil, types.ErrValidatorOwnerExists - } - - pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, msg.Pubkey) - if err != nil { - return nil, err - } - - if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pk)); found { - return nil, types.ErrValidatorPubKeyExists - } - - bondDenom := k.BondDenom(ctx) - if msg.Value.Denom != bondDenom { - return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Value.Denom, bondDenom) - } - - if _, err := msg.Description.EnsureLength(); err != nil { - return nil, err - } - - cp := ctx.ConsensusParams() - if cp != nil && cp.Validator != nil { - if !tmstrings.StringInSlice(pk.Type(), cp.Validator.PubKeyTypes) { - return nil, sdkerrors.Wrapf( - types.ErrValidatorPubKeyTypeNotSupported, - "got: %s, expected: %s", pk.Type(), cp.Validator.PubKeyTypes, - ) - } - } - - validator := types.NewValidator(valAddr, pk, msg.Description) - commission := types.NewCommissionWithTime( - msg.Commission.Rate, msg.Commission.MaxRate, - msg.Commission.MaxChangeRate, ctx.BlockHeader().Time, - ) - - validator, err = validator.SetInitialCommission(commission) - if err != nil { - return nil, err - } - - delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) - if err != nil { - return nil, err - } - - validator.MinSelfDelegation = msg.MinSelfDelegation - - k.SetValidator(ctx, validator) - k.SetValidatorByConsAddr(ctx, validator) - k.SetNewValidatorByPowerIndex(ctx, validator) - - // call the after-creation hook - k.AfterValidatorCreated(ctx, validator.GetOperator()) - - // move coins from the msg.Address account to a (self-delegation) delegator account - // the validator account and global shares are updated within here - // NOTE source will always be from a wallet which are unbonded - _, err = k.Delegate(ctx, delegatorAddress, msg.Value.Amount, types.Unbonded, validator, true) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeCreateValidator, - sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Value.Amount.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), - ), - }) - - return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil -} - -func handleMsgEditValidator(ctx sdk.Context, msg *types.MsgEditValidator, k keeper.Keeper) (*sdk.Result, error) { - valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) - if err != nil { - return nil, err - } - // validator must already be registered - validator, found := k.GetValidator(ctx, valAddr) - if !found { - return nil, types.ErrNoValidatorFound - } - - // replace all editable fields (clients should autofill existing values) - description, err := validator.Description.UpdateDescription(msg.Description) - if err != nil { - return nil, err - } - - validator.Description = description - - if msg.CommissionRate != nil { - commission, err := k.UpdateValidatorCommission(ctx, validator, *msg.CommissionRate) - if err != nil { - return nil, err - } - - // call the before-modification hook since we're about to update the commission - k.BeforeValidatorModified(ctx, valAddr) - - validator.Commission = commission - } - - if msg.MinSelfDelegation != nil { - if !msg.MinSelfDelegation.GT(validator.MinSelfDelegation) { - return nil, types.ErrMinSelfDelegationDecreased - } - - if msg.MinSelfDelegation.GT(validator.Tokens) { - return nil, types.ErrSelfDelegationBelowMinimum - } - - validator.MinSelfDelegation = (*msg.MinSelfDelegation) - } - - k.SetValidator(ctx, validator) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeEditValidator, - sdk.NewAttribute(types.AttributeKeyCommissionRate, validator.Commission.String()), - sdk.NewAttribute(types.AttributeKeyMinSelfDelegation, validator.MinSelfDelegation.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress), - ), - }) - - return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil -} - -func handleMsgDelegate(ctx sdk.Context, msg *types.MsgDelegate, k keeper.Keeper) (*sdk.Result, error) { - valAddr, valErr := sdk.ValAddressFromBech32(msg.ValidatorAddress) - if valErr != nil { - return nil, valErr - } - - validator, found := k.GetValidator(ctx, valAddr) - if !found { - return nil, types.ErrNoValidatorFound - } - - delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) - if err != nil { - return nil, err - } - - bondDenom := k.BondDenom(ctx) - if msg.Amount.Denom != bondDenom { - return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Amount.Denom, bondDenom) - } - - // NOTE: source funds are always unbonded - _, err = k.Delegate(ctx, delegatorAddress, msg.Amount.Amount, types.Unbonded, validator, true) - if err != nil { - return nil, err - } - - defer func() { - telemetry.IncrCounter(1, types.ModuleName, "delegate") - telemetry.SetGaugeWithLabels( - []string{"tx", "msg", msg.Type()}, - float32(msg.Amount.Amount.Int64()), - []metrics.Label{telemetry.NewLabel("denom", msg.Amount.Denom)}, - ) - }() - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeDelegate, - sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), - ), - }) - - return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil -} - -func handleMsgUndelegate(ctx sdk.Context, msg *types.MsgUndelegate, k keeper.Keeper) (*sdk.Result, error) { - addr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) - if err != nil { - return nil, err - } - delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) - if err != nil { - return nil, err - } - shares, err := k.ValidateUnbondAmount( - ctx, delegatorAddress, addr, msg.Amount.Amount, - ) - if err != nil { - return nil, err - } - - bondDenom := k.BondDenom(ctx) - if msg.Amount.Denom != bondDenom { - return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Amount.Denom, bondDenom) - } - - completionTime, err := k.Undelegate(ctx, delegatorAddress, addr, shares) - if err != nil { - return nil, err - } - - ts, err := gogotypes.TimestampProto(completionTime) - if err != nil { - return nil, types.ErrBadRedelegationAddr - } - - defer func() { - telemetry.IncrCounter(1, types.ModuleName, "undelegate") - telemetry.SetGaugeWithLabels( - []string{"tx", "msg", msg.Type()}, - float32(msg.Amount.Amount.Int64()), - []metrics.Label{telemetry.NewLabel("denom", msg.Amount.Denom)}, - ) - }() - - completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUnbond, - sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), - sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), - ), - }) - - return &sdk.Result{Data: completionTimeBz, Events: ctx.EventManager().ABCIEvents()}, nil -} - -func handleMsgBeginRedelegate(ctx sdk.Context, msg *types.MsgBeginRedelegate, k keeper.Keeper) (*sdk.Result, error) { - valSrcAddr, err := sdk.ValAddressFromBech32(msg.ValidatorSrcAddress) - if err != nil { - return nil, err - } - delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) - if err != nil { - return nil, err - } - shares, err := k.ValidateUnbondAmount( - ctx, delegatorAddress, valSrcAddr, msg.Amount.Amount, - ) - if err != nil { - return nil, err - } - - bondDenom := k.BondDenom(ctx) - if msg.Amount.Denom != bondDenom { - return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Amount.Denom, bondDenom) - } - - valDstAddr, err := sdk.ValAddressFromBech32(msg.ValidatorDstAddress) - if err != nil { - return nil, err - } - - completionTime, err := k.BeginRedelegation( - ctx, delegatorAddress, valSrcAddr, valDstAddr, shares, - ) - if err != nil { - return nil, err - } - - ts, err := gogotypes.TimestampProto(completionTime) - if err != nil { - return nil, types.ErrBadRedelegationAddr - } - - defer func() { - telemetry.IncrCounter(1, types.ModuleName, "redelegate") - telemetry.SetGaugeWithLabels( - []string{"tx", "msg", msg.Type()}, - float32(msg.Amount.Amount.Int64()), - []metrics.Label{telemetry.NewLabel("denom", msg.Amount.Denom)}, - ) - }() - - completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRedelegate, - sdk.NewAttribute(types.AttributeKeySrcValidator, msg.ValidatorSrcAddress), - sdk.NewAttribute(types.AttributeKeyDstValidator, msg.ValidatorDstAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), - sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), - ), - }) - - return &sdk.Result{Data: completionTimeBz, Events: ctx.EventManager().ABCIEvents()}, nil -} diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 8114355d90e2..ab249de45d9f 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/golang/protobuf/proto" ) func bootstrapHandlerGenesisTest(t *testing.T, power int64, numAddrs int, accAmount int64) (*simapp.SimApp, sdk.Context, []sdk.AccAddress, []sdk.ValAddress) { @@ -117,8 +118,11 @@ func TestValidatorByPowerIndex(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -255,8 +259,11 @@ func TestLegacyValidatorDelegations(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -500,8 +507,11 @@ func TestIncrementsMsgUnbond(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -618,8 +628,11 @@ func TestMultipleMsgCreateValidator(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) _, err = gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -676,8 +689,11 @@ func TestMultipleMsgDelegate(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -715,8 +731,11 @@ func TestJailValidator(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -735,8 +754,10 @@ func TestJailValidator(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + err = proto.Unmarshal(res.Data, &resData) + ts = &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err = gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -783,8 +804,11 @@ func TestValidatorQueue(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) @@ -889,8 +913,11 @@ func TestUnbondingFromUnbondingValidator(t *testing.T) { require.NotNil(t, res) // change the ctx to Block Time one second before the validator would have unbonded + var resData types.MsgUndelegateResponse + err = proto.Unmarshal(res.Data, &resData) + ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) finishTime, err := gogotypes.TimestampFromProto(ts) require.NoError(t, err) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go new file mode 100644 index 000000000000..c157eca9bc5b --- /dev/null +++ b/x/staking/keeper/msg_server.go @@ -0,0 +1,363 @@ +package keeper + +import ( + "context" + "time" + + metrics "github.com/armon/go-metrics" + gogotypes "github.com/gogo/protobuf/types" + tmstrings "github.com/tendermint/tendermint/libs/strings" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateValidator) (*types.MsgCreateValidatorResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return nil, err + } + + // check to see if the pubkey or sender has been registered before + if _, found := k.GetValidator(ctx, valAddr); found { + return nil, types.ErrValidatorOwnerExists + } + + pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, msg.Pubkey) + if err != nil { + return nil, err + } + + if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pk)); found { + return nil, types.ErrValidatorPubKeyExists + } + + bondDenom := k.BondDenom(ctx) + if msg.Value.Denom != bondDenom { + return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Value.Denom, bondDenom) + } + + if _, err := msg.Description.EnsureLength(); err != nil { + return nil, err + } + + cp := ctx.ConsensusParams() + if cp != nil && cp.Validator != nil { + if !tmstrings.StringInSlice(pk.Type(), cp.Validator.PubKeyTypes) { + return nil, sdkerrors.Wrapf( + types.ErrValidatorPubKeyTypeNotSupported, + "got: %s, expected: %s", pk.Type(), cp.Validator.PubKeyTypes, + ) + } + } + + validator := types.NewValidator(valAddr, pk, msg.Description) + commission := types.NewCommissionWithTime( + msg.Commission.Rate, msg.Commission.MaxRate, + msg.Commission.MaxChangeRate, ctx.BlockHeader().Time, + ) + + validator, err = validator.SetInitialCommission(commission) + if err != nil { + return nil, err + } + + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + + validator.MinSelfDelegation = msg.MinSelfDelegation + + k.SetValidator(ctx, validator) + k.SetValidatorByConsAddr(ctx, validator) + k.SetNewValidatorByPowerIndex(ctx, validator) + + // call the after-creation hook + k.AfterValidatorCreated(ctx, validator.GetOperator()) + + // move coins from the msg.Address account to a (self-delegation) delegator account + // the validator account and global shares are updated within here + // NOTE source will always be from a wallet which are unbonded + _, err = k.Keeper.Delegate(ctx, delegatorAddress, msg.Value.Amount, types.Unbonded, validator, true) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeCreateValidator, + sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Value.Amount.String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), + ), + }) + + return &types.MsgCreateValidatorResponse{}, nil +} + +func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValidator) (*types.MsgEditValidatorResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return nil, err + } + // validator must already be registered + validator, found := k.GetValidator(ctx, valAddr) + if !found { + return nil, types.ErrNoValidatorFound + } + + // replace all editable fields (clients should autofill existing values) + description, err := validator.Description.UpdateDescription(msg.Description) + if err != nil { + return nil, err + } + + validator.Description = description + + if msg.CommissionRate != nil { + commission, err := k.UpdateValidatorCommission(ctx, validator, *msg.CommissionRate) + if err != nil { + return nil, err + } + + // call the before-modification hook since we're about to update the commission + k.BeforeValidatorModified(ctx, valAddr) + + validator.Commission = commission + } + + if msg.MinSelfDelegation != nil { + if !msg.MinSelfDelegation.GT(validator.MinSelfDelegation) { + return nil, types.ErrMinSelfDelegationDecreased + } + + if msg.MinSelfDelegation.GT(validator.Tokens) { + return nil, types.ErrSelfDelegationBelowMinimum + } + + validator.MinSelfDelegation = (*msg.MinSelfDelegation) + } + + k.SetValidator(ctx, validator) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeEditValidator, + sdk.NewAttribute(types.AttributeKeyCommissionRate, validator.Commission.String()), + sdk.NewAttribute(types.AttributeKeyMinSelfDelegation, validator.MinSelfDelegation.String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress), + ), + }) + + return &types.MsgEditValidatorResponse{}, nil +} + +func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + valAddr, valErr := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if valErr != nil { + return nil, valErr + } + + validator, found := k.GetValidator(ctx, valAddr) + if !found { + return nil, types.ErrNoValidatorFound + } + + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + + bondDenom := k.BondDenom(ctx) + if msg.Amount.Denom != bondDenom { + return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Amount.Denom, bondDenom) + } + + // NOTE: source funds are always unbonded + _, err = k.Keeper.Delegate(ctx, delegatorAddress, msg.Amount.Amount, types.Unbonded, validator, true) + if err != nil { + return nil, err + } + + defer func() { + telemetry.IncrCounter(1, types.ModuleName, "delegate") + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", msg.Type()}, + float32(msg.Amount.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", msg.Amount.Denom)}, + ) + }() + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeDelegate, + sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), + ), + }) + + return &types.MsgDelegateResponse{}, nil +} + +func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRedelegate) (*types.MsgBeginRedelegateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + valSrcAddr, err := sdk.ValAddressFromBech32(msg.ValidatorSrcAddress) + if err != nil { + return nil, err + } + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + shares, err := k.ValidateUnbondAmount( + ctx, delegatorAddress, valSrcAddr, msg.Amount.Amount, + ) + if err != nil { + return nil, err + } + + bondDenom := k.BondDenom(ctx) + if msg.Amount.Denom != bondDenom { + return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Amount.Denom, bondDenom) + } + + valDstAddr, err := sdk.ValAddressFromBech32(msg.ValidatorDstAddress) + if err != nil { + return nil, err + } + + completionTime, err := k.BeginRedelegation( + ctx, delegatorAddress, valSrcAddr, valDstAddr, shares, + ) + if err != nil { + return nil, err + } + + ts, err := gogotypes.TimestampProto(completionTime) + if err != nil { + return nil, types.ErrBadRedelegationAddr + } + + defer func() { + telemetry.IncrCounter(1, types.ModuleName, "redelegate") + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", msg.Type()}, + float32(msg.Amount.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", msg.Amount.Denom)}, + ) + }() + + completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRedelegate, + sdk.NewAttribute(types.AttributeKeySrcValidator, msg.ValidatorSrcAddress), + sdk.NewAttribute(types.AttributeKeyDstValidator, msg.ValidatorDstAddress), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), + sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), + ), + }) + + return &types.MsgBeginRedelegateResponse{ + CompletionTime: completionTimeBz, + }, nil +} + +func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + addr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) + if err != nil { + return nil, err + } + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + shares, err := k.ValidateUnbondAmount( + ctx, delegatorAddress, addr, msg.Amount.Amount, + ) + if err != nil { + return nil, err + } + + bondDenom := k.BondDenom(ctx) + if msg.Amount.Denom != bondDenom { + return nil, sdkerrors.Wrapf(types.ErrBadDenom, "got %s, expected %s", msg.Amount.Denom, bondDenom) + } + + completionTime, err := k.Keeper.Undelegate(ctx, delegatorAddress, addr, shares) + if err != nil { + return nil, err + } + + ts, err := gogotypes.TimestampProto(completionTime) + if err != nil { + return nil, types.ErrBadRedelegationAddr + } + + defer func() { + telemetry.IncrCounter(1, types.ModuleName, "undelegate") + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", msg.Type()}, + float32(msg.Amount.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", msg.Amount.Denom)}, + ) + }() + + completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeUnbond, + sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), + sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress), + ), + }) + + return &types.MsgUndelegateResponse{ + CompletionTime: completionTimeBz, + }, nil +} diff --git a/x/staking/types/tx.pb.go b/x/staking/types/tx.pb.go index 07c643c7dc3c..c51b485d649a 100644 --- a/x/staking/types/tx.pb.go +++ b/x/staking/types/tx.pb.go @@ -4,11 +4,16 @@ package types import ( + context "context" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + grpc1 "github.com/gogo/protobuf/grpc" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" @@ -25,7 +30,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgCreateValidator defines an SDK message for creating a new validator. +// MsgCreateValidator defines a SDK message for creating a new validator. type MsgCreateValidator struct { Description Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description"` Commission CommissionRates `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission"` @@ -69,7 +74,44 @@ func (m *MsgCreateValidator) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateValidator proto.InternalMessageInfo -// MsgEditValidator defines an SDK message for editing an existing validator. +// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. +type MsgCreateValidatorResponse struct { +} + +func (m *MsgCreateValidatorResponse) Reset() { *m = MsgCreateValidatorResponse{} } +func (m *MsgCreateValidatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateValidatorResponse) ProtoMessage() {} +func (*MsgCreateValidatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0926ef28816b35ab, []int{1} +} +func (m *MsgCreateValidatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateValidatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateValidatorResponse.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 *MsgCreateValidatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateValidatorResponse.Merge(m, src) +} +func (m *MsgCreateValidatorResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateValidatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateValidatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateValidatorResponse proto.InternalMessageInfo + +// MsgEditValidator defines a SDK message for editing an existing validator. type MsgEditValidator struct { Description Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description"` ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"address"` @@ -86,7 +128,7 @@ func (m *MsgEditValidator) Reset() { *m = MsgEditValidator{} } func (m *MsgEditValidator) String() string { return proto.CompactTextString(m) } func (*MsgEditValidator) ProtoMessage() {} func (*MsgEditValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_0926ef28816b35ab, []int{1} + return fileDescriptor_0926ef28816b35ab, []int{2} } func (m *MsgEditValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -115,7 +157,44 @@ func (m *MsgEditValidator) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEditValidator proto.InternalMessageInfo -// MsgDelegate defines an SDK message for performing a delegation of coins +// MsgEditValidatorResponse defines the Msg/EditValidator response type. +type MsgEditValidatorResponse struct { +} + +func (m *MsgEditValidatorResponse) Reset() { *m = MsgEditValidatorResponse{} } +func (m *MsgEditValidatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEditValidatorResponse) ProtoMessage() {} +func (*MsgEditValidatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0926ef28816b35ab, []int{3} +} +func (m *MsgEditValidatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditValidatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditValidatorResponse.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 *MsgEditValidatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditValidatorResponse.Merge(m, src) +} +func (m *MsgEditValidatorResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEditValidatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditValidatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditValidatorResponse proto.InternalMessageInfo + +// MsgDelegate defines a SDK message for performing a delegation of coins // from a delegator to a validator. type MsgDelegate struct { DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` @@ -127,7 +206,7 @@ func (m *MsgDelegate) Reset() { *m = MsgDelegate{} } func (m *MsgDelegate) String() string { return proto.CompactTextString(m) } func (*MsgDelegate) ProtoMessage() {} func (*MsgDelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_0926ef28816b35ab, []int{2} + return fileDescriptor_0926ef28816b35ab, []int{4} } func (m *MsgDelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -156,7 +235,44 @@ func (m *MsgDelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDelegate proto.InternalMessageInfo -// MsgBeginRedelegate defines an SDK message for performing a redelegation +// MsgDelegateResponse defines the Msg/Delegate response type. +type MsgDelegateResponse struct { +} + +func (m *MsgDelegateResponse) Reset() { *m = MsgDelegateResponse{} } +func (m *MsgDelegateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDelegateResponse) ProtoMessage() {} +func (*MsgDelegateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0926ef28816b35ab, []int{5} +} +func (m *MsgDelegateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDelegateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDelegateResponse.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 *MsgDelegateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDelegateResponse.Merge(m, src) +} +func (m *MsgDelegateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDelegateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDelegateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDelegateResponse proto.InternalMessageInfo + +// MsgBeginRedelegate defines a SDK message for performing a redelegation // of coins from a delegator and source validator to a destination validator. type MsgBeginRedelegate struct { DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` @@ -169,7 +285,7 @@ func (m *MsgBeginRedelegate) Reset() { *m = MsgBeginRedelegate{} } func (m *MsgBeginRedelegate) String() string { return proto.CompactTextString(m) } func (*MsgBeginRedelegate) ProtoMessage() {} func (*MsgBeginRedelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_0926ef28816b35ab, []int{3} + return fileDescriptor_0926ef28816b35ab, []int{6} } func (m *MsgBeginRedelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,7 +314,52 @@ func (m *MsgBeginRedelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBeginRedelegate proto.InternalMessageInfo -// MsgUndelegate defines an SDK message for performing an undelegation from a +// MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. +type MsgBeginRedelegateResponse struct { + CompletionTime []byte `protobuf:"bytes,1,opt,name=completionTime,proto3" json:"completionTime,omitempty"` +} + +func (m *MsgBeginRedelegateResponse) Reset() { *m = MsgBeginRedelegateResponse{} } +func (m *MsgBeginRedelegateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBeginRedelegateResponse) ProtoMessage() {} +func (*MsgBeginRedelegateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0926ef28816b35ab, []int{7} +} +func (m *MsgBeginRedelegateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBeginRedelegateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBeginRedelegateResponse.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 *MsgBeginRedelegateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBeginRedelegateResponse.Merge(m, src) +} +func (m *MsgBeginRedelegateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBeginRedelegateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBeginRedelegateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBeginRedelegateResponse proto.InternalMessageInfo + +func (m *MsgBeginRedelegateResponse) GetCompletionTime() []byte { + if m != nil { + return m.CompletionTime + } + return nil +} + +// MsgUndelegate defines a SDK message for performing an undelegation from a // delegate and a validator. type MsgUndelegate struct { DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` @@ -210,7 +371,7 @@ func (m *MsgUndelegate) Reset() { *m = MsgUndelegate{} } func (m *MsgUndelegate) String() string { return proto.CompactTextString(m) } func (*MsgUndelegate) ProtoMessage() {} func (*MsgUndelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_0926ef28816b35ab, []int{4} + return fileDescriptor_0926ef28816b35ab, []int{8} } func (m *MsgUndelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -239,57 +400,357 @@ func (m *MsgUndelegate) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo +// MsgUndelegateResponse defines the Msg/Undelegate response type. +type MsgUndelegateResponse struct { + CompletionTime []byte `protobuf:"bytes,1,opt,name=completionTime,proto3" json:"completionTime,omitempty"` +} + +func (m *MsgUndelegateResponse) Reset() { *m = MsgUndelegateResponse{} } +func (m *MsgUndelegateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUndelegateResponse) ProtoMessage() {} +func (*MsgUndelegateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0926ef28816b35ab, []int{9} +} +func (m *MsgUndelegateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUndelegateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUndelegateResponse.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 *MsgUndelegateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUndelegateResponse.Merge(m, src) +} +func (m *MsgUndelegateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUndelegateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUndelegateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUndelegateResponse proto.InternalMessageInfo + +func (m *MsgUndelegateResponse) GetCompletionTime() []byte { + if m != nil { + return m.CompletionTime + } + return nil +} + func init() { proto.RegisterType((*MsgCreateValidator)(nil), "cosmos.staking.v1beta1.MsgCreateValidator") + proto.RegisterType((*MsgCreateValidatorResponse)(nil), "cosmos.staking.v1beta1.MsgCreateValidatorResponse") proto.RegisterType((*MsgEditValidator)(nil), "cosmos.staking.v1beta1.MsgEditValidator") + proto.RegisterType((*MsgEditValidatorResponse)(nil), "cosmos.staking.v1beta1.MsgEditValidatorResponse") proto.RegisterType((*MsgDelegate)(nil), "cosmos.staking.v1beta1.MsgDelegate") + proto.RegisterType((*MsgDelegateResponse)(nil), "cosmos.staking.v1beta1.MsgDelegateResponse") proto.RegisterType((*MsgBeginRedelegate)(nil), "cosmos.staking.v1beta1.MsgBeginRedelegate") + proto.RegisterType((*MsgBeginRedelegateResponse)(nil), "cosmos.staking.v1beta1.MsgBeginRedelegateResponse") proto.RegisterType((*MsgUndelegate)(nil), "cosmos.staking.v1beta1.MsgUndelegate") + proto.RegisterType((*MsgUndelegateResponse)(nil), "cosmos.staking.v1beta1.MsgUndelegateResponse") } func init() { proto.RegisterFile("cosmos/staking/v1beta1/tx.proto", fileDescriptor_0926ef28816b35ab) } var fileDescriptor_0926ef28816b35ab = []byte{ - // 621 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x95, 0xc1, 0x8a, 0xd3, 0x40, - 0x1c, 0xc6, 0x93, 0x6e, 0xb7, 0xea, 0x14, 0xd7, 0x6e, 0x56, 0x4b, 0x2d, 0x4b, 0x52, 0xa2, 0xe8, - 0x1e, 0x34, 0x61, 0x15, 0x11, 0xf6, 0x22, 0x76, 0xab, 0xb8, 0x68, 0x2f, 0x59, 0xf5, 0xe0, 0xa5, - 0x4c, 0x93, 0xd9,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 0xcc, 0xe8, 0xae, 0xb6, 0x0b, 0xd1, 0x4b, 0xf9, 0xf8, 0x4f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x4f, 0x9f, 0xcb, 0x45, 0xc0, 0x07, 0x00, 0x00, + // 773 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x96, 0x4f, 0x6b, 0x13, 0x4f, + 0x18, 0xc7, 0xb3, 0x49, 0x9a, 0x5f, 0x7f, 0x4f, 0xed, 0xbf, 0xad, 0x2d, 0x71, 0x29, 0xd9, 0xb2, + 0xd5, 0x5a, 0xd4, 0x26, 0xb6, 0x22, 0x42, 0x2f, 0xc5, 0x34, 0x8a, 0x45, 0x73, 0xd9, 0x56, 0x0f, + 0x22, 0x84, 0xcd, 0xee, 0x74, 0x5d, 0x92, 0xdd, 0x49, 0x77, 0x26, 0xa5, 0x05, 0x5f, 0x80, 0x47, + 0xc1, 0x9b, 0x20, 0xf4, 0xe5, 0xf4, 0x24, 0x3d, 0x8a, 0x87, 0x45, 0x5a, 0x90, 0x9e, 0xf3, 0x0a, + 0x64, 0xff, 0x4d, 0x36, 0x9b, 0x64, 0x89, 0xc5, 0x5e, 0x3c, 0x25, 0x79, 0xf2, 0x99, 0xef, 0xcc, + 0x7c, 0xe7, 0xbb, 0xcf, 0x2c, 0x88, 0x2a, 0x26, 0x26, 0x26, 0x25, 0x42, 0x95, 0x86, 0x61, 0xe9, + 0xa5, 0xc3, 0xf5, 0x3a, 0xa2, 0xca, 0x7a, 0x89, 0x1e, 0x15, 0x5b, 0x36, 0xa6, 0x98, 0x5f, 0xf0, + 0x81, 0x62, 0x00, 0x14, 0x03, 0x40, 0xb8, 0xa9, 0x63, 0x1d, 0x7b, 0x48, 0xc9, 0xfd, 0xe6, 0xd3, + 0x42, 0x21, 0x90, 0xab, 0x2b, 0x04, 0x31, 0x2d, 0x15, 0x1b, 0x56, 0xf0, 0xff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x10, 0x09, 0xf8, 0x9d, 0x04, 0x85, 0x2e, 0x26, 0xac, 0x8d, 0x84, 0x85, 0x73, 0x94, 0x9f, + 0x9f, 0x9e, 0x17, 0xb8, 0xb3, 0xf3, 0x02, 0xf7, 0xf3, 0xbc, 0xc0, 0x7d, 0xba, 0x28, 0xa4, 0xce, + 0x2e, 0x0a, 0xa9, 0xef, 0x17, 0x85, 0xd4, 0xdb, 0x07, 0x89, 0x17, 0xcf, 0x11, 0x7b, 0x4f, 0xf4, + 0xae, 0xa0, 0x7a, 0xce, 0x7b, 0x3d, 0x7c, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xc7, 0xb5, + 0x4c, 0xb5, 0x0a, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreateValidator defines a method for creating a new validator. + CreateValidator(ctx context.Context, in *MsgCreateValidator, opts ...grpc.CallOption) (*MsgCreateValidatorResponse, error) + // EditValidator defines a method for editing an existing validator. + EditValidator(ctx context.Context, in *MsgEditValidator, opts ...grpc.CallOption) (*MsgEditValidatorResponse, error) + // Delegate defines a method for performing a delegation of coins + // from a delegator to a validator. + Delegate(ctx context.Context, in *MsgDelegate, opts ...grpc.CallOption) (*MsgDelegateResponse, error) + // BeginRedelegate defines a method for performing a redelegation + // of coins from a delegator and source validator to a destination validator. + BeginRedelegate(ctx context.Context, in *MsgBeginRedelegate, opts ...grpc.CallOption) (*MsgBeginRedelegateResponse, error) + // Undelegate defines a method for performing an undelegation from a + // delegate and a validator. + Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateValidator(ctx context.Context, in *MsgCreateValidator, opts ...grpc.CallOption) (*MsgCreateValidatorResponse, error) { + out := new(MsgCreateValidatorResponse) + err := c.cc.Invoke(ctx, "/cosmos.staking.v1beta1.Msg/CreateValidator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) EditValidator(ctx context.Context, in *MsgEditValidator, opts ...grpc.CallOption) (*MsgEditValidatorResponse, error) { + out := new(MsgEditValidatorResponse) + err := c.cc.Invoke(ctx, "/cosmos.staking.v1beta1.Msg/EditValidator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Delegate(ctx context.Context, in *MsgDelegate, opts ...grpc.CallOption) (*MsgDelegateResponse, error) { + out := new(MsgDelegateResponse) + err := c.cc.Invoke(ctx, "/cosmos.staking.v1beta1.Msg/Delegate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) BeginRedelegate(ctx context.Context, in *MsgBeginRedelegate, opts ...grpc.CallOption) (*MsgBeginRedelegateResponse, error) { + out := new(MsgBeginRedelegateResponse) + err := c.cc.Invoke(ctx, "/cosmos.staking.v1beta1.Msg/BeginRedelegate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) { + out := new(MsgUndelegateResponse) + err := c.cc.Invoke(ctx, "/cosmos.staking.v1beta1.Msg/Undelegate", 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. + CreateValidator(context.Context, *MsgCreateValidator) (*MsgCreateValidatorResponse, error) + // EditValidator defines a method for editing an existing validator. + EditValidator(context.Context, *MsgEditValidator) (*MsgEditValidatorResponse, error) + // Delegate defines a method for performing a delegation of coins + // from a delegator to a validator. + Delegate(context.Context, *MsgDelegate) (*MsgDelegateResponse, error) + // BeginRedelegate defines a method for performing a redelegation + // of coins from a delegator and source validator to a destination validator. + BeginRedelegate(context.Context, *MsgBeginRedelegate) (*MsgBeginRedelegateResponse, error) + // Undelegate defines a method for performing an undelegation from a + // delegate and a validator. + Undelegate(context.Context, *MsgUndelegate) (*MsgUndelegateResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateValidator(ctx context.Context, req *MsgCreateValidator) (*MsgCreateValidatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateValidator not implemented") +} +func (*UnimplementedMsgServer) EditValidator(ctx context.Context, req *MsgEditValidator) (*MsgEditValidatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditValidator not implemented") +} +func (*UnimplementedMsgServer) Delegate(ctx context.Context, req *MsgDelegate) (*MsgDelegateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delegate not implemented") +} +func (*UnimplementedMsgServer) BeginRedelegate(ctx context.Context, req *MsgBeginRedelegate) (*MsgBeginRedelegateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BeginRedelegate not implemented") +} +func (*UnimplementedMsgServer) Undelegate(ctx context.Context, req *MsgUndelegate) (*MsgUndelegateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Undelegate not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateValidator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateValidator) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateValidator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.staking.v1beta1.Msg/CreateValidator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateValidator(ctx, req.(*MsgCreateValidator)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_EditValidator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditValidator) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EditValidator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.staking.v1beta1.Msg/EditValidator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditValidator(ctx, req.(*MsgEditValidator)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Delegate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDelegate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Delegate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.staking.v1beta1.Msg/Delegate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Delegate(ctx, req.(*MsgDelegate)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_BeginRedelegate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBeginRedelegate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).BeginRedelegate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.staking.v1beta1.Msg/BeginRedelegate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).BeginRedelegate(ctx, req.(*MsgBeginRedelegate)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Undelegate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUndelegate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Undelegate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.staking.v1beta1.Msg/Undelegate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Undelegate(ctx, req.(*MsgUndelegate)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.staking.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateValidator", + Handler: _Msg_CreateValidator_Handler, + }, + { + MethodName: "EditValidator", + Handler: _Msg_EditValidator_Handler, + }, + { + MethodName: "Delegate", + Handler: _Msg_Delegate_Handler, + }, + { + MethodName: "BeginRedelegate", + Handler: _Msg_BeginRedelegate_Handler, + }, + { + MethodName: "Undelegate", + Handler: _Msg_Undelegate_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/staking/v1beta1/tx.proto", } func (m *MsgCreateValidator) Marshal() (dAtA []byte, err error) { @@ -376,6 +837,29 @@ func (m *MsgCreateValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgCreateValidatorResponse) 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 *MsgCreateValidatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateValidatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgEditValidator) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -440,6 +924,29 @@ func (m *MsgEditValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgEditValidatorResponse) 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 *MsgEditValidatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditValidatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgDelegate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -487,6 +994,29 @@ func (m *MsgDelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgDelegateResponse) 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 *MsgDelegateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgBeginRedelegate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -541,6 +1071,36 @@ func (m *MsgBeginRedelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgBeginRedelegateResponse) 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 *MsgBeginRedelegateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBeginRedelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CompletionTime) > 0 { + i -= len(m.CompletionTime) + copy(dAtA[i:], m.CompletionTime) + i = encodeVarintTx(dAtA, i, uint64(len(m.CompletionTime))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgUndelegate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -588,6 +1148,36 @@ func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUndelegateResponse) 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 *MsgUndelegateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUndelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CompletionTime) > 0 { + i -= len(m.CompletionTime) + copy(dAtA[i:], m.CompletionTime) + i = encodeVarintTx(dAtA, i, uint64(len(m.CompletionTime))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -628,6 +1218,15 @@ func (m *MsgCreateValidator) Size() (n int) { return n } +func (m *MsgCreateValidatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgEditValidator) Size() (n int) { if m == nil { return 0 @@ -651,6 +1250,15 @@ func (m *MsgEditValidator) Size() (n int) { return n } +func (m *MsgEditValidatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgDelegate) Size() (n int) { if m == nil { return 0 @@ -670,6 +1278,15 @@ func (m *MsgDelegate) Size() (n int) { return n } +func (m *MsgDelegateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgBeginRedelegate) Size() (n int) { if m == nil { return 0 @@ -693,6 +1310,19 @@ func (m *MsgBeginRedelegate) Size() (n int) { return n } +func (m *MsgBeginRedelegateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CompletionTime) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgUndelegate) Size() (n int) { if m == nil { return 0 @@ -712,6 +1342,19 @@ func (m *MsgUndelegate) Size() (n int) { return n } +func (m *MsgUndelegateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CompletionTime) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1000,6 +1643,59 @@ func (m *MsgCreateValidator) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateValidatorResponse) 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: MsgCreateValidatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateValidatorResponse: 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 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgEditValidator) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1190,6 +1886,59 @@ func (m *MsgEditValidator) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgEditValidatorResponse) 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: MsgEditValidatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditValidatorResponse: 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 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgDelegate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1340,6 +2089,59 @@ func (m *MsgDelegate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgDelegateResponse) 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: MsgDelegateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDelegateResponse: 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 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgBeginRedelegate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1522,6 +2324,93 @@ func (m *MsgBeginRedelegate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgBeginRedelegateResponse) 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: MsgBeginRedelegateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBeginRedelegateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CompletionTime = append(m.CompletionTime[:0], dAtA[iNdEx:postIndex]...) + if m.CompletionTime == nil { + m.CompletionTime = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1672,6 +2561,93 @@ func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUndelegateResponse) 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: MsgUndelegateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUndelegateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CompletionTime = append(m.CompletionTime[:0], dAtA[iNdEx:postIndex]...) + if m.CompletionTime == nil { + m.CompletionTime = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (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 From 3eb5e84ae7accd778b9268a3e9fca40da55f6aaf Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 15 Oct 2020 14:00:34 +0530 Subject: [PATCH 2/5] lint --- proto/cosmos/staking/v1beta1/tx.proto | 4 +- x/staking/types/tx.pb.go | 104 +++++++++++++------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/proto/cosmos/staking/v1beta1/tx.proto b/proto/cosmos/staking/v1beta1/tx.proto index d253207fb51b..341677a748da 100644 --- a/proto/cosmos/staking/v1beta1/tx.proto +++ b/proto/cosmos/staking/v1beta1/tx.proto @@ -103,7 +103,7 @@ message MsgBeginRedelegate { // MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. message MsgBeginRedelegateResponse { - bytes completionTime = 1; + bytes completion_time = 1; } // MsgUndelegate defines a SDK message for performing an undelegation from a @@ -119,5 +119,5 @@ message MsgUndelegate { // MsgUndelegateResponse defines the Msg/Undelegate response type. message MsgUndelegateResponse { - bytes completionTime = 1; + bytes completion_time = 1; } diff --git a/x/staking/types/tx.pb.go b/x/staking/types/tx.pb.go index c51b485d649a..0f1adcf81367 100644 --- a/x/staking/types/tx.pb.go +++ b/x/staking/types/tx.pb.go @@ -316,7 +316,7 @@ var xxx_messageInfo_MsgBeginRedelegate proto.InternalMessageInfo // MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. type MsgBeginRedelegateResponse struct { - CompletionTime []byte `protobuf:"bytes,1,opt,name=completionTime,proto3" json:"completionTime,omitempty"` + CompletionTime []byte `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3" json:"completion_time,omitempty"` } func (m *MsgBeginRedelegateResponse) Reset() { *m = MsgBeginRedelegateResponse{} } @@ -402,7 +402,7 @@ var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo // MsgUndelegateResponse defines the Msg/Undelegate response type. type MsgUndelegateResponse struct { - CompletionTime []byte `protobuf:"bytes,1,opt,name=completionTime,proto3" json:"completionTime,omitempty"` + CompletionTime []byte `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3" json:"completion_time,omitempty"` } func (m *MsgUndelegateResponse) Reset() { *m = MsgUndelegateResponse{} } @@ -461,56 +461,56 @@ func init() { func init() { proto.RegisterFile("cosmos/staking/v1beta1/tx.proto", fileDescriptor_0926ef28816b35ab) } var fileDescriptor_0926ef28816b35ab = []byte{ - // 773 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x96, 0x4f, 0x6b, 0x13, 0x4f, - 0x18, 0xc7, 0xb3, 0x49, 0x9a, 0x5f, 0x7f, 0x4f, 0xed, 0xbf, 0xad, 0x2d, 0x71, 0x29, 0xd9, 0xb2, - 0xd5, 0x5a, 0xd4, 0x26, 0xb6, 0x22, 0x42, 0x2f, 0xc5, 0x34, 0x8a, 0x45, 0x73, 0xd9, 0x56, 0x0f, - 0x22, 0x84, 0xcd, 0xee, 0x74, 0x5d, 0x92, 0xdd, 0x49, 0x77, 0x26, 0xa5, 0x05, 0x5f, 0x80, 0x47, - 0xc1, 0x9b, 0x20, 0xf4, 0xe5, 0xf4, 0x24, 0x3d, 0x8a, 0x87, 0x45, 0x5a, 0x90, 0x9e, 0xf3, 0x0a, - 0x64, 0xff, 0x4d, 0x36, 0x9b, 0x64, 0x89, 0xc5, 0x5e, 0x3c, 0x25, 0x79, 0xf2, 0x99, 0xef, 0xcc, - 0x7c, 0xe7, 0xbb, 0xcf, 0x2c, 0x88, 0x2a, 0x26, 0x26, 0x26, 0x25, 0x42, 0x95, 0x86, 0x61, 0xe9, - 0xa5, 0xc3, 0xf5, 0x3a, 0xa2, 0xca, 0x7a, 0x89, 0x1e, 0x15, 0x5b, 0x36, 0xa6, 0x98, 0x5f, 0xf0, - 0x81, 0x62, 0x00, 0x14, 0x03, 0x40, 0xb8, 0xa9, 0x63, 0x1d, 0x7b, 0x48, 0xc9, 0xfd, 0xe6, 0xd3, - 0x42, 0x21, 0x90, 0xab, 0x2b, 0x04, 0x31, 0x2d, 0x15, 0x1b, 0x56, 0xf0, 0xff, 0xed, 0x21, 0xd3, - 0x85, 0xea, 0x1e, 0x25, 0x7d, 0xcd, 0x02, 0x5f, 0x25, 0xfa, 0xb6, 0x8d, 0x14, 0x8a, 0xde, 0x28, - 0x4d, 0x43, 0x53, 0x28, 0xb6, 0xf9, 0x97, 0x30, 0xa1, 0x21, 0xa2, 0xda, 0x46, 0x8b, 0x1a, 0xd8, - 0xca, 0x73, 0x4b, 0xdc, 0xea, 0xc4, 0xc6, 0x72, 0x71, 0xf0, 0x02, 0x8b, 0x95, 0x2e, 0x5a, 0xce, - 0x9e, 0x3a, 0x62, 0x4a, 0x8e, 0x8e, 0xe6, 0xab, 0x00, 0x2a, 0x36, 0x4d, 0x83, 0x10, 0x57, 0x2b, - 0xed, 0x69, 0xdd, 0x1d, 0xa6, 0xb5, 0xcd, 0x48, 0x59, 0xa1, 0x88, 0x04, 0x7a, 0x11, 0x01, 0xfe, - 0x03, 0xcc, 0x99, 0x86, 0x55, 0x23, 0xa8, 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 0x67, 0x6b, 0x90, - 0x47, 0x69, 0xcf, 0x23, 0xbe, 0xe3, 0x88, 0x53, 0xbe, 0x47, 0x09, 0xce, 0x98, 0x30, 0xdd, 0xcd, - 0x4e, 0xcd, 0x56, 0x28, 0x0a, 0x92, 0x52, 0x19, 0x31, 0x25, 0x15, 0xa4, 0x76, 0x1c, 0x71, 0xc1, - 0x9f, 0x28, 0x26, 0x25, 0xc9, 0x53, 0x6a, 0x4f, 0x5e, 0xf9, 0xa3, 0xc1, 0xe1, 0xf4, 0x03, 0xf2, - 0xe2, 0x1a, 0x83, 0x19, 0x39, 0x33, 0x01, 0xf2, 0xf1, 0x43, 0x61, 0x27, 0xf6, 0x8b, 0x83, 0x89, - 0x2a, 0xd1, 0x83, 0x71, 0x68, 0x70, 0x9c, 0xb9, 0xbf, 0x17, 0xe7, 0xf4, 0x95, 0xe2, 0xfc, 0x04, - 0x72, 0x8a, 0x89, 0xdb, 0x16, 0xf5, 0xce, 0x6a, 0x84, 0xdc, 0x06, 0x78, 0xc4, 0x84, 0x79, 0x98, - 0x8b, 0xec, 0x93, 0xed, 0xff, 0x5b, 0xda, 0xeb, 0x77, 0x65, 0xa4, 0x1b, 0x96, 0x8c, 0xb4, 0x6b, - 0xb0, 0x61, 0x0f, 0xe6, 0xbb, 0x7b, 0x24, 0xb6, 0x1a, 0xb3, 0x62, 0xa9, 0xe3, 0x88, 0x8b, 0x71, - 0x2b, 0x22, 0x98, 0x24, 0xcf, 0xb1, 0xfa, 0xae, 0xad, 0x0e, 0x54, 0xd5, 0x08, 0x65, 0xaa, 0x99, - 0xe1, 0xaa, 0x11, 0x2c, 0xaa, 0x5a, 0x21, 0xb4, 0xdf, 0xe7, 0xec, 0x55, 0x7d, 0xae, 0x78, 0x0d, - 0x22, 0xe6, 0x67, 0x68, 0x37, 0xbf, 0x02, 0xee, 0x03, 0xd2, 0x6a, 0x22, 0x37, 0xa2, 0x7b, 0x86, - 0x89, 0x3c, 0x53, 0x6f, 0xc8, 0xb1, 0xaa, 0x74, 0xc9, 0xc1, 0x64, 0x95, 0xe8, 0xaf, 0x2d, 0xed, - 0x9f, 0x0f, 0xe6, 0x16, 0xcc, 0xf7, 0xec, 0xf4, 0x4f, 0xbd, 0xda, 0xf8, 0x92, 0x85, 0x4c, 0x95, - 0xe8, 0xfc, 0x01, 0x4c, 0xc7, 0xaf, 0xed, 0x7b, 0xc3, 0xba, 0x6c, 0x7f, 0x0f, 0x17, 0x36, 0x46, - 0x67, 0xd9, 0x12, 0x1b, 0x30, 0xd9, 0xdb, 0xeb, 0x57, 0x13, 0x44, 0x7a, 0x48, 0xe1, 0xe1, 0xa8, - 0x24, 0x9b, 0xec, 0x1d, 0x8c, 0xb3, 0x36, 0xb5, 0x9c, 0x30, 0x3a, 0x84, 0x84, 0xfb, 0x23, 0x40, - 0x4c, 0xfd, 0x00, 0xa6, 0xe3, 0x4d, 0x20, 0xc9, 0xbd, 0x18, 0x9b, 0xe8, 0xde, 0xb0, 0x87, 0xa1, - 0x0e, 0x10, 0x09, 0xf8, 0x9d, 0x04, 0x85, 0x2e, 0x26, 0xac, 0x8d, 0x84, 0x85, 0x73, 0x94, 0x9f, - 0x9f, 0x9e, 0x17, 0xb8, 0xb3, 0xf3, 0x02, 0xf7, 0xf3, 0xbc, 0xc0, 0x7d, 0xba, 0x28, 0xa4, 0xce, - 0x2e, 0x0a, 0xa9, 0xef, 0x17, 0x85, 0xd4, 0xdb, 0x07, 0x89, 0x17, 0xcf, 0x11, 0x7b, 0x4f, 0xf4, - 0xae, 0xa0, 0x7a, 0xce, 0x7b, 0x3d, 0x7c, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xc7, 0xb5, - 0x4c, 0xb5, 0x0a, 0x00, 0x00, + // 780 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x96, 0xcf, 0x6e, 0xd3, 0x4a, + 0x18, 0xc5, 0xe3, 0x24, 0xcd, 0xed, 0x9d, 0xde, 0xfe, 0x73, 0x6f, 0xab, 0x60, 0x55, 0x71, 0xe5, + 0x02, 0xad, 0x80, 0x26, 0xb4, 0x08, 0x21, 0x75, 0x03, 0xa4, 0x29, 0xa2, 0x82, 0x6c, 0xdc, 0xc2, + 0x02, 0x21, 0x45, 0x8e, 0x3d, 0x35, 0xa3, 0xc4, 0x9e, 0xd4, 0x33, 0xa9, 0x5a, 0x89, 0x07, 0x60, + 0x89, 0xc4, 0x0e, 0x09, 0xa9, 0x8f, 0xd3, 0x15, 0xea, 0x12, 0xb1, 0xb0, 0x50, 0x2b, 0xa1, 0xae, + 0xf3, 0x04, 0xc8, 0x63, 0x7b, 0xe2, 0x38, 0x89, 0x15, 0x2a, 0xba, 0x61, 0x95, 0xe4, 0xcb, 0x6f, + 0xce, 0x78, 0xce, 0x9c, 0xf9, 0xc6, 0x40, 0xd6, 0x31, 0xb1, 0x30, 0x29, 0x11, 0xaa, 0x35, 0x90, + 0x6d, 0x96, 0x0e, 0xd7, 0xeb, 0x90, 0x6a, 0xeb, 0x25, 0x7a, 0x54, 0x6c, 0x39, 0x98, 0x62, 0x71, + 0xc1, 0x07, 0x8a, 0x01, 0x50, 0x0c, 0x00, 0xe9, 0x7f, 0x13, 0x9b, 0x98, 0x21, 0x25, 0xef, 0x9b, + 0x4f, 0x4b, 0x85, 0x40, 0xae, 0xae, 0x11, 0xc8, 0xb5, 0x74, 0x8c, 0xec, 0xe0, 0xff, 0x9b, 0x43, + 0xa6, 0x0b, 0xd5, 0x19, 0xa5, 0x7c, 0xc9, 0x02, 0xb1, 0x4a, 0xcc, 0x2d, 0x07, 0x6a, 0x14, 0xbe, + 0xd6, 0x9a, 0xc8, 0xd0, 0x28, 0x76, 0xc4, 0x17, 0x60, 0xc2, 0x80, 0x44, 0x77, 0x50, 0x8b, 0x22, + 0x6c, 0xe7, 0x85, 0x25, 0x61, 0x75, 0x62, 0x63, 0xb9, 0x38, 0xf8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 0x4b, + 0xbc, 0x7a, 0x8e, 0xf8, 0x9b, 0x22, 0xbb, 0x84, 0xea, 0x39, 0xf6, 0x82, 0xf8, 0xe0, 0x57, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xfa, 0x65, 0x4a, 0xde, 0xb7, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From dead6cb8aca9cbfc5cafed7c7511bbb3b6ac94b3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 16 Oct 2020 01:11:46 +0530 Subject: [PATCH 3/5] review changes --- proto/cosmos/staking/v1beta1/tx.proto | 7 +- x/staking/handler.go | 4 +- x/staking/handler_test.go | 71 ++-------- x/staking/keeper/msg_server.go | 17 +-- x/staking/types/tx.pb.go | 182 +++++++++++++------------- 5 files changed, 108 insertions(+), 173 deletions(-) diff --git a/proto/cosmos/staking/v1beta1/tx.proto b/proto/cosmos/staking/v1beta1/tx.proto index 341677a748da..c68e037dca3d 100644 --- a/proto/cosmos/staking/v1beta1/tx.proto +++ b/proto/cosmos/staking/v1beta1/tx.proto @@ -3,11 +3,12 @@ package cosmos.staking.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "google/protobuf/timestamp.proto"; import "cosmos/staking/v1beta1/staking.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; -// Msg defines the bank Msg service. +// Msg defines the staking Msg service. service Msg { // CreateValidator defines a method for creating a new validator. rpc CreateValidator(MsgCreateValidator) returns (MsgCreateValidatorResponse); @@ -103,7 +104,7 @@ message MsgBeginRedelegate { // MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. message MsgBeginRedelegateResponse { - bytes completion_time = 1; + google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } // MsgUndelegate defines a SDK message for performing an undelegation from a @@ -119,5 +120,5 @@ message MsgUndelegate { // MsgUndelegateResponse defines the Msg/Undelegate response type. message MsgUndelegateResponse { - bytes completion_time = 1; + google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } diff --git a/x/staking/handler.go b/x/staking/handler.go index e60568aca689..6d89c7a29c53 100644 --- a/x/staking/handler.go +++ b/x/staking/handler.go @@ -8,11 +8,11 @@ import ( ) func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(k) - switch msg := msg.(type) { case *types.MsgCreateValidator: res, err := msgServer.CreateValidator(sdk.WrapSDKContext(ctx), msg) diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index ab249de45d9f..e805fdaebd14 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -121,13 +120,7 @@ func TestValidatorByPowerIndex(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) staking.EndBlocker(ctx, app.StakingKeeper) @@ -262,13 +255,7 @@ func TestLegacyValidatorDelegations(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) // verify the validator record still exists, is jailed, and has correct tokens @@ -510,13 +497,7 @@ func TestIncrementsMsgUnbond(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) // check that the accounts and the bond account have the appropriate values @@ -631,12 +612,6 @@ func TestMultipleMsgCreateValidator(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - _, err = gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - // adds validator into unbonding queue staking.EndBlocker(ctx, app.StakingKeeper) @@ -692,13 +667,7 @@ func TestMultipleMsgDelegate(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) // check that the account is unbonded @@ -734,13 +703,7 @@ func TestJailValidator(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) validator, found := app.StakingKeeper.GetValidator(ctx, validatorAddr) @@ -756,13 +719,7 @@ func TestJailValidator(t *testing.T) { err = proto.Unmarshal(res.Data, &resData) - ts = &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err = gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) // verify that the pubkey can now be reused @@ -807,13 +764,7 @@ func TestValidatorQueue(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime) + ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) origHeader := ctx.BlockHeader() @@ -916,13 +867,7 @@ func TestUnbondingFromUnbondingValidator(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) - ts := &gogotypes.Timestamp{} - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(resData.CompletionTime, ts) - - finishTime, err := gogotypes.TimestampFromProto(ts) - require.NoError(t, err) - - ctx = ctx.WithBlockTime(finishTime.Add(time.Second * -1)) + ctx = ctx.WithBlockTime(resData.CompletionTime.Add(time.Second * -1)) // unbond the delegator from the validator msgUndelegateDelegator := types.NewMsgUndelegate(delegatorAddr, validatorAddr, unbondAmt) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index c157eca9bc5b..d4084402265e 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -5,7 +5,6 @@ import ( "time" metrics "github.com/armon/go-metrics" - gogotypes "github.com/gogo/protobuf/types" tmstrings "github.com/tendermint/tendermint/libs/strings" "github.com/cosmos/cosmos-sdk/telemetry" @@ -265,11 +264,6 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed return nil, err } - ts, err := gogotypes.TimestampProto(completionTime) - if err != nil { - return nil, types.ErrBadRedelegationAddr - } - defer func() { telemetry.IncrCounter(1, types.ModuleName, "redelegate") telemetry.SetGaugeWithLabels( @@ -279,7 +273,6 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed ) }() - completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRedelegate, @@ -296,7 +289,7 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed }) return &types.MsgBeginRedelegateResponse{ - CompletionTime: completionTimeBz, + CompletionTime: completionTime, }, nil } @@ -328,11 +321,6 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) ( return nil, err } - ts, err := gogotypes.TimestampProto(completionTime) - if err != nil { - return nil, types.ErrBadRedelegationAddr - } - defer func() { telemetry.IncrCounter(1, types.ModuleName, "undelegate") telemetry.SetGaugeWithLabels( @@ -342,7 +330,6 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) ( ) }() - completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeUnbond, @@ -358,6 +345,6 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) ( }) return &types.MsgUndelegateResponse{ - CompletionTime: completionTimeBz, + CompletionTime: completionTime, }, nil } diff --git a/x/staking/types/tx.pb.go b/x/staking/types/tx.pb.go index 0f1adcf81367..d2d26bd25116 100644 --- a/x/staking/types/tx.pb.go +++ b/x/staking/types/tx.pb.go @@ -11,18 +11,22 @@ import ( types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/timestamp" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -316,7 +320,7 @@ var xxx_messageInfo_MsgBeginRedelegate proto.InternalMessageInfo // MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. type MsgBeginRedelegateResponse struct { - CompletionTime []byte `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3" json:"completion_time,omitempty"` + CompletionTime time.Time `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time"` } func (m *MsgBeginRedelegateResponse) Reset() { *m = MsgBeginRedelegateResponse{} } @@ -352,11 +356,11 @@ func (m *MsgBeginRedelegateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBeginRedelegateResponse proto.InternalMessageInfo -func (m *MsgBeginRedelegateResponse) GetCompletionTime() []byte { +func (m *MsgBeginRedelegateResponse) GetCompletionTime() time.Time { if m != nil { return m.CompletionTime } - return nil + return time.Time{} } // MsgUndelegate defines a SDK message for performing an undelegation from a @@ -402,7 +406,7 @@ var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo // MsgUndelegateResponse defines the Msg/Undelegate response type. type MsgUndelegateResponse struct { - CompletionTime []byte `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3" json:"completion_time,omitempty"` + CompletionTime time.Time `protobuf:"bytes,1,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time"` } func (m *MsgUndelegateResponse) Reset() { *m = MsgUndelegateResponse{} } @@ -438,11 +442,11 @@ func (m *MsgUndelegateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUndelegateResponse proto.InternalMessageInfo -func (m *MsgUndelegateResponse) GetCompletionTime() []byte { +func (m *MsgUndelegateResponse) GetCompletionTime() time.Time { if m != nil { return m.CompletionTime } - return nil + return time.Time{} } func init() { @@ -461,56 +465,58 @@ func init() { func init() { proto.RegisterFile("cosmos/staking/v1beta1/tx.proto", fileDescriptor_0926ef28816b35ab) } var fileDescriptor_0926ef28816b35ab = []byte{ - // 780 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x96, 0xcf, 0x6e, 0xd3, 0x4a, - 0x18, 0xc5, 0xe3, 0x24, 0xcd, 0xed, 0x9d, 0xde, 0xfe, 0x73, 0x6f, 0xab, 0x60, 0x55, 0x71, 0xe5, - 0x02, 0xad, 0x80, 0x26, 0xb4, 0x08, 0x21, 0x75, 0x03, 0xa4, 0x29, 0xa2, 0x82, 0x6c, 0xdc, 0xc2, - 0x02, 0x21, 0x45, 0x8e, 0x3d, 0x35, 0xa3, 0xc4, 0x9e, 0xd4, 0x33, 0xa9, 0x5a, 0x89, 0x07, 0x60, - 0x89, 0xc4, 0x0e, 0x09, 0xa9, 0x8f, 0xd3, 0x15, 0xea, 0x12, 0xb1, 0xb0, 0x50, 0x2b, 0xa1, 0xae, - 0xf3, 0x04, 0xc8, 0x63, 0x7b, 0xe2, 0x38, 0x89, 0x15, 0x2a, 0xba, 0x61, 0x95, 0xe4, 0xcb, 0x6f, - 0xce, 0x78, 0xce, 0x9c, 0xf9, 0xc6, 0x40, 0xd6, 0x31, 0xb1, 0x30, 0x29, 0x11, 0xaa, 0x35, 0x90, - 0x6d, 0x96, 0x0e, 0xd7, 0xeb, 0x90, 0x6a, 0xeb, 0x25, 0x7a, 0x54, 0x6c, 0x39, 0x98, 0x62, 0x71, - 0xc1, 0x07, 0x8a, 0x01, 0x50, 0x0c,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 0x18, 0xe7, 0x8d, 0x6a, 0x39, 0x61, - 0x74, 0x08, 0x49, 0x77, 0x47, 0x80, 0xb8, 0xfa, 0x01, 0x98, 0x8e, 0xb7, 0x81, 0x24, 0xf7, 0x62, - 0x6c, 0xa2, 0x7b, 0xc3, 0x8e, 0x43, 0x1d, 0x80, 0x48, 0xc2, 0x6f, 0x25, 0x28, 0x74, 0x31, 0x69, - 0x6d, 0x24, 0x2c, 0x9c, 0xa3, 0xfc, 0xec, 0xf4, 0xbc, 0x20, 0x9c, 0x9d, 0x17, 0x84, 0x1f, 0xe7, - 0x05, 0xe1, 0xe3, 0x45, 0x21, 0x75, 0x76, 0x51, 0x48, 0x7d, 0xbb, 0x28, 0xa4, 0xde, 0xdc, 0x4b, - 0xbc, 0x7a, 0x8e, 0xf8, 0x9b, 0x22, 0xbb, 0x84, 0xea, 0x39, 0xf6, 0x82, 0xf8, 0xe0, 0x57, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xfa, 0x65, 0x4a, 0xde, 0xb7, 0x0a, 0x00, 0x00, + // 815 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x96, 0x4f, 0x6b, 0xdb, 0x48, + 0x18, 0xc6, 0x2d, 0xdb, 0xf1, 0x66, 0x27, 0xe4, 0x9f, 0xb2, 0x09, 0x5e, 0x11, 0xac, 0xa0, 0xec, + 0xb6, 0xa1, 0x6d, 0xa4, 0x26, 0xa5, 0x14, 0x72, 0x29, 0x75, 0xdc, 0xd2, 0xd0, 0xfa, 0xa2, 0xa4, + 0x3d, 0x94, 0x82, 0x91, 0xa5, 0xb1, 0x2a, 0x2c, 0x69, 0x1c, 0xcd, 0x38, 0x24, 0xd0, 0x0f, 0xd0, + 0x63, 0xa0, 0xb7, 0x42, 0x21, 0x1f, 0x27, 0xa7, 0x92, 0x63, 0xe9, 0xc1, 0x2d, 0x09, 0x94, 0x9c, + 0xfd, 0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0x1e, 0x24, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1091,13 +1097,14 @@ func (m *MsgBeginRedelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if len(m.CompletionTime) > 0 { - i -= len(m.CompletionTime) - copy(dAtA[i:], m.CompletionTime) - i = encodeVarintTx(dAtA, i, uint64(len(m.CompletionTime))) - i-- - dAtA[i] = 0xa + n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) + if err7 != nil { + return 0, err7 } + i -= n7 + i = encodeVarintTx(dAtA, i, uint64(n7)) + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1168,13 +1175,14 @@ func (m *MsgUndelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.CompletionTime) > 0 { - i -= len(m.CompletionTime) - copy(dAtA[i:], m.CompletionTime) - i = encodeVarintTx(dAtA, i, uint64(len(m.CompletionTime))) - i-- - dAtA[i] = 0xa + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) + if err9 != nil { + return 0, err9 } + i -= n9 + i = encodeVarintTx(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1316,10 +1324,8 @@ func (m *MsgBeginRedelegateResponse) Size() (n int) { } var l int _ = l - l = len(m.CompletionTime) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTx(uint64(l)) return n } @@ -1348,10 +1354,8 @@ func (m *MsgUndelegateResponse) Size() (n int) { } var l int _ = l - l = len(m.CompletionTime) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTx(uint64(l)) return n } @@ -2357,7 +2361,7 @@ func (m *MsgBeginRedelegateResponse) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2367,24 +2371,23 @@ func (m *MsgBeginRedelegateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.CompletionTime = append(m.CompletionTime[:0], dAtA[iNdEx:postIndex]...) - if m.CompletionTime == nil { - m.CompletionTime = []byte{} + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CompletionTime, dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: @@ -2594,7 +2597,7 @@ func (m *MsgUndelegateResponse) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2604,24 +2607,23 @@ func (m *MsgUndelegateResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.CompletionTime = append(m.CompletionTime[:0], dAtA[iNdEx:postIndex]...) - if m.CompletionTime == nil { - m.CompletionTime = []byte{} + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CompletionTime, dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: From 0ebeb41290e990731ec90c8c0aa54d05211180e0 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 16 Oct 2020 01:13:38 +0530 Subject: [PATCH 4/5] review changes --- x/distribution/handler.go | 4 ++-- x/distribution/keeper/msg_server.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/distribution/handler.go b/x/distribution/handler.go index e89b9fbf8c06..279a6bf726de 100644 --- a/x/distribution/handler.go +++ b/x/distribution/handler.go @@ -9,11 +9,11 @@ import ( ) func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(k) - switch msg := msg.(type) { case *types.MsgSetWithdrawAddress: res, err := msgServer.SetWithdrawAddress(sdk.WrapSDKContext(ctx), msg) diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go index 9aa24529d8e7..017aeeb216bf 100644 --- a/x/distribution/keeper/msg_server.go +++ b/x/distribution/keeper/msg_server.go @@ -13,7 +13,7 @@ type msgServer struct { Keeper } -// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// NewMsgServerImpl returns an implementation of the distribution MsgServer interface // for the provided Keeper. func NewMsgServerImpl(keeper Keeper) types.MsgServer { return &msgServer{Keeper: keeper} From 694491b3a06d988ab81aca2b41af012dd24488dd Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 16 Oct 2020 14:23:58 +0530 Subject: [PATCH 5/5] review changes --- x/staking/handler_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index e805fdaebd14..51a7323ca0ab 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -119,6 +119,7 @@ func TestValidatorByPowerIndex(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -254,6 +255,7 @@ func TestLegacyValidatorDelegations(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -496,6 +498,7 @@ func TestIncrementsMsgUnbond(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -611,6 +614,7 @@ func TestMultipleMsgCreateValidator(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) // adds validator into unbonding queue staking.EndBlocker(ctx, app.StakingKeeper) @@ -666,6 +670,7 @@ func TestMultipleMsgDelegate(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -702,6 +707,7 @@ func TestJailValidator(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -718,6 +724,7 @@ func TestJailValidator(t *testing.T) { require.NotNil(t, res) err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -763,6 +770,7 @@ func TestValidatorQueue(t *testing.T) { var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime) staking.EndBlocker(ctx, app.StakingKeeper) @@ -866,6 +874,7 @@ func TestUnbondingFromUnbondingValidator(t *testing.T) { // change the ctx to Block Time one second before the validator would have unbonded var resData types.MsgUndelegateResponse err = proto.Unmarshal(res.Data, &resData) + require.NoError(t, err) ctx = ctx.WithBlockTime(resData.CompletionTime.Add(time.Second * -1))