From 78a21353da978d6c2a9b711f29b3874ff9ca14ae Mon Sep 17 00:00:00 2001 From: frog power 4000 Date: Fri, 11 Jan 2019 15:08:01 -0500 Subject: [PATCH] Rename stake/ to staking/ (#3280) --- CHANGELOG.md | 4 +- PENDING.md | 14 +- client/lcd/lcd_test.go | 52 +++--- client/lcd/swagger-ui/swagger.yaml | 30 ++-- client/lcd/test_helpers.go | 152 +++++++++--------- client/utils/rest.go | 2 +- cmd/gaia/app/app.go | 52 +++--- cmd/gaia/app/app_test.go | 4 +- cmd/gaia/app/export.go | 26 +-- cmd/gaia/app/genesis.go | 28 ++-- cmd/gaia/app/genesis_test.go | 26 +-- cmd/gaia/app/invariants.go | 8 +- cmd/gaia/app/sim_test.go | 58 +++---- cmd/gaia/cli_test/README.md | 2 +- cmd/gaia/cli_test/cli_test.go | 34 ++-- cmd/gaia/cli_test/test_helpers.go | 58 +++---- cmd/gaia/cmd/gaiacli/main.go | 10 +- cmd/gaia/cmd/gaiadebug/hack.go | 37 ++--- cmd/gaia/init/gentx.go | 8 +- cmd/gaia/init/testnet.go | 16 +- docs/examples/basecoin/cmd/basecli/main.go | 44 ++--- docs/examples/democoin/app/app.go | 14 +- docs/examples/democoin/cmd/democli/main.go | 2 +- docs/examples/democoin/x/simplestake/codec.go | 11 -- .../client/cli/commands.go | 16 +- .../democoin/x/simplestaking/codec.go | 11 ++ .../{simplestake => simplestaking}/errors.go | 6 +- .../{simplestake => simplestaking}/handler.go | 4 +- .../{simplestake => simplestaking}/keeper.go | 24 +-- .../keeper_test.go | 24 +-- .../x/{simplestake => simplestaking}/msgs.go | 6 +- .../msgs_test.go | 2 +- .../x/{simplestake => simplestaking}/types.go | 2 +- docs/gaia/deploy-testnet.md | 2 +- docs/gaia/gaiacli.md | 32 ++-- docs/gaia/validators/validator-setup.md | 10 +- docs/modules/README.md | 4 +- docs/spec/auth/vesting.md | 2 +- docs/spec/distribution/hooks.md | 6 +- docs/spec/distribution/transactions.md | 4 +- docs/spec/governance/state.md | 4 +- docs/spec/staking/state.md | 2 +- x/auth/client/txbuilder/txbuilder_test.go | 6 +- x/auth/params.go | 2 +- x/distribution/alias.go | 2 +- x/distribution/keeper/allocation.go | 4 +- x/distribution/keeper/allocation_test.go | 20 +-- x/distribution/keeper/delegation.go | 12 +- x/distribution/keeper/delegation_test.go | 76 ++++----- x/distribution/keeper/hooks.go | 2 +- x/distribution/keeper/keeper.go | 16 +- x/distribution/keeper/test_common.go | 22 +-- x/distribution/keeper/validator.go | 2 +- x/distribution/keeper/validator_test.go | 56 +++---- x/distribution/simulation/invariants.go | 12 +- x/distribution/types/delegation_info_test.go | 4 +- x/distribution/types/keepers.go | 4 +- x/distribution/types/validator_info_test.go | 6 +- x/gov/endblocker_test.go | 16 +- x/gov/genesis.go | 4 +- x/gov/keeper_test.go | 10 +- x/gov/msgs_test.go | 6 +- x/gov/simulation/msgs.go | 8 +- x/gov/tally_test.go | 150 ++++++++--------- x/gov/test_common.go | 30 ++-- x/mint/expected_keepers.go | 4 +- x/mint/keeper.go | 8 +- x/mint/params.go | 4 +- x/slashing/app_test.go | 56 +++---- x/slashing/genesis.go | 2 +- x/slashing/handler_test.go | 30 ++-- x/slashing/keeper.go | 6 +- x/slashing/keeper_test.go | 52 +++--- x/slashing/keys.go | 4 +- x/slashing/querier.go | 2 +- x/slashing/test_common.go | 38 ++--- x/slashing/tick_test.go | 8 +- x/stake/types/keys.go | 15 -- x/{stake => staking}/app_test.go | 26 +-- x/{stake => staking}/client/cli/flags.go | 2 +- x/{stake => staking}/client/cli/query.go | 40 ++--- x/{stake => staking}/client/cli/tx.go | 18 +-- x/{stake => staking}/client/cli/utils.go | 6 +- x/{stake => staking}/client/module_client.go | 18 +-- x/{stake => staking}/client/rest/query.go | 72 ++++----- x/{stake => staking}/client/rest/rest.go | 0 x/{stake => staking}/client/rest/tx.go | 14 +- x/{stake => staking}/client/rest/utils.go | 12 +- x/{stake => staking}/genesis.go | 4 +- x/{stake => staking}/genesis_test.go | 6 +- x/{stake => staking}/handler.go | 8 +- x/{stake => staking}/handler_test.go | 6 +- x/{stake => staking}/keeper/_store.md | 2 +- x/{stake => staking}/keeper/delegation.go | 2 +- .../keeper/delegation_test.go | 2 +- x/{stake => staking}/keeper/hooks.go | 0 x/{stake => staking}/keeper/keeper.go | 4 +- x/{stake => staking}/keeper/keeper_test.go | 2 +- x/{stake => staking}/keeper/key.go | 12 +- x/{stake => staking}/keeper/key_test.go | 2 +- x/{stake => staking}/keeper/params.go | 6 +- x/{stake => staking}/keeper/query_utils.go | 2 +- x/{stake => staking}/keeper/sdk_types.go | 2 +- x/{stake => staking}/keeper/slash.go | 8 +- x/{stake => staking}/keeper/slash_test.go | 4 +- x/{stake => staking}/keeper/test_common.go | 24 +-- .../keeper/val_state_change.go | 2 +- x/{stake => staking}/keeper/validator.go | 2 +- x/{stake => staking}/keeper/validator_test.go | 2 +- x/{stake => staking}/querier/querier.go | 38 ++--- x/{stake => staking}/querier/querier_test.go | 30 ++-- x/{stake => staking}/simulation/invariants.go | 32 ++-- x/{stake => staking}/simulation/msgs.go | 50 +++--- x/{stake/stake.go => staking/staking.go} | 12 +- x/{stake => staking}/tags/tags.go | 0 x/{stake => staking}/test_common.go | 4 +- x/{stake => staking}/types/codec.go | 0 x/{stake => staking}/types/commission.go | 0 x/{stake => staking}/types/delegation.go | 0 x/{stake => staking}/types/delegation_test.go | 0 x/{stake => staking}/types/errors.go | 2 +- x/{stake => staking}/types/genesis.go | 0 x/staking/types/keys.go | 15 ++ x/{stake => staking}/types/msg.go | 0 x/{stake => staking}/types/msg_test.go | 0 x/{stake => staking}/types/params.go | 0 x/{stake => staking}/types/params_test.go | 0 x/{stake => staking}/types/pool.go | 0 x/{stake => staking}/types/pool_test.go | 0 x/{stake => staking}/types/test_utils.go | 0 x/{stake => staking}/types/validator.go | 0 x/{stake => staking}/types/validator_test.go | 0 132 files changed, 1024 insertions(+), 1021 deletions(-) delete mode 100644 docs/examples/democoin/x/simplestake/codec.go rename docs/examples/democoin/x/{simplestake => simplestaking}/client/cli/commands.go (87%) create mode 100644 docs/examples/democoin/x/simplestaking/codec.go rename docs/examples/democoin/x/{simplestake => simplestaking}/errors.go (89%) rename docs/examples/democoin/x/{simplestake => simplestaking}/handler.go (87%) rename docs/examples/democoin/x/{simplestake => simplestaking}/keeper.go (81%) rename docs/examples/democoin/x/{simplestake => simplestaking}/keeper_test.go (74%) rename docs/examples/democoin/x/{simplestake => simplestaking}/msgs.go (94%) rename docs/examples/democoin/x/{simplestake => simplestaking}/msgs_test.go (96%) rename docs/examples/democoin/x/{simplestake => simplestaking}/types.go (90%) delete mode 100644 x/stake/types/keys.go rename x/{stake => staking}/app_test.go (88%) rename x/{stake => staking}/client/cli/flags.go (98%) rename x/{stake => staking}/client/cli/query.go (93%) rename x/{stake => staking}/client/cli/tx.go (94%) rename x/{stake => staking}/client/cli/utils.go (94%) rename x/{stake => staking}/client/module_client.go (84%) rename x/{stake => staking}/client/rest/query.go (79%) rename x/{stake => staking}/client/rest/rest.go (100%) rename x/{stake => staking}/client/rest/tx.go (89%) rename x/{stake => staking}/client/rest/utils.go (93%) rename x/{stake => staking}/genesis.go (98%) rename x/{stake => staking}/genesis_test.go (97%) rename x/{stake => staking}/handler.go (98%) rename x/{stake => staking}/handler_test.go (99%) rename x/{stake => staking}/keeper/_store.md (99%) rename x/{stake => staking}/keeper/delegation.go (99%) rename x/{stake => staking}/keeper/delegation_test.go (99%) rename x/{stake => staking}/keeper/hooks.go (100%) rename x/{stake => staking}/keeper/keeper.go (98%) rename x/{stake => staking}/keeper/keeper_test.go (95%) rename x/{stake => staking}/keeper/key.go (97%) rename x/{stake => staking}/keeper/key_test.go (98%) rename x/{stake => staking}/keeper/params.go (90%) rename x/{stake => staking}/keeper/query_utils.go (98%) rename x/{stake => staking}/keeper/sdk_types.go (98%) rename x/{stake => staking}/keeper/slash.go (97%) rename x/{stake => staking}/keeper/slash_test.go (99%) rename x/{stake => staking}/keeper/test_common.go (89%) rename x/{stake => staking}/keeper/val_state_change.go (99%) rename x/{stake => staking}/keeper/validator.go (99%) rename x/{stake => staking}/keeper/validator_test.go (99%) rename x/{stake => staking}/querier/querier.go (92%) rename x/{stake => staking}/querier/querier_test.go (94%) rename x/{stake => staking}/simulation/invariants.go (82%) rename x/{stake => staking}/simulation/msgs.go (82%) rename x/{stake/stake.go => staking/staking.go} (96%) rename x/{stake => staking}/tags/tags.go (100%) rename x/{stake => staking}/test_common.go (96%) rename x/{stake => staking}/types/codec.go (100%) rename x/{stake => staking}/types/commission.go (100%) rename x/{stake => staking}/types/delegation.go (100%) rename x/{stake => staking}/types/delegation_test.go (100%) rename x/{stake => staking}/types/errors.go (99%) rename x/{stake => staking}/types/genesis.go (100%) create mode 100644 x/staking/types/keys.go rename x/{stake => staking}/types/msg.go (100%) rename x/{stake => staking}/types/msg_test.go (100%) rename x/{stake => staking}/types/params.go (100%) rename x/{stake => staking}/types/params_test.go (100%) rename x/{stake => staking}/types/pool.go (100%) rename x/{stake => staking}/types/pool_test.go (100%) rename x/{stake => staking}/types/test_utils.go (100%) rename x/{stake => staking}/types/validator.go (100%) rename x/{stake => staking}/types/validator_test.go (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3662b7b192..87d7082312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,7 +134,7 @@ BREAKING CHANGES * [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected. * [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure. * [\#2798](https://github.com/cosmos/cosmos-sdk/issues/2798) Governance API has miss-spelled English word in JSON response ('depositer' -> 'depositor') - * [\#2943](https://github.com/cosmos/cosmos-sdk/pull/2943) Transaction action tags equal the message type. Stake EndBlocker tags are included. + * [\#2943](https://github.com/cosmos/cosmos-sdk/pull/2943) Transaction action tags equal the message type. Staking EndBlocker tags are included. * Tendermint * Update to Tendermint 0.27.0 @@ -1062,7 +1062,7 @@ BREAKING CHANGES * All module keepers now require a codespace, see basecoin or democoin for usage * Many changes to names throughout * Type as a prefix naming convention applied (ex. BondMsg -> MsgBond) - * Removed redundancy in names (ex. stake.StakeKeeper -> stake.Keeper) + * Removed redundancy in names (ex. stake.StakingKeeper -> stake.Keeper) * Removed SealedAccountMapper * gaiad init now requires use of `--name` flag * Removed Get from Msg interface diff --git a/PENDING.md b/PENDING.md index 2653e20cef..490fd171fa 100644 --- a/PENDING.md +++ b/PENDING.md @@ -3,7 +3,9 @@ BREAKING CHANGES * Gaia REST API (`gaiacli advanced rest-server`) - * [gaia-lite] [\#2182] Renamed and merged all redelegations endpoints into `/stake/redelegations` + * [gaia-lite] [\#2182] Renamed and merged all redelegations endpoints into `/staking/redelegations` + * [\#3176](https://github.com/cosmos/cosmos-sdk/issues/3176) `tx/sign` endpoint now expects `BaseReq` fields as nested object. + * [\#2222] all endpoints renamed from `/stake` -> `/staking` * Gaia CLI (`gaiacli`) * [\#810](https://github.com/cosmos/cosmos-sdk/issues/810) Don't fallback to any default values for chain ID. @@ -11,22 +13,22 @@ BREAKING CHANGES * Change `chain_id` and `trust_node` in `gaiacli` configuration to `chain-id` and `trust-node` respectively. * [\#3069](https://github.com/cosmos/cosmos-sdk/pull/3069) `--fee` flag renamed to `--fees` to support multiple coins * [\#3156](https://github.com/cosmos/cosmos-sdk/pull/3156) Remove unimplemented `gaiacli init` command + * [\#2222] `gaiacli tx stake` -> `gaiacli tx staking`, `gaiacli query stake` -> `gaiacli query staking` * Gaia * https://github.com/cosmos/cosmos-sdk/issues/2838 - Move store keys to constants * [\#3162](https://github.com/cosmos/cosmos-sdk/issues/3162) The `--gas` flag now takes `auto` instead of `simulate` in order to trigger a simulation of the tx before the actual execution. -* Gaia REST API - * [\#3176](https://github.com/cosmos/cosmos-sdk/issues/3176) `tx/sign` endpoint now expects `BaseReq` fields as nested object. * SDK - * [stake] \#2513 Validator power type from Dec -> Int - * [stake] \#3233 key and value now contain duplicate fields to simplify code + * [staking] \#2513 Validator power type from Dec -> Int + * [staking] \#3233 key and value now contain duplicate fields to simplify code * [\#3064](https://github.com/cosmos/cosmos-sdk/issues/3064) Sanitize `sdk.Coin` denom. Coins denoms are now case insensitive, i.e. 100fooToken equals to 100FOOTOKEN. * [\#3195](https://github.com/cosmos/cosmos-sdk/issues/3195) Allows custom configuration for syncable strategy * [\#3242](https://github.com/cosmos/cosmos-sdk/issues/3242) Fix infinite gas meter utilization during aborted ante handler executions. + * [\#2222] [x/staking] `/stake` -> `/staking` module rename * Tendermint * \#3279 Upgrade to Tendermint 0.28.0-dev0 @@ -45,7 +47,7 @@ FEATURES `query gov proposer [proposal-id]` to query for a proposal's proposer. * Gaia - * [\#2182] [x/stake] Added querier for querying a single redelegation + * [\#2182] [x/staking] Added querier for querying a single redelegation * SDK * \#2996 Update the `AccountKeeper` to contain params used in the context of diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index 1a9cdf2366..bb099711fd 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -28,8 +28,8 @@ import ( authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/slashing" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) const ( @@ -41,7 +41,7 @@ const ( altPw = "12345678901" ) -var fees = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)} +var fees = sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)} func init() { mintkey.BcryptSecurityParameter = 1 @@ -176,14 +176,14 @@ func TestCoinSend(t *testing.T) { coins := acc.GetCoins() expectedBalance := initialBalance[0].Minus(fees[0]) - require.Equal(t, stakeTypes.DefaultBondDenom, coins[0].Denom) + require.Equal(t, stakingTypes.DefaultBondDenom, coins[0].Denom) require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount) expectedBalance = coins[0] // query receiver acc2 := getAccount(t, port, receiveAddr) coins2 := acc2.GetCoins() - require.Equal(t, stakeTypes.DefaultBondDenom, coins2[0].Denom) + require.Equal(t, stakingTypes.DefaultBondDenom, coins2[0].Denom) require.Equal(t, int64(1), coins2[0].Amount.Int64()) // test failure with too little gas @@ -217,7 +217,7 @@ func TestCoinSend(t *testing.T) { require.Nil(t, json.Unmarshal([]byte(body), &responseBody)) acc = getAccount(t, port, addr) - require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom)) res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, fmt.Sprintf("%d", responseBody.GasEstimate), 1.0, false, false, fees) @@ -232,7 +232,7 @@ func TestCoinSend(t *testing.T) { acc = getAccount(t, port, addr) expectedBalance = expectedBalance.Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(1), acc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(1), acc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom)) } func TestCoinSendGenerateSignAndBroadcast(t *testing.T) { @@ -338,14 +338,14 @@ func TestPoolParamsQuery(t *testing.T) { cleanup, _, _, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr}) defer cleanup() - defaultParams := stake.DefaultParams() + defaultParams := staking.DefaultParams() - params := getStakeParams(t, port) + params := getStakingParams(t, port) require.True(t, defaultParams.Equal(params)) - pool := getStakePool(t, port) + pool := getStakingPool(t, port) - initialPool := stake.InitialPool() + initialPool := staking.InitialPool() initialPool.LooseTokens = initialPool.LooseTokens.Add(sdk.NewInt(100)) initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewInt(100)) // Delegate tx on GaiaAppGenState initialPool.LooseTokens = initialPool.LooseTokens.Add(sdk.NewInt(50)) // freeFermionsAcc = 50 on GaiaAppGenState @@ -418,7 +418,7 @@ func TestBonding(t *testing.T) { acc = getAccount(t, port, addr) coins := acc.GetCoins() expectedBalance := initialBalance[0].Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(60), coins.AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(60), coins.AmountOf(stakingTypes.DefaultBondDenom)) expectedBalance = coins[0] // query delegation @@ -453,8 +453,8 @@ func TestBonding(t *testing.T) { coins = acc.GetCoins() expectedBalance = expectedBalance.Minus(fees[0]) require.True(t, - expectedBalance.Amount.LT(coins.AmountOf(stakeTypes.DefaultBondDenom)) || - expectedBalance.Amount.Equal(coins.AmountOf(stakeTypes.DefaultBondDenom)), + expectedBalance.Amount.LT(coins.AmountOf(stakingTypes.DefaultBondDenom)) || + expectedBalance.Amount.Equal(coins.AmountOf(stakingTypes.DefaultBondDenom)), "should get tokens back from automatic withdrawal after an unbonding delegation", ) expectedBalance = coins[0] @@ -481,8 +481,8 @@ func TestBonding(t *testing.T) { acc = getAccount(t, port, addr) expectedBalance = expectedBalance.Minus(fees[0]) require.True(t, - expectedBalance.Amount.LT(coins.AmountOf(stakeTypes.DefaultBondDenom)) || - expectedBalance.Amount.Equal(coins.AmountOf(stakeTypes.DefaultBondDenom)), + expectedBalance.Amount.LT(coins.AmountOf(stakingTypes.DefaultBondDenom)) || + expectedBalance.Amount.Equal(coins.AmountOf(stakingTypes.DefaultBondDenom)), "should get tokens back from automatic withdrawal after an unbonding delegation", ) @@ -559,7 +559,7 @@ func TestSubmitProposal(t *testing.T) { // verify balance acc = getAccount(t, port, addr) expectedBalance := initialBalance[0].Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(5), acc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(5), acc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom)) // query proposal proposal := getProposal(t, port, proposalID) @@ -593,7 +593,7 @@ func TestDeposit(t *testing.T) { acc = getAccount(t, port, addr) coins := acc.GetCoins() expectedBalance := initialBalance[0].Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(5), coins.AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(5), coins.AmountOf(stakingTypes.DefaultBondDenom)) expectedBalance = coins[0] // query proposal @@ -607,7 +607,7 @@ func TestDeposit(t *testing.T) { // verify balance after deposit and fee acc = getAccount(t, port, addr) expectedBalance = expectedBalance.Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(5), acc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(5), acc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom)) // query tx txs := getTransactions(t, port, fmt.Sprintf("action=deposit&depositor=%s", addr)) @@ -616,11 +616,11 @@ func TestDeposit(t *testing.T) { // query proposal proposal = getProposal(t, port, proposalID) - require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)})) + require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)})) // query deposit deposit := getDeposit(t, port, proposalID, addr) - require.True(t, deposit.Amount.IsEqual(sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)})) + require.True(t, deposit.Amount.IsEqual(sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)})) } func TestVote(t *testing.T) { @@ -646,7 +646,7 @@ func TestVote(t *testing.T) { acc = getAccount(t, port, addr) coins := acc.GetCoins() expectedBalance := initialBalance[0].Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(10), coins.AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(10), coins.AmountOf(stakingTypes.DefaultBondDenom)) expectedBalance = coins[0] // query proposal @@ -662,7 +662,7 @@ func TestVote(t *testing.T) { acc = getAccount(t, port, addr) coins = acc.GetCoins() expectedBalance = expectedBalance.Minus(fees[0]) - require.Equal(t, expectedBalance.Amount, coins.AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount, coins.AmountOf(stakingTypes.DefaultBondDenom)) expectedBalance = coins[0] // query tx @@ -685,7 +685,7 @@ func TestVote(t *testing.T) { acc = getAccount(t, port, addr) coins = acc.GetCoins() expectedBalance = expectedBalance.Minus(fees[0]) - require.Equal(t, expectedBalance.Amount.SubRaw(60), coins.AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount.SubRaw(60), coins.AmountOf(stakingTypes.DefaultBondDenom)) expectedBalance = coins[0] tally = getTally(t, port, proposalID) @@ -698,7 +698,7 @@ func TestVote(t *testing.T) { // verify balance acc = getAccount(t, port, addr) expectedBalance = expectedBalance.Minus(fees[0]) - require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom)) + require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom)) tally = getTally(t, port, proposalID) require.Equal(t, sdk.ZeroDec(), tally.Yes, "tally should be 0 the user changed the option") @@ -727,7 +727,7 @@ func TestProposalsQuery(t *testing.T) { defer cleanup() depositParam := getDepositParam(t, port) - halfMinDeposit := depositParam.MinDeposit.AmountOf(stakeTypes.DefaultBondDenom).Int64() / 2 + halfMinDeposit := depositParam.MinDeposit.AmountOf(stakingTypes.DefaultBondDenom).Int64() / 2 getVotingParam(t, port) getTallyingParam(t, port) diff --git a/client/lcd/swagger-ui/swagger.yaml b/client/lcd/swagger-ui/swagger.yaml index 3696c6c5ac..a52f80c8be 100644 --- a/client/lcd/swagger-ui/swagger.yaml +++ b/client/lcd/swagger-ui/swagger.yaml @@ -611,7 +611,7 @@ paths: description: No content about this account address 500: description: Server internel error - /stake/delegators/{delegatorAddr}/delegations: + /staking/delegators/{delegatorAddr}/delegations: parameters: - in: path name: delegatorAddr @@ -669,7 +669,7 @@ paths: description: Key password is wrong 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/delegations/{validatorAddr}: + /staking/delegators/{delegatorAddr}/delegations/{validatorAddr}: parameters: - in: path name: delegatorAddr @@ -696,7 +696,7 @@ paths: description: Invalid delegator address or validator address 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/unbonding_delegations: + /staking/delegators/{delegatorAddr}/unbonding_delegations: parameters: - in: path name: delegatorAddr @@ -765,7 +765,7 @@ paths: description: Key password is wrong 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}: + /staking/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}: parameters: - in: path name: delegatorAddr @@ -794,7 +794,7 @@ paths: description: Invalid delegator address or validator address 500: description: Internal Server Error - /stake/redelegations: + /staking/redelegations: parameters: - in: query name: delegator @@ -826,7 +826,7 @@ paths: $ref: "#/definitions/Redelegation" 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/redelegations: + /staking/delegators/{delegatorAddr}/redelegations: parameters: - in: path name: delegatorAddr @@ -880,7 +880,7 @@ paths: description: Key password is wrong 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/validators: + /staking/delegators/{delegatorAddr}/validators: parameters: - in: path name: delegatorAddr @@ -904,7 +904,7 @@ paths: description: Invalid delegator address 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/validators/{validatorAddr}: + /staking/delegators/{delegatorAddr}/validators/{validatorAddr}: parameters: - in: path name: delegatorAddr @@ -931,7 +931,7 @@ paths: description: Invalid delegator address or validator address 500: description: Internal Server Error - /stake/delegators/{delegatorAddr}/txs: + /staking/delegators/{delegatorAddr}/txs: parameters: - in: path name: delegatorAddr @@ -957,7 +957,7 @@ paths: description: Invalid delegator address 500: description: Internal Server Error - /stake/validators: + /staking/validators: get: summary: Get all validator candidates tags: @@ -973,7 +973,7 @@ paths: $ref: "#/definitions/Validator" 500: description: Internal Server Error - /stake/validators/{validatorAddr}: + /staking/validators/{validatorAddr}: parameters: - in: path name: validatorAddr @@ -995,7 +995,7 @@ paths: description: Invalid validator address 500: description: Internal Server Error - /stake/validators/{validatorAddr}/delegations: + /staking/validators/{validatorAddr}/delegations: parameters: - in: path name: validatorAddr @@ -1019,7 +1019,7 @@ paths: description: Invalid validator address 500: description: Internal Server Error - /stake/validators/{validatorAddr}/unbonding_delegations: + /staking/validators/{validatorAddr}/unbonding_delegations: parameters: - in: path name: validatorAddr @@ -1043,7 +1043,7 @@ paths: description: Invalid validator address 500: description: Internal Server Error - /stake/pool: + /staking/pool: get: summary: Get the current state of the staking pool tags: @@ -1070,7 +1070,7 @@ paths: type: string 500: description: Internal Server Error - /stake/parameters: + /staking/parameters: get: summary: Get the current staking parameter values tags: diff --git a/client/lcd/test_helpers.go b/client/lcd/test_helpers.go index d5af088249..428989ffdd 100644 --- a/client/lcd/test_helpers.go +++ b/client/lcd/test_helpers.go @@ -22,7 +22,7 @@ import ( authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/slashing" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/keys" @@ -37,7 +37,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" "github.com/spf13/viper" "github.com/stretchr/testify/require" @@ -62,7 +62,7 @@ import ( bankRest "github.com/cosmos/cosmos-sdk/x/bank/client/rest" govRest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" slashingRest "github.com/cosmos/cosmos-sdk/x/slashing/client/rest" - stakeRest "github.com/cosmos/cosmos-sdk/x/stake/client/rest" + stakingRest "github.com/cosmos/cosmos-sdk/x/staking/client/rest" ) // makePathname creates a unique pathname for each test. It will panic if it @@ -253,12 +253,12 @@ func InitializeTestLCD( pubKey = ed25519.GenPrivKey().PubKey() delegation = 1 } - msg := stake.NewMsgCreateValidator( + msg := staking.NewMsgCreateValidator( sdk.ValAddress(operAddr), pubKey, - sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(int64(delegation))), - stake.Description{Moniker: fmt.Sprintf("validator-%d", i+1)}, - stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + sdk.NewCoin(stakingTypes.DefaultBondDenom, sdk.NewInt(int64(delegation))), + staking.Description{Moniker: fmt.Sprintf("validator-%d", i+1)}, + staking.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), ) stdSignMsg := txbuilder.StdSignMsg{ ChainID: genDoc.ChainID, @@ -274,7 +274,7 @@ func InitializeTestLCD( valOperAddrs = append(valOperAddrs, sdk.ValAddress(operAddr)) accAuth := auth.NewBaseAccountWithAddress(sdk.AccAddress(operAddr)) - accAuth.Coins = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 150)} + accAuth.Coins = sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 150)} accs = append(accs, gapp.NewGenesisAccount(&accAuth)) } @@ -288,10 +288,10 @@ func InitializeTestLCD( // add some tokens to init accounts for _, addr := range initAddrs { accAuth := auth.NewBaseAccountWithAddress(addr) - accAuth.Coins = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 100)} + accAuth.Coins = sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 100)} acc := gapp.NewGenesisAccount(&accAuth) genesisState.Accounts = append(genesisState.Accounts, acc) - genesisState.StakeData.Pool.LooseTokens = genesisState.StakeData.Pool.LooseTokens.Add(sdk.NewInt(100)) + genesisState.StakingData.Pool.LooseTokens = genesisState.StakingData.Pool.LooseTokens.Add(sdk.NewInt(100)) } appState, err := codec.MarshalJSONIndent(cdc, genesisState) @@ -390,7 +390,7 @@ func registerRoutes(rs *RestServer) { tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc) authRest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, auth.StoreKey) bankRest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) - stakeRest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) + stakingRest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) slashingRest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) govRest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc) } @@ -709,7 +709,7 @@ func doTransferWithGas(t *testing.T, port, seed, name, memo, password string, ad ) sr := sendReq{ - Amount: sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 1)}, + Amount: sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 1)}, BaseReq: baseReq, } @@ -729,7 +729,7 @@ type sendReq struct { // ICS 21 - Stake // ---------------------------------------------------------------------- -// POST /stake/delegators/{delegatorAddr}/delegations Submit delegation +// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation func doDelegate(t *testing.T, port, name, password string, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount int64, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { acc := getAccount(t, port, delAddr) @@ -741,11 +741,11 @@ func doDelegate(t *testing.T, port, name, password string, BaseReq: baseReq, DelegatorAddr: delAddr, ValidatorAddr: valAddr, - Delegation: sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, amount), + Delegation: sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, amount), } req, err := cdc.MarshalJSON(msg) require.NoError(t, err) - res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/delegations", delAddr.String()), req) + res, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/delegations", delAddr.String()), req) require.Equal(t, http.StatusOK, res.StatusCode, body) var result ctypes.ResultBroadcastTxCommit @@ -762,7 +762,7 @@ type msgDelegationsInput struct { Delegation sdk.Coin `json:"delegation"` } -// POST /stake/delegators/{delegatorAddr}/delegations Submit delegation +// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation func doBeginUnbonding(t *testing.T, port, name, password string, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount int64, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { @@ -780,7 +780,7 @@ func doBeginUnbonding(t *testing.T, port, name, password string, req, err := cdc.MarshalJSON(msg) require.NoError(t, err) - res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/unbonding_delegations", delAddr), req) + res, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/unbonding_delegations", delAddr), req) require.Equal(t, http.StatusOK, res.StatusCode, body) var result ctypes.ResultBroadcastTxCommit @@ -797,7 +797,7 @@ type msgBeginUnbondingInput struct { SharesAmount sdk.Dec `json:"shares"` } -// POST /stake/delegators/{delegatorAddr}/delegations Submit delegation +// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation func doBeginRedelegation(t *testing.T, port, name, password string, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount int64, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { @@ -818,7 +818,7 @@ func doBeginRedelegation(t *testing.T, port, name, password string, req, err := cdc.MarshalJSON(msg) require.NoError(t, err) - res, body := Request(t, port, "POST", fmt.Sprintf("/stake/delegators/%s/redelegations", delAddr), req) + res, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/redelegations", delAddr), req) require.Equal(t, http.StatusOK, res.StatusCode, body) var result ctypes.ResultBroadcastTxCommit @@ -836,12 +836,12 @@ type msgBeginRedelegateInput struct { SharesAmount sdk.Dec `json:"shares"` } -// GET /stake/delegators/{delegatorAddr}/delegations Get all delegations from a delegator -func getDelegatorDelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress) []stake.Delegation { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/delegations", delegatorAddr), nil) +// GET /staking/delegators/{delegatorAddr}/delegations Get all delegations from a delegator +func getDelegatorDelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress) []staking.Delegation { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/delegations", delegatorAddr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var dels []stake.Delegation + var dels []staking.Delegation err := cdc.UnmarshalJSON([]byte(body), &dels) require.Nil(t, err) @@ -849,12 +849,12 @@ func getDelegatorDelegations(t *testing.T, port string, delegatorAddr sdk.AccAdd return dels } -// GET /stake/delegators/{delegatorAddr}/unbonding_delegations Get all unbonding delegations from a delegator -func getDelegatorUnbondingDelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress) []stake.UnbondingDelegation { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/unbonding_delegations", delegatorAddr), nil) +// GET /staking/delegators/{delegatorAddr}/unbonding_delegations Get all unbonding delegations from a delegator +func getDelegatorUnbondingDelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress) []staking.UnbondingDelegation { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/unbonding_delegations", delegatorAddr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var ubds []stake.UnbondingDelegation + var ubds []staking.UnbondingDelegation err := cdc.UnmarshalJSON([]byte(body), &ubds) require.Nil(t, err) @@ -862,11 +862,11 @@ func getDelegatorUnbondingDelegations(t *testing.T, port string, delegatorAddr s return ubds } -// GET /stake/redelegations?delegator=0xdeadbeef&validator_from=0xdeadbeef&validator_to=0xdeadbeef& Get redelegations filters by params passed in -func getRedelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress, srcValidatorAddr sdk.ValAddress, dstValidatorAddr sdk.ValAddress) []stake.Redelegation { +// GET /staking/redelegations?delegator=0xdeadbeef&validator_from=0xdeadbeef&validator_to=0xdeadbeef& Get redelegations filters by params passed in +func getRedelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress, srcValidatorAddr sdk.ValAddress, dstValidatorAddr sdk.ValAddress) []staking.Redelegation { var res *http.Response var body string - endpoint := "/stake/redelegations?" + endpoint := "/staking/redelegations?" if !delegatorAddr.Empty() { endpoint += fmt.Sprintf("delegator=%s&", delegatorAddr) } @@ -878,18 +878,18 @@ func getRedelegations(t *testing.T, port string, delegatorAddr sdk.AccAddress, s } res, body = Request(t, port, "GET", endpoint, nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var redels []stake.Redelegation + var redels []staking.Redelegation err := cdc.UnmarshalJSON([]byte(body), &redels) require.Nil(t, err) return redels } -// GET /stake/delegators/{delegatorAddr}/validators Query all validators that a delegator is bonded to -func getDelegatorValidators(t *testing.T, port string, delegatorAddr sdk.AccAddress) []stake.Validator { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/validators", delegatorAddr), nil) +// GET /staking/delegators/{delegatorAddr}/validators Query all validators that a delegator is bonded to +func getDelegatorValidators(t *testing.T, port string, delegatorAddr sdk.AccAddress) []staking.Validator { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/validators", delegatorAddr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var bondedValidators []stake.Validator + var bondedValidators []staking.Validator err := cdc.UnmarshalJSON([]byte(body), &bondedValidators) require.Nil(t, err) @@ -897,27 +897,27 @@ func getDelegatorValidators(t *testing.T, port string, delegatorAddr sdk.AccAddr return bondedValidators } -// GET /stake/delegators/{delegatorAddr}/validators/{validatorAddr} Query a validator that a delegator is bonded to -func getDelegatorValidator(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) stake.Validator { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/validators/%s", delegatorAddr, validatorAddr), nil) +// GET /staking/delegators/{delegatorAddr}/validators/{validatorAddr} Query a validator that a delegator is bonded to +func getDelegatorValidator(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) staking.Validator { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/validators/%s", delegatorAddr, validatorAddr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var bondedValidator stake.Validator + var bondedValidator staking.Validator err := cdc.UnmarshalJSON([]byte(body), &bondedValidator) require.Nil(t, err) return bondedValidator } -// GET /stake/delegators/{delegatorAddr}/txs Get all staking txs (i.e msgs) from a delegator +// GET /staking/delegators/{delegatorAddr}/txs Get all staking txs (i.e msgs) from a delegator func getBondingTxs(t *testing.T, port string, delegatorAddr sdk.AccAddress, query string) []tx.Info { var res *http.Response var body string if len(query) > 0 { - res, body = Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/txs?type=%s", delegatorAddr, query), nil) + res, body = Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/txs?type=%s", delegatorAddr, query), nil) } else { - res, body = Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/txs", delegatorAddr), nil) + res, body = Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/txs", delegatorAddr), nil) } require.Equal(t, http.StatusOK, res.StatusCode, body) @@ -929,95 +929,95 @@ func getBondingTxs(t *testing.T, port string, delegatorAddr sdk.AccAddress, quer return txs } -// GET /stake/delegators/{delegatorAddr}/delegations/{validatorAddr} Query the current delegation between a delegator and a validator -func getDelegation(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) stake.Delegation { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/delegations/%s", delegatorAddr, validatorAddr), nil) +// GET /staking/delegators/{delegatorAddr}/delegations/{validatorAddr} Query the current delegation between a delegator and a validator +func getDelegation(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) staking.Delegation { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/delegations/%s", delegatorAddr, validatorAddr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var bond stake.Delegation + var bond staking.Delegation err := cdc.UnmarshalJSON([]byte(body), &bond) require.Nil(t, err) return bond } -// GET /stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr} Query all unbonding delegations between a delegator and a validator -func getUndelegation(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) stake.UnbondingDelegation { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/delegators/%s/unbonding_delegations/%s", delegatorAddr, validatorAddr), nil) +// GET /staking/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr} Query all unbonding delegations between a delegator and a validator +func getUndelegation(t *testing.T, port string, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) staking.UnbondingDelegation { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/delegators/%s/unbonding_delegations/%s", delegatorAddr, validatorAddr), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var unbond stake.UnbondingDelegation + var unbond staking.UnbondingDelegation err := cdc.UnmarshalJSON([]byte(body), &unbond) require.Nil(t, err) return unbond } -// GET /stake/validators Get all validator candidates -func getValidators(t *testing.T, port string) []stake.Validator { - res, body := Request(t, port, "GET", "/stake/validators", nil) +// GET /staking/validators Get all validator candidates +func getValidators(t *testing.T, port string) []staking.Validator { + res, body := Request(t, port, "GET", "/staking/validators", nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var validators []stake.Validator + var validators []staking.Validator err := cdc.UnmarshalJSON([]byte(body), &validators) require.Nil(t, err) return validators } -// GET /stake/validators/{validatorAddr} Query the information from a single validator -func getValidator(t *testing.T, port string, validatorAddr sdk.ValAddress) stake.Validator { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/validators/%s", validatorAddr.String()), nil) +// GET /staking/validators/{validatorAddr} Query the information from a single validator +func getValidator(t *testing.T, port string, validatorAddr sdk.ValAddress) staking.Validator { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/validators/%s", validatorAddr.String()), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var validator stake.Validator + var validator staking.Validator err := cdc.UnmarshalJSON([]byte(body), &validator) require.Nil(t, err) return validator } -// GET /stake/validators/{validatorAddr}/delegations Get all delegations from a validator -func getValidatorDelegations(t *testing.T, port string, validatorAddr sdk.ValAddress) []stake.Delegation { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/validators/%s/delegations", validatorAddr.String()), nil) +// GET /staking/validators/{validatorAddr}/delegations Get all delegations from a validator +func getValidatorDelegations(t *testing.T, port string, validatorAddr sdk.ValAddress) []staking.Delegation { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/validators/%s/delegations", validatorAddr.String()), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var delegations []stake.Delegation + var delegations []staking.Delegation err := cdc.UnmarshalJSON([]byte(body), &delegations) require.Nil(t, err) return delegations } -// GET /stake/validators/{validatorAddr}/unbonding_delegations Get all unbonding delegations from a validator -func getValidatorUnbondingDelegations(t *testing.T, port string, validatorAddr sdk.ValAddress) []stake.UnbondingDelegation { - res, body := Request(t, port, "GET", fmt.Sprintf("/stake/validators/%s/unbonding_delegations", validatorAddr.String()), nil) +// GET /staking/validators/{validatorAddr}/unbonding_delegations Get all unbonding delegations from a validator +func getValidatorUnbondingDelegations(t *testing.T, port string, validatorAddr sdk.ValAddress) []staking.UnbondingDelegation { + res, body := Request(t, port, "GET", fmt.Sprintf("/staking/validators/%s/unbonding_delegations", validatorAddr.String()), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var ubds []stake.UnbondingDelegation + var ubds []staking.UnbondingDelegation err := cdc.UnmarshalJSON([]byte(body), &ubds) require.Nil(t, err) return ubds } -// GET /stake/pool Get the current state of the staking pool -func getStakePool(t *testing.T, port string) stake.Pool { - res, body := Request(t, port, "GET", "/stake/pool", nil) +// GET /staking/pool Get the current state of the staking pool +func getStakingPool(t *testing.T, port string) staking.Pool { + res, body := Request(t, port, "GET", "/staking/pool", nil) require.Equal(t, http.StatusOK, res.StatusCode, body) require.NotNil(t, body) - var pool stake.Pool + var pool staking.Pool err := cdc.UnmarshalJSON([]byte(body), &pool) require.Nil(t, err) return pool } -// GET /stake/parameters Get the current staking parameter values -func getStakeParams(t *testing.T, port string) stake.Params { - res, body := Request(t, port, "GET", "/stake/parameters", nil) +// GET /staking/parameters Get the current staking parameter values +func getStakingParams(t *testing.T, port string) staking.Params { + res, body := Request(t, port, "GET", "/staking/parameters", nil) require.Equal(t, http.StatusOK, res.StatusCode, body) - var params stake.Params + var params staking.Params err := cdc.UnmarshalJSON([]byte(body), ¶ms) require.Nil(t, err) return params @@ -1039,7 +1039,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA Description: "test", ProposalType: "Text", Proposer: proposerAddr, - InitialDeposit: sdk.Coins{sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(amount))}, + InitialDeposit: sdk.Coins{sdk.NewCoin(stakingTypes.DefaultBondDenom, sdk.NewInt(amount))}, BaseReq: baseReq, } @@ -1132,7 +1132,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk dr := depositReq{ Depositor: proposerAddr, - Amount: sdk.Coins{sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(amount))}, + Amount: sdk.Coins{sdk.NewCoin(stakingTypes.DefaultBondDenom, sdk.NewInt(amount))}, BaseReq: baseReq, } diff --git a/client/utils/rest.go b/client/utils/rest.go index 2cdecab64c..09663291e5 100644 --- a/client/utils/rest.go +++ b/client/utils/rest.go @@ -203,7 +203,7 @@ func ReadRESTReq(w http.ResponseWriter, r *http.Request, cdc *codec.Codec, req i // supplied messages. Finally, it broadcasts the signed transaction to a node. // // NOTE: Also see CompleteAndBroadcastTxCli. -// NOTE: Also see x/stake/client/rest/tx.go delegationsRequestHandlerFn. +// NOTE: Also see x/staking/client/rest/tx.go delegationsRequestHandlerFn. func CompleteAndBroadcastTxREST(w http.ResponseWriter, r *http.Request, cliCtx context.CLIContext, baseReq BaseReq, msgs []sdk.Msg, cdc *codec.Codec) { gasAdjustment, ok := ParseFloat64OrReturnBadRequest(w, baseReq.GasAdjustment, client.DefaultGasAdjustment) if !ok { diff --git a/cmd/gaia/app/app.go b/cmd/gaia/app/app.go index d14a855445..4e8b5c40af 100644 --- a/cmd/gaia/app/app.go +++ b/cmd/gaia/app/app.go @@ -21,7 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/slashing" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) const ( @@ -44,8 +44,8 @@ type GaiaApp struct { // keys to access the substores keyMain *sdk.KVStoreKey keyAccount *sdk.KVStoreKey - keyStake *sdk.KVStoreKey - tkeyStake *sdk.TransientStoreKey + keyStaking *sdk.KVStoreKey + tkeyStaking *sdk.TransientStoreKey keySlashing *sdk.KVStoreKey keyMint *sdk.KVStoreKey keyDistr *sdk.KVStoreKey @@ -59,7 +59,7 @@ type GaiaApp struct { accountKeeper auth.AccountKeeper feeCollectionKeeper auth.FeeCollectionKeeper bankKeeper bank.Keeper - stakeKeeper stake.Keeper + stakingKeeper staking.Keeper slashingKeeper slashing.Keeper mintKeeper mint.Keeper distrKeeper distr.Keeper @@ -79,8 +79,8 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b cdc: cdc, keyMain: sdk.NewKVStoreKey(bam.MainStoreKey), keyAccount: sdk.NewKVStoreKey(auth.StoreKey), - keyStake: sdk.NewKVStoreKey(stake.StoreKey), - tkeyStake: sdk.NewTransientStoreKey(stake.TStoreKey), + keyStaking: sdk.NewKVStoreKey(staking.StoreKey), + tkeyStaking: sdk.NewTransientStoreKey(staking.TStoreKey), keyMint: sdk.NewKVStoreKey(mint.StoreKey), keyDistr: sdk.NewKVStoreKey(distr.StoreKey), tkeyDistr: sdk.NewTransientStoreKey(distr.TStoreKey), @@ -107,47 +107,47 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b app.cdc, app.keyFeeCollection, ) - stakeKeeper := stake.NewKeeper( + stakingKeeper := staking.NewKeeper( app.cdc, - app.keyStake, app.tkeyStake, - app.bankKeeper, app.paramsKeeper.Subspace(stake.DefaultParamspace), - stake.DefaultCodespace, + app.keyStaking, app.tkeyStaking, + app.bankKeeper, app.paramsKeeper.Subspace(staking.DefaultParamspace), + staking.DefaultCodespace, ) app.mintKeeper = mint.NewKeeper(app.cdc, app.keyMint, app.paramsKeeper.Subspace(mint.DefaultParamspace), - &stakeKeeper, app.feeCollectionKeeper, + &stakingKeeper, app.feeCollectionKeeper, ) app.distrKeeper = distr.NewKeeper( app.cdc, app.keyDistr, app.paramsKeeper.Subspace(distr.DefaultParamspace), - app.bankKeeper, &stakeKeeper, app.feeCollectionKeeper, + app.bankKeeper, &stakingKeeper, app.feeCollectionKeeper, distr.DefaultCodespace, ) app.slashingKeeper = slashing.NewKeeper( app.cdc, app.keySlashing, - &stakeKeeper, app.paramsKeeper.Subspace(slashing.DefaultParamspace), + &stakingKeeper, app.paramsKeeper.Subspace(slashing.DefaultParamspace), slashing.DefaultCodespace, ) app.govKeeper = gov.NewKeeper( app.cdc, app.keyGov, - app.paramsKeeper, app.paramsKeeper.Subspace(gov.DefaultParamspace), app.bankKeeper, &stakeKeeper, + app.paramsKeeper, app.paramsKeeper.Subspace(gov.DefaultParamspace), app.bankKeeper, &stakingKeeper, gov.DefaultCodespace, ) // register the staking hooks - // NOTE: The stakeKeeper above is passed by reference, so that it can be + // NOTE: The stakingKeeper above is passed by reference, so that it can be // modified like below: - app.stakeKeeper = *stakeKeeper.SetHooks( + app.stakingKeeper = *stakingKeeper.SetHooks( NewStakingHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()), ) // register message routes app.Router(). AddRoute(bank.RouterKey, bank.NewHandler(app.bankKeeper)). - AddRoute(stake.RouterKey, stake.NewHandler(app.stakeKeeper)). + AddRoute(staking.RouterKey, staking.NewHandler(app.stakingKeeper)). AddRoute(distr.RouterKey, distr.NewHandler(app.distrKeeper)). AddRoute(slashing.RouterKey, slashing.NewHandler(app.slashingKeeper)). AddRoute(gov.RouterKey, gov.NewHandler(app.govKeeper)) @@ -155,15 +155,15 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b app.QueryRouter(). AddRoute(gov.QuerierRoute, gov.NewQuerier(app.govKeeper)). AddRoute(slashing.QuerierRoute, slashing.NewQuerier(app.slashingKeeper, app.cdc)). - AddRoute(stake.QuerierRoute, stake.NewQuerier(app.stakeKeeper, app.cdc)) + AddRoute(staking.QuerierRoute, staking.NewQuerier(app.stakingKeeper, app.cdc)) // initialize BaseApp - app.MountStores(app.keyMain, app.keyAccount, app.keyStake, app.keyMint, app.keyDistr, + app.MountStores(app.keyMain, app.keyAccount, app.keyStaking, app.keyMint, app.keyDistr, app.keySlashing, app.keyGov, app.keyFeeCollection, app.keyParams) app.SetInitChainer(app.initChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper, app.feeCollectionKeeper)) - app.MountStoresTransient(app.tkeyParams, app.tkeyStake, app.tkeyDistr) + app.MountStoresTransient(app.tkeyParams, app.tkeyStaking, app.tkeyDistr) app.SetEndBlocker(app.EndBlocker) if loadLatest { @@ -180,7 +180,7 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b func MakeCodec() *codec.Codec { var cdc = codec.New() bank.RegisterCodec(cdc) - stake.RegisterCodec(cdc) + staking.RegisterCodec(cdc) distr.RegisterCodec(cdc) slashing.RegisterCodec(cdc) gov.RegisterCodec(cdc) @@ -214,7 +214,7 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab // nolint: unparam func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { tags := gov.EndBlocker(ctx, app.govKeeper) - validatorUpdates, endBlockerTags := stake.EndBlocker(ctx, app.stakeKeeper) + validatorUpdates, endBlockerTags := staking.EndBlocker(ctx, app.stakingKeeper) tags = append(tags, endBlockerTags...) app.assertRuntimeInvariants() @@ -238,15 +238,15 @@ func (app *GaiaApp) initFromGenesisState(ctx sdk.Context, genesisState GenesisSt app.accountKeeper.SetAccount(ctx, acc) } - // load the initial stake information - validators, err := stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData) + // load the initial staking information + validators, err := staking.InitGenesis(ctx, app.stakingKeeper, genesisState.StakingData) if err != nil { panic(err) // TODO find a way to do this w/o panics } // initialize module-specific stores auth.InitGenesis(ctx, app.accountKeeper, app.feeCollectionKeeper, genesisState.AuthData) - slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.SlashingData, genesisState.StakeData) + slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.SlashingData, genesisState.StakingData) gov.InitGenesis(ctx, app.govKeeper, genesisState.GovData) mint.InitGenesis(ctx, app.mintKeeper, genesisState.MintData) distr.InitGenesis(ctx, app.distrKeeper, genesisState.DistrData) @@ -271,7 +271,7 @@ func (app *GaiaApp) initFromGenesisState(ctx sdk.Context, genesisState GenesisSt } } - validators = app.stakeKeeper.ApplyAndReturnValidatorSetUpdates(ctx) + validators = app.stakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) } return validators } diff --git a/cmd/gaia/app/app_test.go b/cmd/gaia/app/app_test.go index 87b2ec2a95..5f2b5b9687 100644 --- a/cmd/gaia/app/app_test.go +++ b/cmd/gaia/app/app_test.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/slashing" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" abci "github.com/tendermint/tendermint/abci/types" ) @@ -28,7 +28,7 @@ func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error { genesisState := NewGenesisState( genaccs, auth.DefaultGenesisState(), - stake.DefaultGenesisState(), + staking.DefaultGenesisState(), mint.DefaultGenesisState(), distr.DefaultGenesisState(), gov.DefaultGenesisState(), diff --git a/cmd/gaia/app/export.go b/cmd/gaia/app/export.go index f8968ceec6..05e8e29a34 100644 --- a/cmd/gaia/app/export.go +++ b/cmd/gaia/app/export.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/slashing" - stake "github.com/cosmos/cosmos-sdk/x/stake" + staking "github.com/cosmos/cosmos-sdk/x/staking" ) // export the state of gaia for a genesis file @@ -40,7 +40,7 @@ func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool) ( genState := NewGenesisState( accounts, auth.ExportGenesis(ctx, app.accountKeeper, app.feeCollectionKeeper), - stake.ExportGenesis(ctx, app.stakeKeeper), + staking.ExportGenesis(ctx, app.stakingKeeper), mint.ExportGenesis(ctx, app.mintKeeper), distr.ExportGenesis(ctx, app.distrKeeper), gov.ExportGenesis(ctx, app.govKeeper), @@ -50,7 +50,7 @@ func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool) ( if err != nil { return nil, nil, err } - validators = stake.WriteValidators(ctx, app.stakeKeeper) + validators = staking.WriteValidators(ctx, app.stakingKeeper) return appState, validators, nil } @@ -102,7 +102,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) { if !feePool.TotalValAccum.Accum.IsZero() { panic("unexpected leftover validator accum") } - bondDenom := app.stakeKeeper.GetParams(ctx).BondDenom + bondDenom := app.stakingKeeper.GetParams(ctx).BondDenom if !feePool.ValPool.AmountOf(bondDenom).IsZero() { panic(fmt.Sprintf("unexpected leftover validator pool coins: %v", feePool.ValPool.AmountOf(bondDenom).String())) @@ -112,32 +112,32 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) { feePool.TotalValAccum = distr.NewTotalAccum(0) app.distrKeeper.SetFeePool(ctx, feePool) - /* Handle stake state. */ + /* Handle staking state. */ // iterate through redelegations, reset creation height - app.stakeKeeper.IterateRedelegations(ctx, func(_ int64, red stake.Redelegation) (stop bool) { + app.stakingKeeper.IterateRedelegations(ctx, func(_ int64, red staking.Redelegation) (stop bool) { red.CreationHeight = 0 - app.stakeKeeper.SetRedelegation(ctx, red) + app.stakingKeeper.SetRedelegation(ctx, red) return false }) // iterate through unbonding delegations, reset creation height - app.stakeKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stake.UnbondingDelegation) (stop bool) { + app.stakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd staking.UnbondingDelegation) (stop bool) { ubd.CreationHeight = 0 - app.stakeKeeper.SetUnbondingDelegation(ctx, ubd) + app.stakingKeeper.SetUnbondingDelegation(ctx, ubd) return false }) // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. - store := ctx.KVStore(app.keyStake) - iter := sdk.KVStoreReversePrefixIterator(store, stake.ValidatorsKey) + store := ctx.KVStore(app.keyStaking) + iter := sdk.KVStoreReversePrefixIterator(store, staking.ValidatorsKey) counter := int16(0) var valConsAddrs []sdk.ConsAddress for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.stakeKeeper.GetValidator(ctx, addr) + validator, found := app.stakingKeeper.GetValidator(ctx, addr) if !found { panic("expected validator, not found") } @@ -146,7 +146,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) { validator.UnbondingHeight = 0 valConsAddrs = append(valConsAddrs, validator.ConsAddress()) - app.stakeKeeper.SetValidator(ctx, validator) + app.stakingKeeper.SetValidator(ctx, validator) counter++ } diff --git a/cmd/gaia/app/genesis.go b/cmd/gaia/app/genesis.go index 19cc3faeff..fcfd600621 100644 --- a/cmd/gaia/app/genesis.go +++ b/cmd/gaia/app/genesis.go @@ -19,22 +19,22 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mint" "github.com/cosmos/cosmos-sdk/x/slashing" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( // bonded tokens given to genesis validators/accounts freeFermionVal = int64(100) freeFermionsAcc = sdk.NewInt(150) - bondDenom = stakeTypes.DefaultBondDenom + bondDenom = stakingTypes.DefaultBondDenom ) // State to Unmarshal type GenesisState struct { Accounts []GenesisAccount `json:"accounts"` AuthData auth.GenesisState `json:"auth"` - StakeData stake.GenesisState `json:"stake"` + StakingData staking.GenesisState `json:"staking"` MintData mint.GenesisState `json:"mint"` DistrData distr.GenesisState `json:"distr"` GovData gov.GenesisState `json:"gov"` @@ -43,14 +43,14 @@ type GenesisState struct { } func NewGenesisState(accounts []GenesisAccount, authData auth.GenesisState, - stakeData stake.GenesisState, mintData mint.GenesisState, + stakingData staking.GenesisState, mintData mint.GenesisState, distrData distr.GenesisState, govData gov.GenesisState, slashingData slashing.GenesisState) GenesisState { return GenesisState{ Accounts: accounts, AuthData: authData, - StakeData: stakeData, + StakingData: stakingData, MintData: mintData, DistrData: distrData, GovData: govData, @@ -108,7 +108,7 @@ func GaiaAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []js return genesisState, errors.New("there must be at least one genesis tx") } - stakeData := genesisState.StakeData + stakingData := genesisState.StakingData for i, genTx := range appGenTxs { var tx auth.StdTx if err := cdc.UnmarshalJSON(genTx, &tx); err != nil { @@ -119,7 +119,7 @@ func GaiaAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []js return genesisState, errors.New( "must provide genesis StdTx with exactly 1 CreateValidator message") } - if _, ok := msgs[0].(stake.MsgCreateValidator); !ok { + if _, ok := msgs[0].(staking.MsgCreateValidator); !ok { return genesisState, fmt.Errorf( "Genesis transaction %v does not contain a MsgCreateValidator", i) } @@ -129,12 +129,12 @@ func GaiaAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []js // create the genesis account, give'm few steaks and a buncha token with there name for _, coin := range acc.Coins { if coin.Denom == bondDenom { - stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens. + stakingData.Pool.LooseTokens = stakingData.Pool.LooseTokens. Add(coin.Amount) // increase the supply } } } - genesisState.StakeData = stakeData + genesisState.StakingData = stakingData genesisState.GenTxs = appGenTxs return genesisState, nil } @@ -144,7 +144,7 @@ func NewDefaultGenesisState() GenesisState { return GenesisState{ Accounts: nil, AuthData: auth.DefaultGenesisState(), - StakeData: stake.DefaultGenesisState(), + StakingData: staking.DefaultGenesisState(), MintData: mint.DefaultGenesisState(), DistrData: distr.DefaultGenesisState(), GovData: gov.DefaultGenesisState(), @@ -162,7 +162,7 @@ func GaiaValidateGenesisState(genesisState GenesisState) error { return err } - // skip stakeData validation as genesis is created from txs + // skip stakingData validation as genesis is created from txs if len(genesisState.GenTxs) > 0 { return nil } @@ -170,7 +170,7 @@ func GaiaValidateGenesisState(genesisState GenesisState) error { if err := auth.ValidateGenesis(genesisState.AuthData); err != nil { return err } - if err := stake.ValidateGenesis(genesisState.StakeData); err != nil { + if err := staking.ValidateGenesis(genesisState.StakingData); err != nil { return err } if err := mint.ValidateGenesis(genesisState.MintData); err != nil { @@ -272,7 +272,7 @@ func CollectStdTxs(cdc *codec.Codec, moniker string, genTxsDir string, genDoc tm "each genesis transaction must provide a single genesis message") } - msg := msgs[0].(stake.MsgCreateValidator) + msg := msgs[0].(staking.MsgCreateValidator) // validate delegator and validator addresses and funds against the accounts in the state delAddr := msg.DelegatorAddr.String() valAddr := sdk.AccAddress(msg.ValidatorAddr).String() diff --git a/cmd/gaia/app/genesis_test.go b/cmd/gaia/app/genesis_test.go index df541341d1..90fcb86715 100644 --- a/cmd/gaia/app/genesis_test.go +++ b/cmd/gaia/app/genesis_test.go @@ -13,8 +13,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -32,18 +32,18 @@ var ( func makeGenesisState(t *testing.T, genTxs []auth.StdTx) GenesisState { // start with the default staking genesis state appState := NewDefaultGenesisState() - stakeData := appState.StakeData + stakingData := appState.StakingData genAccs := make([]GenesisAccount, len(genTxs)) for i, genTx := range genTxs { msgs := genTx.GetMsgs() require.Equal(t, 1, len(msgs)) - msg := msgs[0].(stake.MsgCreateValidator) + msg := msgs[0].(staking.MsgCreateValidator) acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddr)) acc.Coins = sdk.Coins{sdk.NewInt64Coin(bondDenom, 150)} genAccs[i] = NewGenesisAccount(&acc) - stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens.Add(sdk.NewInt(150)) // increase the supply + stakingData.Pool.LooseTokens = stakingData.Pool.LooseTokens.Add(sdk.NewInt(150)) // increase the supply } // create the final app state @@ -91,9 +91,9 @@ func TestGaiaAppGenState(t *testing.T) { } func makeMsg(name string, pk crypto.PubKey) auth.StdTx { - desc := stake.NewDescription(name, "", "", "") - comm := stakeTypes.CommissionMsg{} - msg := stake.NewMsgCreateValidator(sdk.ValAddress(pk.Address()), pk, sdk.NewInt64Coin(bondDenom, + desc := staking.NewDescription(name, "", "", "") + comm := stakingTypes.CommissionMsg{} + msg := staking.NewMsgCreateValidator(sdk.ValAddress(pk.Address()), pk, sdk.NewInt64Coin(bondDenom, 50), desc, comm) return auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, nil, "") } @@ -108,18 +108,18 @@ func TestGaiaGenesisValidation(t *testing.T) { require.NotNil(t, err) // Test bonded + jailed validator fails genesisState = makeGenesisState(t, genTxs) - val1 := stakeTypes.NewValidator(addr1, pk1, stakeTypes.Description{Moniker: "test #2"}) + val1 := stakingTypes.NewValidator(addr1, pk1, stakingTypes.Description{Moniker: "test #2"}) val1.Jailed = true val1.Status = sdk.Bonded - genesisState.StakeData.Validators = append(genesisState.StakeData.Validators, val1) + genesisState.StakingData.Validators = append(genesisState.StakingData.Validators, val1) err = GaiaValidateGenesisState(genesisState) require.NotNil(t, err) // Test duplicate validator fails val1.Jailed = false genesisState = makeGenesisState(t, genTxs) - val2 := stakeTypes.NewValidator(addr1, pk1, stakeTypes.Description{Moniker: "test #3"}) - genesisState.StakeData.Validators = append(genesisState.StakeData.Validators, val1) - genesisState.StakeData.Validators = append(genesisState.StakeData.Validators, val2) + val2 := stakingTypes.NewValidator(addr1, pk1, stakingTypes.Description{Moniker: "test #3"}) + genesisState.StakingData.Validators = append(genesisState.StakingData.Validators, val1) + genesisState.StakingData.Validators = append(genesisState.StakingData.Validators, val2) err = GaiaValidateGenesisState(genesisState) require.NotNil(t, err) } diff --git a/cmd/gaia/app/invariants.go b/cmd/gaia/app/invariants.go index 4582457fcb..bc5a7c5f30 100644 --- a/cmd/gaia/app/invariants.go +++ b/cmd/gaia/app/invariants.go @@ -10,16 +10,16 @@ import ( banksim "github.com/cosmos/cosmos-sdk/x/bank/simulation" distrsim "github.com/cosmos/cosmos-sdk/x/distribution/simulation" "github.com/cosmos/cosmos-sdk/x/mock/simulation" - stakesim "github.com/cosmos/cosmos-sdk/x/stake/simulation" + stakingsim "github.com/cosmos/cosmos-sdk/x/staking/simulation" ) func (app *GaiaApp) runtimeInvariants() []simulation.Invariant { return []simulation.Invariant{ banksim.NonnegativeBalanceInvariant(app.accountKeeper), - distrsim.ValAccumInvariants(app.distrKeeper, app.stakeKeeper), - stakesim.SupplyInvariants(app.bankKeeper, app.stakeKeeper, + distrsim.ValAccumInvariants(app.distrKeeper, app.stakingKeeper), + stakingsim.SupplyInvariants(app.bankKeeper, app.stakingKeeper, app.feeCollectionKeeper, app.distrKeeper, app.accountKeeper), - stakesim.NonNegativePowerInvariant(app.stakeKeeper), + stakingsim.NonNegativePowerInvariant(app.stakingKeeper), } } diff --git a/cmd/gaia/app/sim_test.go b/cmd/gaia/app/sim_test.go index 14469a6ce7..ba359a15de 100644 --- a/cmd/gaia/app/sim_test.go +++ b/cmd/gaia/app/sim_test.go @@ -29,9 +29,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/mock/simulation" "github.com/cosmos/cosmos-sdk/x/slashing" slashingsim "github.com/cosmos/cosmos-sdk/x/slashing/simulation" - stake "github.com/cosmos/cosmos-sdk/x/stake" - stakesim "github.com/cosmos/cosmos-sdk/x/stake/simulation" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + staking "github.com/cosmos/cosmos-sdk/x/staking" + stakingsim "github.com/cosmos/cosmos-sdk/x/staking/simulation" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -69,7 +69,7 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage { // Randomly generate some genesis accounts for _, acc := range accs { - coins := sdk.Coins{sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(amount))} + coins := sdk.Coins{sdk.NewCoin(stakingTypes.DefaultBondDenom, sdk.NewInt(amount))} genesisAccounts = append(genesisAccounts, GenesisAccount{ Address: acc.Address, Coins: coins, @@ -92,7 +92,7 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage { govGenesis := gov.GenesisState{ StartingProposalID: uint64(r.Intn(100)), DepositParams: gov.DepositParams{ - MinDeposit: sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, int64(r.Intn(1e3)))}, + MinDeposit: sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, int64(r.Intn(1e3)))}, MaxDepositPeriod: vp, }, VotingParams: gov.VotingParams{ @@ -106,19 +106,19 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage { } fmt.Printf("Selected randomly generated governance parameters:\n\t%+v\n", govGenesis) - stakeGenesis := stake.GenesisState{ - Pool: stake.InitialPool(), - Params: stake.Params{ + stakingGenesis := staking.GenesisState{ + Pool: staking.InitialPool(), + Params: staking.Params{ UnbondingTime: time.Duration(randIntBetween(r, 60, 60*60*24*3*2)) * time.Second, MaxValidators: uint16(r.Intn(250)), - BondDenom: stakeTypes.DefaultBondDenom, + BondDenom: stakingTypes.DefaultBondDenom, }, } - fmt.Printf("Selected randomly generated staking parameters:\n\t%+v\n", stakeGenesis) + fmt.Printf("Selected randomly generated staking parameters:\n\t%+v\n", stakingGenesis) slashingGenesis := slashing.GenesisState{ Params: slashing.Params{ - MaxEvidenceAge: stakeGenesis.Params.UnbondingTime, + MaxEvidenceAge: stakingGenesis.Params.UnbondingTime, SignedBlocksWindow: int64(randIntBetween(r, 10, 1000)), DowntimeJailDuration: time.Duration(randIntBetween(r, 60, 60*60*24)) * time.Second, MinSignedPerWindow: sdk.NewDecWithPrec(int64(r.Intn(10)), 1), @@ -132,7 +132,7 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage { Minter: mint.InitialMinter( sdk.NewDecWithPrec(int64(r.Intn(99)), 2)), Params: mint.NewParams( - stakeTypes.DefaultBondDenom, + stakingTypes.DefaultBondDenom, sdk.NewDecWithPrec(int64(r.Intn(99)), 2), sdk.NewDecWithPrec(20, 2), sdk.NewDecWithPrec(7, 2), @@ -141,29 +141,29 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage { } fmt.Printf("Selected randomly generated minting parameters:\n\t%+v\n", mintGenesis) - var validators []stake.Validator - var delegations []stake.Delegation + var validators []staking.Validator + var delegations []staking.Delegation valAddrs := make([]sdk.ValAddress, numInitiallyBonded) for i := 0; i < int(numInitiallyBonded); i++ { valAddr := sdk.ValAddress(accs[i].Address) valAddrs[i] = valAddr - validator := stake.NewValidator(valAddr, accs[i].PubKey, stake.Description{}) + validator := staking.NewValidator(valAddr, accs[i].PubKey, staking.Description{}) validator.Tokens = sdk.NewInt(amount) validator.DelegatorShares = sdk.NewDec(amount) - delegation := stake.Delegation{accs[i].Address, valAddr, sdk.NewDec(amount)} + delegation := staking.Delegation{accs[i].Address, valAddr, sdk.NewDec(amount)} validators = append(validators, validator) delegations = append(delegations, delegation) } - stakeGenesis.Pool.LooseTokens = sdk.NewInt((amount * numAccs) + (numInitiallyBonded * amount)) - stakeGenesis.Validators = validators - stakeGenesis.Bonds = delegations + stakingGenesis.Pool.LooseTokens = sdk.NewInt((amount * numAccs) + (numInitiallyBonded * amount)) + stakingGenesis.Validators = validators + stakingGenesis.Bonds = delegations genesis := GenesisState{ Accounts: genesisAccounts, AuthData: authGenesis, - StakeData: stakeGenesis, + StakingData: stakingGenesis, MintData: mintGenesis, DistrData: distr.DefaultGenesisWithValidators(valAddrs), SlashingData: slashingGenesis, @@ -191,13 +191,13 @@ func testAndRunTxs(app *GaiaApp) []simulation.WeightedOperation { {50, distrsim.SimulateMsgWithdrawDelegatorRewardsAll(app.accountKeeper, app.distrKeeper)}, {50, distrsim.SimulateMsgWithdrawDelegatorReward(app.accountKeeper, app.distrKeeper)}, {50, distrsim.SimulateMsgWithdrawValidatorRewardsAll(app.accountKeeper, app.distrKeeper)}, - {5, govsim.SimulateSubmittingVotingAndSlashingForProposal(app.govKeeper, app.stakeKeeper)}, + {5, govsim.SimulateSubmittingVotingAndSlashingForProposal(app.govKeeper, app.stakingKeeper)}, {100, govsim.SimulateMsgDeposit(app.govKeeper)}, - {100, stakesim.SimulateMsgCreateValidator(app.accountKeeper, app.stakeKeeper)}, - {5, stakesim.SimulateMsgEditValidator(app.stakeKeeper)}, - {100, stakesim.SimulateMsgDelegate(app.accountKeeper, app.stakeKeeper)}, - {100, stakesim.SimulateMsgBeginUnbonding(app.accountKeeper, app.stakeKeeper)}, - {100, stakesim.SimulateMsgBeginRedelegate(app.accountKeeper, app.stakeKeeper)}, + {100, stakingsim.SimulateMsgCreateValidator(app.accountKeeper, app.stakingKeeper)}, + {5, stakingsim.SimulateMsgEditValidator(app.stakingKeeper)}, + {100, stakingsim.SimulateMsgDelegate(app.accountKeeper, app.stakingKeeper)}, + {100, stakingsim.SimulateMsgBeginUnbonding(app.accountKeeper, app.stakingKeeper)}, + {100, stakingsim.SimulateMsgBeginRedelegate(app.accountKeeper, app.stakingKeeper)}, {100, slashingsim.SimulateMsgUnjail(app.slashingKeeper)}, } } @@ -206,8 +206,8 @@ func invariants(app *GaiaApp) []simulation.Invariant { return []simulation.Invariant{ simulation.PeriodicInvariant(banksim.NonnegativeBalanceInvariant(app.accountKeeper), period, 0), simulation.PeriodicInvariant(govsim.AllInvariants(), period, 0), - simulation.PeriodicInvariant(distrsim.AllInvariants(app.distrKeeper, app.stakeKeeper), period, 0), - simulation.PeriodicInvariant(stakesim.AllInvariants(app.bankKeeper, app.stakeKeeper, + simulation.PeriodicInvariant(distrsim.AllInvariants(app.distrKeeper, app.stakingKeeper), period, 0), + simulation.PeriodicInvariant(stakingsim.AllInvariants(app.bankKeeper, app.stakingKeeper, app.feeCollectionKeeper, app.distrKeeper, app.accountKeeper), period, 0), simulation.PeriodicInvariant(slashingsim.AllInvariants(), period, 0), } @@ -370,7 +370,7 @@ func TestGaiaImportExport(t *testing.T) { storeKeysPrefixes := []StoreKeysPrefixes{ {app.keyMain, newApp.keyMain, [][]byte{}}, {app.keyAccount, newApp.keyAccount, [][]byte{}}, - {app.keyStake, newApp.keyStake, [][]byte{stake.UnbondingQueueKey, stake.RedelegationQueueKey, stake.ValidatorQueueKey}}, // ordering may change but it doesn't matter + {app.keyStaking, newApp.keyStaking, [][]byte{staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey}}, // ordering may change but it doesn't matter {app.keySlashing, newApp.keySlashing, [][]byte{}}, {app.keyMint, newApp.keyMint, [][]byte{}}, {app.keyDistr, newApp.keyDistr, [][]byte{}}, diff --git a/cmd/gaia/cli_test/README.md b/cmd/gaia/cli_test/README.md index 2de40e06ac..37fd41ce7e 100644 --- a/cmd/gaia/cli_test/README.md +++ b/cmd/gaia/cli_test/README.md @@ -44,7 +44,7 @@ This boilerplate above: ### Notes when adding/running tests - Because the tests run against a built binary, you should make sure you build every time the code changes and you want to test again, otherwise you will be testing against an older version. If you are adding new tests this can easily lead to confusing test results. -- The [`test_helpers.go`](./test_helpers.go) file is organized according to the format of `gaiacli` and `gaiad` commands. There are comments with section headers describing the different areas. Helper functions to call CLI functionality are generally named after the command (e.g. `gaiacli query stake validator` would be `QueryStakeValidator`). Try to keep functions grouped by their position in the command tree. +- The [`test_helpers.go`](./test_helpers.go) file is organized according to the format of `gaiacli` and `gaiad` commands. There are comments with section headers describing the different areas. Helper functions to call CLI functionality are generally named after the command (e.g. `gaiacli query staking validator` would be `QueryStakingValidator`). Try to keep functions grouped by their position in the command tree. - Test state that is needed by `tx` and `query` commands (`home`, `chain_id`, etc...) is stored on the `Fixtures` object. This makes constructing your new tests almost trivial. - Sometimes if you exit a test early there can be still running `gaiad` and `gaiacli` processes that will interrupt subsequent runs. Still running `gaiacli` processes will block access to the keybase while still running `gaiad` processes will block ports and prevent new tests from spinning up. You can ensure new tests spin up clean by running `pkill -9 gaiad && pkill -9 gaiacli` before each test run. - Most `query` and `tx` commands take a variadic `flags` argument. This pattern allows for the creation of a general function which is easily modified by adding flags. See the `TxSend` function and its use for a good example. diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 8f83aabd55..398f630ff3 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -20,8 +20,8 @@ import ( "github.com/cosmos/cosmos-sdk/tests" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestGaiaCLIMinimumFees(t *testing.T) { @@ -45,7 +45,7 @@ func TestGaiaCLIMinimumFees(t *testing.T) { require.False(f.T, success) tests.WaitForNextNBlocksTM(1, f.Port) - // Ensure tx w/ correct fees (stake) pass + // Ensure tx w/ correct fees (staking) pass txFees := fmt.Sprintf("--fees=%s", sdk.NewInt64Coin(denom, 23)) success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), txFees) require.True(f.T, success) @@ -254,12 +254,12 @@ func TestGaiaCLICreateValidator(t *testing.T) { fooAcc := f.QueryAccount(fooAddr) require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64()) - defaultParams := stake.DefaultParams() - initialPool := stake.InitialPool() + defaultParams := staking.DefaultParams() + initialPool := staking.InitialPool() initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewInt(101)) // Delegate tx on GaiaAppGenState // Generate a create validator transaction and ensure correctness - success, stdout, stderr := f.TxStakeCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2), "--generate-only") + success, stdout, stderr := f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2), "--generate-only") require.True(f.T, success) require.Empty(f.T, stderr) @@ -269,11 +269,11 @@ func TestGaiaCLICreateValidator(t *testing.T) { require.Equal(t, 0, len(msg.GetSignatures())) // Test --dry-run - success, _, _ = f.TxStakeCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2), "--dry-run") + success, _, _ = f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2), "--dry-run") require.True(t, success) // Create the validator - f.TxStakeCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2)) + f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2)) tests.WaitForNextNBlocksTM(1, f.Port) // Ensure funds were deducted properly @@ -281,35 +281,35 @@ func TestGaiaCLICreateValidator(t *testing.T) { require.Equal(t, int64(8), barAcc.GetCoins().AmountOf(denom).Int64()) // Ensure that validator state is as expected - validator := f.QueryStakeValidator(barVal) + validator := f.QueryStakingValidator(barVal) require.Equal(t, validator.OperatorAddr, barVal) require.True(sdk.IntEq(t, sdk.NewInt(2), validator.Tokens)) // Query delegations to the validator - validatorDelegations := f.QueryStakeDelegationsTo(barVal) + validatorDelegations := f.QueryStakingDelegationsTo(barVal) require.Len(t, validatorDelegations, 1) require.NotZero(t, validatorDelegations[0].Shares) // unbond a single share - success = f.TxStakeUnbond(keyBar, "1", barVal) + success = f.TxStakingUnbond(keyBar, "1", barVal) require.True(t, success) tests.WaitForNextNBlocksTM(1, f.Port) - // Ensure bonded stake is correct - validator = f.QueryStakeValidator(barVal) + // Ensure bonded staking is correct + validator = f.QueryStakingValidator(barVal) require.Equal(t, "1", validator.Tokens.String()) // Get unbonding delegations from the validator - validatorUbds := f.QueryStakeUnbondingDelegationsFrom(barVal) + validatorUbds := f.QueryStakingUnbondingDelegationsFrom(barVal) require.Len(t, validatorUbds, 1) require.Equal(t, "1", validatorUbds[0].Balance.Amount.String()) // Query staking parameters - params := f.QueryStakeParameters() + params := f.QueryStakingParameters() require.True(t, defaultParams.Equal(params)) // Query staking pool - pool := f.QueryStakePool() + pool := f.QueryStakingPool() require.Equal(t, initialPool.BondedTokens, pool.BondedTokens) f.Cleanup() @@ -330,7 +330,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) { fooAddr := f.KeyAddress(keyFoo) fooAcc := f.QueryAccount(fooAddr) - require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64()) + require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom).Int64()) proposalsQuery := f.QueryGovProposals() require.Equal(t, "No matching proposals found", proposalsQuery) diff --git a/cmd/gaia/cli_test/test_helpers.go b/cmd/gaia/cli_test/test_helpers.go index 7712fdcc20..3896fdf50b 100644 --- a/cmd/gaia/cli_test/test_helpers.go +++ b/cmd/gaia/cli_test/test_helpers.go @@ -23,7 +23,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/slashing" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) const ( @@ -234,19 +234,19 @@ func (f *Fixtures) TxBroadcast(fileName string, flags ...string) (bool, string, } //___________________________________________________________________________________ -// gaiacli tx stake +// gaiacli tx staking -// TxStakeCreateValidator is gaiacli tx stake create-validator -func (f *Fixtures) TxStakeCreateValidator(from, consPubKey string, amount sdk.Coin, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("gaiacli tx stake create-validator %v --from=%s --pubkey=%s", f.Flags(), from, consPubKey) +// TxStakingCreateValidator is gaiacli tx staking create-validator +func (f *Fixtures) TxStakingCreateValidator(from, consPubKey string, amount sdk.Coin, flags ...string) (bool, string, string) { + cmd := fmt.Sprintf("gaiacli tx staking create-validator %v --from=%s --pubkey=%s", f.Flags(), from, consPubKey) cmd += fmt.Sprintf(" --amount=%v --moniker=%v --commission-rate=%v", amount, from, "0.05") cmd += fmt.Sprintf(" --commission-max-rate=%v --commission-max-change-rate=%v", "0.20", "0.10") return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass) } -// TxStakeUnbond is gaiacli tx stake unbond -func (f *Fixtures) TxStakeUnbond(from, shares string, validator sdk.ValAddress, flags ...string) bool { - cmd := fmt.Sprintf("gaiacli tx stake unbond %v --from=%s --validator=%s --shares-amount=%v", f.Flags(), from, validator, shares) +// TxStakingUnbond is gaiacli tx staking unbond +func (f *Fixtures) TxStakingUnbond(from, shares string, validator sdk.ValAddress, flags ...string) bool { + cmd := fmt.Sprintf("gaiacli tx staking unbond %v --from=%s --validator=%s --shares-amount=%v", f.Flags(), from, validator, shares) return executeWrite(f.T, addFlags(cmd, flags), app.DefaultKeyPass) } @@ -306,57 +306,57 @@ func (f *Fixtures) QueryTxs(tags ...string) []tx.Info { } //___________________________________________________________________________________ -// gaiacli query stake +// gaiacli query staking -// QueryStakeValidator is gaiacli query stake validator -func (f *Fixtures) QueryStakeValidator(valAddr sdk.ValAddress, flags ...string) stake.Validator { - cmd := fmt.Sprintf("gaiacli query stake validator %s %v", valAddr, f.Flags()) +// QueryStakingValidator is gaiacli query staking validator +func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string) staking.Validator { + cmd := fmt.Sprintf("gaiacli query staking validator %s %v", valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") - var validator stake.Validator + var validator staking.Validator cdc := app.MakeCodec() err := cdc.UnmarshalJSON([]byte(out), &validator) require.NoError(f.T, err, "out %v\n, err %v", out, err) return validator } -// QueryStakeUnbondingDelegationsFrom is gaiacli query stake unbonding-delegations-from -func (f *Fixtures) QueryStakeUnbondingDelegationsFrom(valAddr sdk.ValAddress, flags ...string) []stake.UnbondingDelegation { - cmd := fmt.Sprintf("gaiacli query stake unbonding-delegations-from %s %v", valAddr, f.Flags()) +// QueryStakingUnbondingDelegationsFrom is gaiacli query staking unbonding-delegations-from +func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress, flags ...string) []staking.UnbondingDelegation { + cmd := fmt.Sprintf("gaiacli query staking unbonding-delegations-from %s %v", valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") - var ubds []stake.UnbondingDelegation + var ubds []staking.UnbondingDelegation cdc := app.MakeCodec() err := cdc.UnmarshalJSON([]byte(out), &ubds) require.NoError(f.T, err, "out %v\n, err %v", out, err) return ubds } -// QueryStakeDelegationsTo is gaiacli query stake delegations-to -func (f *Fixtures) QueryStakeDelegationsTo(valAddr sdk.ValAddress, flags ...string) []stake.Delegation { - cmd := fmt.Sprintf("gaiacli query stake delegations-to %s %v", valAddr, f.Flags()) +// QueryStakingDelegationsTo is gaiacli query staking delegations-to +func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...string) []staking.Delegation { + cmd := fmt.Sprintf("gaiacli query staking delegations-to %s %v", valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") - var delegations []stake.Delegation + var delegations []staking.Delegation cdc := app.MakeCodec() err := cdc.UnmarshalJSON([]byte(out), &delegations) require.NoError(f.T, err, "out %v\n, err %v", out, err) return delegations } -// QueryStakePool is gaiacli query stake pool -func (f *Fixtures) QueryStakePool(flags ...string) stake.Pool { - cmd := fmt.Sprintf("gaiacli query stake pool %v", f.Flags()) +// QueryStakingPool is gaiacli query staking pool +func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool { + cmd := fmt.Sprintf("gaiacli query staking pool %v", f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") - var pool stake.Pool + var pool staking.Pool cdc := app.MakeCodec() err := cdc.UnmarshalJSON([]byte(out), &pool) require.NoError(f.T, err, "out %v\n, err %v", out, err) return pool } -// QueryStakeParameters is gaiacli query stake parameters -func (f *Fixtures) QueryStakeParameters(flags ...string) stake.Params { - cmd := fmt.Sprintf("gaiacli query stake parameters %v", f.Flags()) +// QueryStakingParameters is gaiacli query staking parameters +func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params { + cmd := fmt.Sprintf("gaiacli query staking parameters %v", f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") - var params stake.Params + var params staking.Params cdc := app.MakeCodec() err := cdc.UnmarshalJSON([]byte(out), ¶ms) require.NoError(f.T, err, "out %v\n, err %v", out, err) diff --git a/cmd/gaia/cmd/gaiacli/main.go b/cmd/gaia/cmd/gaiacli/main.go index 823cb44fa7..176be4f97f 100644 --- a/cmd/gaia/cmd/gaiacli/main.go +++ b/cmd/gaia/cmd/gaiacli/main.go @@ -30,15 +30,15 @@ import ( gov "github.com/cosmos/cosmos-sdk/x/gov/client/rest" sl "github.com/cosmos/cosmos-sdk/x/slashing" slashing "github.com/cosmos/cosmos-sdk/x/slashing/client/rest" - st "github.com/cosmos/cosmos-sdk/x/stake" - stake "github.com/cosmos/cosmos-sdk/x/stake/client/rest" + st "github.com/cosmos/cosmos-sdk/x/staking" + staking "github.com/cosmos/cosmos-sdk/x/staking/client/rest" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" distClient "github.com/cosmos/cosmos-sdk/x/distribution/client" govClient "github.com/cosmos/cosmos-sdk/x/gov/client" slashingClient "github.com/cosmos/cosmos-sdk/x/slashing/client" - stakeClient "github.com/cosmos/cosmos-sdk/x/stake/client" + stakingClient "github.com/cosmos/cosmos-sdk/x/staking/client" _ "github.com/cosmos/cosmos-sdk/client/lcd/statik" ) @@ -66,7 +66,7 @@ func main() { mc := []sdk.ModuleClients{ govClient.NewModuleClient(gv.StoreKey, cdc), distClient.NewModuleClient(dist.StoreKey, cdc), - stakeClient.NewModuleClient(st.StoreKey, cdc), + stakingClient.NewModuleClient(st.StoreKey, cdc), slashingClient.NewModuleClient(sl.StoreKey, cdc), } @@ -157,7 +157,7 @@ func registerRoutes(rs *lcd.RestServer) { tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc) auth.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, at.StoreKey) bank.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) - stake.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) + staking.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) slashing.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) gov.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc) } diff --git a/cmd/gaia/cmd/gaiadebug/hack.go b/cmd/gaia/cmd/gaiadebug/hack.go index 5a4a847390..67a402dd21 100644 --- a/cmd/gaia/cmd/gaiadebug/hack.go +++ b/cmd/gaia/cmd/gaiadebug/hack.go @@ -4,10 +4,11 @@ import ( "encoding/base64" "encoding/hex" "fmt" - "github.com/cosmos/cosmos-sdk/store" "os" "path" + "github.com/cosmos/cosmos-sdk/store" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/spf13/cobra" @@ -27,7 +28,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/slashing" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" gaia "github.com/cosmos/cosmos-sdk/cmd/gaia/app" ) @@ -83,9 +84,9 @@ func runHackCmd(cmd *cobra.Command, args []string) error { ctx := app.NewContext(true, abci.Header{}) // check for the powerkey and the validator from the store - store := ctx.KVStore(app.keyStake) + store := ctx.KVStore(app.keyStaking) res := store.Get(powerKey) - val, _ := app.stakeKeeper.GetValidator(ctx, trouble) + val, _ := app.stakingKeeper.GetValidator(ctx, trouble) fmt.Println("checking height", checkHeight, res, val) if res == nil { bottomHeight = checkHeight @@ -132,8 +133,8 @@ type GaiaApp struct { // keys to access the substores keyMain *sdk.KVStoreKey keyAccount *sdk.KVStoreKey - keyStake *sdk.KVStoreKey - tkeyStake *sdk.TransientStoreKey + keyStaking *sdk.KVStoreKey + tkeyStaking *sdk.TransientStoreKey keySlashing *sdk.KVStoreKey keyParams *sdk.KVStoreKey tkeyParams *sdk.TransientStoreKey @@ -142,7 +143,7 @@ type GaiaApp struct { accountKeeper auth.AccountKeeper feeCollectionKeeper auth.FeeCollectionKeeper bankKeeper bank.Keeper - stakeKeeper stake.Keeper + stakingKeeper staking.Keeper slashingKeeper slashing.Keeper paramsKeeper params.Keeper } @@ -159,8 +160,8 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp cdc: cdc, keyMain: sdk.NewKVStoreKey(bam.MainStoreKey), keyAccount: sdk.NewKVStoreKey(auth.StoreKey), - keyStake: sdk.NewKVStoreKey(stake.StoreKey), - tkeyStake: sdk.NewTransientStoreKey(stake.TStoreKey), + keyStaking: sdk.NewKVStoreKey(staking.StoreKey), + tkeyStaking: sdk.NewTransientStoreKey(staking.TStoreKey), keySlashing: sdk.NewKVStoreKey(slashing.StoreKey), keyParams: sdk.NewKVStoreKey(params.StoreKey), tkeyParams: sdk.NewTransientStoreKey(params.TStoreKey), @@ -178,20 +179,20 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp // add handlers app.bankKeeper = bank.NewBaseKeeper(app.accountKeeper) - app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.tkeyStake, app.bankKeeper, app.paramsKeeper.Subspace(stake.DefaultParamspace), stake.DefaultCodespace) - app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Subspace(slashing.DefaultParamspace), slashing.DefaultCodespace) + app.stakingKeeper = staking.NewKeeper(app.cdc, app.keyStaking, app.tkeyStaking, app.bankKeeper, app.paramsKeeper.Subspace(staking.DefaultParamspace), staking.DefaultCodespace) + app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakingKeeper, app.paramsKeeper.Subspace(slashing.DefaultParamspace), slashing.DefaultCodespace) // register message routes app.Router(). AddRoute("bank", bank.NewHandler(app.bankKeeper)). - AddRoute(stake.RouterKey, stake.NewHandler(app.stakeKeeper)) + AddRoute(staking.RouterKey, staking.NewHandler(app.stakingKeeper)) // initialize BaseApp app.SetInitChainer(app.initChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) app.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper, app.feeCollectionKeeper)) - app.MountStores(app.keyMain, app.keyAccount, app.keyStake, app.keySlashing, app.keyParams) + app.MountStores(app.keyMain, app.keyAccount, app.keyStaking, app.keySlashing, app.keyParams) app.MountStore(app.tkeyParams, sdk.StoreTypeTransient) err := app.LoadLatestVersion(app.keyMain) if err != nil { @@ -207,7 +208,7 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseAp func MakeCodec() *codec.Codec { var cdc = codec.New() bank.RegisterCodec(cdc) - stake.RegisterCodec(cdc) + staking.RegisterCodec(cdc) slashing.RegisterCodec(cdc) auth.RegisterCodec(cdc) sdk.RegisterCodec(cdc) @@ -228,7 +229,7 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab // application updates every end block // nolint: unparam func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - validatorUpdates, tags := stake.EndBlocker(ctx, app.stakeKeeper) + validatorUpdates, tags := staking.EndBlocker(ctx, app.stakingKeeper) return abci.ResponseEndBlock{ ValidatorUpdates: validatorUpdates, @@ -253,13 +254,13 @@ func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci app.accountKeeper.SetAccount(ctx, acc) } - // load the initial stake information - validators, err := stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData) + // load the initial staking information + validators, err := staking.InitGenesis(ctx, app.stakingKeeper, genesisState.StakingData) if err != nil { panic(err) // TODO https://github.com/cosmos/cosmos-sdk/issues/468 // return sdk.ErrGenesisParse("").TraceCause(err, "") } - slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.SlashingData, genesisState.StakeData) + slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.SlashingData, genesisState.StakingData) return abci.ResponseInitChain{ Validators: validators, diff --git a/cmd/gaia/init/gentx.go b/cmd/gaia/init/gentx.go index 8e5480a541..13a7a3a879 100644 --- a/cmd/gaia/init/gentx.go +++ b/cmd/gaia/init/gentx.go @@ -26,12 +26,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" - "github.com/cosmos/cosmos-sdk/x/stake/client/cli" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) const ( - defaultAmount = "100" + stakeTypes.DefaultBondDenom + defaultAmount = "100" + stakingTypes.DefaultBondDenom defaultCommissionRate = "0.1" defaultCommissionMaxRate = "0.2" defaultCommissionMaxChangeRate = "0.01" @@ -168,7 +168,7 @@ following delegation and commission default parameters: func accountInGenesis(genesisState app.GenesisState, key sdk.AccAddress, coins sdk.Coins) error { accountIsInGenesis := false - bondDenom := genesisState.StakeData.Params.BondDenom + bondDenom := genesisState.StakingData.Params.BondDenom // Check if the account is in genesis for _, acc := range genesisState.Accounts { diff --git a/cmd/gaia/init/testnet.go b/cmd/gaia/init/testnet.go index a5bca72c51..5865827bb0 100644 --- a/cmd/gaia/init/testnet.go +++ b/cmd/gaia/init/testnet.go @@ -14,8 +14,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" authtx "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" - "github.com/cosmos/cosmos-sdk/x/stake" - staketypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -82,7 +82,7 @@ Example: client.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created", ) cmd.Flags().String( - flagMinimumFees, fmt.Sprintf("1%s", staketypes.DefaultBondDenom), "Validator minimum fees", + flagMinimumFees, fmt.Sprintf("1%s", stakingtypes.DefaultBondDenom), "Validator minimum fees", ) return cmd @@ -192,16 +192,16 @@ func initTestnet(config *tmconfig.Config, cdc *codec.Codec) error { Address: addr, Coins: sdk.Coins{ sdk.NewInt64Coin(fmt.Sprintf("%stoken", nodeDirName), 1000), - sdk.NewInt64Coin(staketypes.DefaultBondDenom, 500), + sdk.NewInt64Coin(stakingtypes.DefaultBondDenom, 500), }, }) - msg := stake.NewMsgCreateValidator( + msg := staking.NewMsgCreateValidator( sdk.ValAddress(addr), valPubKeys[i], - sdk.NewInt64Coin(staketypes.DefaultBondDenom, 100), - stake.NewDescription(nodeDirName, "", "", ""), - stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + sdk.NewInt64Coin(stakingtypes.DefaultBondDenom, 100), + staking.NewDescription(nodeDirName, "", "", ""), + staking.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), ) tx := auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, []auth.StdSignature{}, memo) txBldr := authtx.NewTxBuilderFromCLI().WithChainID(chainID).WithMemo(memo) diff --git a/docs/examples/basecoin/cmd/basecli/main.go b/docs/examples/basecoin/cmd/basecli/main.go index 10fa9fd1e6..451494b028 100644 --- a/docs/examples/basecoin/cmd/basecli/main.go +++ b/docs/examples/basecoin/cmd/basecli/main.go @@ -23,9 +23,9 @@ import ( sl "github.com/cosmos/cosmos-sdk/x/slashing" slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli" slashing "github.com/cosmos/cosmos-sdk/x/slashing/client/rest" - st "github.com/cosmos/cosmos-sdk/x/stake" - stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli" - stake "github.com/cosmos/cosmos-sdk/x/stake/client/rest" + st "github.com/cosmos/cosmos-sdk/x/staking" + stakingcmd "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + staking "github.com/cosmos/cosmos-sdk/x/staking/client/rest" ) // rootCmd is the entry point for this binary @@ -65,20 +65,20 @@ func main() { // add query/post commands (custom to binary) rootCmd.AddCommand( - stakecmd.GetCmdQueryValidator(st.StoreKey, cdc), - stakecmd.GetCmdQueryValidators(st.StoreKey, cdc), - stakecmd.GetCmdQueryValidatorUnbondingDelegations(st.StoreKey, cdc), - stakecmd.GetCmdQueryValidatorRedelegations(st.StoreKey, cdc), - stakecmd.GetCmdQueryDelegation(st.StoreKey, cdc), - stakecmd.GetCmdQueryDelegations(st.StoreKey, cdc), - stakecmd.GetCmdQueryPool(st.StoreKey, cdc), - stakecmd.GetCmdQueryParams(st.StoreKey, cdc), - stakecmd.GetCmdQueryUnbondingDelegation(st.StoreKey, cdc), - stakecmd.GetCmdQueryUnbondingDelegations(st.StoreKey, cdc), - stakecmd.GetCmdQueryRedelegation(st.StoreKey, cdc), - stakecmd.GetCmdQueryRedelegations(st.StoreKey, cdc), + stakingcmd.GetCmdQueryValidator(st.StoreKey, cdc), + stakingcmd.GetCmdQueryValidators(st.StoreKey, cdc), + stakingcmd.GetCmdQueryValidatorUnbondingDelegations(st.StoreKey, cdc), + stakingcmd.GetCmdQueryValidatorRedelegations(st.StoreKey, cdc), + stakingcmd.GetCmdQueryDelegation(st.StoreKey, cdc), + stakingcmd.GetCmdQueryDelegations(st.StoreKey, cdc), + stakingcmd.GetCmdQueryPool(st.StoreKey, cdc), + stakingcmd.GetCmdQueryParams(st.StoreKey, cdc), + stakingcmd.GetCmdQueryUnbondingDelegation(st.StoreKey, cdc), + stakingcmd.GetCmdQueryUnbondingDelegations(st.StoreKey, cdc), + stakingcmd.GetCmdQueryRedelegation(st.StoreKey, cdc), + stakingcmd.GetCmdQueryRedelegations(st.StoreKey, cdc), slashingcmd.GetCmdQuerySigningInfo(sl.StoreKey, cdc), - stakecmd.GetCmdQueryValidatorDelegations(st.StoreKey, cdc), + stakingcmd.GetCmdQueryValidatorDelegations(st.StoreKey, cdc), authcmd.GetAccountCmd(at.StoreKey, cdc), ) @@ -86,11 +86,11 @@ func main() { bankcmd.SendTxCmd(cdc), ibccmd.IBCTransferCmd(cdc), ibccmd.IBCRelayCmd(cdc), - stakecmd.GetCmdCreateValidator(cdc), - stakecmd.GetCmdEditValidator(cdc), - stakecmd.GetCmdDelegate(cdc), - stakecmd.GetCmdUnbond(st.StoreKey, cdc), - stakecmd.GetCmdRedelegate(st.StoreKey, cdc), + stakingcmd.GetCmdCreateValidator(cdc), + stakingcmd.GetCmdEditValidator(cdc), + stakingcmd.GetCmdDelegate(cdc), + stakingcmd.GetCmdUnbond(st.StoreKey, cdc), + stakingcmd.GetCmdRedelegate(st.StoreKey, cdc), slashingcmd.GetCmdUnjail(cdc), ) @@ -118,6 +118,6 @@ func registerRoutes(rs *lcd.RestServer) { tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc) auth.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, at.StoreKey) bank.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) - stake.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) + staking.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) slashing.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase) } diff --git a/docs/examples/democoin/app/app.go b/docs/examples/democoin/app/app.go index cbfe6e5c33..93af70deb2 100644 --- a/docs/examples/democoin/app/app.go +++ b/docs/examples/democoin/app/app.go @@ -17,12 +17,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/ibc" "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/docs/examples/democoin/types" "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/cool" "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/pow" - "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestake" + "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestaking" "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/sketchy" ) @@ -57,7 +57,7 @@ type DemocoinApp struct { coolKeeper cool.Keeper powKeeper pow.Keeper ibcMapper ibc.Mapper - stakeKeeper simplestake.Keeper + stakingKeeper simplestaking.Keeper // Manage getting and setting accounts accountKeeper auth.AccountKeeper @@ -76,7 +76,7 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp { capKeyAccountStore: sdk.NewKVStoreKey(auth.StoreKey), capKeyPowStore: sdk.NewKVStoreKey("pow"), capKeyIBCStore: sdk.NewKVStoreKey("ibc"), - capKeyStakingStore: sdk.NewKVStoreKey(stake.StoreKey), + capKeyStakingStore: sdk.NewKVStoreKey(staking.StoreKey), keyParams: sdk.NewKVStoreKey("params"), tkeyParams: sdk.NewTransientStoreKey("transient_params"), } @@ -96,14 +96,14 @@ func NewDemocoinApp(logger log.Logger, db dbm.DB) *DemocoinApp { app.coolKeeper = cool.NewKeeper(app.capKeyMainStore, app.bankKeeper, cool.DefaultCodespace) app.powKeeper = pow.NewKeeper(app.capKeyPowStore, pow.NewConfig("pow", int64(1)), app.bankKeeper, pow.DefaultCodespace) app.ibcMapper = ibc.NewMapper(app.cdc, app.capKeyIBCStore, ibc.DefaultCodespace) - app.stakeKeeper = simplestake.NewKeeper(app.capKeyStakingStore, app.bankKeeper, simplestake.DefaultCodespace) + app.stakingKeeper = simplestaking.NewKeeper(app.capKeyStakingStore, app.bankKeeper, simplestaking.DefaultCodespace) app.Router(). AddRoute("bank", bank.NewHandler(app.bankKeeper)). AddRoute("cool", cool.NewHandler(app.coolKeeper)). AddRoute("pow", app.powKeeper.Handler). AddRoute("sketchy", sketchy.NewHandler()). AddRoute("ibc", ibc.NewHandler(app.ibcMapper, app.bankKeeper)). - AddRoute("simplestake", simplestake.NewHandler(app.stakeKeeper)) + AddRoute("simplestaking", simplestaking.NewHandler(app.stakingKeeper)) // Initialize BaseApp. app.SetInitChainer(app.initChainerFn(app.coolKeeper, app.powKeeper)) @@ -128,7 +128,7 @@ func MakeCodec() *codec.Codec { pow.RegisterCodec(cdc) bank.RegisterCodec(cdc) ibc.RegisterCodec(cdc) - simplestake.RegisterCodec(cdc) + simplestaking.RegisterCodec(cdc) // Register AppAccount cdc.RegisterInterface((*auth.Account)(nil), nil) diff --git a/docs/examples/democoin/cmd/democli/main.go b/docs/examples/democoin/cmd/democli/main.go index c0843540aa..07ded7f206 100644 --- a/docs/examples/democoin/cmd/democli/main.go +++ b/docs/examples/democoin/cmd/democli/main.go @@ -21,7 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/docs/examples/democoin/app" coolcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/cool/client/cli" powcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/pow/client/cli" - simplestakingcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestake/client/cli" + simplestakingcmd "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestaking/client/cli" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/docs/examples/democoin/x/simplestake/codec.go b/docs/examples/democoin/x/simplestake/codec.go deleted file mode 100644 index 7813fd6423..0000000000 --- a/docs/examples/democoin/x/simplestake/codec.go +++ /dev/null @@ -1,11 +0,0 @@ -package simplestake - -import ( - "github.com/cosmos/cosmos-sdk/codec" -) - -// Register concrete types on codec codec -func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgBond{}, "simplestake/BondMsg", nil) - cdc.RegisterConcrete(MsgUnbond{}, "simplestake/UnbondMsg", nil) -} diff --git a/docs/examples/democoin/x/simplestake/client/cli/commands.go b/docs/examples/democoin/x/simplestaking/client/cli/commands.go similarity index 87% rename from docs/examples/democoin/x/simplestake/client/cli/commands.go rename to docs/examples/democoin/x/simplestaking/client/cli/commands.go index 8717a5f3ba..5a2b819f3f 100644 --- a/docs/examples/democoin/x/simplestake/client/cli/commands.go +++ b/docs/examples/democoin/x/simplestaking/client/cli/commands.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestake" + "github.com/cosmos/cosmos-sdk/docs/examples/democoin/x/simplestaking" sdk "github.com/cosmos/cosmos-sdk/types" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" @@ -17,7 +17,7 @@ import ( ) const ( - flagStake = "stake" + flagStake = "staking" flagValidator = "validator" ) @@ -37,9 +37,9 @@ func BondTxCmd(cdc *codec.Codec) *cobra.Command { return err } - stakeString := viper.GetString(flagStake) - if len(stakeString) == 0 { - return fmt.Errorf("specify coins to bond with --stake") + stakingString := viper.GetString(flagStake) + if len(stakingString) == 0 { + return fmt.Errorf("specify coins to bond with --staking") } valString := viper.GetString(flagValidator) @@ -47,7 +47,7 @@ func BondTxCmd(cdc *codec.Codec) *cobra.Command { return fmt.Errorf("specify pubkey to bond to with --validator") } - stake, err := sdk.ParseCoin(stakeString) + staking, err := sdk.ParseCoin(stakingString) if err != nil { return err } @@ -60,7 +60,7 @@ func BondTxCmd(cdc *codec.Codec) *cobra.Command { var pubKeyEd ed25519.PubKeyEd25519 copy(pubKeyEd[:], rawPubKey) - msg := simplestake.NewMsgBond(from, stake, pubKeyEd) + msg := simplestaking.NewMsgBond(from, staking, pubKeyEd) // Build and sign the transaction, then broadcast to a Tendermint // node. @@ -89,7 +89,7 @@ func UnbondTxCmd(cdc *codec.Codec) *cobra.Command { return err } - msg := simplestake.NewMsgUnbond(from) + msg := simplestaking.NewMsgUnbond(from) // Build and sign the transaction, then broadcast to a Tendermint // node. diff --git a/docs/examples/democoin/x/simplestaking/codec.go b/docs/examples/democoin/x/simplestaking/codec.go new file mode 100644 index 0000000000..1bc866a393 --- /dev/null +++ b/docs/examples/democoin/x/simplestaking/codec.go @@ -0,0 +1,11 @@ +package simplestaking + +import ( + "github.com/cosmos/cosmos-sdk/codec" +) + +// Register concrete types on codec codec +func RegisterCodec(cdc *codec.Codec) { + cdc.RegisterConcrete(MsgBond{}, "simplestaking/BondMsg", nil) + cdc.RegisterConcrete(MsgUnbond{}, "simplestaking/UnbondMsg", nil) +} diff --git a/docs/examples/democoin/x/simplestake/errors.go b/docs/examples/democoin/x/simplestaking/errors.go similarity index 89% rename from docs/examples/democoin/x/simplestake/errors.go rename to docs/examples/democoin/x/simplestaking/errors.go index a0fc6e1acc..f5ec400085 100644 --- a/docs/examples/democoin/x/simplestake/errors.go +++ b/docs/examples/democoin/x/simplestaking/errors.go @@ -1,14 +1,14 @@ -package simplestake +package simplestaking import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// simple stake errors reserve 300 ~ 399. +// simple staking errors reserve 300 ~ 399. const ( DefaultCodespace sdk.CodespaceType = moduleName - // simplestake errors reserve 300 - 399. + // simplestaking errors reserve 300 - 399. CodeEmptyValidator sdk.CodeType = 300 CodeInvalidUnbond sdk.CodeType = 301 CodeEmptyStake sdk.CodeType = 302 diff --git a/docs/examples/democoin/x/simplestake/handler.go b/docs/examples/democoin/x/simplestaking/handler.go similarity index 87% rename from docs/examples/democoin/x/simplestake/handler.go rename to docs/examples/democoin/x/simplestaking/handler.go index 104058eec2..d8cb46e812 100644 --- a/docs/examples/democoin/x/simplestake/handler.go +++ b/docs/examples/democoin/x/simplestaking/handler.go @@ -1,10 +1,10 @@ -package simplestake +package simplestaking import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewHandler returns a handler for "simplestake" type messages. +// NewHandler returns a handler for "simplestaking" type messages. func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) sdk.Result { switch msg.(type) { diff --git a/docs/examples/democoin/x/simplestake/keeper.go b/docs/examples/democoin/x/simplestaking/keeper.go similarity index 81% rename from docs/examples/democoin/x/simplestake/keeper.go rename to docs/examples/democoin/x/simplestaking/keeper.go index fe459267d4..87551f1c0e 100644 --- a/docs/examples/democoin/x/simplestake/keeper.go +++ b/docs/examples/democoin/x/simplestaking/keeper.go @@ -1,4 +1,4 @@ -package simplestake +package simplestaking import ( "github.com/tendermint/tendermint/crypto" @@ -6,12 +6,12 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -const moduleName = "simplestake" +const moduleName = "simplestaking" -// simple stake keeper +// simple staking keeper type Keeper struct { ck bank.Keeper @@ -60,12 +60,12 @@ func (k Keeper) deleteBondInfo(ctx sdk.Context, addr sdk.AccAddress) { } // register a bond with the keeper -func (k Keeper) Bond(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, stake sdk.Coin) (int64, sdk.Error) { - if stake.Denom != stakeTypes.DefaultBondDenom { +func (k Keeper) Bond(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, staking sdk.Coin) (int64, sdk.Error) { + if staking.Denom != stakingTypes.DefaultBondDenom { return 0, ErrIncorrectStakingToken(k.codespace) } - _, _, err := k.ck.SubtractCoins(ctx, addr, []sdk.Coin{stake}) + _, _, err := k.ck.SubtractCoins(ctx, addr, []sdk.Coin{staking}) if err != nil { return 0, err } @@ -78,7 +78,7 @@ func (k Keeper) Bond(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, } } - bi.Power = bi.Power + stake.Amount.Int64() + bi.Power = bi.Power + staking.Amount.Int64() k.setBondInfo(ctx, addr, bi) return bi.Power, nil @@ -92,7 +92,7 @@ func (k Keeper) Unbond(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, int } k.deleteBondInfo(ctx, addr) - returnedBond := sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, bi.Power) + returnedBond := sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, bi.Power) _, _, err := k.ck.AddCoins(ctx, addr, []sdk.Coin{returnedBond}) if err != nil { @@ -104,8 +104,8 @@ func (k Keeper) Unbond(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, int // FOR TESTING PURPOSES ------------------------------------------------- -func (k Keeper) bondWithoutCoins(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, stake sdk.Coin) (int64, sdk.Error) { - if stake.Denom != stakeTypes.DefaultBondDenom { +func (k Keeper) bondWithoutCoins(ctx sdk.Context, addr sdk.AccAddress, pubKey crypto.PubKey, staking sdk.Coin) (int64, sdk.Error) { + if staking.Denom != stakingTypes.DefaultBondDenom { return 0, ErrIncorrectStakingToken(k.codespace) } @@ -117,7 +117,7 @@ func (k Keeper) bondWithoutCoins(ctx sdk.Context, addr sdk.AccAddress, pubKey cr } } - bi.Power = bi.Power + stake.Amount.Int64() + bi.Power = bi.Power + staking.Amount.Int64() k.setBondInfo(ctx, addr, bi) return bi.Power, nil diff --git a/docs/examples/democoin/x/simplestake/keeper_test.go b/docs/examples/democoin/x/simplestaking/keeper_test.go similarity index 74% rename from docs/examples/democoin/x/simplestake/keeper_test.go rename to docs/examples/democoin/x/simplestaking/keeper_test.go index 8ad87e530b..ef83f42567 100644 --- a/docs/examples/democoin/x/simplestake/keeper_test.go +++ b/docs/examples/democoin/x/simplestaking/keeper_test.go @@ -1,4 +1,4 @@ -package simplestake +package simplestaking import ( "fmt" @@ -17,7 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/params" - staketypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) type testInput struct { @@ -55,10 +55,10 @@ func TestKeeperGetSet(t *testing.T) { input := setupTestInput() ctx := input.ctx - stakeKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace) + stakingKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace) addr := sdk.AccAddress([]byte("some-address")) - bi := stakeKeeper.getBondInfo(ctx, addr) + bi := stakingKeeper.getBondInfo(ctx, addr) require.Equal(t, bi, bondInfo{}) privKey := ed25519.GenPrivKey() @@ -68,9 +68,9 @@ func TestKeeperGetSet(t *testing.T) { Power: int64(10), } fmt.Printf("Pubkey: %v\n", privKey.PubKey()) - stakeKeeper.setBondInfo(ctx, addr, bi) + stakingKeeper.setBondInfo(ctx, addr, bi) - savedBi := stakeKeeper.getBondInfo(ctx, addr) + savedBi := stakingKeeper.getBondInfo(ctx, addr) require.NotNil(t, savedBi) fmt.Printf("Bond Info: %v\n", savedBi) require.Equal(t, int64(10), savedBi.Power) @@ -80,25 +80,25 @@ func TestBonding(t *testing.T) { input := setupTestInput() ctx := input.ctx - stakeKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace) + stakingKeeper := NewKeeper(input.capKey, input.bk, DefaultCodespace) addr := sdk.AccAddress([]byte("some-address")) privKey := ed25519.GenPrivKey() pubKey := privKey.PubKey() - _, _, err := stakeKeeper.unbondWithoutCoins(ctx, addr) + _, _, err := stakingKeeper.unbondWithoutCoins(ctx, addr) require.Equal(t, err, ErrInvalidUnbond(DefaultCodespace)) - _, err = stakeKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(staketypes.DefaultBondDenom, 10)) + _, err = stakingKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(stakingtypes.DefaultBondDenom, 10)) require.Nil(t, err) - power, err := stakeKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(staketypes.DefaultBondDenom, 10)) + power, err := stakingKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewInt64Coin(stakingtypes.DefaultBondDenom, 10)) require.Nil(t, err) require.Equal(t, int64(20), power) - pk, _, err := stakeKeeper.unbondWithoutCoins(ctx, addr) + pk, _, err := stakingKeeper.unbondWithoutCoins(ctx, addr) require.Nil(t, err) require.Equal(t, pubKey, pk) - _, _, err = stakeKeeper.unbondWithoutCoins(ctx, addr) + _, _, err = stakingKeeper.unbondWithoutCoins(ctx, addr) require.Equal(t, err, ErrInvalidUnbond(DefaultCodespace)) } diff --git a/docs/examples/democoin/x/simplestake/msgs.go b/docs/examples/democoin/x/simplestaking/msgs.go similarity index 94% rename from docs/examples/democoin/x/simplestake/msgs.go rename to docs/examples/democoin/x/simplestaking/msgs.go index f3edb4ce0d..1f3af1a678 100644 --- a/docs/examples/democoin/x/simplestake/msgs.go +++ b/docs/examples/democoin/x/simplestaking/msgs.go @@ -1,4 +1,4 @@ -package simplestake +package simplestaking import ( "encoding/json" @@ -26,7 +26,7 @@ func NewMsgBond(addr sdk.AccAddress, stake sdk.Coin, pubKey crypto.PubKey) MsgBo } //nolint -func (msg MsgBond) Route() string { return moduleName } //TODO update "stake/createvalidator" +func (msg MsgBond) Route() string { return moduleName } //TODO update "staking/createvalidator" func (msg MsgBond) Type() string { return "bond" } func (msg MsgBond) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Address} } @@ -66,7 +66,7 @@ func NewMsgUnbond(addr sdk.AccAddress) MsgUnbond { } //nolint -func (msg MsgUnbond) Route() string { return moduleName } //TODO update "stake/createvalidator" +func (msg MsgUnbond) Route() string { return moduleName } //TODO update "staking/createvalidator" func (msg MsgUnbond) Type() string { return "unbond" } func (msg MsgUnbond) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Address} } func (msg MsgUnbond) ValidateBasic() sdk.Error { return nil } diff --git a/docs/examples/democoin/x/simplestake/msgs_test.go b/docs/examples/democoin/x/simplestaking/msgs_test.go similarity index 96% rename from docs/examples/democoin/x/simplestake/msgs_test.go rename to docs/examples/democoin/x/simplestaking/msgs_test.go index 4eb4509d89..c9e692407a 100644 --- a/docs/examples/democoin/x/simplestake/msgs_test.go +++ b/docs/examples/democoin/x/simplestaking/msgs_test.go @@ -1,4 +1,4 @@ -package simplestake +package simplestaking import ( "testing" diff --git a/docs/examples/democoin/x/simplestake/types.go b/docs/examples/democoin/x/simplestaking/types.go similarity index 90% rename from docs/examples/democoin/x/simplestake/types.go rename to docs/examples/democoin/x/simplestaking/types.go index 937d36d650..7e6d74d3ed 100644 --- a/docs/examples/democoin/x/simplestake/types.go +++ b/docs/examples/democoin/x/simplestaking/types.go @@ -1,4 +1,4 @@ -package simplestake +package simplestaking import "github.com/tendermint/tendermint/crypto" diff --git a/docs/gaia/deploy-testnet.md b/docs/gaia/deploy-testnet.md index 7323585d87..c617e2052b 100644 --- a/docs/gaia/deploy-testnet.md +++ b/docs/gaia/deploy-testnet.md @@ -33,7 +33,7 @@ gaiacli keys add validator # Add that key into the genesis.app_state.accounts array in the genesis file # NOTE: this command lets you set the number of coins. Make sure this account has some coins -# with the genesis.app_state.stake.params.bond_denom denom, the default is stake +# with the genesis.app_state.staking.params.bond_denom denom, the default is staking gaiad add-genesis-account $(gaiacli keys show validator -a) 1000stake,1000validatortoken # Generate the transaction that creates your validator diff --git a/docs/gaia/gaiacli.md b/docs/gaia/gaiacli.md index e1b07678c5..fb3b89f3a6 100644 --- a/docs/gaia/gaiacli.md +++ b/docs/gaia/gaiacli.md @@ -221,7 +221,7 @@ The action tag always equals the message type returned by the `Type()` function You can find a list of available `tags` on each of the SDK modules: - [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63) -- [Staking tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/stake/tags/tags.go#L8-L24) +- [Staking tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/staking/tags/tags.go#L8-L24) - [Governance tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/gov/tags/tags.go#L8-L22) - [Slashing tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/x/slashing/handler.go#L52) - [Distribution tags](https://github.com/cosmos/cosmos-sdk/blob/develop/x/distribution/tags/tags.go#L8-L17) @@ -277,13 +277,13 @@ On the upcoming mainnet, you can delegate `atom` to a validator. These [delegato You can query the list of all validators of a specific chain: ```bash -gaiacli query stake validators +gaiacli query staking validators ``` If you want to get the information of a single validator you can check it with: ```bash -gaiacli query stake validator +gaiacli query staking validator ``` #### Bond Tokens @@ -291,7 +291,7 @@ gaiacli query stake validator On the testnet, we delegate `steak` instead of `atom`. Here's how you can bond tokens to a testnet validator (_i.e._ delegate): ```bash -gaiacli tx stake delegate \ +gaiacli tx staking delegate \ --amount=10steak \ --validator= \ --from= \ @@ -317,7 +317,7 @@ Don't use more `steak` thank you have! You can always get more by using the [Fau Once submitted a delegation to a validator, you can see it's information by using the following command: ```bash -gaiacli query stake delegation \ +gaiacli query staking delegation \ --address-delegator= \ --validator= ``` @@ -325,7 +325,7 @@ gaiacli query stake delegation \ Or if you want to check all your current delegations with disctinct validators: ```bash -gaiacli query stake delegations +gaiacli query staking delegations ``` You can also get previous delegation(s) status by adding the `--height` flag. @@ -335,7 +335,7 @@ You can also get previous delegation(s) status by adding the `--height` flag. If for any reason the validator misbehaves, or you just want to unbond a certain amount of tokens, use this following command. You can unbond a specific `shares-amount` (eg:`12.1`\) or a `shares-fraction` (eg:`0.25`) with the corresponding flags. ```bash -gaiacli tx stake unbond \ +gaiacli tx staking unbond \ --validator= \ --shares-fraction=0.5 \ --from= \ @@ -349,7 +349,7 @@ The unbonding will be automatically completed when the unbonding period has pass Once you begin an unbonding-delegation, you can see it's information by using the following command: ```bash -gaiacli query stake unbonding-delegation \ +gaiacli query staking unbonding-delegation \ --address-delegator= \ --validator= \ ``` @@ -357,13 +357,13 @@ gaiacli query stake unbonding-delegation \ Or if you want to check all your current unbonding-delegations with disctinct validators: ```bash -gaiacli query stake unbonding-delegations +gaiacli query staking unbonding-delegations ``` Additionally, as you can get all the unbonding-delegations from a particular validator: ```bash - gaiacli query stake unbonding-delegations-from + gaiacli query staking unbonding-delegations-from ``` To get previous unbonding-delegation(s) status on past blocks, try adding the `--height` flag. @@ -373,7 +373,7 @@ To get previous unbonding-delegation(s) status on past blocks, try adding the `- A redelegation is a type delegation that allows you to bond illiquid tokens from one validator to another: ```bash -gaiacli tx stake redelegate \ +gaiacli tx staking redelegate \ --addr-validator-source= \ --addr-validator-dest= \ --shares-fraction=50 \ @@ -390,7 +390,7 @@ The redelegation will be automatically completed when the unbonding period has p Once you begin an redelegation, you can see it's information by using the following command: ```bash -gaiacli query stake redelegation \ +gaiacli query staking redelegation \ --address-delegator= \ --addr-validator-source= \ --addr-validator-dest= \ @@ -399,13 +399,13 @@ gaiacli query stake redelegation \ Or if you want to check all your current unbonding-delegations with disctinct validators: ```bash -gaiacli query stake redelegations +gaiacli query staking redelegations ``` Additionally, as you can get all the outgoing redelegations from a particular validator: ```bash - gaiacli query stake redelegations-from + gaiacli query staking redelegations-from ``` To get previous redelegation(s) status on past blocks, try adding the `--height` flag. @@ -415,7 +415,7 @@ To get previous redelegation(s) status on past blocks, try adding the `--height` Parameters define high level settings for staking. You can get the current values by using: ```bash -gaiacli query stake parameters +gaiacli query staking parameters ``` With the above command you will get the values for: @@ -431,7 +431,7 @@ All these values will be subject to updates though a `governance` process by `Pa A staking `Pool` defines the dynamic parameters of the current state. You can query them with the following command: ```bash -gaiacli query stake pool +gaiacli query staking pool ``` With the `pool` command you will get the values for: diff --git a/docs/gaia/validators/validator-setup.md b/docs/gaia/validators/validator-setup.md index 1495a82d0d..cac1508d04 100644 --- a/docs/gaia/validators/validator-setup.md +++ b/docs/gaia/validators/validator-setup.md @@ -33,7 +33,7 @@ Don't use more `STAKE` thank you have! You can always get more by using the [Fau ::: ```bash -gaiacli tx stake create-validator \ +gaiacli tx staking create-validator \ --amount=5STAKE \ --pubkey=$(gaiad tendermint show-validator) \ --moniker="choose a moniker" \ @@ -91,7 +91,7 @@ A `gentx` is a JSON file carrying a self-delegation. All genesis transactions ar In this case, you need both the signature of the validator and the delegator. Start by creating an unsigned `create-validator` transaction, and save it in a file called `unsignedValTx`: ```bash -gaiacli tx stake create-validator \ +gaiacli tx staking create-validator \ --amount=5STAKE \ --pubkey=$(gaiad tendermint show-validator) \ --moniker="choose a moniker" \ @@ -140,7 +140,7 @@ Once you've collected all genesis transactions in `~/.gaiad/config/gentx`, you c gaiad collect-gentxs ``` -__Note:__ The accounts from which you delegate in the `gentx` transactions need to possess staking tokens in the genesis file, otherwise `collect-gentx` will fail. +__Note:__ The accounts from which you delegate in the `gentx` transactions need to possess stake tokens in the genesis file, otherwise `collect-gentx` will fail. The previous command will collect all genesis transactions and finalise `genesis.json`. To verify the correctness of the configuration and start the node run: @@ -155,7 +155,7 @@ You can edit your validator's public description. This info is to identify your The `--identity` can be used as to verify identity with systems like Keybase or UPort. When using with Keybase `--identity` should be populated with a 16-digit string that is generated with a [keybase.io](https://keybase.io) account. It's a cryptographically secure method of verifying your identity across multiple online networks. The Keybase API allows us to retrieve your Keybase avatar. This is how you can add a logo to your validator profile. ```bash -gaiacli tx stake edit-validator +gaiacli tx staking edit-validator --moniker="choose a moniker" \ --website="https://cosmos.network" \ --identity=6A0D65E29A4CBC8E \ @@ -177,7 +177,7 @@ __Note__: The `commission-rate` value must adhere to the following invariants: View the validator's information with this command: ```bash -gaiacli query stake validator +gaiacli query staking validator ``` ## Track Validator Signing Information diff --git a/docs/modules/README.md b/docs/modules/README.md index 53e02687ea..665a26a78b 100644 --- a/docs/modules/README.md +++ b/docs/modules/README.md @@ -6,9 +6,9 @@ See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/bank). # Stake -The `x/stake` module is for Cosmos Delegated-Proof-of-Stake. +The `x/staking` module is for Cosmos Delegated-Proof-of-Stake. -See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/stake). +See the [API docs](https://godoc.org/github.com/cosmos/cosmos-sdk/x/staking). See the [specification](https://github.com/cosmos/cosmos-sdk/tree/develop/docs/spec/staking) diff --git a/docs/spec/auth/vesting.md b/docs/spec/auth/vesting.md index b8785619b2..36a7a80b1e 100644 --- a/docs/spec/auth/vesting.md +++ b/docs/spec/auth/vesting.md @@ -333,7 +333,7 @@ func UndelegateCoins(to Account, amount Coins) { ## Keepers & Handlers The `VestingAccount` implementations reside in `x/auth`. However, any keeper in -a module (e.g. staking in `x/stake`) wishing to potentially utilize any vesting +a module (e.g. staking in `x/staking`) wishing to potentially utilize any vesting coins, must call explicit methods on the `x/bank` keeper (e.g. `DelegateCoins`) opposed to `SendCoins` and `SubtractCoins`. diff --git a/docs/spec/distribution/hooks.md b/docs/spec/distribution/hooks.md index 8c2b4b91a1..ca18dad080 100644 --- a/docs/spec/distribution/hooks.md +++ b/docs/spec/distribution/hooks.md @@ -2,7 +2,7 @@ ## Create or modify delegation distribution - - triggered-by: `stake.TxDelegate`, `stake.TxBeginRedelegate`, `stake.TxBeginUnbonding` + - triggered-by: `staking.TxDelegate`, `staking.TxBeginRedelegate`, `staking.TxBeginUnbonding` The pool of a new delegator bond will be 0 for the height at which the bond was added, or the withdrawal has taken place. This is achieved by setting @@ -10,7 +10,7 @@ added, or the withdrawal has taken place. This is achieved by setting ## Commission rate change - - triggered-by: `stake.TxEditValidator` + - triggered-by: `staking.TxEditValidator` If a validator changes its commission rate, all commission on fees must be simultaneously withdrawn using the transaction `TxWithdrawValidator`. @@ -19,7 +19,7 @@ Additionally the change and associated height must be recorded in a ## Change in Validator State - - triggered-by: `stake.Slash`, `stake.UpdateValidator` + - triggered-by: `staking.Slash`, `staking.UpdateValidator` Whenever a validator is slashed or enters/leaves the validator group all of the validator entitled reward tokens must be simultaneously withdrawn from diff --git a/docs/spec/distribution/transactions.md b/docs/spec/distribution/transactions.md index 821c4ba352..57c4d31035 100644 --- a/docs/spec/distribution/transactions.md +++ b/docs/spec/distribution/transactions.md @@ -24,7 +24,7 @@ func GetDelegatorRewardsAll(delegatorAddr sdk.AccAddress, height int64) DecCoins // collect all entitled rewards withdraw = 0 - pool = stake.GetPool() + pool = staking.GetPool() feePool = GetFeePool() for delegation = range delegations delInfo = GetDelegationDistInfo(delegation.DelegatorAddr, @@ -55,7 +55,7 @@ func WithdrawDelegationReward(delegatorAddr, validatorAddr, withdrawAddr sdk.Acc height = GetHeight() // get all distribution scenarios - pool = stake.GetPool() + pool = staking.GetPool() feePool = GetFeePool() delInfo = GetDelegationDistInfo(delegatorAddr, validatorAddr) diff --git a/docs/spec/governance/state.md b/docs/spec/governance/state.md index abe2dc41b4..f28a309a44 100644 --- a/docs/spec/governance/state.md +++ b/docs/spec/governance/state.md @@ -160,14 +160,14 @@ And the pseudocode for the `ProposalProcessingQueue`: // Tally voterIterator = rangeQuery(Governance, ) //return all the addresses that voted on the proposal for each (voterAddress, vote) in voterIterator - delegations = stakeKeeper.getDelegations(voterAddress) // get all delegations for current voter + delegations = stakingKeeper.getDelegations(voterAddress) // get all delegations for current voter for each delegation in delegations // make sure delegation.Shares does NOT include shares being unbonded tmpValMap(delegation.ValidatorAddr).Minus += delegation.Shares proposal.updateTally(vote, delegation.Shares) - _, isVal = stakeKeeper.getValidator(voterAddress) + _, isVal = stakingKeeper.getValidator(voterAddress) if (isVal) tmpValMap(voterAddress).Vote = vote diff --git a/docs/spec/staking/state.md b/docs/spec/staking/state.md index d2f461e103..1336e1e4ca 100644 --- a/docs/spec/staking/state.md +++ b/docs/spec/staking/state.md @@ -18,7 +18,7 @@ type Pool struct { ### Params Params is global data structure that stores system parameters and defines -overall functioning of the stake module. +overall functioning of the staking module. - Params: `0x00 -> amino(params)` diff --git a/x/auth/client/txbuilder/txbuilder_test.go b/x/auth/client/txbuilder/txbuilder_test.go index f33c96be18..7d3dfc7ec7 100644 --- a/x/auth/client/txbuilder/txbuilder_test.go +++ b/x/auth/client/txbuilder/txbuilder_test.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -48,7 +48,7 @@ func TestTxBuilderBuild(t *testing.T) { SimulateGas: false, ChainID: "test-chain", Memo: "hello from Voyager !", - Fees: sdk.Coins{sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(1))}, + Fees: sdk.Coins{sdk.NewCoin(stakingTypes.DefaultBondDenom, sdk.NewInt(1))}, }, defaultMsg, StdSignMsg{ @@ -57,7 +57,7 @@ func TestTxBuilderBuild(t *testing.T) { Sequence: 1, Memo: "hello from Voyager !", Msgs: defaultMsg, - Fee: auth.NewStdFee(100, sdk.Coins{sdk.NewCoin(stakeTypes.DefaultBondDenom, sdk.NewInt(1))}), + Fee: auth.NewStdFee(100, sdk.Coins{sdk.NewCoin(stakingTypes.DefaultBondDenom, sdk.NewInt(1))}), }, false, }, diff --git a/x/auth/params.go b/x/auth/params.go index 94cf69ff0b..9fcde581cd 100644 --- a/x/auth/params.go +++ b/x/auth/params.go @@ -42,7 +42,7 @@ type Params struct { SigVerifyCostSecp256k1 uint64 } -// ParamTable for stake module +// ParamTable for staking module func ParamTypeTable() params.TypeTable { return params.NewTypeTable().RegisterParamSet(&Params{}) } diff --git a/x/distribution/alias.go b/x/distribution/alias.go index c9922e2c63..626c55dc5d 100644 --- a/x/distribution/alias.go +++ b/x/distribution/alias.go @@ -27,7 +27,7 @@ type ( GenesisState = types.GenesisState // expected keepers - StakeKeeper = types.StakeKeeper + StakingKeeper = types.StakingKeeper BankKeeper = types.BankKeeper FeeCollectionKeeper = types.FeeCollectionKeeper ) diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 97b1e4b379..4468f7d3c4 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -9,7 +9,7 @@ import ( func (k Keeper) AllocateTokens(ctx sdk.Context, percentVotes sdk.Dec, proposer sdk.ConsAddress) { // get the proposer of this block - proposerValidator := k.stakeKeeper.ValidatorByConsAddr(ctx, proposer) + proposerValidator := k.stakingKeeper.ValidatorByConsAddr(ctx, proposer) proposerDist := k.GetValidatorDistInfo(ctx, proposerValidator.GetOperator()) @@ -21,7 +21,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, percentVotes sdk.Dec, proposer s feePool := k.GetFeePool(ctx) // Temporary workaround to keep CanWithdrawInvariant happy. // General discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 - if k.stakeKeeper.GetLastTotalPower(ctx).IsZero() { + if k.stakingKeeper.GetLastTotalPower(ctx).IsZero() { feePool.CommunityPool = feePool.CommunityPool.Plus(feesCollectedDec) k.SetFeePool(ctx, feePool) k.feeCollectionKeeper.ClearCollectedFees(ctx) diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index b6b28ac456..dae7beee79 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -7,21 +7,21 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) func TestAllocateTokensBasic(t *testing.T) { // no community tax on inputs ctx, _, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator totalPower := int64(10) totalPowerInt := sdk.NewInt(totalPower) - msgCreateValidator := stake.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, totalPower) - got := stakeHandler(ctx, msgCreateValidator) + msgCreateValidator := staking.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, totalPower) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) @@ -56,13 +56,13 @@ func TestAllocateTokensBasic(t *testing.T) { func TestAllocateTokensWithCommunityTax(t *testing.T) { communityTax := sdk.NewDecWithPrec(1, 2) //1% ctx, _, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, communityTax) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator totalPower := int64(10) - msgCreateValidator := stake.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, totalPower) - got := stakeHandler(ctx, msgCreateValidator) + msgCreateValidator := staking.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, totalPower) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) @@ -84,13 +84,13 @@ func TestAllocateTokensWithCommunityTax(t *testing.T) { func TestAllocateTokensWithPartialPrecommitPower(t *testing.T) { communityTax := sdk.NewDecWithPrec(1, 2) ctx, _, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, communityTax) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator totalPower := int64(100) - msgCreateValidator := stake.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, totalPower) - got := stakeHandler(ctx, msgCreateValidator) + msgCreateValidator := staking.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, totalPower) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index dc54a6e4fe..93e068cec8 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -105,8 +105,8 @@ func (k Keeper) withdrawDelegationReward(ctx sdk.Context, wc := k.GetWithdrawContext(ctx, valAddr) valInfo := k.GetValidatorDistInfo(ctx, valAddr) delInfo := k.GetDelegationDistInfo(ctx, delAddr, valAddr) - validator := k.stakeKeeper.Validator(ctx, valAddr) - delegation := k.stakeKeeper.Delegation(ctx, delAddr, valAddr) + validator := k.stakingKeeper.Validator(ctx, valAddr) + delegation := k.stakingKeeper.Delegation(ctx, delAddr, valAddr) delInfo, valInfo, feePool, withdraw := delInfo.WithdrawRewards(wc, valInfo, validator.GetDelegatorShares(), delegation.GetShares()) @@ -122,8 +122,8 @@ func (k Keeper) currentDelegationReward(ctx sdk.Context, delAddr sdk.AccAddress, valInfo := k.GetValidatorDistInfo(ctx, valAddr) delInfo := k.GetDelegationDistInfo(ctx, delAddr, valAddr) - validator := k.stakeKeeper.Validator(ctx, valAddr) - delegation := k.stakeKeeper.Delegation(ctx, delAddr, valAddr) + validator := k.stakingKeeper.Validator(ctx, valAddr) + delegation := k.stakingKeeper.Delegation(ctx, delAddr, valAddr) estimation := delInfo.CurrentRewards(wc, valInfo, validator.GetDelegatorShares(), delegation.GetShares()) @@ -209,7 +209,7 @@ func (k Keeper) withdrawDelegationRewardsAll(ctx sdk.Context, return false } - k.stakeKeeper.IterateDelegations(ctx, delAddr, operationAtDelegation) + k.stakingKeeper.IterateDelegations(ctx, delAddr, operationAtDelegation) return withdraw } @@ -225,6 +225,6 @@ func (k Keeper) CurrentDelegationRewardsAll(ctx sdk.Context, total = total.Plus(est) return false } - k.stakeKeeper.IterateDelegations(ctx, delAddr, operationAtDelegation) + k.stakingKeeper.IterateDelegations(ctx, delAddr, operationAtDelegation) return total } diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 67606cc842..114ec1b633 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -6,23 +6,23 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) func TestWithdrawDelegationRewardBasic(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator - msgCreateValidator := stake.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, 10) - got := stakeHandler(ctx, msgCreateValidator) + msgCreateValidator := staking.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, 10) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) @@ -46,19 +46,19 @@ func TestWithdrawDelegationRewardBasic(t *testing.T) { func TestWithdrawDelegationRewardWithCommission(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator with 10% commission - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, sdk.NewDecWithPrec(1, 1)) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) @@ -80,25 +80,25 @@ func TestWithdrawDelegationRewardWithCommission(t *testing.T) { func TestWithdrawDelegationRewardTwoDelegators(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator with 10% commission - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, sdk.NewDecWithPrec(1, 1)) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) - msgDelegate = stake.NewTestMsgDelegate(delAddr2, valOpAddr1, 20) - got = stakeHandler(ctx, msgDelegate) + msgDelegate = staking.NewTestMsgDelegate(delAddr2, valOpAddr1, 20) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt = accMapper.GetAccount(ctx, delAddr2).GetCoins().AmountOf(denom) require.Equal(t, int64(80), amt.Int64()) @@ -122,25 +122,25 @@ func TestWithdrawDelegationRewardTwoDelegators(t *testing.T) { // with different rewards in the end func TestWithdrawDelegationRewardTwoDelegatorsUneven(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator with no commission - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, sdk.ZeroDec()) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) - msgDelegate = stake.NewTestMsgDelegate(delAddr2, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate = staking.NewTestMsgDelegate(delAddr2, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt = accMapper.GetAccount(ctx, delAddr2).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) @@ -188,32 +188,32 @@ func TestWithdrawDelegationRewardTwoDelegatorsUneven(t *testing.T) { func TestWithdrawDelegationRewardsAll(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //make some validators with different commissions - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, sdk.NewDecWithPrec(1, 1)) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) - msgCreateValidator = stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator = staking.NewTestMsgCreateValidatorWithCommission( valOpAddr2, valConsPk2, 50, sdk.NewDecWithPrec(2, 1)) - got = stakeHandler(ctx, msgCreateValidator) + got = stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) - msgCreateValidator = stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator = staking.NewTestMsgCreateValidatorWithCommission( valOpAddr3, valConsPk3, 40, sdk.NewDecWithPrec(3, 1)) - got = stakeHandler(ctx, msgCreateValidator) + got = stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) // delegate to all the validators - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - require.True(t, stakeHandler(ctx, msgDelegate).IsOK()) - msgDelegate = stake.NewTestMsgDelegate(delAddr1, valOpAddr2, 20) - require.True(t, stakeHandler(ctx, msgDelegate).IsOK()) - msgDelegate = stake.NewTestMsgDelegate(delAddr1, valOpAddr3, 30) - require.True(t, stakeHandler(ctx, msgDelegate).IsOK()) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + require.True(t, stakingHandler(ctx, msgDelegate).IsOK()) + msgDelegate = staking.NewTestMsgDelegate(delAddr1, valOpAddr2, 20) + require.True(t, stakingHandler(ctx, msgDelegate).IsOK()) + msgDelegate = staking.NewTestMsgDelegate(delAddr1, valOpAddr3, 30) + require.True(t, stakingHandler(ctx, msgDelegate).IsOK()) // Update sk's LastValidatorPower/LastTotalPowers. _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go index 7729e6b543..10d4f059b1 100644 --- a/x/distribution/keeper/hooks.go +++ b/x/distribution/keeper/hooks.go @@ -40,7 +40,7 @@ func (k Keeper) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) // Withdraw all validator rewards func (k Keeper) AfterValidatorBonded(ctx sdk.Context, valAddr sdk.ValAddress) { - lastPower := k.stakeKeeper.GetLastValidatorPower(ctx, valAddr) + lastPower := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) if !lastPower.Equal(sdk.ZeroInt()) { panic("expected last power to be 0 for validator entering bonded state") } diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index a6fed96358..f2c68b8a00 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -7,13 +7,13 @@ import ( "github.com/cosmos/cosmos-sdk/x/params" ) -// keeper of the stake store +// keeper of the staking store type Keeper struct { storeKey sdk.StoreKey cdc *codec.Codec paramSpace params.Subspace bankKeeper types.BankKeeper - stakeKeeper types.StakeKeeper + stakingKeeper types.StakingKeeper feeCollectionKeeper types.FeeCollectionKeeper // codespace @@ -21,14 +21,14 @@ type Keeper struct { } func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, ck types.BankKeeper, - sk types.StakeKeeper, fck types.FeeCollectionKeeper, codespace sdk.CodespaceType) Keeper { + sk types.StakingKeeper, fck types.FeeCollectionKeeper, codespace sdk.CodespaceType) Keeper { keeper := Keeper{ storeKey: key, cdc: cdc, paramSpace: paramSpace.WithTypeTable(ParamTypeTable()), bankKeeper: ck, - stakeKeeper: sk, + stakingKeeper: sk, feeCollectionKeeper: fck, codespace: codespace, } @@ -61,7 +61,7 @@ func (k Keeper) GetFeePoolValAccum(ctx sdk.Context) sdk.Dec { // withdraw self-delegation height := ctx.BlockHeight() - totalPower := sdk.NewDecFromInt(k.stakeKeeper.GetLastTotalPower(ctx)) + totalPower := sdk.NewDecFromInt(k.stakingKeeper.GetLastTotalPower(ctx)) fp := k.GetFeePool(ctx) return fp.GetTotalValAccum(height, totalPower) } @@ -96,9 +96,9 @@ func (k Keeper) GetWithdrawContext(ctx sdk.Context, feePool := k.GetFeePool(ctx) height := ctx.BlockHeight() - validator := k.stakeKeeper.Validator(ctx, valOperatorAddr) - lastValPower := k.stakeKeeper.GetLastValidatorPower(ctx, valOperatorAddr) - lastTotalPower := sdk.NewDecFromInt(k.stakeKeeper.GetLastTotalPower(ctx)) + validator := k.stakingKeeper.Validator(ctx, valOperatorAddr) + lastValPower := k.stakingKeeper.GetLastValidatorPower(ctx, valOperatorAddr) + lastTotalPower := sdk.NewDecFromInt(k.stakingKeeper.GetLastTotalPower(ctx)) return types.NewWithdrawContext( feePool, height, lastTotalPower, sdk.NewDecFromInt(lastValPower), diff --git a/x/distribution/keeper/test_common.go b/x/distribution/keeper/test_common.go index 64bd7d5e9c..793f557738 100644 --- a/x/distribution/keeper/test_common.go +++ b/x/distribution/keeper/test_common.go @@ -17,7 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/distribution/types" ) @@ -61,7 +61,7 @@ var ( func MakeTestCodec() *codec.Codec { var cdc = codec.New() bank.RegisterCodec(cdc) - stake.RegisterCodec(cdc) + staking.RegisterCodec(cdc) auth.RegisterCodec(cdc) sdk.RegisterCodec(cdc) codec.RegisterCrypto(cdc) @@ -72,7 +72,7 @@ func MakeTestCodec() *codec.Codec { // test input with default values func CreateTestInputDefault(t *testing.T, isCheckTx bool, initCoins int64) ( - sdk.Context, auth.AccountKeeper, Keeper, stake.Keeper, DummyFeeCollectionKeeper) { + sdk.Context, auth.AccountKeeper, Keeper, staking.Keeper, DummyFeeCollectionKeeper) { communityTax := sdk.NewDecWithPrec(2, 2) return CreateTestInputAdvanced(t, isCheckTx, initCoins, communityTax) @@ -81,11 +81,11 @@ func CreateTestInputDefault(t *testing.T, isCheckTx bool, initCoins int64) ( // hogpodge of all sorts of input required for testing func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initCoins int64, communityTax sdk.Dec) ( - sdk.Context, auth.AccountKeeper, Keeper, stake.Keeper, DummyFeeCollectionKeeper) { + sdk.Context, auth.AccountKeeper, Keeper, staking.Keeper, DummyFeeCollectionKeeper) { keyDistr := sdk.NewKVStoreKey(types.StoreKey) - keyStake := sdk.NewKVStoreKey(stake.StoreKey) - tkeyStake := sdk.NewTransientStoreKey(stake.TStoreKey) + keyStaking := sdk.NewKVStoreKey(staking.StoreKey) + tkeyStaking := sdk.NewTransientStoreKey(staking.TStoreKey) keyAcc := sdk.NewKVStoreKey(auth.StoreKey) keyFeeCollection := sdk.NewKVStoreKey(auth.FeeStoreKey) keyParams := sdk.NewKVStoreKey(params.StoreKey) @@ -95,8 +95,8 @@ func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initCoins int64, ms := store.NewCommitMultiStore(db) ms.MountStoreWithDB(keyDistr, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkeyStake, sdk.StoreTypeTransient, nil) - ms.MountStoreWithDB(keyStake, sdk.StoreTypeIAVL, db) + ms.MountStoreWithDB(tkeyStaking, sdk.StoreTypeTransient, nil) + ms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyFeeCollection, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) @@ -111,9 +111,9 @@ func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initCoins int64, ctx := sdk.NewContext(ms, abci.Header{ChainID: "foochainid"}, isCheckTx, log.NewNopLogger()) accountKeeper := auth.NewAccountKeeper(cdc, keyAcc, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount) ck := bank.NewBaseKeeper(accountKeeper) - sk := stake.NewKeeper(cdc, keyStake, tkeyStake, ck, pk.Subspace(stake.DefaultParamspace), stake.DefaultCodespace) - sk.SetPool(ctx, stake.InitialPool()) - sk.SetParams(ctx, stake.DefaultParams()) + sk := staking.NewKeeper(cdc, keyStaking, tkeyStaking, ck, pk.Subspace(staking.DefaultParamspace), staking.DefaultCodespace) + sk.SetPool(ctx, staking.InitialPool()) + sk.SetParams(ctx, staking.DefaultParams()) // fill all the addresses with some coins, set the loose pool tokens simultaneously for _, addr := range addrs { diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index 8d861fef80..76e5fe8d33 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -87,7 +87,7 @@ func (k Keeper) GetValidatorAccum(ctx sdk.Context, operatorAddr sdk.ValAddress) // withdraw self-delegation height := ctx.BlockHeight() - lastValPower := k.stakeKeeper.GetLastValidatorPower(ctx, operatorAddr) + lastValPower := k.stakingKeeper.GetLastValidatorPower(ctx, operatorAddr) valInfo := k.GetValidatorDistInfo(ctx, operatorAddr) accum := valInfo.GetValAccum(height, sdk.NewDecFromInt(lastValPower)) diff --git a/x/distribution/keeper/validator_test.go b/x/distribution/keeper/validator_test.go index 58079241cc..a6956fcc0c 100644 --- a/x/distribution/keeper/validator_test.go +++ b/x/distribution/keeper/validator_test.go @@ -6,17 +6,17 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) func TestWithdrawValidatorRewardsAllNoDelegator(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom // first make a validator - msgCreateValidator := stake.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, 10) - got := stakeHandler(ctx, msgCreateValidator) + msgCreateValidator := staking.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, 10) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) @@ -36,18 +36,18 @@ func TestWithdrawValidatorRewardsAllNoDelegator(t *testing.T) { func TestWithdrawValidatorRewardsAllDelegatorNoCommission(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator - msgCreateValidator := stake.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, 10) - got := stakeHandler(ctx, msgCreateValidator) + msgCreateValidator := staking.NewTestMsgCreateValidator(valOpAddr1, valConsPk1, 10) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) @@ -68,20 +68,20 @@ func TestWithdrawValidatorRewardsAllDelegatorNoCommission(t *testing.T) { func TestWithdrawValidatorRewardsAllDelegatorWithCommission(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator commissionRate := sdk.NewDecWithPrec(1, 1) - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, commissionRate) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) @@ -105,26 +105,26 @@ func TestWithdrawValidatorRewardsAllDelegatorWithCommission(t *testing.T) { func TestWithdrawValidatorRewardsAllMultipleValidator(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom // Make some validators with different commissions. // Bond 10 of 100 with 0.1 commission. - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, sdk.NewDecWithPrec(1, 1)) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) // Bond 50 of 100 with 0.2 commission. - msgCreateValidator = stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator = staking.NewTestMsgCreateValidatorWithCommission( valOpAddr2, valConsPk2, 50, sdk.NewDecWithPrec(2, 1)) - got = stakeHandler(ctx, msgCreateValidator) + got = stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) // Bond 40 of 100 with 0.3 commission. - msgCreateValidator = stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator = staking.NewTestMsgCreateValidatorWithCommission( valOpAddr3, valConsPk3, 40, sdk.NewDecWithPrec(3, 1)) - got = stakeHandler(ctx, msgCreateValidator) + got = stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) @@ -156,26 +156,26 @@ func TestWithdrawValidatorRewardsAllMultipleValidator(t *testing.T) { func TestWithdrawValidatorRewardsAllMultipleDelegator(t *testing.T) { ctx, accMapper, keeper, sk, fck := CreateTestInputAdvanced(t, false, 100, sdk.ZeroDec()) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) denom := sk.GetParams(ctx).BondDenom //first make a validator with 10% commission commissionRate := sdk.NewDecWithPrec(1, 1) - msgCreateValidator := stake.NewTestMsgCreateValidatorWithCommission( + msgCreateValidator := staking.NewTestMsgCreateValidatorWithCommission( valOpAddr1, valConsPk1, 10, sdk.NewDecWithPrec(1, 1)) - got := stakeHandler(ctx, msgCreateValidator) + got := stakingHandler(ctx, msgCreateValidator) require.True(t, got.IsOK(), "expected msg to be ok, got %v", got) _ = sk.ApplyAndReturnValidatorSetUpdates(ctx) // delegate - msgDelegate := stake.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) - got = stakeHandler(ctx, msgDelegate) + msgDelegate := staking.NewTestMsgDelegate(delAddr1, valOpAddr1, 10) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt := accMapper.GetAccount(ctx, delAddr1).GetCoins().AmountOf(denom) require.Equal(t, int64(90), amt.Int64()) - msgDelegate = stake.NewTestMsgDelegate(delAddr2, valOpAddr1, 20) - got = stakeHandler(ctx, msgDelegate) + msgDelegate = staking.NewTestMsgDelegate(delAddr2, valOpAddr1, 20) + got = stakingHandler(ctx, msgDelegate) require.True(t, got.IsOK()) amt = accMapper.GetAccount(ctx, delAddr2).GetCoins().AmountOf(denom) require.Equal(t, int64(80), amt.Int64()) diff --git a/x/distribution/simulation/invariants.go b/x/distribution/simulation/invariants.go index 2f954d6e12..cdebc98d2c 100644 --- a/x/distribution/simulation/invariants.go +++ b/x/distribution/simulation/invariants.go @@ -6,13 +6,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" distr "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/mock/simulation" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) // AllInvariants runs all invariants of the distribution module // Currently: total supply, positive power -func AllInvariants(d distr.Keeper, stk stake.Keeper) simulation.Invariant { - sk := distr.StakeKeeper(stk) +func AllInvariants(d distr.Keeper, stk staking.Keeper) simulation.Invariant { + sk := distr.StakingKeeper(stk) return func(ctx sdk.Context) error { err := ValAccumInvariants(d, sk)(ctx) if err != nil { @@ -31,7 +31,7 @@ func AllInvariants(d distr.Keeper, stk stake.Keeper) simulation.Invariant { } // ValAccumInvariants checks that the fee pool accum == sum all validators' accum -func ValAccumInvariants(k distr.Keeper, sk distr.StakeKeeper) simulation.Invariant { +func ValAccumInvariants(k distr.Keeper, sk distr.StakingKeeper) simulation.Invariant { return func(ctx sdk.Context) error { height := ctx.BlockHeight() @@ -56,7 +56,7 @@ func ValAccumInvariants(k distr.Keeper, sk distr.StakeKeeper) simulation.Invaria } // DelAccumInvariants checks that each validator del accum == sum all delegators' accum -func DelAccumInvariants(k distr.Keeper, sk distr.StakeKeeper) simulation.Invariant { +func DelAccumInvariants(k distr.Keeper, sk distr.StakingKeeper) simulation.Invariant { return func(ctx sdk.Context) error { height := ctx.BlockHeight() @@ -133,7 +133,7 @@ func DelAccumInvariants(k distr.Keeper, sk distr.StakeKeeper) simulation.Invaria } // CanWithdrawInvariant checks that current rewards can be completely withdrawn -func CanWithdrawInvariant(k distr.Keeper, sk stake.Keeper) simulation.Invariant { +func CanWithdrawInvariant(k distr.Keeper, sk staking.Keeper) simulation.Invariant { return func(ctx sdk.Context) error { // we don't want to write the changes ctx, _ = ctx.CacheContext() diff --git a/x/distribution/types/delegation_info_test.go b/x/distribution/types/delegation_info_test.go index 9c2a4980f6..e97ea80510 100644 --- a/x/distribution/types/delegation_info_test.go +++ b/x/distribution/types/delegation_info_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" sdk "github.com/cosmos/cosmos-sdk/types" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestWithdrawRewards(t *testing.T) { @@ -28,7 +28,7 @@ func TestWithdrawRewards(t *testing.T) { // simulate adding some stake for inflation height = 10 - fp.ValPool = DecCoins{NewDecCoin(stakeTypes.DefaultBondDenom, 1000)} + fp.ValPool = DecCoins{NewDecCoin(stakingTypes.DefaultBondDenom, 1000)} // withdraw rewards wc := NewWithdrawContext(fp, height, diff --git a/x/distribution/types/keepers.go b/x/distribution/types/keepers.go index c44c0dedf2..4411ebc8de 100644 --- a/x/distribution/types/keepers.go +++ b/x/distribution/types/keepers.go @@ -2,8 +2,8 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" -// expected stake keeper -type StakeKeeper interface { +// expected staking keeper +type StakingKeeper interface { IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation sdk.Delegation) (stop bool)) Delegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation diff --git a/x/distribution/types/validator_info_test.go b/x/distribution/types/validator_info_test.go index 3761c4e765..9982a7dc1c 100644 --- a/x/distribution/types/validator_info_test.go +++ b/x/distribution/types/validator_info_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestTakeFeePoolRewards(t *testing.T) { @@ -28,7 +28,7 @@ func TestTakeFeePoolRewards(t *testing.T) { // simulate adding some stake for inflation height = 10 - fp.ValPool = DecCoins{NewDecCoin(stakeTypes.DefaultBondDenom, 1000)} + fp.ValPool = DecCoins{NewDecCoin(stakingTypes.DefaultBondDenom, 1000)} vi1, fp = vi1.TakeFeePoolRewards(NewWithdrawContext( fp, height, totalBondedTokens, validatorTokens1, commissionRate1)) @@ -68,7 +68,7 @@ func TestWithdrawCommission(t *testing.T) { // simulate adding some stake for inflation height = 10 - fp.ValPool = DecCoins{NewDecCoin(stakeTypes.DefaultBondDenom, 1000)} + fp.ValPool = DecCoins{NewDecCoin(stakingTypes.DefaultBondDenom, 1000)} // for a more fun staring condition, have an non-withdraw update vi, fp = vi.TakeFeePoolRewards(NewWithdrawContext( diff --git a/x/gov/endblocker_test.go b/x/gov/endblocker_test.go index d9035e7188..1eb60c4f2b 100644 --- a/x/gov/endblocker_test.go +++ b/x/gov/endblocker_test.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestTickExpiredDepositPeriod(t *testing.T) { @@ -22,7 +22,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) { require.False(t, inactiveQueue.Valid()) inactiveQueue.Close() - newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res := govHandler(ctx, newProposalMsg) require.True(t, res.IsOK()) @@ -64,7 +64,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { require.False(t, inactiveQueue.Valid()) inactiveQueue.Close() - newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res := govHandler(ctx, newProposalMsg) require.True(t, res.IsOK()) @@ -81,7 +81,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { require.False(t, inactiveQueue.Valid()) inactiveQueue.Close() - newProposalMsg2 := NewMsgSubmitProposal("Test2", "test2", ProposalTypeText, addrs[1], sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newProposalMsg2 := NewMsgSubmitProposal("Test2", "test2", ProposalTypeText, addrs[1], sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res = govHandler(ctx, newProposalMsg2) require.True(t, res.IsOK()) @@ -123,7 +123,7 @@ func TestTickPassedDepositPeriod(t *testing.T) { require.False(t, activeQueue.Valid()) activeQueue.Close() - newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res := govHandler(ctx, newProposalMsg) require.True(t, res.IsOK()) @@ -142,7 +142,7 @@ func TestTickPassedDepositPeriod(t *testing.T) { require.False(t, inactiveQueue.Valid()) inactiveQueue.Close() - newDepositMsg := NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newDepositMsg := NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res = govHandler(ctx, newDepositMsg) require.True(t, res.IsOK()) @@ -165,7 +165,7 @@ func TestTickPassedVotingPeriod(t *testing.T) { require.False(t, activeQueue.Valid()) activeQueue.Close() - newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newProposalMsg := NewMsgSubmitProposal("Test", "test", ProposalTypeText, addrs[0], sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res := govHandler(ctx, newProposalMsg) require.True(t, res.IsOK()) @@ -176,7 +176,7 @@ func TestTickPassedVotingPeriod(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(1) * time.Second) ctx = ctx.WithBlockHeader(newHeader) - newDepositMsg := NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)}) + newDepositMsg := NewMsgDeposit(addrs[1], proposalID, sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)}) res = govHandler(ctx, newDepositMsg) require.True(t, res.IsOK()) diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 6430de254f..e06d79b21f 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // GenesisState - all staking state that must be provided at genesis @@ -45,7 +45,7 @@ func DefaultGenesisState() GenesisState { return GenesisState{ StartingProposalID: 1, DepositParams: DepositParams{ - MinDeposit: sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)}, + MinDeposit: sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)}, MaxDepositPeriod: time.Duration(172800) * time.Second, }, VotingParams: VotingParams{ diff --git a/x/gov/keeper_test.go b/x/gov/keeper_test.go index 4fffce43a6..f4308ef19c 100644 --- a/x/gov/keeper_test.go +++ b/x/gov/keeper_test.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestGetSetProposal(t *testing.T) { @@ -70,14 +70,14 @@ func TestDeposits(t *testing.T) { proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() - fourSteak := sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 4)} - fiveSteak := sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 5)} + fourSteak := sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 4)} + fiveSteak := sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 5)} addr0Initial := keeper.ck.GetCoins(ctx, addrs[0]) addr1Initial := keeper.ck.GetCoins(ctx, addrs[1]) - // require.True(t, addr0Initial.IsEqual(sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 42)})) - require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 42)}, addr0Initial) + // require.True(t, addr0Initial.IsEqual(sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 42)})) + require.Equal(t, sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 42)}, addr0Initial) require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{})) diff --git a/x/gov/msgs_test.go b/x/gov/msgs_test.go index 36bc10a6a0..83881834f8 100644 --- a/x/gov/msgs_test.go +++ b/x/gov/msgs_test.go @@ -7,14 +7,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/mock" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( - coinsPos = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 1000)} + coinsPos = sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 1000)} coinsZero = sdk.Coins{} coinsPosNotAtoms = sdk.Coins{sdk.NewInt64Coin("foo", 10000)} - coinsMulti = sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000)} + coinsMulti = sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000)} ) func init() { diff --git a/x/gov/simulation/msgs.go b/x/gov/simulation/msgs.go index 5319ee7b2c..faca7ec8e9 100644 --- a/x/gov/simulation/msgs.go +++ b/x/gov/simulation/msgs.go @@ -10,12 +10,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mock/simulation" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) const ( - denom = stakeTypes.DefaultBondDenom + denom = stakingTypes.DefaultBondDenom ) // SimulateSubmittingVotingAndSlashingForProposal simulates creating a msg Submit Proposal @@ -23,7 +23,7 @@ const ( // future operations. // TODO: Vote more intelligently, so we can actually do some checks regarding votes passing or failing // TODO: Actually check that validator slashings happened -func SimulateSubmittingVotingAndSlashingForProposal(k gov.Keeper, sk stake.Keeper) simulation.Operation { +func SimulateSubmittingVotingAndSlashingForProposal(k gov.Keeper, sk staking.Keeper) simulation.Operation { handler := gov.NewHandler(k) // The states are: // column 1: All validators vote diff --git a/x/gov/tally_test.go b/x/gov/tally_test.go index 3c90183049..77a22996b0 100644 --- a/x/gov/tally_test.go +++ b/x/gov/tally_test.go @@ -11,26 +11,26 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( pubkeys = []crypto.PubKey{ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey()} - testDescription = stake.NewDescription("T", "E", "S", "T") - testCommissionMsg = stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + testDescription = staking.NewDescription("T", "E", "S", "T") + testCommissionMsg = staking.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) ) -func createValidators(t *testing.T, stakeHandler sdk.Handler, ctx sdk.Context, addrs []sdk.ValAddress, coinAmt []int64) { +func createValidators(t *testing.T, stakingHandler sdk.Handler, ctx sdk.Context, addrs []sdk.ValAddress, coinAmt []int64) { require.True(t, len(addrs) <= len(pubkeys), "Not enough pubkeys specified at top of file.") for i := 0; i < len(addrs); i++ { - valCreateMsg := stake.NewMsgCreateValidator( - addrs[i], pubkeys[i], sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, coinAmt[i]), testDescription, testCommissionMsg, + valCreateMsg := staking.NewMsgCreateValidator( + addrs[i], pubkeys[i], sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, coinAmt[i]), testDescription, testCommissionMsg, ) - res := stakeHandler(ctx, valCreateMsg) + res := stakingHandler(ctx, valCreateMsg) require.True(t, res.IsOK()) } } @@ -39,15 +39,15 @@ func TestTallyNoOneVotes(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:2])) for i, addr := range addrs[:2] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{5, 5}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{5, 5}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -64,15 +64,15 @@ func TestTallyNoQuorum(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:2])) for i, addr := range addrs[:2] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{2, 5}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{2, 5}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -90,15 +90,15 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:2])) for i, addr := range addrs[:2] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{5, 5}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{5, 5}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -120,15 +120,15 @@ func TestTallyOnlyValidators51No(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:2])) for i, addr := range addrs[:2] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{5, 6}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{5, 6}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -149,15 +149,15 @@ func TestTallyOnlyValidators51Yes(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{6, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{6, 6, 7}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -181,15 +181,15 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{6, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{6, 6, 7}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -213,15 +213,15 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{6, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{6, 6, 7}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -245,15 +245,15 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{6, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{6, 6, 7}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -277,15 +277,15 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{6, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{6, 6, 7}) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -307,18 +307,18 @@ func TestTallyDelgatorOverride(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{5, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{5, 6, 7}) + staking.EndBlocker(ctx, sk) - delegator1Msg := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 30)) - stakeHandler(ctx, delegator1Msg) + delegator1Msg := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 30)) + stakingHandler(ctx, delegator1Msg) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -344,18 +344,18 @@ func TestTallyDelgatorInherit(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{5, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{5, 6, 7}) + staking.EndBlocker(ctx, sk) - delegator1Msg := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 30)) - stakeHandler(ctx, delegator1Msg) + delegator1Msg := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 30)) + stakingHandler(ctx, delegator1Msg) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -379,20 +379,20 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{5, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{5, 6, 7}) + staking.EndBlocker(ctx, sk) - delegator1Msg := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)) - stakeHandler(ctx, delegator1Msg) - delegator1Msg2 := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[1]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)) - stakeHandler(ctx, delegator1Msg2) + delegator1Msg := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)) + stakingHandler(ctx, delegator1Msg) + delegator1Msg2 := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[1]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)) + stakingHandler(ctx, delegator1Msg2) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -418,30 +418,30 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) - val1CreateMsg := stake.NewMsgCreateValidator( - sdk.ValAddress(addrs[0]), ed25519.GenPrivKey().PubKey(), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 25), testDescription, testCommissionMsg, + val1CreateMsg := staking.NewMsgCreateValidator( + sdk.ValAddress(addrs[0]), ed25519.GenPrivKey().PubKey(), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 25), testDescription, testCommissionMsg, ) - stakeHandler(ctx, val1CreateMsg) + stakingHandler(ctx, val1CreateMsg) - val2CreateMsg := stake.NewMsgCreateValidator( - sdk.ValAddress(addrs[1]), ed25519.GenPrivKey().PubKey(), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 6), testDescription, testCommissionMsg, + val2CreateMsg := staking.NewMsgCreateValidator( + sdk.ValAddress(addrs[1]), ed25519.GenPrivKey().PubKey(), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 6), testDescription, testCommissionMsg, ) - stakeHandler(ctx, val2CreateMsg) + stakingHandler(ctx, val2CreateMsg) - val3CreateMsg := stake.NewMsgCreateValidator( - sdk.ValAddress(addrs[2]), ed25519.GenPrivKey().PubKey(), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 7), testDescription, testCommissionMsg, + val3CreateMsg := staking.NewMsgCreateValidator( + sdk.ValAddress(addrs[2]), ed25519.GenPrivKey().PubKey(), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 7), testDescription, testCommissionMsg, ) - stakeHandler(ctx, val3CreateMsg) + stakingHandler(ctx, val3CreateMsg) - delegator1Msg := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)) - stakeHandler(ctx, delegator1Msg) + delegator1Msg := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)) + stakingHandler(ctx, delegator1Msg) - delegator1Msg2 := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[1]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)) - stakeHandler(ctx, delegator1Msg2) + delegator1Msg2 := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[1]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)) + stakingHandler(ctx, delegator1Msg2) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() @@ -465,27 +465,27 @@ func TestTallyJailedValidator(t *testing.T) { mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10, GenesisState{}, nil) mapp.BeginBlock(abci.RequestBeginBlock{}) ctx := mapp.BaseApp.NewContext(false, abci.Header{}) - stakeHandler := stake.NewHandler(sk) + stakingHandler := staking.NewHandler(sk) valAddrs := make([]sdk.ValAddress, len(addrs[:3])) for i, addr := range addrs[:3] { valAddrs[i] = sdk.ValAddress(addr) } - createValidators(t, stakeHandler, ctx, valAddrs, []int64{25, 6, 7}) - stake.EndBlocker(ctx, sk) + createValidators(t, stakingHandler, ctx, valAddrs, []int64{25, 6, 7}) + staking.EndBlocker(ctx, sk) - delegator1Msg := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)) - stakeHandler(ctx, delegator1Msg) + delegator1Msg := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[2]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)) + stakingHandler(ctx, delegator1Msg) - delegator1Msg2 := stake.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[1]), sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10)) - stakeHandler(ctx, delegator1Msg2) + delegator1Msg2 := staking.NewMsgDelegate(addrs[3], sdk.ValAddress(addrs[1]), sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10)) + stakingHandler(ctx, delegator1Msg2) val2, found := sk.GetValidator(ctx, sdk.ValAddress(addrs[1])) require.True(t, found) sk.Jail(ctx, sdk.ConsAddress(val2.ConsPubKey.Address())) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText) proposalID := proposal.GetProposalID() diff --git a/x/gov/test_common.go b/x/gov/test_common.go index 8e91c416f5..4c6c2607d0 100644 --- a/x/gov/test_common.go +++ b/x/gov/test_common.go @@ -15,24 +15,24 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/mock" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // initialize the mock application for this module -func getMockApp(t *testing.T, numGenAccs int, genState GenesisState, genAccs []auth.Account) (mapp *mock.App, keeper Keeper, sk stake.Keeper, addrs []sdk.AccAddress, pubKeys []crypto.PubKey, privKeys []crypto.PrivKey) { +func getMockApp(t *testing.T, numGenAccs int, genState GenesisState, genAccs []auth.Account) (mapp *mock.App, keeper Keeper, sk staking.Keeper, addrs []sdk.AccAddress, pubKeys []crypto.PubKey, privKeys []crypto.PrivKey) { mapp = mock.NewApp() - stake.RegisterCodec(mapp.Cdc) + staking.RegisterCodec(mapp.Cdc) RegisterCodec(mapp.Cdc) - keyStake := sdk.NewKVStoreKey(stake.StoreKey) - tkeyStake := sdk.NewTransientStoreKey(stake.TStoreKey) + keyStaking := sdk.NewKVStoreKey(staking.StoreKey) + tkeyStaking := sdk.NewTransientStoreKey(staking.TStoreKey) keyGov := sdk.NewKVStoreKey(StoreKey) pk := mapp.ParamsKeeper ck := bank.NewBaseKeeper(mapp.AccountKeeper) - sk = stake.NewKeeper(mapp.Cdc, keyStake, tkeyStake, ck, pk.Subspace(stake.DefaultParamspace), stake.DefaultCodespace) + sk = staking.NewKeeper(mapp.Cdc, keyStaking, tkeyStaking, ck, pk.Subspace(staking.DefaultParamspace), staking.DefaultCodespace) keeper = NewKeeper(mapp.Cdc, keyGov, pk, pk.Subspace("testgov"), ck, sk, DefaultCodespace) mapp.Router().AddRoute(RouterKey, NewHandler(keeper)) @@ -41,10 +41,10 @@ func getMockApp(t *testing.T, numGenAccs int, genState GenesisState, genAccs []a mapp.SetEndBlocker(getEndBlocker(keeper)) mapp.SetInitChainer(getInitChainer(mapp, keeper, sk, genState)) - require.NoError(t, mapp.CompleteSetup(keyStake, tkeyStake, keyGov)) + require.NoError(t, mapp.CompleteSetup(keyStaking, tkeyStaking, keyGov)) if genAccs == nil || len(genAccs) == 0 { - genAccs, addrs, pubKeys, privKeys = mock.CreateGenAccounts(numGenAccs, sdk.Coins{sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 42)}) + genAccs, addrs, pubKeys, privKeys = mock.CreateGenAccounts(numGenAccs, sdk.Coins{sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 42)}) } mock.SetGenesis(mapp, genAccs) @@ -52,7 +52,7 @@ func getMockApp(t *testing.T, numGenAccs int, genState GenesisState, genAccs []a return mapp, keeper, sk, addrs, pubKeys, privKeys } -// gov and stake endblocker +// gov and staking endblocker func getEndBlocker(keeper Keeper) sdk.EndBlocker { return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { tags := EndBlocker(ctx, keeper) @@ -62,15 +62,15 @@ func getEndBlocker(keeper Keeper) sdk.EndBlocker { } } -// gov and stake initchainer -func getInitChainer(mapp *mock.App, keeper Keeper, stakeKeeper stake.Keeper, genState GenesisState) sdk.InitChainer { +// gov and staking initchainer +func getInitChainer(mapp *mock.App, keeper Keeper, stakingKeeper staking.Keeper, genState GenesisState) sdk.InitChainer { return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { mapp.InitChainer(ctx, req) - stakeGenesis := stake.DefaultGenesisState() - stakeGenesis.Pool.LooseTokens = sdk.NewInt(100000) + stakingGenesis := staking.DefaultGenesisState() + stakingGenesis.Pool.LooseTokens = sdk.NewInt(100000) - validators, err := stake.InitGenesis(ctx, stakeKeeper, stakeGenesis) + validators, err := staking.InitGenesis(ctx, stakingKeeper, stakingGenesis) if err != nil { panic(err) } diff --git a/x/mint/expected_keepers.go b/x/mint/expected_keepers.go index 995f9aafe5..72bc36a5f5 100644 --- a/x/mint/expected_keepers.go +++ b/x/mint/expected_keepers.go @@ -4,8 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// expected stake keeper -type StakeKeeper interface { +// expected staking keeper +type StakingKeeper interface { TotalPower(ctx sdk.Context) sdk.Int BondedRatio(ctx sdk.Context) sdk.Dec InflateSupply(ctx sdk.Context, newTokens sdk.Int) diff --git a/x/mint/keeper.go b/x/mint/keeper.go index 34e0826f6a..1a508dc293 100644 --- a/x/mint/keeper.go +++ b/x/mint/keeper.go @@ -6,17 +6,17 @@ import ( "github.com/cosmos/cosmos-sdk/x/params" ) -// keeper of the stake store +// keeper of the staking store type Keeper struct { storeKey sdk.StoreKey cdc *codec.Codec paramSpace params.Subspace - sk StakeKeeper + sk StakingKeeper fck FeeCollectionKeeper } func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, - paramSpace params.Subspace, sk StakeKeeper, fck FeeCollectionKeeper) Keeper { + paramSpace params.Subspace, sk StakingKeeper, fck FeeCollectionKeeper) Keeper { keeper := Keeper{ storeKey: key, @@ -38,7 +38,7 @@ var ( ParamStoreKeyParams = []byte("params") ) -// ParamTable for stake module +// ParamTable for staking module func ParamTypeTable() params.TypeTable { return params.NewTypeTable( ParamStoreKeyParams, Params{}, diff --git a/x/mint/params.go b/x/mint/params.go index e1acd3a630..45a66f7fc1 100644 --- a/x/mint/params.go +++ b/x/mint/params.go @@ -3,7 +3,7 @@ package mint import ( "fmt" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -34,7 +34,7 @@ func NewParams(mintDenom string, inflationRateChange, inflationMax, // default minting module parameters func DefaultParams() Params { return Params{ - MintDenom: stakeTypes.DefaultBondDenom, + MintDenom: stakingTypes.DefaultBondDenom, InflationRateChange: sdk.NewDecWithPrec(13, 2), InflationMax: sdk.NewDecWithPrec(20, 2), InflationMin: sdk.NewDecWithPrec(7, 2), diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index d576175818..b198aaa248 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -11,8 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/mock" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -22,32 +22,32 @@ var ( ) // initialize the mock application for this module -func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) { +func getMockApp(t *testing.T) (*mock.App, staking.Keeper, Keeper) { mapp := mock.NewApp() RegisterCodec(mapp.Cdc) - keyStake := sdk.NewKVStoreKey(stake.StoreKey) - tkeyStake := sdk.NewTransientStoreKey(stake.TStoreKey) + keyStaking := sdk.NewKVStoreKey(staking.StoreKey) + tkeyStaking := sdk.NewTransientStoreKey(staking.TStoreKey) keySlashing := sdk.NewKVStoreKey(StoreKey) bankKeeper := bank.NewBaseKeeper(mapp.AccountKeeper) - stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, tkeyStake, bankKeeper, mapp.ParamsKeeper.Subspace(stake.DefaultParamspace), stake.DefaultCodespace) - keeper := NewKeeper(mapp.Cdc, keySlashing, stakeKeeper, mapp.ParamsKeeper.Subspace(DefaultParamspace), DefaultCodespace) - mapp.Router().AddRoute(stake.RouterKey, stake.NewHandler(stakeKeeper)) + stakingKeeper := staking.NewKeeper(mapp.Cdc, keyStaking, tkeyStaking, bankKeeper, mapp.ParamsKeeper.Subspace(staking.DefaultParamspace), staking.DefaultCodespace) + keeper := NewKeeper(mapp.Cdc, keySlashing, stakingKeeper, mapp.ParamsKeeper.Subspace(DefaultParamspace), DefaultCodespace) + mapp.Router().AddRoute(staking.RouterKey, staking.NewHandler(stakingKeeper)) mapp.Router().AddRoute(RouterKey, NewHandler(keeper)) - mapp.SetEndBlocker(getEndBlocker(stakeKeeper)) - mapp.SetInitChainer(getInitChainer(mapp, stakeKeeper)) + mapp.SetEndBlocker(getEndBlocker(stakingKeeper)) + mapp.SetInitChainer(getInitChainer(mapp, stakingKeeper)) - require.NoError(t, mapp.CompleteSetup(keyStake, tkeyStake, keySlashing)) + require.NoError(t, mapp.CompleteSetup(keyStaking, tkeyStaking, keySlashing)) - return mapp, stakeKeeper, keeper + return mapp, stakingKeeper, keeper } -// stake endblocker -func getEndBlocker(keeper stake.Keeper) sdk.EndBlocker { +// staking endblocker +func getEndBlocker(keeper staking.Keeper) sdk.EndBlocker { return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - validatorUpdates, tags := stake.EndBlocker(ctx, keeper) + validatorUpdates, tags := staking.EndBlocker(ctx, keeper) return abci.ResponseEndBlock{ ValidatorUpdates: validatorUpdates, Tags: tags, @@ -56,12 +56,12 @@ func getEndBlocker(keeper stake.Keeper) sdk.EndBlocker { } // overwrite the mock init chainer -func getInitChainer(mapp *mock.App, keeper stake.Keeper) sdk.InitChainer { +func getInitChainer(mapp *mock.App, keeper staking.Keeper) sdk.InitChainer { return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { mapp.InitChainer(ctx, req) - stakeGenesis := stake.DefaultGenesisState() - stakeGenesis.Pool.LooseTokens = sdk.NewInt(100000) - validators, err := stake.InitGenesis(ctx, keeper, stakeGenesis) + stakingGenesis := staking.DefaultGenesisState() + stakingGenesis.Pool.LooseTokens = sdk.NewInt(100000) + validators, err := staking.InitGenesis(ctx, keeper, stakingGenesis) if err != nil { panic(err) } @@ -72,8 +72,8 @@ func getInitChainer(mapp *mock.App, keeper stake.Keeper) sdk.InitChainer { } } -func checkValidator(t *testing.T, mapp *mock.App, keeper stake.Keeper, - addr sdk.AccAddress, expFound bool) stake.Validator { +func checkValidator(t *testing.T, mapp *mock.App, keeper staking.Keeper, + addr sdk.AccAddress, expFound bool) staking.Validator { ctxCheck := mapp.BaseApp.NewContext(true, abci.Header{}) validator, found := keeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) require.Equal(t, expFound, found) @@ -89,10 +89,10 @@ func checkValidatorSigningInfo(t *testing.T, mapp *mock.App, keeper Keeper, } func TestSlashingMsgs(t *testing.T) { - mapp, stakeKeeper, keeper := getMockApp(t) + mapp, stakingKeeper, keeper := getMockApp(t) - genCoin := sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 42) - bondCoin := sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10) + genCoin := sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 42) + bondCoin := sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10) acc1 := &auth.BaseAccount{ Address: addr1, @@ -101,17 +101,17 @@ func TestSlashingMsgs(t *testing.T) { accs := []auth.Account{acc1} mock.SetGenesis(mapp, accs) - description := stake.NewDescription("foo_moniker", "", "", "") - commission := stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + description := staking.NewDescription("foo_moniker", "", "", "") + commission := staking.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - createValidatorMsg := stake.NewMsgCreateValidator( + createValidatorMsg := staking.NewMsgCreateValidator( sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commission, ) mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1) mock.CheckBalance(t, mapp, addr1, sdk.Coins{genCoin.Minus(bondCoin)}) mapp.BeginBlock(abci.RequestBeginBlock{}) - validator := checkValidator(t, mapp, stakeKeeper, addr1, true) + validator := checkValidator(t, mapp, stakingKeeper, addr1, true) require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddr) require.Equal(t, sdk.Bonded, validator.Status) require.True(sdk.IntEq(t, sdk.NewInt(10), validator.BondedTokens())) diff --git a/x/slashing/genesis.go b/x/slashing/genesis.go index eb943799b9..c3672c3d69 100644 --- a/x/slashing/genesis.go +++ b/x/slashing/genesis.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // GenesisState - all slashing state that must be provided at genesis diff --git a/x/slashing/handler_test.go b/x/slashing/handler_test.go index b7a0e42ad0..516d1b2b99 100644 --- a/x/slashing/handler_test.go +++ b/x/slashing/handler_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) func TestCannotUnjailUnlessJailed(t *testing.T) { @@ -17,9 +17,9 @@ func TestCannotUnjailUnlessJailed(t *testing.T) { amtInt := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) msg := NewTestMsgCreateValidator(addr, val, amt) - got := stake.NewHandler(sk)(ctx, msg) + got := staking.NewHandler(sk)(ctx, msg) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) require.Equal( t, ck.GetCoins(ctx, sdk.AccAddress(addr)), @@ -35,11 +35,11 @@ func TestCannotUnjailUnlessJailed(t *testing.T) { } func TestJailedValidatorDelegations(t *testing.T) { - ctx, _, stakeKeeper, _, slashingKeeper := createTestInput(t, DefaultParams()) + ctx, _, stakingKeeper, _, slashingKeeper := createTestInput(t, DefaultParams()) - stakeParams := stakeKeeper.GetParams(ctx) - stakeParams.UnbondingTime = 0 - stakeKeeper.SetParams(ctx, stakeParams) + stakingParams := stakingKeeper.GetParams(ctx) + stakingParams.UnbondingTime = 0 + stakingKeeper.SetParams(ctx, stakingParams) // create a validator amount := int64(10) @@ -47,11 +47,11 @@ func TestJailedValidatorDelegations(t *testing.T) { valAddr, consAddr := addrs[1], sdk.ConsAddress(addrs[0]) msgCreateVal := NewTestMsgCreateValidator(valAddr, valPubKey, bondAmount) - got := stake.NewHandler(stakeKeeper)(ctx, msgCreateVal) + got := staking.NewHandler(stakingKeeper)(ctx, msgCreateVal) require.True(t, got.IsOK(), "expected create validator msg to be ok, got: %v", got) // end block - stake.EndBlocker(ctx, stakeKeeper) + staking.EndBlocker(ctx, stakingKeeper) // set dummy signing info newInfo := ValidatorSigningInfo{ @@ -65,21 +65,21 @@ func TestJailedValidatorDelegations(t *testing.T) { // delegate tokens to the validator delAddr := sdk.AccAddress(addrs[2]) msgDelegate := newTestMsgDelegate(delAddr, valAddr, bondAmount) - got = stake.NewHandler(stakeKeeper)(ctx, msgDelegate) + got = staking.NewHandler(stakingKeeper)(ctx, msgDelegate) require.True(t, got.IsOK(), "expected delegation to be ok, got %v", got) unbondShares := sdk.NewDec(10) // unbond validator total self-delegations (which should jail the validator) - msgBeginUnbonding := stake.NewMsgBeginUnbonding(sdk.AccAddress(valAddr), valAddr, unbondShares) - got = stake.NewHandler(stakeKeeper)(ctx, msgBeginUnbonding) + msgBeginUnbonding := staking.NewMsgBeginUnbonding(sdk.AccAddress(valAddr), valAddr, unbondShares) + got = staking.NewHandler(stakingKeeper)(ctx, msgBeginUnbonding) require.True(t, got.IsOK(), "expected begin unbonding validator msg to be ok, got: %v", got) - err := stakeKeeper.CompleteUnbonding(ctx, sdk.AccAddress(valAddr), valAddr) + err := stakingKeeper.CompleteUnbonding(ctx, sdk.AccAddress(valAddr), valAddr) require.Nil(t, err, "expected complete unbonding validator to be ok, got: %v", err) // verify validator still exists and is jailed - validator, found := stakeKeeper.GetValidator(ctx, valAddr) + validator, found := stakingKeeper.GetValidator(ctx, valAddr) require.True(t, found) require.True(t, validator.GetJailed()) @@ -89,7 +89,7 @@ func TestJailedValidatorDelegations(t *testing.T) { // self-delegate to validator msgSelfDelegate := newTestMsgDelegate(sdk.AccAddress(valAddr), valAddr, bondAmount) - got = stake.NewHandler(stakeKeeper)(ctx, msgSelfDelegate) + got = staking.NewHandler(stakingKeeper)(ctx, msgSelfDelegate) require.True(t, got.IsOK(), "expected delegation to not be ok, got %v", got) // verify the validator can now unjail itself diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index c0ea431f7b..f8494a8877 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/params" - stake "github.com/cosmos/cosmos-sdk/x/stake/types" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Keeper of the slashing store @@ -79,7 +79,7 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio // Note that this *can* result in a negative "distributionHeight", up to -ValidatorUpdateDelay, // i.e. at the end of the pre-genesis block (none) = at the beginning of the genesis block. // That's fine since this is just used to filter unbonding delegations & redelegations. - distributionHeight := infractionHeight - stake.ValidatorUpdateDelay + distributionHeight := infractionHeight - staking.ValidatorUpdateDelay // get the percentage slash penalty fraction fraction := k.SlashFractionDoubleSign(ctx) @@ -160,7 +160,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p // Note that this *can* result in a negative "distributionHeight" up to -ValidatorUpdateDelay-1, // i.e. at the end of the pre-genesis block (none) = at the beginning of the genesis block. // That's fine since this is just used to filter unbonding delegations & redelegations. - distributionHeight := height - stake.ValidatorUpdateDelay - 1 + distributionHeight := height - staking.ValidatorUpdateDelay - 1 k.validatorSet.Slash(ctx, consAddr, distributionHeight, power, k.SlashFractionDowntime(ctx)) k.validatorSet.Jail(ctx, consAddr) signInfo.JailedUntil = ctx.BlockHeader().Time.Add(k.DowntimeJailDuration(ctx)) diff --git a/x/slashing/keeper_test.go b/x/slashing/keeper_test.go index f9fe6cfa87..9c9e7a28e9 100644 --- a/x/slashing/keeper_test.go +++ b/x/slashing/keeper_test.go @@ -8,7 +8,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) // Have to change these parameters for tests @@ -32,9 +32,9 @@ func TestHandleDoubleSign(t *testing.T) { ctx = ctx.WithBlockHeight(-1) amtInt := int64(100) operatorAddr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) - got := stake.NewHandler(sk)(ctx, NewTestMsgCreateValidator(operatorAddr, val, amt)) + got := staking.NewHandler(sk)(ctx, NewTestMsgCreateValidator(operatorAddr, val, amt)) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) require.Equal( t, ck.GetCoins(ctx, sdk.AccAddress(operatorAddr)), sdk.Coins{sdk.NewCoin(sk.GetParams(ctx).BondDenom, initCoins.Sub(amt))}, @@ -72,8 +72,8 @@ func TestHandleDoubleSign(t *testing.T) { // Should be able to unbond now del, _ := sk.GetDelegation(ctx, sdk.AccAddress(operatorAddr), operatorAddr) - msgUnbond := stake.NewMsgBeginUnbonding(sdk.AccAddress(operatorAddr), operatorAddr, del.GetShares()) - res = stake.NewHandler(sk)(ctx, msgUnbond) + msgUnbond := staking.NewMsgBeginUnbonding(sdk.AccAddress(operatorAddr), operatorAddr, del.GetShares()) + res = staking.NewHandler(sk)(ctx, msgUnbond) require.True(t, res.IsOK()) } @@ -89,9 +89,9 @@ func TestPastMaxEvidenceAge(t *testing.T) { ctx = ctx.WithBlockHeight(-1) amtInt := int64(100) operatorAddr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) - got := stake.NewHandler(sk)(ctx, NewTestMsgCreateValidator(operatorAddr, val, amt)) + got := staking.NewHandler(sk)(ctx, NewTestMsgCreateValidator(operatorAddr, val, amt)) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) require.Equal( t, ck.GetCoins(ctx, sdk.AccAddress(operatorAddr)), sdk.Coins{sdk.NewCoin(sk.GetParams(ctx).BondDenom, initCoins.Sub(amt))}, @@ -123,11 +123,11 @@ func TestHandleAbsentValidator(t *testing.T) { ctx, ck, sk, _, keeper := createTestInput(t, keeperTestParams()) amtInt64 := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt64) - sh := stake.NewHandler(sk) + sh := staking.NewHandler(sk) slh := NewHandler(keeper) got := sh(ctx, NewTestMsgCreateValidator(addr, val, amt)) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) require.Equal( t, ck.GetCoins(ctx, sdk.AccAddress(addr)), @@ -180,7 +180,7 @@ func TestHandleAbsentValidator(t *testing.T) { require.Equal(t, int64(0), info.MissedBlocksCounter) // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // validator should have been jailed validator, _ = sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val)) @@ -201,7 +201,7 @@ func TestHandleAbsentValidator(t *testing.T) { require.Equal(t, int64(1), info.MissedBlocksCounter) // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // validator should not have been slashed any more, since it was already jailed validator, _ = sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val)) @@ -217,7 +217,7 @@ func TestHandleAbsentValidator(t *testing.T) { require.True(t, got.IsOK()) // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // validator should be rebonded now validator, _ = sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val)) @@ -249,7 +249,7 @@ func TestHandleAbsentValidator(t *testing.T) { } // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // validator should be jailed again after 500 unsigned blocks nextHeight = height + keeper.MinSignedPerWindow(ctx) + 1 @@ -259,7 +259,7 @@ func TestHandleAbsentValidator(t *testing.T) { } // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) validator, _ = sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val)) require.Equal(t, sdk.Unbonding, validator.GetStatus()) @@ -272,7 +272,7 @@ func TestHandleNewValidator(t *testing.T) { // initial setup ctx, ck, sk, _, keeper := createTestInput(t, keeperTestParams()) addr, val, amt := addrs[0], pks[0], int64(100) - sh := stake.NewHandler(sk) + sh := staking.NewHandler(sk) // 1000 first blocks not a validator ctx = ctx.WithBlockHeight(keeper.SignedBlocksWindow(ctx) + 1) @@ -280,7 +280,7 @@ func TestHandleNewValidator(t *testing.T) { // Validator created got := sh(ctx, NewTestMsgCreateValidator(addr, val, sdk.NewInt(amt))) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) require.Equal( t, ck.GetCoins(ctx, sdk.AccAddress(addr)), @@ -315,10 +315,10 @@ func TestHandleAlreadyJailed(t *testing.T) { ctx, _, sk, _, keeper := createTestInput(t, DefaultParams()) amtInt := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) - sh := stake.NewHandler(sk) + sh := staking.NewHandler(sk) got := sh(ctx, NewTestMsgCreateValidator(addr, val, amt)) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // 1000 first blocks OK height := int64(0) @@ -334,7 +334,7 @@ func TestHandleAlreadyJailed(t *testing.T) { } // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // validator should have been jailed and slashed validator, _ := sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val)) @@ -367,10 +367,10 @@ func TestValidatorDippingInAndOut(t *testing.T) { amtInt := int64(100) addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt) consAddr := sdk.ConsAddress(addr) - sh := stake.NewHandler(sk) + sh := staking.NewHandler(sk) got := sh(ctx, NewTestMsgCreateValidator(addr, val, amt)) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // 100 first blocks OK height := int64(0) @@ -383,7 +383,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { newAmt := int64(101) got = sh(ctx, NewTestMsgCreateValidator(addrs[1], pks[1], sdk.NewInt(newAmt))) require.True(t, got.IsOK()) - validatorUpdates, _ := stake.EndBlocker(ctx, sk) + validatorUpdates, _ := staking.EndBlocker(ctx, sk) require.Equal(t, 2, len(validatorUpdates)) validator, _ := sk.GetValidator(ctx, addr) require.Equal(t, sdk.Unbonding, validator.Status) @@ -395,7 +395,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { // validator added back in got = sh(ctx, newTestMsgDelegate(sdk.AccAddress(addrs[2]), addrs[0], sdk.NewInt(3))) require.True(t, got.IsOK()) - validatorUpdates, _ = stake.EndBlocker(ctx, sk) + validatorUpdates, _ = staking.EndBlocker(ctx, sk) require.Equal(t, 2, len(validatorUpdates)) validator, _ = sk.GetValidator(ctx, addr) require.Equal(t, sdk.Bonded, validator.Status) @@ -417,7 +417,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { } // should now be jailed & kicked - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) validator, _ = sk.GetValidator(ctx, addr) require.Equal(t, sdk.Unbonding, validator.Status) @@ -442,7 +442,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { height++ // validator should not be kicked since we reset counter/array when it was jailed - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) validator, _ = sk.GetValidator(ctx, addr) require.Equal(t, sdk.Bonded, validator.Status) @@ -454,7 +454,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { } // validator should now be jailed & kicked - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) validator, _ = sk.GetValidator(ctx, addr) require.Equal(t, sdk.Unbonding, validator.Status) diff --git a/x/slashing/keys.go b/x/slashing/keys.go index 4900c063e1..5e5b08a7f4 100644 --- a/x/slashing/keys.go +++ b/x/slashing/keys.go @@ -4,7 +4,7 @@ import ( "encoding/binary" sdk "github.com/cosmos/cosmos-sdk/types" - stake "github.com/cosmos/cosmos-sdk/x/stake/types" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) const ( @@ -61,7 +61,7 @@ func GetValidatorSlashingPeriodPrefix(v sdk.ConsAddress) []byte { func GetValidatorSlashingPeriodKey(v sdk.ConsAddress, startHeight int64) []byte { b := make([]byte, 8) // this needs to be height + ValidatorUpdateDelay because the slashing period for genesis validators starts at height -ValidatorUpdateDelay - binary.BigEndian.PutUint64(b, uint64(startHeight+stake.ValidatorUpdateDelay)) + binary.BigEndian.PutUint64(b, uint64(startHeight+staking.ValidatorUpdateDelay)) return append(GetValidatorSlashingPeriodPrefix(v), b...) } diff --git a/x/slashing/querier.go b/x/slashing/querier.go index 841925f79c..a0faaeb509 100644 --- a/x/slashing/querier.go +++ b/x/slashing/querier.go @@ -19,7 +19,7 @@ func NewQuerier(k Keeper, cdc *codec.Codec) sdk.Querier { case QueryParameters: return queryParams(ctx, cdc, k) default: - return nil, sdk.ErrUnknownRequest("unknown stake query endpoint") + return nil, sdk.ErrUnknownRequest("unknown staking query endpoint") } } } diff --git a/x/slashing/test_common.go b/x/slashing/test_common.go index 8a5f44773e..803ce21241 100644 --- a/x/slashing/test_common.go +++ b/x/slashing/test_common.go @@ -20,8 +20,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/stake" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // TODO remove dependencies on staking (should only refer to validator set type from sdk) @@ -45,23 +45,23 @@ func createTestCodec() *codec.Codec { sdk.RegisterCodec(cdc) auth.RegisterCodec(cdc) bank.RegisterCodec(cdc) - stake.RegisterCodec(cdc) + staking.RegisterCodec(cdc) codec.RegisterCrypto(cdc) return cdc } -func createTestInput(t *testing.T, defaults Params) (sdk.Context, bank.Keeper, stake.Keeper, params.Subspace, Keeper) { +func createTestInput(t *testing.T, defaults Params) (sdk.Context, bank.Keeper, staking.Keeper, params.Subspace, Keeper) { keyAcc := sdk.NewKVStoreKey(auth.StoreKey) - keyStake := sdk.NewKVStoreKey(stake.StoreKey) - tkeyStake := sdk.NewTransientStoreKey(stake.TStoreKey) + keyStaking := sdk.NewKVStoreKey(staking.StoreKey) + tkeyStaking := sdk.NewTransientStoreKey(staking.TStoreKey) keySlashing := sdk.NewKVStoreKey(StoreKey) keyParams := sdk.NewKVStoreKey(params.StoreKey) tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey) db := dbm.NewMemDB() ms := store.NewCommitMultiStore(db) ms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db) - ms.MountStoreWithDB(tkeyStake, sdk.StoreTypeTransient, nil) - ms.MountStoreWithDB(keyStake, sdk.StoreTypeIAVL, db) + ms.MountStoreWithDB(tkeyStaking, sdk.StoreTypeTransient, nil) + ms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keySlashing, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) @@ -73,12 +73,12 @@ func createTestInput(t *testing.T, defaults Params) (sdk.Context, bank.Keeper, s accountKeeper := auth.NewAccountKeeper(cdc, keyAcc, paramsKeeper.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount) ck := bank.NewBaseKeeper(accountKeeper) - sk := stake.NewKeeper(cdc, keyStake, tkeyStake, ck, paramsKeeper.Subspace(stake.DefaultParamspace), stake.DefaultCodespace) - genesis := stake.DefaultGenesisState() + sk := staking.NewKeeper(cdc, keyStaking, tkeyStaking, ck, paramsKeeper.Subspace(staking.DefaultParamspace), staking.DefaultCodespace) + genesis := staking.DefaultGenesisState() genesis.Pool.LooseTokens = sdk.NewInt(initCoins.MulRaw(int64(len(addrs))).Int64()) - _, err = stake.InitGenesis(ctx, sk, genesis) + _, err = staking.InitGenesis(ctx, sk, genesis) require.Nil(t, err) for _, addr := range addrs { @@ -113,22 +113,22 @@ func testAddr(addr string) sdk.AccAddress { return res } -func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) stake.MsgCreateValidator { - commission := stake.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - return stake.MsgCreateValidator{ - Description: stake.Description{}, +func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator { + commission := staking.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + return staking.MsgCreateValidator{ + Description: staking.Description{}, Commission: commission, DelegatorAddr: sdk.AccAddress(address), ValidatorAddr: address, PubKey: pubKey, - Delegation: sdk.NewCoin(stakeTypes.DefaultBondDenom, amt), + Delegation: sdk.NewCoin(stakingTypes.DefaultBondDenom, amt), } } -func newTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, delAmount sdk.Int) stake.MsgDelegate { - return stake.MsgDelegate{ +func newTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, delAmount sdk.Int) staking.MsgDelegate { + return staking.MsgDelegate{ DelegatorAddr: delAddr, ValidatorAddr: valAddr, - Delegation: sdk.NewCoin(stakeTypes.DefaultBondDenom, delAmount), + Delegation: sdk.NewCoin(stakingTypes.DefaultBondDenom, delAmount), } } diff --git a/x/slashing/tick_test.go b/x/slashing/tick_test.go index 0afb6f5cd6..9ee6d03c04 100644 --- a/x/slashing/tick_test.go +++ b/x/slashing/tick_test.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" ) func TestBeginBlocker(t *testing.T) { @@ -17,9 +17,9 @@ func TestBeginBlocker(t *testing.T) { addr, pk, amt := addrs[2], pks[2], sdk.NewInt(100) // bond the validator - got := stake.NewHandler(sk)(ctx, NewTestMsgCreateValidator(addr, pk, amt)) + got := staking.NewHandler(sk)(ctx, NewTestMsgCreateValidator(addr, pk, amt)) require.True(t, got.IsOK()) - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) require.Equal( t, ck.GetCoins(ctx, sdk.AccAddress(addr)), sdk.Coins{sdk.NewCoin(sk.GetParams(ctx).BondDenom, initCoins.Sub(amt))}, @@ -80,7 +80,7 @@ func TestBeginBlocker(t *testing.T) { } // end block - stake.EndBlocker(ctx, sk) + staking.EndBlocker(ctx, sk) // validator should be jailed validator, found := sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pk)) diff --git a/x/stake/types/keys.go b/x/stake/types/keys.go deleted file mode 100644 index 28d099a023..0000000000 --- a/x/stake/types/keys.go +++ /dev/null @@ -1,15 +0,0 @@ -package types - -const ( - // StoreKey is the string store representation - StoreKey = "stake" - - // TStoreKey is the string transient store representation - TStoreKey = "transient_stake" - - // QuerierRoute is the querier route for the stake module - QuerierRoute = "stake" - - // RouterKey is the msg router key for the stake module - RouterKey = "stake" -) diff --git a/x/stake/app_test.go b/x/staking/app_test.go similarity index 88% rename from x/stake/app_test.go rename to x/staking/app_test.go index 1be37c1e35..80f416d716 100644 --- a/x/stake/app_test.go +++ b/x/staking/app_test.go @@ -1,4 +1,4 @@ -package stake +package staking import ( "testing" @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/mock" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // getMockApp returns an initialized mock application for this module. @@ -19,21 +19,21 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) { RegisterCodec(mApp.Cdc) - keyStake := sdk.NewKVStoreKey(StoreKey) - tkeyStake := sdk.NewTransientStoreKey(TStoreKey) + keyStaking := sdk.NewKVStoreKey(StoreKey) + tkeyStaking := sdk.NewTransientStoreKey(TStoreKey) bankKeeper := bank.NewBaseKeeper(mApp.AccountKeeper) - keeper := NewKeeper(mApp.Cdc, keyStake, tkeyStake, bankKeeper, mApp.ParamsKeeper.Subspace(DefaultParamspace), DefaultCodespace) + keeper := NewKeeper(mApp.Cdc, keyStaking, tkeyStaking, bankKeeper, mApp.ParamsKeeper.Subspace(DefaultParamspace), DefaultCodespace) mApp.Router().AddRoute(RouterKey, NewHandler(keeper)) mApp.SetEndBlocker(getEndBlocker(keeper)) mApp.SetInitChainer(getInitChainer(mApp, keeper)) - require.NoError(t, mApp.CompleteSetup(keyStake, tkeyStake)) + require.NoError(t, mApp.CompleteSetup(keyStaking, tkeyStaking)) return mApp, keeper } -// getEndBlocker returns a stake endblocker. +// getEndBlocker returns a staking endblocker. func getEndBlocker(keeper Keeper) sdk.EndBlocker { return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { validatorUpdates, tags := EndBlocker(ctx, keeper) @@ -51,10 +51,10 @@ func getInitChainer(mapp *mock.App, keeper Keeper) sdk.InitChainer { return func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { mapp.InitChainer(ctx, req) - stakeGenesis := DefaultGenesisState() - stakeGenesis.Pool.LooseTokens = sdk.NewInt(100000) + stakingGenesis := DefaultGenesisState() + stakingGenesis.Pool.LooseTokens = sdk.NewInt(100000) - validators, err := InitGenesis(ctx, keeper, stakeGenesis) + validators, err := InitGenesis(ctx, keeper, stakingGenesis) if err != nil { panic(err) } @@ -94,11 +94,11 @@ func checkDelegation( require.False(t, found) } -func TestStakeMsgs(t *testing.T) { +func TestStakingMsgs(t *testing.T) { mApp, keeper := getMockApp(t) - genCoin := sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 42) - bondCoin := sdk.NewInt64Coin(stakeTypes.DefaultBondDenom, 10) + genCoin := sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 42) + bondCoin := sdk.NewInt64Coin(stakingTypes.DefaultBondDenom, 10) acc1 := &auth.BaseAccount{ Address: addr1, diff --git a/x/stake/client/cli/flags.go b/x/staking/client/cli/flags.go similarity index 98% rename from x/stake/client/cli/flags.go rename to x/staking/client/cli/flags.go index a29bdf3762..6e1c4e51d7 100644 --- a/x/stake/client/cli/flags.go +++ b/x/staking/client/cli/flags.go @@ -3,7 +3,7 @@ package cli import ( flag "github.com/spf13/pflag" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // nolint diff --git a/x/stake/client/cli/query.go b/x/staking/client/cli/query.go similarity index 93% rename from x/stake/client/cli/query.go rename to x/staking/client/cli/query.go index 488ea5b043..e1aac2466e 100644 --- a/x/stake/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // GetCmdQueryValidator implements the validator query command. @@ -26,7 +26,7 @@ func GetCmdQueryValidator(storeName string, cdc *codec.Codec) *cobra.Command { return err } - key := stake.GetValidatorKey(addr) + key := staking.GetValidatorKey(addr) cliCtx := context.NewCLIContext().WithCodec(cdc) res, err := cliCtx.QueryStore(key, storeName) @@ -70,7 +70,7 @@ func GetCmdQueryValidators(storeName string, cdc *codec.Codec) *cobra.Command { Use: "validators", Short: "Query for all validators", RunE: func(cmd *cobra.Command, args []string) error { - key := stake.ValidatorsKey + key := staking.ValidatorsKey cliCtx := context.NewCLIContext().WithCodec(cdc) resKVs, err := cliCtx.QuerySubspace(key, storeName) @@ -79,7 +79,7 @@ func GetCmdQueryValidators(storeName string, cdc *codec.Codec) *cobra.Command { } // parse out the validators - var validators []stake.Validator + var validators []staking.Validator for _, kv := range resKVs { validator := types.MustUnmarshalValidator(cdc, kv.Value) validators = append(validators, validator) @@ -126,7 +126,7 @@ func GetCmdQueryValidatorUnbondingDelegations(storeKey string, cdc *codec.Codec) } cliCtx := context.NewCLIContext().WithCodec(cdc) - params := stake.NewQueryValidatorParams(valAddr) + params := staking.NewQueryValidatorParams(valAddr) bz, err := cdc.MarshalJSON(params) if err != nil { @@ -161,7 +161,7 @@ func GetCmdQueryValidatorRedelegations(storeKey string, cdc *codec.Codec) *cobra } cliCtx := context.NewCLIContext().WithCodec(cdc) - params := stake.NewQueryValidatorParams(valAddr) + params := staking.NewQueryValidatorParams(valAddr) bz, err := cdc.MarshalJSON(params) if err != nil { @@ -199,7 +199,7 @@ func GetCmdQueryDelegation(storeName string, cdc *codec.Codec) *cobra.Command { return err } - key := stake.GetDelegationKey(delAddr, valAddr) + key := staking.GetDelegationKey(delAddr, valAddr) cliCtx := context.NewCLIContext().WithCodec(cdc) res, err := cliCtx.QueryStore(key, storeName) @@ -254,7 +254,7 @@ func GetCmdQueryDelegations(storeName string, cdc *codec.Codec) *cobra.Command { return err } - key := stake.GetDelegationsKey(delegatorAddr) + key := staking.GetDelegationsKey(delegatorAddr) cliCtx := context.NewCLIContext().WithCodec(cdc) resKVs, err := cliCtx.QuerySubspace(key, storeName) @@ -263,7 +263,7 @@ func GetCmdQueryDelegations(storeName string, cdc *codec.Codec) *cobra.Command { } // parse out the validators - var delegations []stake.Delegation + var delegations []staking.Delegation for _, kv := range resKVs { delegation := types.MustUnmarshalDelegation(cdc, kv.Value) delegations = append(delegations, delegation) @@ -297,7 +297,7 @@ func GetCmdQueryValidatorDelegations(storeKey string, cdc *codec.Codec) *cobra.C return err } - params := stake.NewQueryValidatorParams(validatorAddr) + params := staking.NewQueryValidatorParams(validatorAddr) bz, err := cdc.MarshalJSON(params) if err != nil { @@ -336,7 +336,7 @@ func GetCmdQueryUnbondingDelegation(storeName string, cdc *codec.Codec) *cobra.C return err } - key := stake.GetUBDKey(delAddr, valAddr) + key := staking.GetUBDKey(delAddr, valAddr) cliCtx := context.NewCLIContext().WithCodec(cdc) res, err := cliCtx.QueryStore(key, storeName) @@ -388,7 +388,7 @@ func GetCmdQueryUnbondingDelegations(storeName string, cdc *codec.Codec) *cobra. return err } - key := stake.GetUBDsKey(delegatorAddr) + key := staking.GetUBDsKey(delegatorAddr) cliCtx := context.NewCLIContext().WithCodec(cdc) resKVs, err := cliCtx.QuerySubspace(key, storeName) @@ -397,7 +397,7 @@ func GetCmdQueryUnbondingDelegations(storeName string, cdc *codec.Codec) *cobra. } // parse out the unbonding delegations - var ubds []stake.UnbondingDelegation + var ubds []staking.UnbondingDelegation for _, kv := range resKVs { ubd := types.MustUnmarshalUBD(cdc, kv.Value) ubds = append(ubds, ubd) @@ -440,7 +440,7 @@ func GetCmdQueryRedelegation(storeName string, cdc *codec.Codec) *cobra.Command return err } - key := stake.GetREDKey(delAddr, valSrcAddr, valDstAddr) + key := staking.GetREDKey(delAddr, valSrcAddr, valDstAddr) cliCtx := context.NewCLIContext().WithCodec(cdc) res, err := cliCtx.QueryStore(key, storeName) @@ -492,7 +492,7 @@ func GetCmdQueryRedelegations(storeName string, cdc *codec.Codec) *cobra.Command return err } - key := stake.GetREDsKey(delegatorAddr) + key := staking.GetREDsKey(delegatorAddr) cliCtx := context.NewCLIContext().WithCodec(cdc) resKVs, err := cliCtx.QuerySubspace(key, storeName) @@ -501,7 +501,7 @@ func GetCmdQueryRedelegations(storeName string, cdc *codec.Codec) *cobra.Command } // parse out the validators - var reds []stake.Redelegation + var reds []staking.Redelegation for _, kv := range resKVs { red := types.MustUnmarshalRED(cdc, kv.Value) reds = append(reds, red) @@ -529,7 +529,7 @@ func GetCmdQueryPool(storeName string, cdc *codec.Codec) *cobra.Command { Short: "Query the current staking pool values", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - key := stake.PoolKey + key := staking.PoolKey cliCtx := context.NewCLIContext().WithCodec(cdc) res, err := cliCtx.QueryStore(key, storeName) @@ -569,12 +569,12 @@ func GetCmdQueryParams(storeName string, cdc *codec.Codec) *cobra.Command { Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - bz, err := cliCtx.QueryWithData("custom/stake/"+stake.QueryParameters, nil) + bz, err := cliCtx.QueryWithData("custom/staking/"+staking.QueryParameters, nil) if err != nil { return err } - var params stake.Params + var params staking.Params err = cdc.UnmarshalJSON(bz, ¶ms) if err != nil { return err diff --git a/x/stake/client/cli/tx.go b/x/staking/client/cli/tx.go similarity index 94% rename from x/stake/client/cli/tx.go rename to x/staking/client/cli/tx.go index adcff3799b..6788a2db65 100644 --- a/x/stake/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -76,7 +76,7 @@ func GetCmdEditValidator(cdc *codec.Codec) *cobra.Command { return err } - description := stake.Description{ + description := staking.Description{ Moniker: viper.GetString(FlagMoniker), Identity: viper.GetString(FlagIdentity), Website: viper.GetString(FlagWebsite), @@ -95,7 +95,7 @@ func GetCmdEditValidator(cdc *codec.Codec) *cobra.Command { newRate = &rate } - msg := stake.NewMsgEditValidator(sdk.ValAddress(valAddr), description, newRate) + msg := staking.NewMsgEditValidator(sdk.ValAddress(valAddr), description, newRate) if cliCtx.GenerateOnly { return utils.PrintUnsignedStdTx(os.Stdout, txBldr, cliCtx, []sdk.Msg{msg}, false) @@ -138,7 +138,7 @@ func GetCmdDelegate(cdc *codec.Codec) *cobra.Command { return err } - msg := stake.NewMsgDelegate(delAddr, valAddr, amount) + msg := staking.NewMsgDelegate(delAddr, valAddr, amount) if cliCtx.GenerateOnly { return utils.PrintUnsignedStdTx(os.Stdout, txBldr, cliCtx, []sdk.Msg{msg}, false) @@ -193,7 +193,7 @@ func GetCmdRedelegate(storeName string, cdc *codec.Codec) *cobra.Command { return err } - msg := stake.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, sharesAmount) + msg := staking.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, sharesAmount) if cliCtx.GenerateOnly { return utils.PrintUnsignedStdTx(os.Stdout, txBldr, cliCtx, []sdk.Msg{msg}, false) @@ -241,7 +241,7 @@ func GetCmdUnbond(storeName string, cdc *codec.Codec) *cobra.Command { return err } - msg := stake.NewMsgBeginUnbonding(delAddr, valAddr, sharesAmount) + msg := staking.NewMsgBeginUnbonding(delAddr, valAddr, sharesAmount) if cliCtx.GenerateOnly { return utils.PrintUnsignedStdTx(os.Stdout, txBldr, cliCtx, []sdk.Msg{msg}, false) @@ -276,7 +276,7 @@ func BuildCreateValidatorMsg(cliCtx context.CLIContext, txBldr authtxb.TxBuilder return txBldr, nil, err } - description := stake.NewDescription( + description := staking.NewDescription( viper.GetString(FlagMoniker), viper.GetString(FlagIdentity), viper.GetString(FlagWebsite), @@ -301,11 +301,11 @@ func BuildCreateValidatorMsg(cliCtx context.CLIContext, txBldr authtxb.TxBuilder return txBldr, nil, err } - msg = stake.NewMsgCreateValidatorOnBehalfOf( + msg = staking.NewMsgCreateValidatorOnBehalfOf( delAddr, sdk.ValAddress(valAddr), pk, amount, description, commissionMsg, ) } else { - msg = stake.NewMsgCreateValidator( + msg = staking.NewMsgCreateValidator( sdk.ValAddress(valAddr), pk, amount, description, commissionMsg, ) } diff --git a/x/stake/client/cli/utils.go b/x/staking/client/cli/utils.go similarity index 94% rename from x/stake/client/cli/utils.go rename to x/staking/client/cli/utils.go index 8a83e53144..43eb10e4b0 100644 --- a/x/stake/client/cli/utils.go +++ b/x/staking/client/cli/utils.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func getShares( @@ -42,7 +42,7 @@ func getShares( } // make a query to get the existing delegation shares - key := stake.GetDelegationKey(delAddr, valAddr) + key := staking.GetDelegationKey(delAddr, valAddr) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithAccountDecoder(cdc) diff --git a/x/stake/client/module_client.go b/x/staking/client/module_client.go similarity index 84% rename from x/stake/client/module_client.go rename to x/staking/client/module_client.go index 03a7c25e2a..ae2c8e7e80 100644 --- a/x/stake/client/module_client.go +++ b/x/staking/client/module_client.go @@ -5,7 +5,7 @@ import ( amino "github.com/tendermint/go-amino" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/x/stake/client/cli" + "github.com/cosmos/cosmos-sdk/x/staking/client/cli" ) // ModuleClient exports all client functionality from this module @@ -20,11 +20,11 @@ func NewModuleClient(storeKey string, cdc *amino.Codec) ModuleClient { // GetQueryCmd returns the cli query commands for this module func (mc ModuleClient) GetQueryCmd() *cobra.Command { - stakeQueryCmd := &cobra.Command{ - Use: "stake", + stakingQueryCmd := &cobra.Command{ + Use: "staking", Short: "Querying commands for the staking module", } - stakeQueryCmd.AddCommand(client.GetCommands( + stakingQueryCmd.AddCommand(client.GetCommands( cli.GetCmdQueryDelegation(mc.storeKey, mc.cdc), cli.GetCmdQueryDelegations(mc.storeKey, mc.cdc), cli.GetCmdQueryUnbondingDelegation(mc.storeKey, mc.cdc), @@ -39,18 +39,18 @@ func (mc ModuleClient) GetQueryCmd() *cobra.Command { cli.GetCmdQueryParams(mc.storeKey, mc.cdc), cli.GetCmdQueryPool(mc.storeKey, mc.cdc))...) - return stakeQueryCmd + return stakingQueryCmd } // GetTxCmd returns the transaction commands for this module func (mc ModuleClient) GetTxCmd() *cobra.Command { - stakeTxCmd := &cobra.Command{ - Use: "stake", + stakingTxCmd := &cobra.Command{ + Use: "staking", Short: "Staking transaction subcommands", } - stakeTxCmd.AddCommand(client.PostCommands( + stakingTxCmd.AddCommand(client.PostCommands( cli.GetCmdCreateValidator(mc.cdc), cli.GetCmdEditValidator(mc.cdc), cli.GetCmdDelegate(mc.cdc), @@ -58,5 +58,5 @@ func (mc ModuleClient) GetTxCmd() *cobra.Command { cli.GetCmdUnbond(mc.storeKey, mc.cdc), )...) - return stakeTxCmd + return stakingTxCmd } diff --git a/x/stake/client/rest/query.go b/x/staking/client/rest/query.go similarity index 79% rename from x/stake/client/rest/query.go rename to x/staking/client/rest/query.go index b46a24344e..aa9f52b52b 100644 --- a/x/stake/client/rest/query.go +++ b/x/staking/client/rest/query.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/cosmos-sdk/x/stake/tags" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/tags" "github.com/gorilla/mux" ) @@ -19,85 +19,85 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Co // Get all delegations from a delegator r.HandleFunc( - "/stake/delegators/{delegatorAddr}/delegations", + "/staking/delegators/{delegatorAddr}/delegations", delegatorDelegationsHandlerFn(cliCtx, cdc), ).Methods("GET") // Get all unbonding delegations from a delegator r.HandleFunc( - "/stake/delegators/{delegatorAddr}/unbonding_delegations", + "/staking/delegators/{delegatorAddr}/unbonding_delegations", delegatorUnbondingDelegationsHandlerFn(cliCtx, cdc), ).Methods("GET") // Get all staking txs (i.e msgs) from a delegator r.HandleFunc( - "/stake/delegators/{delegatorAddr}/txs", + "/staking/delegators/{delegatorAddr}/txs", delegatorTxsHandlerFn(cliCtx, cdc), ).Methods("GET") // Query all validators that a delegator is bonded to r.HandleFunc( - "/stake/delegators/{delegatorAddr}/validators", + "/staking/delegators/{delegatorAddr}/validators", delegatorValidatorsHandlerFn(cliCtx, cdc), ).Methods("GET") // Query a validator that a delegator is bonded to r.HandleFunc( - "/stake/delegators/{delegatorAddr}/validators/{validatorAddr}", + "/staking/delegators/{delegatorAddr}/validators/{validatorAddr}", delegatorValidatorHandlerFn(cliCtx, cdc), ).Methods("GET") // Query a delegation between a delegator and a validator r.HandleFunc( - "/stake/delegators/{delegatorAddr}/delegations/{validatorAddr}", + "/staking/delegators/{delegatorAddr}/delegations/{validatorAddr}", delegationHandlerFn(cliCtx, cdc), ).Methods("GET") // Query all unbonding delegations between a delegator and a validator r.HandleFunc( - "/stake/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}", + "/staking/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}", unbondingDelegationHandlerFn(cliCtx, cdc), ).Methods("GET") // Query redelegations (filters in query params) r.HandleFunc( - "/stake/redelegations", + "/staking/redelegations", redelegationsHandlerFn(cliCtx, cdc), ).Methods("GET") // Get all validators r.HandleFunc( - "/stake/validators", + "/staking/validators", validatorsHandlerFn(cliCtx, cdc), ).Methods("GET") // Get a single validator info r.HandleFunc( - "/stake/validators/{validatorAddr}", + "/staking/validators/{validatorAddr}", validatorHandlerFn(cliCtx, cdc), ).Methods("GET") // Get all delegations to a validator r.HandleFunc( - "/stake/validators/{validatorAddr}/delegations", + "/staking/validators/{validatorAddr}/delegations", validatorDelegationsHandlerFn(cliCtx, cdc), ).Methods("GET") // Get all unbonding delegations from a validator r.HandleFunc( - "/stake/validators/{validatorAddr}/unbonding_delegations", + "/staking/validators/{validatorAddr}/unbonding_delegations", validatorUnbondingDelegationsHandlerFn(cliCtx, cdc), ).Methods("GET") // Get the current state of the staking pool r.HandleFunc( - "/stake/pool", + "/staking/pool", poolHandlerFn(cliCtx, cdc), ).Methods("GET") // Get the current staking parameter values r.HandleFunc( - "/stake/parameters", + "/staking/parameters", paramsHandlerFn(cliCtx, cdc), ).Methods("GET") @@ -105,12 +105,12 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Co // HTTP request handler to query a delegator delegations func delegatorDelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryDelegator(cliCtx, cdc, "custom/stake/delegatorDelegations") + return queryDelegator(cliCtx, cdc, "custom/staking/delegatorDelegations") } // HTTP request handler to query a delegator unbonding delegations func delegatorUnbondingDelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryDelegator(cliCtx, cdc, "custom/stake/delegatorUnbondingDelegations") + return queryDelegator(cliCtx, cdc, "custom/staking/delegatorUnbondingDelegations") } // HTTP request handler to query all staking txs (msgs) from a delegator @@ -149,18 +149,18 @@ func delegatorTxsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Han switch { case isBondTx: - actions = append(actions, stake.MsgDelegate{}.Type()) + actions = append(actions, staking.MsgDelegate{}.Type()) case isUnbondTx: - actions = append(actions, stake.MsgBeginUnbonding{}.Type()) + actions = append(actions, staking.MsgBeginUnbonding{}.Type()) actions = append(actions, string(tags.ActionCompleteUnbonding)) case isRedTx: - actions = append(actions, stake.MsgBeginRedelegate{}.Type()) + actions = append(actions, staking.MsgBeginRedelegate{}.Type()) actions = append(actions, string(tags.ActionCompleteRedelegation)) case noQuery: - actions = append(actions, stake.MsgDelegate{}.Type()) - actions = append(actions, stake.MsgBeginUnbonding{}.Type()) + actions = append(actions, staking.MsgDelegate{}.Type()) + actions = append(actions, staking.MsgBeginUnbonding{}.Type()) actions = append(actions, string(tags.ActionCompleteUnbonding)) - actions = append(actions, stake.MsgBeginRedelegate{}.Type()) + actions = append(actions, staking.MsgBeginRedelegate{}.Type()) actions = append(actions, string(tags.ActionCompleteRedelegation)) default: w.WriteHeader(http.StatusNoContent) @@ -186,13 +186,13 @@ func delegatorTxsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Han // HTTP request handler to query an unbonding-delegation func unbondingDelegationHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryBonds(cliCtx, cdc, "custom/stake/unbondingDelegation") + return queryBonds(cliCtx, cdc, "custom/staking/unbondingDelegation") } // HTTP request handler to query redelegations func redelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var params stake.QueryRedelegationParams + var params staking.QueryRedelegationParams bechDelegatorAddr := r.URL.Query().Get("delegator") bechSrcValidatorAddr := r.URL.Query().Get("validator_from") @@ -231,7 +231,7 @@ func redelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Ha return } - res, err := cliCtx.QueryWithData("custom/stake/redelegations", bz) + res, err := cliCtx.QueryWithData("custom/staking/redelegations", bz) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return @@ -242,23 +242,23 @@ func redelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Ha // HTTP request handler to query a delegation func delegationHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryBonds(cliCtx, cdc, "custom/stake/delegation") + return queryBonds(cliCtx, cdc, "custom/staking/delegation") } // HTTP request handler to query all delegator bonded validators func delegatorValidatorsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryDelegator(cliCtx, cdc, "custom/stake/delegatorValidators") + return queryDelegator(cliCtx, cdc, "custom/staking/delegatorValidators") } // HTTP request handler to get information from a currently bonded validator func delegatorValidatorHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryBonds(cliCtx, cdc, "custom/stake/delegatorValidator") + return queryBonds(cliCtx, cdc, "custom/staking/delegatorValidator") } // HTTP request handler to query list of validators func validatorsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - res, err := cliCtx.QueryWithData("custom/stake/validators", nil) + res, err := cliCtx.QueryWithData("custom/staking/validators", nil) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return @@ -269,23 +269,23 @@ func validatorsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Handl // HTTP request handler to query the validator information from a given validator address func validatorHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryValidator(cliCtx, cdc, "custom/stake/validator") + return queryValidator(cliCtx, cdc, "custom/staking/validator") } // HTTP request handler to query all unbonding delegations from a validator func validatorDelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryValidator(cliCtx, cdc, "custom/stake/validatorDelegations") + return queryValidator(cliCtx, cdc, "custom/staking/validatorDelegations") } // HTTP request handler to query all unbonding delegations from a validator func validatorUnbondingDelegationsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { - return queryValidator(cliCtx, cdc, "custom/stake/validatorUnbondingDelegations") + return queryValidator(cliCtx, cdc, "custom/staking/validatorUnbondingDelegations") } // HTTP request handler to query the pool information func poolHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - res, err := cliCtx.QueryWithData("custom/stake/pool", nil) + res, err := cliCtx.QueryWithData("custom/staking/pool", nil) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return @@ -297,7 +297,7 @@ func poolHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc // HTTP request handler to query the staking params values func paramsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - res, err := cliCtx.QueryWithData("custom/stake/parameters", nil) + res, err := cliCtx.QueryWithData("custom/staking/parameters", nil) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return diff --git a/x/stake/client/rest/rest.go b/x/staking/client/rest/rest.go similarity index 100% rename from x/stake/client/rest/rest.go rename to x/staking/client/rest/rest.go diff --git a/x/stake/client/rest/tx.go b/x/staking/client/rest/tx.go similarity index 89% rename from x/stake/client/rest/tx.go rename to x/staking/client/rest/tx.go index 7fde46acbd..26e7c9ea21 100644 --- a/x/stake/client/rest/tx.go +++ b/x/staking/client/rest/tx.go @@ -9,22 +9,22 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/cosmos/cosmos-sdk/x/staking" "github.com/gorilla/mux" ) func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, kb keys.Keybase) { r.HandleFunc( - "/stake/delegators/{delegatorAddr}/delegations", + "/staking/delegators/{delegatorAddr}/delegations", postDelegationsHandlerFn(cdc, kb, cliCtx), ).Methods("POST") r.HandleFunc( - "/stake/delegators/{delegatorAddr}/unbonding_delegations", + "/staking/delegators/{delegatorAddr}/unbonding_delegations", postUnbondingDelegationsHandlerFn(cdc, kb, cliCtx), ).Methods("POST") r.HandleFunc( - "/stake/delegators/{delegatorAddr}/redelegations", + "/staking/delegators/{delegatorAddr}/redelegations", postRedelegationsHandlerFn(cdc, kb, cliCtx), ).Methods("POST") } @@ -79,7 +79,7 @@ func postDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx context. return } - msg := stake.NewMsgDelegate(req.DelegatorAddr, req.ValidatorAddr, req.Delegation) + msg := staking.NewMsgDelegate(req.DelegatorAddr, req.ValidatorAddr, req.Delegation) err = msg.ValidateBasic() if err != nil { utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) @@ -116,7 +116,7 @@ func postRedelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx contex return } - msg := stake.NewMsgBeginRedelegate(req.DelegatorAddr, req.ValidatorSrcAddr, req.ValidatorDstAddr, req.SharesAmount) + msg := staking.NewMsgBeginRedelegate(req.DelegatorAddr, req.ValidatorSrcAddr, req.ValidatorDstAddr, req.SharesAmount) err = msg.ValidateBasic() if err != nil { utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) @@ -153,7 +153,7 @@ func postUnbondingDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx return } - msg := stake.NewMsgBeginUnbonding(req.DelegatorAddr, req.ValidatorAddr, req.SharesAmount) + msg := staking.NewMsgBeginUnbonding(req.DelegatorAddr, req.ValidatorAddr, req.SharesAmount) err = msg.ValidateBasic() if err != nil { utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) diff --git a/x/stake/client/rest/utils.go b/x/staking/client/rest/utils.go similarity index 93% rename from x/stake/client/rest/utils.go rename to x/staking/client/rest/utils.go index f499e323d2..2a95776e3d 100644 --- a/x/stake/client/rest/utils.go +++ b/x/staking/client/rest/utils.go @@ -11,8 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/utils" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/cosmos-sdk/x/stake/tags" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/tags" rpcclient "github.com/tendermint/tendermint/rpc/client" ) @@ -73,7 +73,7 @@ func queryRedelegations(cliCtx context.CLIContext, cdc *codec.Codec, endpoint st return } - params := stake.QueryRedelegationParams{ + params := staking.QueryRedelegationParams{ DelegatorAddr: delegatorAddr, SrcValidatorAddr: srcValidatorAddr, DstValidatorAddr: dstValidatorAddr, @@ -107,7 +107,7 @@ func queryBonds(cliCtx context.CLIContext, cdc *codec.Codec, endpoint string) ht return } - params := stake.NewQueryBondsParams(delegatorAddr, validatorAddr) + params := staking.NewQueryBondsParams(delegatorAddr, validatorAddr) bz, err := cdc.MarshalJSON(params) if err != nil { @@ -135,7 +135,7 @@ func queryDelegator(cliCtx context.CLIContext, cdc *codec.Codec, endpoint string return } - params := stake.NewQueryDelegatorParams(delegatorAddr) + params := staking.NewQueryDelegatorParams(delegatorAddr) bz, err := cdc.MarshalJSON(params) if err != nil { @@ -163,7 +163,7 @@ func queryValidator(cliCtx context.CLIContext, cdc *codec.Codec, endpoint string return } - params := stake.NewQueryValidatorParams(validatorAddr) + params := staking.NewQueryValidatorParams(validatorAddr) bz, err := cdc.MarshalJSON(params) if err != nil { diff --git a/x/stake/genesis.go b/x/staking/genesis.go similarity index 98% rename from x/stake/genesis.go rename to x/staking/genesis.go index 65998b6575..62ee49efd4 100644 --- a/x/stake/genesis.go +++ b/x/staking/genesis.go @@ -1,4 +1,4 @@ -package stake +package staking import ( "fmt" @@ -8,7 +8,7 @@ import ( tmtypes "github.com/tendermint/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // InitGenesis sets the pool and parameters for the provided keeper. For each diff --git a/x/stake/genesis_test.go b/x/staking/genesis_test.go similarity index 97% rename from x/stake/genesis_test.go rename to x/staking/genesis_test.go index f7c874b708..ac91746517 100644 --- a/x/stake/genesis_test.go +++ b/x/staking/genesis_test.go @@ -1,4 +1,4 @@ -package stake +package staking import ( "fmt" @@ -12,8 +12,8 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - keep "github.com/cosmos/cosmos-sdk/x/stake/keeper" - "github.com/cosmos/cosmos-sdk/x/stake/types" + keep "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestInitGenesis(t *testing.T) { diff --git a/x/stake/handler.go b/x/staking/handler.go similarity index 98% rename from x/stake/handler.go rename to x/staking/handler.go index 4e1ced5dc0..a4c856f6f4 100644 --- a/x/stake/handler.go +++ b/x/staking/handler.go @@ -1,4 +1,4 @@ -package stake +package staking import ( "bytes" @@ -9,9 +9,9 @@ import ( tmtypes "github.com/tendermint/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/keeper" - "github.com/cosmos/cosmos-sdk/x/stake/tags" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/tags" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func NewHandler(k keeper.Keeper) sdk.Handler { diff --git a/x/stake/handler_test.go b/x/staking/handler_test.go similarity index 99% rename from x/stake/handler_test.go rename to x/staking/handler_test.go index eb6e5f8fb7..96f804fb4a 100644 --- a/x/stake/handler_test.go +++ b/x/staking/handler_test.go @@ -1,4 +1,4 @@ -package stake +package staking import ( "testing" @@ -12,8 +12,8 @@ import ( tmtypes "github.com/tendermint/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" - keep "github.com/cosmos/cosmos-sdk/x/stake/keeper" - "github.com/cosmos/cosmos-sdk/x/stake/types" + keep "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) //______________________________________________________________________ diff --git a/x/stake/keeper/_store.md b/x/staking/keeper/_store.md similarity index 99% rename from x/stake/keeper/_store.md rename to x/staking/keeper/_store.md index d569389417..f6430c312b 100644 --- a/x/stake/keeper/_store.md +++ b/x/staking/keeper/_store.md @@ -1,7 +1,7 @@ # Stores This document provided a bit more insight as to the purpose of several related -prefixed areas of the staking store which are accessed in `x/stake/keeper.go`. +prefixed areas of the staking store which are accessed in `x/staking/keeper.go`. # IAVL Store diff --git a/x/stake/keeper/delegation.go b/x/staking/keeper/delegation.go similarity index 99% rename from x/stake/keeper/delegation.go rename to x/staking/keeper/delegation.go index 28009ca751..63bd2cfb05 100644 --- a/x/stake/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // return a specific delegation diff --git a/x/stake/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go similarity index 99% rename from x/stake/keeper/delegation_test.go rename to x/staking/keeper/delegation_test.go index 37545ab227..7a00b3ee47 100644 --- a/x/stake/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -6,7 +6,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x/stake/keeper/hooks.go b/x/staking/keeper/hooks.go similarity index 100% rename from x/stake/keeper/hooks.go rename to x/staking/keeper/hooks.go diff --git a/x/stake/keeper/keeper.go b/x/staking/keeper/keeper.go similarity index 98% rename from x/stake/keeper/keeper.go rename to x/staking/keeper/keeper.go index 93b75958d1..ea3527d5d6 100644 --- a/x/stake/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -8,12 +8,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) const aminoCacheSize = 500 -// keeper of the stake store +// keeper of the staking store type Keeper struct { storeKey sdk.StoreKey storeTKey sdk.StoreKey diff --git a/x/stake/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go similarity index 95% rename from x/stake/keeper/keeper_test.go rename to x/staking/keeper/keeper_test.go index be45fc20c1..89ffe13d19 100644 --- a/x/stake/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestParams(t *testing.T) { diff --git a/x/stake/keeper/key.go b/x/staking/keeper/key.go similarity index 97% rename from x/stake/keeper/key.go rename to x/staking/keeper/key.go index 8c45f98813..6dbb053cf6 100644 --- a/x/stake/keeper/key.go +++ b/x/staking/keeper/key.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // TODO remove some of these prefixes once have working multistore @@ -14,7 +14,7 @@ import ( var ( // Keys for store prefixes // TODO DEPRECATED: delete in next release and reorder keys - // ParamKey = []byte{0x00} // key for parameters relating to staking + // ParamKey = []byte{0x00} // key for parameters relating to stake PoolKey = []byte{0x01} // key for the staking pools // Last* values are const during a block. @@ -40,7 +40,7 @@ var ( const maxDigitsForAccount = 12 // ~220,000,000 atoms created at launch // gets the key for the validator with address -// VALUE: stake/types.Validator +// VALUE: staking/types.Validator func GetValidatorKey(operatorAddr sdk.ValAddress) []byte { return append(ValidatorsKey, operatorAddr.Bytes()...) } @@ -120,7 +120,7 @@ func GetValidatorQueueTimeKey(timestamp time.Time) []byte { //______________________________________________________________________________ // gets the key for delegator bond with validator -// VALUE: stake/types.Delegation +// VALUE: staking/types.Delegation func GetDelegationKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte { return append(GetDelegationsKey(delAddr), valAddr.Bytes()...) } @@ -133,7 +133,7 @@ func GetDelegationsKey(delAddr sdk.AccAddress) []byte { //______________________________________________________________________________ // gets the key for an unbonding delegation by delegator and validator addr -// VALUE: stake/types.UnbondingDelegation +// VALUE: staking/types.UnbondingDelegation func GetUBDKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte { return append( GetUBDsKey(delAddr.Bytes()), @@ -178,7 +178,7 @@ func GetUnbondingDelegationTimeKey(timestamp time.Time) []byte { //________________________________________________________________________________ // gets the key for a redelegation -// VALUE: stake/types.RedelegationKey +// VALUE: staking/types.RedelegationKey func GetREDKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { key := make([]byte, 1+sdk.AddrLen*3) diff --git a/x/stake/keeper/key_test.go b/x/staking/keeper/key_test.go similarity index 98% rename from x/stake/keeper/key_test.go rename to x/staking/keeper/key_test.go index 0645fd85bb..9f80062ac4 100644 --- a/x/stake/keeper/key_test.go +++ b/x/staking/keeper/key_test.go @@ -9,7 +9,7 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( diff --git a/x/stake/keeper/params.go b/x/staking/keeper/params.go similarity index 90% rename from x/stake/keeper/params.go rename to x/staking/keeper/params.go index b62a7688fb..2d3fdf296e 100644 --- a/x/stake/keeper/params.go +++ b/x/staking/keeper/params.go @@ -5,15 +5,15 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Default parameter namespace const ( - DefaultParamspace = "stake" + DefaultParamspace = "staking" ) -// ParamTable for stake module +// ParamTable for staking module func ParamTypeTable() params.TypeTable { return params.NewTypeTable().RegisterParamSet(&types.Params{}) } diff --git a/x/stake/keeper/query_utils.go b/x/staking/keeper/query_utils.go similarity index 98% rename from x/stake/keeper/query_utils.go rename to x/staking/keeper/query_utils.go index aef7bad47d..872059f110 100644 --- a/x/stake/keeper/query_utils.go +++ b/x/staking/keeper/query_utils.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Return all validators that a delegator is bonded to. If maxRetrieve is supplied, the respective amount will be returned. diff --git a/x/stake/keeper/sdk_types.go b/x/staking/keeper/sdk_types.go similarity index 98% rename from x/stake/keeper/sdk_types.go rename to x/staking/keeper/sdk_types.go index 316ca79ff7..265ee4c798 100644 --- a/x/stake/keeper/sdk_types.go +++ b/x/staking/keeper/sdk_types.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Implements ValidatorSet diff --git a/x/stake/keeper/slash.go b/x/staking/keeper/slash.go similarity index 97% rename from x/stake/keeper/slash.go rename to x/staking/keeper/slash.go index 01fe195bd5..afe58742c0 100644 --- a/x/stake/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/x/stake/types" + types "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Slash a validator for an infraction committed at a known height @@ -22,7 +22,7 @@ import ( // Infraction committed at the current height or at a past height, // not at a height in the future func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) { - logger := ctx.Logger().With("module", "x/stake") + logger := ctx.Logger().With("module", "x/staking") if slashFactor.LT(sdk.ZeroDec()) { panic(fmt.Errorf("attempted to slash with a negative slash factor: %v", slashFactor)) @@ -123,7 +123,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh func (k Keeper) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) { validator := k.mustGetValidatorByConsAddr(ctx, consAddr) k.jailValidator(ctx, validator) - logger := ctx.Logger().With("module", "x/stake") + logger := ctx.Logger().With("module", "x/staking") logger.Info(fmt.Sprintf("validator %s jailed", consAddr)) // TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803 return @@ -133,7 +133,7 @@ func (k Keeper) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) { func (k Keeper) Unjail(ctx sdk.Context, consAddr sdk.ConsAddress) { validator := k.mustGetValidatorByConsAddr(ctx, consAddr) k.unjailValidator(ctx, validator) - logger := ctx.Logger().With("module", "x/stake") + logger := ctx.Logger().With("module", "x/staking") logger.Info(fmt.Sprintf("validator %s unjailed", consAddr)) // TODO Return event(s), blocked on https://github.com/tendermint/tendermint/pull/1803 return diff --git a/x/stake/keeper/slash_test.go b/x/staking/keeper/slash_test.go similarity index 99% rename from x/stake/keeper/slash_test.go rename to x/staking/keeper/slash_test.go index 294bf2fe6c..a39b5b0a4b 100644 --- a/x/stake/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // TODO integrate with test_common.go helper (CreateTestInput) @@ -82,7 +82,7 @@ func TestSlashUnbondingDelegation(t *testing.T) { } keeper.SetUnbondingDelegation(ctx, ubd) - // unbonding started prior to the infraction height, stake didn't contribute + // unbonding started prior to the infraction height, stakw didn't contribute slashAmount := keeper.slashUnbondingDelegation(ctx, ubd, 1, fraction) require.Equal(t, int64(0), slashAmount.Int64()) diff --git a/x/stake/keeper/test_common.go b/x/staking/keeper/test_common.go similarity index 89% rename from x/stake/keeper/test_common.go rename to x/staking/keeper/test_common.go index 10d856f05b..04323b2d59 100644 --- a/x/stake/keeper/test_common.go +++ b/x/staking/keeper/test_common.go @@ -22,7 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/params" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // dummy addresses used for testing @@ -60,15 +60,15 @@ func MakeTestCodec() *codec.Codec { // Register Msgs cdc.RegisterInterface((*sdk.Msg)(nil), nil) - cdc.RegisterConcrete(bank.MsgSend{}, "test/stake/Send", nil) - cdc.RegisterConcrete(types.MsgCreateValidator{}, "test/stake/CreateValidator", nil) - cdc.RegisterConcrete(types.MsgEditValidator{}, "test/stake/EditValidator", nil) - cdc.RegisterConcrete(types.MsgBeginUnbonding{}, "test/stake/BeginUnbonding", nil) - cdc.RegisterConcrete(types.MsgBeginRedelegate{}, "test/stake/BeginRedelegate", nil) + cdc.RegisterConcrete(bank.MsgSend{}, "test/staking/Send", nil) + cdc.RegisterConcrete(types.MsgCreateValidator{}, "test/staking/CreateValidator", nil) + cdc.RegisterConcrete(types.MsgEditValidator{}, "test/staking/EditValidator", nil) + cdc.RegisterConcrete(types.MsgBeginUnbonding{}, "test/staking/BeginUnbonding", nil) + cdc.RegisterConcrete(types.MsgBeginRedelegate{}, "test/staking/BeginRedelegate", nil) // Register AppAccount cdc.RegisterInterface((*auth.Account)(nil), nil) - cdc.RegisterConcrete(&auth.BaseAccount{}, "test/stake/Account", nil) + cdc.RegisterConcrete(&auth.BaseAccount{}, "test/staking/Account", nil) codec.RegisterCrypto(cdc) return cdc @@ -77,16 +77,16 @@ func MakeTestCodec() *codec.Codec { // hogpodge of all sorts of input required for testing func CreateTestInput(t *testing.T, isCheckTx bool, initCoins int64) (sdk.Context, auth.AccountKeeper, Keeper) { - keyStake := sdk.NewKVStoreKey(types.StoreKey) - tkeyStake := sdk.NewTransientStoreKey(types.TStoreKey) + keyStaking := sdk.NewKVStoreKey(types.StoreKey) + tkeyStaking := sdk.NewTransientStoreKey(types.TStoreKey) keyAcc := sdk.NewKVStoreKey(auth.StoreKey) keyParams := sdk.NewKVStoreKey(params.StoreKey) tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey) db := dbm.NewMemDB() ms := store.NewCommitMultiStore(db) - ms.MountStoreWithDB(tkeyStake, sdk.StoreTypeTransient, nil) - ms.MountStoreWithDB(keyStake, sdk.StoreTypeIAVL, db) + ms.MountStoreWithDB(tkeyStaking, sdk.StoreTypeTransient, nil) + ms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db) ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db) @@ -108,7 +108,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initCoins int64) (sdk.Context ck := bank.NewBaseKeeper(accountKeeper) - keeper := NewKeeper(cdc, keyStake, tkeyStake, ck, pk.Subspace(DefaultParamspace), types.DefaultCodespace) + keeper := NewKeeper(cdc, keyStaking, tkeyStaking, ck, pk.Subspace(DefaultParamspace), types.DefaultCodespace) keeper.SetPool(ctx, types.InitialPool()) keeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/stake/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go similarity index 99% rename from x/stake/keeper/val_state_change.go rename to x/staking/keeper/val_state_change.go index 55f8438d3d..84d13d655c 100644 --- a/x/stake/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -8,7 +8,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Apply and return accumulated updates to the bonded validator set. Also, diff --git a/x/stake/keeper/validator.go b/x/staking/keeper/validator.go similarity index 99% rename from x/stake/keeper/validator.go rename to x/staking/keeper/validator.go index 50cfaf70d8..56467d5316 100644 --- a/x/stake/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -6,7 +6,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // Cache the amino decoding of validators, as it can be the case that repeated slashing calls diff --git a/x/stake/keeper/validator_test.go b/x/staking/keeper/validator_test.go similarity index 99% rename from x/stake/keeper/validator_test.go rename to x/staking/keeper/validator_test.go index 8d23a80f97..69b0782225 100644 --- a/x/stake/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -8,7 +8,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/x/stake/querier/querier.go b/x/staking/querier/querier.go similarity index 92% rename from x/stake/querier/querier.go rename to x/staking/querier/querier.go index 14ca42d676..4d8ad619cd 100644 --- a/x/stake/querier/querier.go +++ b/x/staking/querier/querier.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - keep "github.com/cosmos/cosmos-sdk/x/stake/keeper" - "github.com/cosmos/cosmos-sdk/x/stake/types" + keep "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) // query endpoints supported by the staking Querier @@ -58,16 +58,16 @@ func NewQuerier(k keep.Keeper, cdc *codec.Codec) sdk.Querier { case QueryParameters: return queryParameters(ctx, cdc, k) default: - return nil, sdk.ErrUnknownRequest("unknown stake query endpoint") + return nil, sdk.ErrUnknownRequest("unknown staking query endpoint") } } } // defines the params for the following queries: -// - 'custom/stake/delegatorDelegations' -// - 'custom/stake/delegatorUnbondingDelegations' -// - 'custom/stake/delegatorRedelegations' -// - 'custom/stake/delegatorValidators' +// - 'custom/staking/delegatorDelegations' +// - 'custom/staking/delegatorUnbondingDelegations' +// - 'custom/staking/delegatorRedelegations' +// - 'custom/staking/delegatorValidators' type QueryDelegatorParams struct { DelegatorAddr sdk.AccAddress } @@ -79,10 +79,10 @@ func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams } // defines the params for the following queries: -// - 'custom/stake/validator' -// - 'custom/stake/validatorDelegations' -// - 'custom/stake/validatorUnbondingDelegations' -// - 'custom/stake/validatorRedelegations' +// - 'custom/staking/validator' +// - 'custom/staking/validatorDelegations' +// - 'custom/staking/validatorUnbondingDelegations' +// - 'custom/staking/validatorRedelegations' type QueryValidatorParams struct { ValidatorAddr sdk.ValAddress } @@ -94,9 +94,9 @@ func NewQueryValidatorParams(validatorAddr sdk.ValAddress) QueryValidatorParams } // defines the params for the following queries: -// - 'custom/stake/delegation' -// - 'custom/stake/unbondingDelegation' -// - 'custom/stake/delegatorValidator' +// - 'custom/staking/delegation' +// - 'custom/staking/unbondingDelegation' +// - 'custom/staking/delegatorValidator' type QueryBondsParams struct { DelegatorAddr sdk.AccAddress ValidatorAddr sdk.ValAddress @@ -110,7 +110,7 @@ func NewQueryBondsParams(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddr } // defines the params for the following queries: -// - 'custom/stake/redelegation' +// - 'custom/staking/redelegation' type QueryRedelegationParams struct { DelegatorAddr sdk.AccAddress SrcValidatorAddr sdk.ValAddress @@ -126,8 +126,8 @@ func NewQueryRedelegationParams(delegatorAddr sdk.AccAddress, srcValidatorAddr s } func queryValidators(ctx sdk.Context, cdc *codec.Codec, k keep.Keeper) (res []byte, err sdk.Error) { - stakeParams := k.GetParams(ctx) - validators := k.GetValidators(ctx, stakeParams.MaxValidators) + stakingParams := k.GetParams(ctx) + validators := k.GetValidators(ctx, stakingParams.MaxValidators) res, errRes := codec.MarshalJSONIndent(cdc, validators) if err != nil { @@ -227,14 +227,14 @@ func queryDelegatorUnbondingDelegations(ctx sdk.Context, cdc *codec.Codec, req a func queryDelegatorValidators(ctx sdk.Context, cdc *codec.Codec, req abci.RequestQuery, k keep.Keeper) (res []byte, err sdk.Error) { var params QueryDelegatorParams - stakeParams := k.GetParams(ctx) + stakingParams := k.GetParams(ctx) errRes := cdc.UnmarshalJSON(req.Data, ¶ms) if errRes != nil { return []byte{}, sdk.ErrUnknownAddress("") } - validators := k.GetDelegatorValidators(ctx, params.DelegatorAddr, stakeParams.MaxValidators) + validators := k.GetDelegatorValidators(ctx, params.DelegatorAddr, stakingParams.MaxValidators) res, errRes = codec.MarshalJSONIndent(cdc, validators) if errRes != nil { diff --git a/x/stake/querier/querier_test.go b/x/staking/querier/querier_test.go similarity index 94% rename from x/stake/querier/querier_test.go rename to x/staking/querier/querier_test.go index 5541cb81c6..ab9f243809 100644 --- a/x/stake/querier/querier_test.go +++ b/x/staking/querier/querier_test.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - keep "github.com/cosmos/cosmos-sdk/x/stake/keeper" - "github.com/cosmos/cosmos-sdk/x/stake/types" + keep "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -57,7 +57,7 @@ func TestNewQuerier(t *testing.T) { bz, errRes := cdc.MarshalJSON(queryValParams) require.Nil(t, errRes) - query.Path = "/custom/stake/validator" + query.Path = "/custom/staking/validator" query.Data = bz _, err = querier(ctx, []string{"validator"}, query) @@ -73,7 +73,7 @@ func TestNewQuerier(t *testing.T) { bz, errRes = cdc.MarshalJSON(queryDelParams) require.Nil(t, errRes) - query.Path = "/custom/stake/validator" + query.Path = "/custom/staking/validator" query.Data = bz _, err = querier(ctx, []string{"delegatorDelegations"}, query) @@ -150,7 +150,7 @@ func TestQueryValidators(t *testing.T) { require.Nil(t, errRes) query := abci.RequestQuery{ - Path: "/custom/stake/validator", + Path: "/custom/staking/validator", Data: bz, } res, err = queryValidator(ctx, cdc, query, keeper) @@ -188,7 +188,7 @@ func TestQueryDelegation(t *testing.T) { require.Nil(t, errRes) query := abci.RequestQuery{ - Path: "/custom/stake/delegatorValidators", + Path: "/custom/staking/delegatorValidators", Data: bz, } @@ -216,7 +216,7 @@ func TestQueryDelegation(t *testing.T) { require.Nil(t, errRes) query = abci.RequestQuery{ - Path: "/custom/stake/delegatorValidator", + Path: "/custom/staking/delegatorValidator", Data: bz, } @@ -238,7 +238,7 @@ func TestQueryDelegation(t *testing.T) { // Query delegation query = abci.RequestQuery{ - Path: "/custom/stake/delegation", + Path: "/custom/staking/delegation", Data: bz, } @@ -257,7 +257,7 @@ func TestQueryDelegation(t *testing.T) { // Query Delegator Delegations query = abci.RequestQuery{ - Path: "/custom/stake/delegatorDelegations", + Path: "/custom/staking/delegatorDelegations", Data: bz, } @@ -282,7 +282,7 @@ func TestQueryDelegation(t *testing.T) { require.Nil(t, errRes) query = abci.RequestQuery{ - Path: "custom/stake/validatorDelegations", + Path: "custom/staking/validatorDelegations", Data: bz, } @@ -303,7 +303,7 @@ func TestQueryDelegation(t *testing.T) { require.Nil(t, errRes) query = abci.RequestQuery{ - Path: "/custom/stake/unbondingDelegation", + Path: "/custom/staking/unbondingDelegation", Data: bz, } @@ -328,7 +328,7 @@ func TestQueryDelegation(t *testing.T) { // Query Delegator Delegations query = abci.RequestQuery{ - Path: "/custom/stake/delegatorUnbondingDelegations", + Path: "/custom/staking/delegatorUnbondingDelegations", Data: bz, } @@ -354,7 +354,7 @@ func TestQueryDelegation(t *testing.T) { require.Nil(t, errRes) query = abci.RequestQuery{ - Path: "/custom/stake/redelegations", + Path: "/custom/staking/redelegations", Data: bz, } @@ -393,7 +393,7 @@ func TestQueryRedelegations(t *testing.T) { require.Nil(t, errRes) query := abci.RequestQuery{ - Path: "/custom/stake/redelegations", + Path: "/custom/staking/redelegations", Data: bz, } @@ -412,7 +412,7 @@ func TestQueryRedelegations(t *testing.T) { require.Nil(t, errRes) query = abci.RequestQuery{ - Path: "/custom/stake/redelegations", + Path: "/custom/staking/redelegations", Data: bz, } diff --git a/x/stake/simulation/invariants.go b/x/staking/simulation/invariants.go similarity index 82% rename from x/stake/simulation/invariants.go rename to x/staking/simulation/invariants.go index 52775d268c..1bba6ccb23 100644 --- a/x/stake/simulation/invariants.go +++ b/x/staking/simulation/invariants.go @@ -9,14 +9,14 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/mock/simulation" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/cosmos-sdk/x/stake/keeper" - stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// AllInvariants runs all invariants of the stake module. +// AllInvariants runs all invariants of the staking module. // Currently: total supply, positive power -func AllInvariants(ck bank.Keeper, k stake.Keeper, +func AllInvariants(ck bank.Keeper, k staking.Keeper, f auth.FeeCollectionKeeper, d distribution.Keeper, am auth.AccountKeeper) simulation.Invariant { @@ -47,7 +47,7 @@ func AllInvariants(ck bank.Keeper, k stake.Keeper, // SupplyInvariants checks that the total supply reflects all held loose tokens, bonded tokens, and unbonding delegations // nolint: unparam -func SupplyInvariants(ck bank.Keeper, k stake.Keeper, +func SupplyInvariants(ck bank.Keeper, k staking.Keeper, f auth.FeeCollectionKeeper, d distribution.Keeper, am auth.AccountKeeper) simulation.Invariant { return func(ctx sdk.Context) error { pool := k.GetPool(ctx) @@ -55,10 +55,10 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper, loose := sdk.ZeroDec() bonded := sdk.ZeroDec() am.IterateAccounts(ctx, func(acc auth.Account) bool { - loose = loose.Add(sdk.NewDecFromInt(acc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom))) + loose = loose.Add(sdk.NewDecFromInt(acc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom))) return false }) - k.IterateUnbondingDelegations(ctx, func(_ int64, ubd stake.UnbondingDelegation) bool { + k.IterateUnbondingDelegations(ctx, func(_ int64, ubd staking.UnbondingDelegation) bool { loose = loose.Add(sdk.NewDecFromInt(ubd.Balance.Amount)) return false }) @@ -75,19 +75,19 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper, feePool := d.GetFeePool(ctx) // add outstanding fees - loose = loose.Add(sdk.NewDecFromInt(f.GetCollectedFees(ctx).AmountOf(stakeTypes.DefaultBondDenom))) + loose = loose.Add(sdk.NewDecFromInt(f.GetCollectedFees(ctx).AmountOf(stakingTypes.DefaultBondDenom))) // add community pool - loose = loose.Add(feePool.CommunityPool.AmountOf(stakeTypes.DefaultBondDenom)) + loose = loose.Add(feePool.CommunityPool.AmountOf(stakingTypes.DefaultBondDenom)) // add validator distribution pool - loose = loose.Add(feePool.ValPool.AmountOf(stakeTypes.DefaultBondDenom)) + loose = loose.Add(feePool.ValPool.AmountOf(stakingTypes.DefaultBondDenom)) // add validator distribution commission and yet-to-be-withdrawn-by-delegators d.IterateValidatorDistInfos(ctx, func(_ int64, distInfo distribution.ValidatorDistInfo) (stop bool) { - loose = loose.Add(distInfo.DelPool.AmountOf(stakeTypes.DefaultBondDenom)) - loose = loose.Add(distInfo.ValCommission.AmountOf(stakeTypes.DefaultBondDenom)) + loose = loose.Add(distInfo.DelPool.AmountOf(stakingTypes.DefaultBondDenom)) + loose = loose.Add(distInfo.ValCommission.AmountOf(stakingTypes.DefaultBondDenom)) return false }, ) @@ -112,7 +112,7 @@ func SupplyInvariants(ck bank.Keeper, k stake.Keeper, } // NonNegativePowerInvariant checks that all stored validators have >= 0 power. -func NonNegativePowerInvariant(k stake.Keeper) simulation.Invariant { +func NonNegativePowerInvariant(k staking.Keeper) simulation.Invariant { return func(ctx sdk.Context) error { iterator := k.ValidatorsPowerStoreIterator(ctx) @@ -139,7 +139,7 @@ func NonNegativePowerInvariant(k stake.Keeper) simulation.Invariant { } // PositiveDelegationInvariant checks that all stored delegations have > 0 shares. -func PositiveDelegationInvariant(k stake.Keeper) simulation.Invariant { +func PositiveDelegationInvariant(k staking.Keeper) simulation.Invariant { return func(ctx sdk.Context) error { delegations := k.GetAllDelegations(ctx) for _, delegation := range delegations { @@ -158,7 +158,7 @@ func PositiveDelegationInvariant(k stake.Keeper) simulation.Invariant { // DelegatorSharesInvariant checks whether all the delegator shares which persist // in the delegator object add up to the correct total delegator shares // amount stored in each validator -func DelegatorSharesInvariant(k stake.Keeper) simulation.Invariant { +func DelegatorSharesInvariant(k staking.Keeper) simulation.Invariant { return func(ctx sdk.Context) error { validators := k.GetAllValidators(ctx) for _, validator := range validators { diff --git a/x/stake/simulation/msgs.go b/x/staking/simulation/msgs.go similarity index 82% rename from x/stake/simulation/msgs.go rename to x/staking/simulation/msgs.go index 9fa469d6ca..473681cc07 100644 --- a/x/stake/simulation/msgs.go +++ b/x/staking/simulation/msgs.go @@ -8,24 +8,24 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/mock/simulation" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/cosmos-sdk/x/stake/keeper" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) // SimulateMsgCreateValidator -func SimulateMsgCreateValidator(m auth.AccountKeeper, k stake.Keeper) simulation.Operation { - handler := stake.NewHandler(k) +func SimulateMsgCreateValidator(m auth.AccountKeeper, k staking.Keeper) simulation.Operation { + handler := staking.NewHandler(k) return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, event func(string)) ( action string, fOp []simulation.FutureOperation, err error) { denom := k.GetParams(ctx).BondDenom - description := stake.Description{ + description := staking.Description{ Moniker: simulation.RandStringOfLength(r, 10), } maxCommission := sdk.NewDecWithPrec(r.Int63n(1000), 3) - commission := stake.NewCommissionMsg( + commission := staking.NewCommissionMsg( simulation.RandomDecAmount(r, maxCommission), maxCommission, simulation.RandomDecAmount(r, maxCommission), @@ -42,7 +42,7 @@ func SimulateMsgCreateValidator(m auth.AccountKeeper, k stake.Keeper) simulation return "no-operation", nil, nil } - msg := stake.MsgCreateValidator{ + msg := staking.MsgCreateValidator{ Description: description, Commission: commission, ValidatorAddr: address, @@ -61,7 +61,7 @@ func SimulateMsgCreateValidator(m auth.AccountKeeper, k stake.Keeper) simulation write() } - event(fmt.Sprintf("stake/MsgCreateValidator/%v", result.IsOK())) + event(fmt.Sprintf("staking/MsgCreateValidator/%v", result.IsOK())) // require.True(t, result.IsOK(), "expected OK result but instead got %v", result) action = fmt.Sprintf("TestMsgCreateValidator: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) @@ -70,13 +70,13 @@ func SimulateMsgCreateValidator(m auth.AccountKeeper, k stake.Keeper) simulation } // SimulateMsgEditValidator -func SimulateMsgEditValidator(k stake.Keeper) simulation.Operation { - handler := stake.NewHandler(k) +func SimulateMsgEditValidator(k staking.Keeper) simulation.Operation { + handler := staking.NewHandler(k) return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, event func(string)) ( action string, fOp []simulation.FutureOperation, err error) { - description := stake.Description{ + description := staking.Description{ Moniker: simulation.RandStringOfLength(r, 10), Identity: simulation.RandStringOfLength(r, 10), Website: simulation.RandStringOfLength(r, 10), @@ -87,7 +87,7 @@ func SimulateMsgEditValidator(k stake.Keeper) simulation.Operation { address := val.GetOperator() newCommissionRate := simulation.RandomDecAmount(r, val.Commission.MaxRate) - msg := stake.MsgEditValidator{ + msg := staking.MsgEditValidator{ Description: description, ValidatorAddr: address, CommissionRate: &newCommissionRate, @@ -102,15 +102,15 @@ func SimulateMsgEditValidator(k stake.Keeper) simulation.Operation { if result.IsOK() { write() } - event(fmt.Sprintf("stake/MsgEditValidator/%v", result.IsOK())) + event(fmt.Sprintf("staking/MsgEditValidator/%v", result.IsOK())) action = fmt.Sprintf("TestMsgEditValidator: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil, nil } } // SimulateMsgDelegate -func SimulateMsgDelegate(m auth.AccountKeeper, k stake.Keeper) simulation.Operation { - handler := stake.NewHandler(k) +func SimulateMsgDelegate(m auth.AccountKeeper, k staking.Keeper) simulation.Operation { + handler := staking.NewHandler(k) return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, event func(string)) ( action string, fOp []simulation.FutureOperation, err error) { @@ -127,7 +127,7 @@ func SimulateMsgDelegate(m auth.AccountKeeper, k stake.Keeper) simulation.Operat if amount.Equal(sdk.ZeroInt()) { return "no-operation", nil, nil } - msg := stake.MsgDelegate{ + msg := staking.MsgDelegate{ DelegatorAddr: delegatorAddress, ValidatorAddr: validatorAddress, Delegation: sdk.NewCoin(denom, amount), @@ -140,15 +140,15 @@ func SimulateMsgDelegate(m auth.AccountKeeper, k stake.Keeper) simulation.Operat if result.IsOK() { write() } - event(fmt.Sprintf("stake/MsgDelegate/%v", result.IsOK())) + event(fmt.Sprintf("staking/MsgDelegate/%v", result.IsOK())) action = fmt.Sprintf("TestMsgDelegate: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil, nil } } // SimulateMsgBeginUnbonding -func SimulateMsgBeginUnbonding(m auth.AccountKeeper, k stake.Keeper) simulation.Operation { - handler := stake.NewHandler(k) +func SimulateMsgBeginUnbonding(m auth.AccountKeeper, k staking.Keeper) simulation.Operation { + handler := staking.NewHandler(k) return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, event func(string)) ( action string, fOp []simulation.FutureOperation, err error) { @@ -165,7 +165,7 @@ func SimulateMsgBeginUnbonding(m auth.AccountKeeper, k stake.Keeper) simulation. if numShares.Equal(sdk.ZeroDec()) { return "no-operation", nil, nil } - msg := stake.MsgBeginUnbonding{ + msg := staking.MsgBeginUnbonding{ DelegatorAddr: delegatorAddress, ValidatorAddr: delegation.ValidatorAddr, SharesAmount: numShares, @@ -179,15 +179,15 @@ func SimulateMsgBeginUnbonding(m auth.AccountKeeper, k stake.Keeper) simulation. if result.IsOK() { write() } - event(fmt.Sprintf("stake/MsgBeginUnbonding/%v", result.IsOK())) + event(fmt.Sprintf("staking/MsgBeginUnbonding/%v", result.IsOK())) action = fmt.Sprintf("TestMsgBeginUnbonding: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil, nil } } // SimulateMsgBeginRedelegate -func SimulateMsgBeginRedelegate(m auth.AccountKeeper, k stake.Keeper) simulation.Operation { - handler := stake.NewHandler(k) +func SimulateMsgBeginRedelegate(m auth.AccountKeeper, k staking.Keeper) simulation.Operation { + handler := staking.NewHandler(k) return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, event func(string)) ( action string, fOp []simulation.FutureOperation, err error) { @@ -207,7 +207,7 @@ func SimulateMsgBeginRedelegate(m auth.AccountKeeper, k stake.Keeper) simulation if amount.Equal(sdk.ZeroInt()) { return "no-operation", nil, nil } - msg := stake.MsgBeginRedelegate{ + msg := staking.MsgBeginRedelegate{ DelegatorAddr: delegatorAddress, ValidatorSrcAddr: srcValidatorAddress, ValidatorDstAddr: destValidatorAddress, @@ -221,7 +221,7 @@ func SimulateMsgBeginRedelegate(m auth.AccountKeeper, k stake.Keeper) simulation if result.IsOK() { write() } - event(fmt.Sprintf("stake/MsgBeginRedelegate/%v", result.IsOK())) + event(fmt.Sprintf("staking/MsgBeginRedelegate/%v", result.IsOK())) action = fmt.Sprintf("TestMsgBeginRedelegate: %s", msg.GetSignBytes()) return action, nil, nil } diff --git a/x/stake/stake.go b/x/staking/staking.go similarity index 96% rename from x/stake/stake.go rename to x/staking/staking.go index 4043c10ce0..67fa3bb2e6 100644 --- a/x/stake/stake.go +++ b/x/staking/staking.go @@ -1,11 +1,11 @@ // nolint -package stake +package staking import ( - "github.com/cosmos/cosmos-sdk/x/stake/keeper" - "github.com/cosmos/cosmos-sdk/x/stake/querier" - "github.com/cosmos/cosmos-sdk/x/stake/tags" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/querier" + "github.com/cosmos/cosmos-sdk/x/staking/tags" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) type ( @@ -108,7 +108,7 @@ const ( const ( StoreKey = types.StoreKey TStoreKey = types.TStoreKey - QuerierRoute = types.QuerierRoute + QuerierRoute = types.QuerierRoute RouterKey = types.RouterKey DefaultCodespace = types.DefaultCodespace CodeInvalidValidator = types.CodeInvalidValidator diff --git a/x/stake/tags/tags.go b/x/staking/tags/tags.go similarity index 100% rename from x/stake/tags/tags.go rename to x/staking/tags/tags.go diff --git a/x/stake/test_common.go b/x/staking/test_common.go similarity index 96% rename from x/stake/test_common.go rename to x/staking/test_common.go index c9389d6eb9..e4bc3a22e3 100644 --- a/x/stake/test_common.go +++ b/x/staking/test_common.go @@ -1,4 +1,4 @@ -package stake +package staking import ( "github.com/tendermint/tendermint/crypto" @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/stake/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( diff --git a/x/stake/types/codec.go b/x/staking/types/codec.go similarity index 100% rename from x/stake/types/codec.go rename to x/staking/types/codec.go diff --git a/x/stake/types/commission.go b/x/staking/types/commission.go similarity index 100% rename from x/stake/types/commission.go rename to x/staking/types/commission.go diff --git a/x/stake/types/delegation.go b/x/staking/types/delegation.go similarity index 100% rename from x/stake/types/delegation.go rename to x/staking/types/delegation.go diff --git a/x/stake/types/delegation_test.go b/x/staking/types/delegation_test.go similarity index 100% rename from x/stake/types/delegation_test.go rename to x/staking/types/delegation_test.go diff --git a/x/stake/types/errors.go b/x/staking/types/errors.go similarity index 99% rename from x/stake/types/errors.go rename to x/staking/types/errors.go index c3e52f5e44..1ba5f4ca25 100644 --- a/x/stake/types/errors.go +++ b/x/staking/types/errors.go @@ -12,7 +12,7 @@ import ( type CodeType = sdk.CodeType const ( - DefaultCodespace sdk.CodespaceType = "stake" + DefaultCodespace sdk.CodespaceType = "staking" CodeInvalidValidator CodeType = 101 CodeInvalidDelegation CodeType = 102 diff --git a/x/stake/types/genesis.go b/x/staking/types/genesis.go similarity index 100% rename from x/stake/types/genesis.go rename to x/staking/types/genesis.go diff --git a/x/staking/types/keys.go b/x/staking/types/keys.go new file mode 100644 index 0000000000..aa1b92d46d --- /dev/null +++ b/x/staking/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // StoreKey is the string store representation + StoreKey = "staking" + + // TStoreKey is the string transient store representation + TStoreKey = "transient_staking" + + // QuerierRoute is the querier route for the staking module + QuerierRoute = "staking" + + // RouterKey is the msg router key for the staking module + RouterKey = "staking" +) diff --git a/x/stake/types/msg.go b/x/staking/types/msg.go similarity index 100% rename from x/stake/types/msg.go rename to x/staking/types/msg.go diff --git a/x/stake/types/msg_test.go b/x/staking/types/msg_test.go similarity index 100% rename from x/stake/types/msg_test.go rename to x/staking/types/msg_test.go diff --git a/x/stake/types/params.go b/x/staking/types/params.go similarity index 100% rename from x/stake/types/params.go rename to x/staking/types/params.go diff --git a/x/stake/types/params_test.go b/x/staking/types/params_test.go similarity index 100% rename from x/stake/types/params_test.go rename to x/staking/types/params_test.go diff --git a/x/stake/types/pool.go b/x/staking/types/pool.go similarity index 100% rename from x/stake/types/pool.go rename to x/staking/types/pool.go diff --git a/x/stake/types/pool_test.go b/x/staking/types/pool_test.go similarity index 100% rename from x/stake/types/pool_test.go rename to x/staking/types/pool_test.go diff --git a/x/stake/types/test_utils.go b/x/staking/types/test_utils.go similarity index 100% rename from x/stake/types/test_utils.go rename to x/staking/types/test_utils.go diff --git a/x/stake/types/validator.go b/x/staking/types/validator.go similarity index 100% rename from x/stake/types/validator.go rename to x/staking/types/validator.go diff --git a/x/stake/types/validator_test.go b/x/staking/types/validator_test.go similarity index 100% rename from x/stake/types/validator_test.go rename to x/staking/types/validator_test.go