From a14194b7aa9a681024b3d96f294299a1c6db902b Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 5 May 2021 10:50:55 +0530 Subject: [PATCH 1/7] update staking specs --- x/staking/spec/01_state.md | 4 ++++ x/staking/spec/03_messages.md | 4 ++-- x/staking/spec/07_events.md | 2 +- x/staking/spec/README.md | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/x/staking/spec/01_state.md b/x/staking/spec/01_state.md index 7238994118f1..9dacbb22fdec 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 8b5fa28d6698..c66f228770ec 100644 --- a/x/staking/spec/03_messages.md +++ b/x/staking/spec/03_messages.md @@ -34,7 +34,7 @@ in the first end-block. ## Msg/EditValidator The `Description`, `CommissionRate` of a validator can be updated using the -`Msg/EditCandidacy` service message. +`Msg/EditValidator` service message. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L19-L20 @@ -61,7 +61,7 @@ assigned to `Delegation.Shares`. This service 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 diff --git a/x/staking/spec/07_events.md b/x/staking/spec/07_events.md index 660319b3c1a4..a73e9db78580 100644 --- a/x/staking/spec/07_events.md +++ b/x/staking/spec/07_events.md @@ -18,7 +18,7 @@ The staking module emits the following events: | complete_redelegation | destination_validator | {dstValidatorAddress} | | complete_redelegation | delegator | {delegatorAddress} | -## Service Messages +## ServiceMessages ### Msg/CreateValidator diff --git a/x/staking/spec/README.md b/x/staking/spec/README.md index a2cb7cf3a8df..995b642dfd7b 100644 --- a/x/staking/spec/README.md +++ b/x/staking/spec/README.md @@ -41,7 +41,7 @@ network. - [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/Undelegate](03_messages.md#msgundelegate) - [Msg/BeginRedelegate](03_messages.md#msgbeginredelegate) 4. **[Begin-Block](04_begin_block.md)** - [Historical Info Tracking](04_begin_block.md#historical-info-tracking) @@ -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) + - [ServiceMessages](07_events.md#servicemessages) 8. **[Parameters](08_params.md)** From a7a15d76046970f65acc85860b582bbfffc81a64 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 5 May 2021 11:49:15 +0530 Subject: [PATCH 2/7] use gosimple code in x/staking/client/testutil/suite.go --- x/staking/client/testutil/suite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index a6e385b405aa..dc0da8dcc67a 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, }, } From faae250d8a50038b0d139b057bbc36ff92a22462 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 5 May 2021 12:58:52 +0530 Subject: [PATCH 3/7] small fixes --- x/staking/client/cli/query.go | 2 +- x/staking/keeper/delegation_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/x/staking/client/cli/query.go b/x/staking/client/cli/query.go index 7bf3ae41ccbe..38ee1dd2fca0 100644 --- a/x/staking/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -659,8 +659,8 @@ $ %s query staking historical-info 5 } params := &types.QueryHistoricalInfoRequest{Height: height} - res, err := queryClient.HistoricalInfo(cmd.Context(), params) + res, err := queryClient.HistoricalInfo(cmd.Context(), params) if err != nil { return err } diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index de7a9ba0e62a..49083d23760d 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) From ab63b82a3a174b3eaf48936edaa952fb4f922729 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 5 May 2021 20:22:53 +0530 Subject: [PATCH 4/7] add godoc to methods in msg_server and grpc_query --- x/authz/client/rest/grpc_query_test.go | 2 +- x/staking/keeper/grpc_query.go | 4 +++- x/staking/keeper/msg_server.go | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/x/authz/client/rest/grpc_query_test.go b/x/authz/client/rest/grpc_query_test.go index 698bd359bea1..a210218c5e72 100644 --- a/x/authz/client/rest/grpc_query_test.go +++ b/x/authz/client/rest/grpc_query_test.go @@ -190,7 +190,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizationsGRPC() { "", func() {}, func(authorizations *types.QueryAuthorizationsResponse) { - s.Require().Len(authorizations.Authorizations), 1) + s.Require().Equal(len(authorizations.Authorizations), 1) }, }, { diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 49d9b92ce26d..4852848255c0 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/msg_server.go b/x/staking/keeper/msg_server.go index 37e5edb042dd..25031c963861 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) From f52bbd208dccfeaa3aa584be234e28d37cfd66f5 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Thu, 6 May 2021 10:36:52 +0530 Subject: [PATCH 5/7] changes to godoc and small fixes --- x/staking/client/testutil/suite.go | 12 ++++++------ x/staking/keeper/grpc_query_test.go | 4 ++-- x/staking/simulation/genesis.go | 18 +++++++++--------- x/staking/simulation/genesis_test.go | 2 +- x/staking/simulation/params.go | 9 ++++----- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index dc0da8dcc67a..d75978cb6fb2 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -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/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index c82f71552e0f..dc47dc34c17a 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/simulation/genesis.go b/x/staking/simulation/genesis.go index bf01b90bfe9c..2f1caf2692f7 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 a307ce9ad756..f7b31b29e1e3 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 ffbbe4fe47ff..30789d346770 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)) }, ), } From 707855424c1f2eb88eebd8698e9b3879ef808dd0 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Sun, 9 May 2021 13:46:03 +0530 Subject: [PATCH 6/7] remove unnecessary lines --- x/staking/client/cli/query.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/staking/client/cli/query.go b/x/staking/client/cli/query.go index 38ee1dd2fca0..0982296161e4 100644 --- a/x/staking/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -659,7 +659,6 @@ $ %s query staking historical-info 5 } params := &types.QueryHistoricalInfoRequest{Height: height} - res, err := queryClient.HistoricalInfo(cmd.Context(), params) if err != nil { return err From 9f5bdef26e057193ab26f05819a99feb71199b1d Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 10 May 2021 15:21:34 +0530 Subject: [PATCH 7/7] remove mentions of serviceMsg and avoid having slash after Msg --- docs/core/proto-docs.md | 16 +++++++------- x/staking/spec/03_messages.md | 40 +++++++++++++++++------------------ x/staking/spec/07_events.md | 12 +++++------ x/staking/spec/README.md | 12 +++++------ 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index d8b85efe7bc7..633f855c630e 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -6183,9 +6183,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 | @@ -7168,7 +7168,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 | @@ -7204,7 +7204,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. @@ -7232,7 +7232,7 @@ from a delegator to a validator. ### MsgDelegateResponse -MsgDelegateResponse defines the Msg/Delegate response type. +MsgDelegateResponse defines the MsgDelegate response type. @@ -7260,7 +7260,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. @@ -7288,7 +7288,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/spec/03_messages.md b/x/staking/spec/03_messages.md index c66f228770ec..4dd654227de5 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/EditValidator` 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,7 +59,7 @@ 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 does not exist - the `Amount` `Coin` has a denomination different than one defined by `params.BondDenom` @@ -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 a73e9db78580..f219fa2ca4c1 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} | -## ServiceMessages +## 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 995b642dfd7b..8eb42de8aac1 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/Undelegate](03_messages.md#msgundelegate) - - [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) - - [ServiceMessages](07_events.md#servicemessages) + - [Msg's](07_events.md#msg's) 8. **[Parameters](08_params.md)**