Rename stake/ to staking/ (#3280)

This commit is contained in:
frog power 4000 2019-01-11 15:08:01 -05:00 committed by Jack Zampolin
parent df567616a9
commit 78a21353da
132 changed files with 1024 additions and 1021 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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), &params)
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,
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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(),

View File

@ -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++
}

View File

@ -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()

View File

@ -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)
}

View File

@ -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),
}
}

View File

@ -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{}},

View File

@ -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.

View File

@ -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)

View File

@ -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), &params)
require.NoError(f.T, err, "out %v\n, err %v", out, err)

View File

@ -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)
}

View File

@ -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,

View File

@ -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 {

View File

@ -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)

View File

@ -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)
}

View File

@ -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)

View File

@ -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"
)

View File

@ -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)
}

View File

@ -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.

View File

@ -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)
}

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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))
}

View File

@ -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 }

View File

@ -1,4 +1,4 @@
package simplestake
package simplestaking
import (
"testing"

View File

@ -1,4 +1,4 @@
package simplestake
package simplestaking
import "github.com/tendermint/tendermint/crypto"

View File

@ -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

View File

@ -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 <account_cosmosval>
gaiacli query staking validator <account_cosmosval>
```
#### Bond Tokens
@ -291,7 +291,7 @@ gaiacli query stake validator <account_cosmosval>
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=<validator> \
--from=<key_name> \
@ -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=<account_cosmos> \
--validator=<account_cosmosval>
```
@ -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 <account_cosmos>
gaiacli query staking delegations <account_cosmos>
```
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=<account_cosmosval> \
--shares-fraction=0.5 \
--from=<key_name> \
@ -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=<account_cosmos> \
--validator=<account_cosmosval> \
```
@ -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 <account_cosmos>
gaiacli query staking unbonding-delegations <account_cosmos>
```
Additionally, as you can get all the unbonding-delegations from a particular validator:
```bash
gaiacli query stake unbonding-delegations-from <account_cosmosval>
gaiacli query staking unbonding-delegations-from <account_cosmosval>
```
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=<account_cosmosval> \
--addr-validator-dest=<account_cosmosval> \
--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=<account_cosmos> \
--addr-validator-source=<account_cosmosval> \
--addr-validator-dest=<account_cosmosval> \
@ -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 <account_cosmos>
gaiacli query staking redelegations <account_cosmos>
```
Additionally, as you can get all the outgoing redelegations from a particular validator:
```bash
gaiacli query stake redelegations-from <account_cosmosval>
gaiacli query staking redelegations-from <account_cosmosval>
```
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:

View File

@ -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 <account_cosmos>
gaiacli query staking validator <account_cosmos>
```
## Track Validator Signing Information

View File

@ -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)

View File

@ -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`.

View File

@ -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

View File

@ -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)

View File

@ -160,14 +160,14 @@ And the pseudocode for the `ProposalProcessingQueue`:
// Tally
voterIterator = rangeQuery(Governance, <proposalID|'addresses'>) //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

View File

@ -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)`

View File

@ -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,
},

View File

@ -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{})
}

View File

@ -27,7 +27,7 @@ type (
GenesisState = types.GenesisState
// expected keepers
StakeKeeper = types.StakeKeeper
StakingKeeper = types.StakingKeeper
BankKeeper = types.BankKeeper
FeeCollectionKeeper = types.FeeCollectionKeeper
)

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -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)

View File

@ -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")
}

View File

@ -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),

View File

@ -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 {

View File

@ -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))

View File

@ -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())

View File

@ -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()

View File

@ -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,

View File

@ -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

View File

@ -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(

View File

@ -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())

View File

@ -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{

View File

@ -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{}))

View File

@ -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() {

View File

@ -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

View File

@ -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()

View File

@ -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)
}

View File

@ -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)

View File

@ -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{},

View File

@ -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),

View File

@ -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()))

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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)

View File

@ -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...)
}

View File

@ -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")
}
}
}

View File

@ -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),
}
}

View File

@ -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))

View File

@ -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"
)

View File

@ -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,

View File

@ -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

View File

@ -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, &params)
if err != nil {
return err

View File

@ -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,
)
}

View File

@ -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)

View File

@ -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
}

View File

@ -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

View File

@ -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())

View File

@ -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 {

View File

@ -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

View File

@ -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) {

View File

@ -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 {

View File

@ -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"
)
//______________________________________________________________________

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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) {

View File

@ -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)

View File

@ -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 (

Some files were not shown because too many files have changed in this diff Show More