* stake/fees spec updates * staking overview.md revisions, moving files * docs reorganization * staking spec state revisions * transaction stake updates * complete staking spec update * WIP adding unbonding/redelegation commands * added msg types for unbonding, redelegation * stake sub-package reorg * working stake reorg * modify lcd tests to not use hardcoded json strings * add description update * index keys * key managment for unbonding redelegation complete * update stake errors * completed handleMsgCompleteUnbonding fn * updated to use begin/complete unbonding/redelegation * fix token shares bug * develop docs into unbonding * got non-tests compiling after merge develop * working fixing tests * PrivlegedKeeper -> PrivilegedKeeper * tests compile * fix some tests * fixing tests * remove PrivilegedKeeper * get unbonding bug * only rpc sig verification failed tests now * move percent unbonding/redelegation to the CLI and out of handler logic * remove min unbonding height * add lcd txs * add pool sanity checks, fix a buncha tests * fix ante. set lcd log to debug (#1322) * redelegation tests, adding query functionality for bonds * add self-delegations at genesis ref #1165 * PR comments (mostly) addressed * cleanup, added Query LCD functionality * test cleanup/fixes * fix governance test * SlashValidatorSet -> ValidatorSet * changelog * stake lcd fix * x/auth: fix chainID in ante * fix lcd test * fix lint, update lint make command for spelling * lowercase error string * don't expose coinkeeper in staking * remove a few duplicate lines in changelog * chain_id in stake lcd tests * added transient redelegation * 'transient' => 'transitive' * Re-add nolint instruction * Fix tiny linter error
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
package stake
|
|
|
|
import (
|
|
tmtypes "github.com/tendermint/tendermint/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/stake/types"
|
|
)
|
|
|
|
// InitGenesis - store genesis parameters
|
|
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) {
|
|
keeper.SetPool(ctx, data.Pool)
|
|
keeper.SetNewParams(ctx, data.Params)
|
|
keeper.InitIntraTxCounter(ctx)
|
|
for _, validator := range data.Validators {
|
|
|
|
// set validator
|
|
keeper.SetValidator(ctx, validator)
|
|
|
|
// manually set indexes for the first time
|
|
keeper.SetValidatorByPubKeyIndex(ctx, validator)
|
|
keeper.SetValidatorByPowerIndex(ctx, validator, data.Pool)
|
|
if validator.Status() == sdk.Bonded {
|
|
keeper.SetValidatorBondedIndex(ctx, validator)
|
|
}
|
|
}
|
|
for _, bond := range data.Bonds {
|
|
keeper.SetDelegation(ctx, bond)
|
|
}
|
|
keeper.UpdateBondedValidatorsFull(ctx)
|
|
}
|
|
|
|
// WriteGenesis - output genesis parameters
|
|
func WriteGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
|
|
pool := keeper.GetPool(ctx)
|
|
params := keeper.GetParams(ctx)
|
|
validators := keeper.GetAllValidators(ctx)
|
|
bonds := keeper.GetAllDelegations(ctx)
|
|
return types.GenesisState{
|
|
pool,
|
|
params,
|
|
validators,
|
|
bonds,
|
|
}
|
|
}
|
|
|
|
// WriteValidators - output current validator set
|
|
func WriteValidators(ctx sdk.Context, keeper Keeper) (vals []tmtypes.GenesisValidator) {
|
|
keeper.IterateValidatorsBonded(ctx, func(_ int64, validator sdk.Validator) (stop bool) {
|
|
vals = append(vals, tmtypes.GenesisValidator{
|
|
PubKey: validator.GetPubKey(),
|
|
Power: validator.GetPower().Evaluate(),
|
|
Name: validator.GetMoniker(),
|
|
})
|
|
return false
|
|
})
|
|
return
|
|
}
|