From e96839de2f30f7afecb2b697434fe2c33f772f95 Mon Sep 17 00:00:00 2001 From: likhita-809 <78951027+likhita-809@users.noreply.github.com> Date: Mon, 10 May 2021 18:11:24 +0530 Subject: [PATCH] x/staking v0.43 Audit updates (#9267) * update staking specs * use gosimple code in x/staking/client/testutil/suite.go * small fixes * add godoc to methods in msg_server and grpc_query * changes to godoc and small fixes * remove unnecessary lines * remove mentions of serviceMsg and avoid having slash after Msg --- docs/core/proto-docs.md | 16 +++++------ x/staking/client/cli/query.go | 1 - x/staking/client/testutil/suite.go | 14 +++++----- x/staking/keeper/delegation_test.go | 5 +++- x/staking/keeper/grpc_query.go | 4 ++- x/staking/keeper/grpc_query_test.go | 4 +-- x/staking/keeper/msg_server.go | 5 ++++ x/staking/simulation/genesis.go | 18 ++++++------ x/staking/simulation/genesis_test.go | 2 +- x/staking/simulation/params.go | 9 +++--- x/staking/spec/01_state.md | 4 +++ x/staking/spec/03_messages.md | 42 ++++++++++++++-------------- x/staking/spec/07_events.md | 12 ++++---- x/staking/spec/README.md | 12 ++++---- 14 files changed, 80 insertions(+), 68 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 682831615c..254ce496c8 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -6182,9 +6182,9 @@ AuthorizationType defines the type of staking module authorization type | Name | Number | Description | | ---- | ------ | ----------- | | AUTHORIZATION_TYPE_UNSPECIFIED | 0 | AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type | -| AUTHORIZATION_TYPE_DELEGATE | 1 | AUTHORIZATION_TYPE_DELEGATE defines an authorization type for Msg/Delegate | -| AUTHORIZATION_TYPE_UNDELEGATE | 2 | AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for Msg/Undelegate | -| AUTHORIZATION_TYPE_REDELEGATE | 3 | AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for Msg/BeginRedelegate | +| AUTHORIZATION_TYPE_DELEGATE | 1 | AUTHORIZATION_TYPE_DELEGATE defines an authorization type for MsgDelegate | +| AUTHORIZATION_TYPE_UNDELEGATE | 2 | AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for MsgUndelegate | +| AUTHORIZATION_TYPE_REDELEGATE | 3 | AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for MsgBeginRedelegate | @@ -7167,7 +7167,7 @@ of coins from a delegator and source validator to a destination validator. ### MsgBeginRedelegateResponse -MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. +MsgBeginRedelegateResponse defines the MsgBeginRedelegate response type. | Field | Type | Label | Description | @@ -7203,7 +7203,7 @@ MsgCreateValidator defines a SDK message for creating a new validator. ### MsgCreateValidatorResponse -MsgCreateValidatorResponse defines the Msg/CreateValidator response type. +MsgCreateValidatorResponse defines the MsgCreateValidator response type. @@ -7231,7 +7231,7 @@ from a delegator to a validator. ### MsgDelegateResponse -MsgDelegateResponse defines the Msg/Delegate response type. +MsgDelegateResponse defines the MsgDelegate response type. @@ -7259,7 +7259,7 @@ MsgEditValidator defines a SDK message for editing an existing validator. ### MsgEditValidatorResponse -MsgEditValidatorResponse defines the Msg/EditValidator response type. +MsgEditValidatorResponse defines the MsgEditValidator response type. @@ -7287,7 +7287,7 @@ delegate and a validator. ### MsgUndelegateResponse -MsgUndelegateResponse defines the Msg/Undelegate response type. +MsgUndelegateResponse defines the MsgUndelegate response type. | Field | Type | Label | Description | diff --git a/x/staking/client/cli/query.go b/x/staking/client/cli/query.go index 7bf3ae41cc..0982296161 100644 --- a/x/staking/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -660,7 +660,6 @@ $ %s query staking historical-info 5 params := &types.QueryHistoricalInfoRequest{Height: height} res, err := queryClient.HistoricalInfo(cmd.Context(), params) - if err != nil { return err } diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index a6e385b405..d75978cb6f 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -230,7 +230,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidator() { }, { "happy case", - []string{fmt.Sprintf("%s", val.ValAddress), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + []string{val.ValAddress.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, false, }, } @@ -415,7 +415,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegations() { } } -func (s *IntegrationTestSuite) TestGetCmdQueryDelegationsTo() { +func (s *IntegrationTestSuite) TestGetCmdQueryValidatorDelegations() { val := s.network.Validators[0] testCases := []struct { @@ -755,7 +755,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() { } } -func (s *IntegrationTestSuite) TestGetCmdQueryRedelegationsFrom() { +func (s *IntegrationTestSuite) TestGetCmdQueryValidatorRedelegations() { val := s.network.Validators[0] val2 := s.network.Validators[1] @@ -925,7 +925,7 @@ not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()), } } -func (s *IntegrationTestSuite) TestNewCmdEditValidator() { +func (s *IntegrationTestSuite) TestNewEditValidatorCmd() { val := s.network.Validators[0] details := "bio" @@ -1041,7 +1041,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() { } } -func (s *IntegrationTestSuite) TestNewCmdDelegate() { +func (s *IntegrationTestSuite) TestNewDelegateCmd() { val := s.network.Validators[0] info, _, err := val.ClientCtx.Keyring.NewMnemonic("NewAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) @@ -1123,7 +1123,7 @@ func (s *IntegrationTestSuite) TestNewCmdDelegate() { } } -func (s *IntegrationTestSuite) TestNewCmdRedelegate() { +func (s *IntegrationTestSuite) TestNewRedelegateCmd() { val := s.network.Validators[0] val2 := s.network.Validators[1] @@ -1209,7 +1209,7 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() { } } -func (s *IntegrationTestSuite) TestNewCmdUnbond() { +func (s *IntegrationTestSuite) TestNewUnbondCmd() { val := s.network.Validators[0] testCases := []struct { diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index de7a9ba0e6..49083d2376 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -384,6 +384,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { selfDelegation := types.NewDelegation(addrVals[0].Bytes(), addrVals[0], issuedShares) app.StakingKeeper.SetDelegation(ctx, selfDelegation) + // add bonded tokens to pool for delegations bondedPool := app.StakingKeeper.GetBondedPool(ctx) require.NoError(t, simapp.FundModuleAccount(app, ctx, bondedPool.GetName(), delCoins)) app.AccountKeeper.SetModuleAccount(ctx, bondedPool) @@ -470,6 +471,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { selfDelegation := types.NewDelegation(val0AccAddr, addrVals[0], issuedShares) app.StakingKeeper.SetDelegation(ctx, selfDelegation) + // add bonded tokens to pool for delegations bondedPool := app.StakingKeeper.GetBondedPool(ctx) require.NoError(t, simapp.FundModuleAccount(app, ctx, bondedPool.GetName(), delCoins)) app.AccountKeeper.SetModuleAccount(ctx, bondedPool) @@ -518,7 +520,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], remainingTokens.ToDec()) require.NoError(t, err) - // now validator should now be deleted from state + // now validator should be deleted from state validator, found = app.StakingKeeper.GetValidator(ctx, addrVals[0]) require.False(t, found, "%v", validator) } @@ -556,6 +558,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { validator, issuedShares = validator.AddTokensFromDel(delTokens) require.Equal(t, delTokens, issuedShares.RoundInt()) + // add bonded tokens to pool for delegations bondedPool := app.StakingKeeper.GetBondedPool(ctx) require.NoError(t, simapp.FundModuleAccount(app, ctx, bondedPool.GetName(), delCoins)) app.AccountKeeper.SetModuleAccount(ctx, bondedPool) diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 49d9b92ce2..4852848255 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -61,7 +61,7 @@ func (k Querier) Validators(c context.Context, req *types.QueryValidatorsRequest return &types.QueryValidatorsResponse{Validators: validators, Pagination: pageRes}, nil } -// Validator queries validator info for given validator addr +// Validator queries validator info for given validator address func (k Querier) Validator(c context.Context, req *types.QueryValidatorRequest) (*types.QueryValidatorResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -380,6 +380,7 @@ func (k Querier) HistoricalInfo(c context.Context, req *types.QueryHistoricalInf return &types.QueryHistoricalInfoResponse{Hist: &hi}, nil } +// Redelegations queries redelegations of given address func (k Querier) Redelegations(c context.Context, req *types.QueryRedelegationsRequest) (*types.QueryRedelegationsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -410,6 +411,7 @@ func (k Querier) Redelegations(c context.Context, req *types.QueryRedelegationsR return &types.QueryRedelegationsResponse{RedelegationResponses: redelResponses, Pagination: pageRes}, nil } +// DelegatorValidators queries all validators info for given delegator address func (k Querier) DelegatorValidators(c context.Context, req *types.QueryDelegatorValidatorsRequest) (*types.QueryDelegatorValidatorsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index c82f71552e..dc47dc34c1 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidators() { } } -func (suite *KeeperTestSuite) TestGRPCValidator() { +func (suite *KeeperTestSuite) TestGRPCQueryValidator() { app, ctx, queryClient, vals := suite.app, suite.ctx, suite.queryClient, suite.vals validator, found := app.StakingKeeper.GetValidator(ctx, vals[0].GetOperator()) suite.True(found) @@ -586,7 +586,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryHistoricalInfo() { } } -func (suite *KeeperTestSuite) TestGRPCQueryRedelegation() { +func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { app, ctx, queryClient, addrs, vals := suite.app, suite.ctx, suite.queryClient, suite.addrs, suite.vals addrAcc, addrAcc1 := addrs[0], addrs[1] diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 37e5edb042..25031c9638 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -26,6 +26,7 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { var _ types.MsgServer = msgServer{} +// CreateValidator defines a method for creating a new validator func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateValidator) (*types.MsgCreateValidatorResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -119,6 +120,7 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa return &types.MsgCreateValidatorResponse{}, nil } +// EditValidator defines a method for editing an existing validator func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValidator) (*types.MsgEditValidatorResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress) @@ -181,6 +183,7 @@ func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValida return &types.MsgEditValidatorResponse{}, nil } +// Delegate defines a method for performing a delegation of coins from a delegator to a validator func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) valAddr, valErr := sdk.ValAddressFromBech32(msg.ValidatorAddress) @@ -237,6 +240,7 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ return &types.MsgDelegateResponse{}, nil } +// BeginRedelegate defines a method for performing a redelegation of coins from a delegator and source validator to a destination validator func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRedelegate) (*types.MsgBeginRedelegateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) valSrcAddr, err := sdk.ValAddressFromBech32(msg.ValidatorSrcAddress) @@ -302,6 +306,7 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed }, nil } +// Undelegate defines a method for performing an undelegation from a delegate and a validator func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/staking/simulation/genesis.go b/x/staking/simulation/genesis.go index bf01b90bfe..2f1caf2692 100644 --- a/x/staking/simulation/genesis.go +++ b/x/staking/simulation/genesis.go @@ -21,18 +21,18 @@ const ( historicalEntries = "historical_entries" ) -// GenUnbondingTime randomized UnbondingTime -func GenUnbondingTime(r *rand.Rand) (ubdTime time.Duration) { +// genUnbondingTime returns randomized UnbondingTime +func genUnbondingTime(r *rand.Rand) (ubdTime time.Duration) { return time.Duration(simulation.RandIntBetween(r, 60, 60*60*24*3*2)) * time.Second } -// GenMaxValidators randomized MaxValidators -func GenMaxValidators(r *rand.Rand) (maxValidators uint32) { +// genMaxValidators returns randomized MaxValidators +func genMaxValidators(r *rand.Rand) (maxValidators uint32) { return uint32(r.Intn(250) + 1) } -// GetHistEntries randomized HistoricalEntries between 0-100. -func GetHistEntries(r *rand.Rand) uint32 { +// getHistEntries returns randomized HistoricalEntries between 0-100. +func getHistEntries(r *rand.Rand) uint32 { return uint32(r.Intn(int(types.DefaultHistoricalEntries + 1))) } @@ -47,17 +47,17 @@ func RandomizedGenState(simState *module.SimulationState) { simState.AppParams.GetOrGenerate( simState.Cdc, unbondingTime, &unbondTime, simState.Rand, - func(r *rand.Rand) { unbondTime = GenUnbondingTime(r) }, + func(r *rand.Rand) { unbondTime = genUnbondingTime(r) }, ) simState.AppParams.GetOrGenerate( simState.Cdc, maxValidators, &maxVals, simState.Rand, - func(r *rand.Rand) { maxVals = GenMaxValidators(r) }, + func(r *rand.Rand) { maxVals = genMaxValidators(r) }, ) simState.AppParams.GetOrGenerate( simState.Cdc, historicalEntries, &histEntries, simState.Rand, - func(r *rand.Rand) { histEntries = GetHistEntries(r) }, + func(r *rand.Rand) { histEntries = getHistEntries(r) }, ) // NOTE: the slashing module need to be defined after the staking module on the diff --git a/x/staking/simulation/genesis_test.go b/x/staking/simulation/genesis_test.go index a307ce9ad7..f7b31b29e1 100644 --- a/x/staking/simulation/genesis_test.go +++ b/x/staking/simulation/genesis_test.go @@ -68,7 +68,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, "1", stakingGenesis.Validators[2].MinSelfDelegation.String()) } -// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. +// TestRandomizedGenState1 tests abnormal scenarios of applying RandomizedGenState. func TestRandomizedGenState1(t *testing.T) { interfaceRegistry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(interfaceRegistry) diff --git a/x/staking/simulation/params.go b/x/staking/simulation/params.go index ffbbe4fe47..30789d3467 100644 --- a/x/staking/simulation/params.go +++ b/x/staking/simulation/params.go @@ -6,9 +6,8 @@ import ( "fmt" "math/rand" - "github.com/cosmos/cosmos-sdk/x/simulation" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -18,17 +17,17 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, string(types.KeyMaxValidators), func(r *rand.Rand) string { - return fmt.Sprintf("%d", GenMaxValidators(r)) + return fmt.Sprintf("%d", genMaxValidators(r)) }, ), simulation.NewSimParamChange(types.ModuleName, string(types.KeyUnbondingTime), func(r *rand.Rand) string { - return fmt.Sprintf("\"%d\"", GenUnbondingTime(r)) + return fmt.Sprintf("\"%d\"", genUnbondingTime(r)) }, ), simulation.NewSimParamChange(types.ModuleName, string(types.KeyHistoricalEntries), func(r *rand.Rand) string { - return fmt.Sprintf("%d", GetHistEntries(r)) + return fmt.Sprintf("%d", getHistEntries(r)) }, ), } diff --git a/x/staking/spec/01_state.md b/x/staking/spec/01_state.md index 7238994118..9dacbb22fd 100644 --- a/x/staking/spec/01_state.md +++ b/x/staking/spec/01_state.md @@ -4,6 +4,10 @@ order: 1 # State +## Pool + +Pool is used for tracking bonded and not-bonded token supply of the bond denomination. + ## LastTotalPower LastTotalPower tracks the total amounts of bonded tokens recorded during the previous end block. diff --git a/x/staking/spec/03_messages.md b/x/staking/spec/03_messages.md index 8b5fa28d66..4dd654227d 100644 --- a/x/staking/spec/03_messages.md +++ b/x/staking/spec/03_messages.md @@ -6,16 +6,16 @@ order: 3 In this section we describe the processing of the staking messages and the corresponding updates to the state. All created/modified state objects specified by each message are defined within the [state](./02_state_transitions.md) section. -## Msg/CreateValidator +## MsgCreateValidator -A validator is created using the `Msg/CreateValidator` service message. +A validator is created using the `MsgCreateValidator` message. The validator must be created with an initial delegation from the operator. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L16-L17 +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L35-L51 -This service message is expected to fail if: +This message is expected to fail if: - another validator with this operator address is already registered - another validator with this pubkey is already registered @@ -26,32 +26,32 @@ This service message is expected to fail if: - the initial `MaxChangeRate` is either negative or > `MaxRate` - the description fields are too large -This service message creates and stores the `Validator` object at appropriate indexes. +This message creates and stores the `Validator` object at appropriate indexes. Additionally a self-delegation is made with the initial tokens delegation tokens `Delegation`. The validator always starts as unbonded but may be bonded in the first end-block. -## Msg/EditValidator +## MsgEditValidator The `Description`, `CommissionRate` of a validator can be updated using the -`Msg/EditCandidacy` service message. +`MsgEditValidator` message. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L19-L20 +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L56-L76 -This service message is expected to fail if: +This message is expected to fail if: - the initial `CommissionRate` is either negative or > `MaxRate` - the `CommissionRate` has already been updated within the previous 24 hours - the `CommissionRate` is > `MaxChangeRate` - the description fields are too large -This service message stores the updated `Validator` object. +This message stores the updated `Validator` object. -## Msg/Delegate +## MsgDelegate -Within this service message the delegator provides coins, and in return receives +Within this message the delegator provides coins, and in return receives some amount of their validator's (newly created) delegator-shares that are assigned to `Delegation.Shares`. @@ -59,9 +59,9 @@ assigned to `Delegation.Shares`. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90 -This service message is expected to fail if: +This message is expected to fail if: -- the validator is does not exist +- the validator does not exist - the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom` - the exchange rate is invalid, meaning the validator has no tokens (due to slashing) but there are outstanding shares - the amount delegated is less than the minimum allowed delegation @@ -82,20 +82,20 @@ will not be added to the power index until it is unjailed. ![Delegation sequence](../../../docs/uml/svg/delegation_sequence.svg) -## Msg/Undelegate +## MsgUndelegate -The `Msg/Undelegate` service message allows delegators to undelegate their tokens from +The `MsgUndelegate` message allows delegators to undelegate their tokens from validator. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L30-L32 +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121 -This service message returns a response containing the completion time of the undelegation: +This message returns a response containing the completion time of the undelegation: +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L123-L126 -This service message is expected to fail if: +This message is expected to fail if: - the delegation doesn't exist - the validator doesn't exist @@ -103,7 +103,7 @@ This service message is expected to fail if: - existing `UnbondingDelegation` has maximum entries as defined by `params.MaxEntries` - the `Amount` has a denomination different than one defined by `params.BondDenom` -When this service message is processed the following actions occur: +When this message is processed the following actions occur: - validator's `DelegatorShares` and the delegation's `Shares` are both reduced by the message `SharesAmount` - calculate the token worth of the shares remove that amount tokens held within the validator @@ -116,7 +116,7 @@ When this service message is processed the following actions occur: ![Unbond sequence](../../../docs/uml/svg/unbond_sequence.svg) -## Msg/BeginRedelegate +## MsgBeginRedelegate The redelegation command allows delegators to instantly switch validators. Once the unbonding period has passed, the redelegation is automatically completed in @@ -126,11 +126,11 @@ the EndBlocker. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105 -This service message returns a response containing the completion time of the redelegation: +This message returns a response containing the completion time of the redelegation: +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L107-L110 -This service message is expected to fail if: +This message is expected to fail if: - the delegation doesn't exist - the source or destination validators don't exist @@ -139,7 +139,7 @@ This service message is expected to fail if: - existing `Redelegation` has maximum entries as defined by `params.MaxEntries` - the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom` -When this service message is processed the following actions occur: +When this message is processed the following actions occur: - the source validator's `DelegatorShares` and the delegations `Shares` are both reduced by the message `SharesAmount` - calculate the token worth of the shares remove that amount tokens held within the source validator. diff --git a/x/staking/spec/07_events.md b/x/staking/spec/07_events.md index 660319b3c1..f219fa2ca4 100644 --- a/x/staking/spec/07_events.md +++ b/x/staking/spec/07_events.md @@ -18,9 +18,9 @@ The staking module emits the following events: | complete_redelegation | destination_validator | {dstValidatorAddress} | | complete_redelegation | delegator | {delegatorAddress} | -## Service Messages +## Msg's -### Msg/CreateValidator +### MsgCreateValidator | Type | Attribute Key | Attribute Value | | ---------------- | ------------- | ------------------ | @@ -30,7 +30,7 @@ The staking module emits the following events: | message | action | create_validator | | message | sender | {senderAddress} | -### Msg/EditValidator +### MsgEditValidator | Type | Attribute Key | Attribute Value | | -------------- | ------------------- | ------------------- | @@ -40,7 +40,7 @@ The staking module emits the following events: | message | action | edit_validator | | message | sender | {senderAddress} | -### Msg/Delegate +### MsgDelegate | Type | Attribute Key | Attribute Value | | -------- | ------------- | ------------------ | @@ -50,7 +50,7 @@ The staking module emits the following events: | message | action | delegate | | message | sender | {senderAddress} | -### Msg/Undelegate +### MsgUndelegate | Type | Attribute Key | Attribute Value | | ------- | ------------------- | ------------------ | @@ -63,7 +63,7 @@ The staking module emits the following events: - [0] Time is formatted in the RFC3339 standard -### Msg/BeginRedelegate +### MsgBeginRedelegate | Type | Attribute Key | Attribute Value | | ---------- | --------------------- | --------------------- | diff --git a/x/staking/spec/README.md b/x/staking/spec/README.md index a2cb7cf3a8..8eb42de8aa 100644 --- a/x/staking/spec/README.md +++ b/x/staking/spec/README.md @@ -38,11 +38,11 @@ network. - [Delegations](02_state_transitions.md#delegations) - [Slashing](02_state_transitions.md#slashing) 3. **[Messages](03_messages.md)** - - [Msg/CreateValidator](03_messages.md#msgcreatevalidator) - - [Msg/EditValidator](03_messages.md#msgeditvalidator) - - [Msg/Delegate](03_messages.md#msgdelegate) - - [Msg/BeginUnbonding](03_messages.md#msgbeginunbonding) - - [Msg/BeginRedelegate](03_messages.md#msgbeginredelegate) + - [MsgCreateValidator](03_messages.md#msgcreatevalidator) + - [MsgEditValidator](03_messages.md#msgeditvalidator) + - [MsgDelegate](03_messages.md#msgdelegate) + - [MsgUndelegate](03_messages.md#msgundelegate) + - [MsgBeginRedelegate](03_messages.md#msgbeginredelegate) 4. **[Begin-Block](04_begin_block.md)** - [Historical Info Tracking](04_begin_block.md#historical-info-tracking) 5. **[End-Block ](05_end_block.md)** @@ -51,5 +51,5 @@ network. 6. **[Hooks](06_hooks.md)** 7. **[Events](07_events.md)** - [EndBlocker](07_events.md#endblocker) - - [Handlers](07_events.md#handlers) + - [Msg's](07_events.md#msg's) 8. **[Parameters](08_params.md)**