Documentation ¶
Index ¶
- Variables
- func GetAddressFromValBondedIndexKey(IndexKey []byte) []byte
- func GetDelegationKey(delegatorAddr, validatorAddr sdk.AccAddress) []byte
- func GetDelegationsKey(delegatorAddr sdk.AccAddress) []byte
- func GetREDByValDstIndexKey(delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) []byte
- func GetREDByValSrcIndexKey(delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) []byte
- func GetREDKey(delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) []byte
- func GetREDKeyFromValDstIndexKey(IndexKey []byte) []byte
- func GetREDKeyFromValSrcIndexKey(IndexKey []byte) []byte
- func GetREDsByDelToValDstIndexKey(delegatorAddr, validatorDstAddr sdk.AccAddress) []byte
- func GetREDsFromValSrcIndexKey(validatorSrcAddr sdk.AccAddress) []byte
- func GetREDsKey(delegatorAddr sdk.AccAddress) []byte
- func GetREDsToValDstIndexKey(validatorDstAddr sdk.AccAddress) []byte
- func GetTendermintUpdatesKey(ownerAddr sdk.AccAddress) []byte
- func GetUBDByValIndexKey(delegatorAddr, validatorAddr sdk.AccAddress) []byte
- func GetUBDKey(delegatorAddr, validatorAddr sdk.AccAddress) []byte
- func GetUBDKeyFromValIndexKey(IndexKey []byte) []byte
- func GetUBDsByValIndexKey(validatorAddr sdk.AccAddress) []byte
- func GetUBDsKey(delegatorAddr sdk.AccAddress) []byte
- func GetValidatorByPubKeyIndexKey(pubkey crypto.PubKey) []byte
- func GetValidatorKey(ownerAddr sdk.AccAddress) []byte
- func GetValidatorsBondedIndexKey(ownerAddr sdk.AccAddress) []byte
- func GetValidatorsByPowerIndexKey(validator types.Validator, pool types.Pool) []byte
- func MakeTestCodec() *wire.Codec
- func NewPubKey(pk string) (res crypto.PubKey)
- func ParamsNoInflation() types.Params
- func TestAddr(addr string, bech string) sdk.AccAddress
- func ValEq(t *testing.T, exp, got types.Validator) (*testing.T, bool, string, types.Validator, types.Validator)
- func ValidatorByPowerIndexExists(ctx sdk.Context, keeper Keeper, power []byte) bool
- type Keeper
- func (k Keeper) BeginRedelegation(ctx sdk.Context, ...) sdk.Error
- func (k Keeper) BeginUnbonding(ctx sdk.Context, delegatorAddr, validatorAddr sdk.AccAddress, ...) sdk.Error
- func (k Keeper) ClearTendermintUpdates(ctx sdk.Context)
- func (k Keeper) Codespace() sdk.CodespaceType
- func (k Keeper) CompleteRedelegation(ctx sdk.Context, ...) sdk.Error
- func (k Keeper) CompleteUnbonding(ctx sdk.Context, delegatorAddr, validatorAddr sdk.AccAddress) sdk.Error
- func (k Keeper) Delegate(ctx sdk.Context, delegatorAddr sdk.AccAddress, bondAmt sdk.Coin, ...) (newShares sdk.Rat, err sdk.Error)
- func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk.AccAddress) sdk.Delegation
- func (k Keeper) GetAllDelegations(ctx sdk.Context) (delegations []types.Delegation)
- func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []types.Validator)
- func (k Keeper) GetCliffValidator(ctx sdk.Context) []byte
- func (k Keeper) GetCliffValidatorPower(ctx sdk.Context) []byte
- func (k Keeper) GetDelegation(ctx sdk.Context, delegatorAddr, validatorAddr sdk.AccAddress) (delegation types.Delegation, found bool)
- func (k Keeper) GetDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve int16) (delegations []types.Delegation)
- func (k Keeper) GetIntraTxCounter(ctx sdk.Context) int16
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetPool(ctx sdk.Context) (pool types.Pool)
- func (k Keeper) GetRedelegation(ctx sdk.Context, ...) (red types.Redelegation, found bool)
- func (k Keeper) GetRedelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (reds []types.Redelegation)
- func (k Keeper) GetTendermintUpdates(ctx sdk.Context) (updates []abci.Validator)
- func (k Keeper) GetUnbondingDelegation(ctx sdk.Context, DelegatorAddr, ValidatorAddr sdk.AccAddress) (ubd types.UnbondingDelegation, found bool)
- func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (ubds []types.UnbondingDelegation)
- func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.AccAddress) (validator types.Validator, found bool)
- func (k Keeper) GetValidatorByPubKey(ctx sdk.Context, pubkey crypto.PubKey) (validator types.Validator, found bool)
- func (k Keeper) GetValidatorSet() sdk.ValidatorSet
- func (k Keeper) GetValidators(ctx sdk.Context, maxRetrieve int16) (validators []types.Validator)
- func (k Keeper) GetValidatorsBonded(ctx sdk.Context) (validators []types.Validator)
- func (k Keeper) GetValidatorsByPower(ctx sdk.Context) []types.Validator
- func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, DelegatorAddr, ValidatorDstAddr sdk.AccAddress) bool
- func (k Keeper) InitIntraTxCounter(ctx sdk.Context)
- func (k Keeper) IterateDelegations(ctx sdk.Context, delAddr sdk.AccAddress, ...)
- func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, ...)
- func (k Keeper) IterateValidators(ctx sdk.Context, fn func(index int64, validator sdk.Validator) (stop bool))
- func (k Keeper) IterateValidatorsBonded(ctx sdk.Context, fn func(index int64, validator sdk.Validator) (stop bool))
- func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation)
- func (k Keeper) RemoveRedelegation(ctx sdk.Context, red types.Redelegation)
- func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation)
- func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.AccAddress)
- func (k Keeper) Revoke(ctx sdk.Context, pubkey crypto.PubKey)
- func (k Keeper) SetDelegation(ctx sdk.Context, delegation types.Delegation)
- func (k Keeper) SetIntraTxCounter(ctx sdk.Context, counter int16)
- func (k Keeper) SetNewParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetPool(ctx sdk.Context, pool types.Pool)
- func (k Keeper) SetRedelegation(ctx sdk.Context, red types.Redelegation)
- func (k Keeper) SetUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation)
- func (k Keeper) SetValidator(ctx sdk.Context, validator types.Validator)
- func (k Keeper) SetValidatorBondedIndex(ctx sdk.Context, validator types.Validator)
- func (k Keeper) SetValidatorByPowerIndex(ctx sdk.Context, validator types.Validator, pool types.Pool)
- func (k Keeper) SetValidatorByPubKeyIndex(ctx sdk.Context, validator types.Validator)
- func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight int64, power int64, ...)
- func (k Keeper) TotalPower(ctx sdk.Context) sdk.Rat
- func (k Keeper) Unrevoke(ctx sdk.Context, pubkey crypto.PubKey)
- func (k Keeper) UpdateBondedValidators(ctx sdk.Context, affectedValidator types.Validator) (updatedVal types.Validator, updated bool)
- func (k Keeper) UpdateBondedValidatorsFull(ctx sdk.Context)
- func (k Keeper) UpdateValidator(ctx sdk.Context, validator types.Validator) types.Validator
- func (k Keeper) Validator(ctx sdk.Context, address sdk.AccAddress) sdk.Validator
- func (k Keeper) ValidatorByPubKey(ctx sdk.Context, pubkey crypto.PubKey) sdk.Validator
Constants ¶
This section is empty.
Variables ¶
var ( // Keys for store prefixes ParamKey = []byte{0x00} // key for parameters relating to staking PoolKey = []byte{0x01} // key for the staking pools ValidatorsKey = []byte{0x02} // prefix for each key to a validator ValidatorsByPubKeyIndexKey = []byte{0x03} // prefix for each key to a validator index, by pubkey ValidatorsBondedIndexKey = []byte{0x04} // prefix for each key to a validator index, for bonded validators ValidatorsByPowerIndexKey = []byte{0x05} // prefix for each key to a validator index, sorted by power ValidatorCliffIndexKey = []byte{0x06} // key for the validator index of the cliff validator ValidatorPowerCliffKey = []byte{0x07} // key for the power of the validator on the cliff TendermintUpdatesKey = []byte{0x08} // prefix for each key to a validator which is being updated IntraTxCounterKey = []byte{0x09} // key for intra-block tx index DelegationKey = []byte{0x0A} // key for a delegation UnbondingDelegationKey = []byte{0x0B} // key for an unbonding-delegation UnbondingDelegationByValIndexKey = []byte{0x0C} // prefix for each key for an unbonding-delegation, by validator owner RedelegationKey = []byte{0x0D} // key for a redelegation RedelegationByValSrcIndexKey = []byte{0x0E} // prefix for each key for an redelegation, by source validator owner RedelegationByValDstIndexKey = []byte{0x0F} // prefix for each key for an redelegation, by destination validator owner )
nolint
var ( Addrs = createTestAddrs(500) PKs = createTestPubKeys(500) )
dummy addresses used for testing
Functions ¶
func GetAddressFromValBondedIndexKey ¶
Get the validator owner address from ValBondedIndexKey
func GetDelegationKey ¶
func GetDelegationKey(delegatorAddr, validatorAddr sdk.AccAddress) []byte
gets the key for delegator bond with validator VALUE: stake/types.Delegation
func GetDelegationsKey ¶
func GetDelegationsKey(delegatorAddr sdk.AccAddress) []byte
gets the prefix for a delegator for all validators
func GetREDByValDstIndexKey ¶
func GetREDByValDstIndexKey(delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) []byte
gets the index-key for a redelegation, stored by destination-validator-index VALUE: none (key rearrangement used)
func GetREDByValSrcIndexKey ¶
func GetREDByValSrcIndexKey(delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) []byte
gets the index-key for a redelegation, stored by source-validator-index VALUE: none (key rearrangement used)
func GetREDKey ¶
func GetREDKey(delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) []byte
gets the key for a redelegation VALUE: stake/types.RedelegationKey
func GetREDKeyFromValDstIndexKey ¶
rearranges the ValDstIndexKey to get the REDKey
func GetREDKeyFromValSrcIndexKey ¶
rearranges the ValSrcIndexKey to get the REDKey
func GetREDsByDelToValDstIndexKey ¶
func GetREDsByDelToValDstIndexKey(delegatorAddr, validatorDstAddr sdk.AccAddress) []byte
gets the prefix keyspace for all redelegations redelegating towards a destination validator from a particular delegator
func GetREDsFromValSrcIndexKey ¶
func GetREDsFromValSrcIndexKey(validatorSrcAddr sdk.AccAddress) []byte
gets the prefix keyspace for all redelegations redelegating away from a source validator
func GetREDsKey ¶
func GetREDsKey(delegatorAddr sdk.AccAddress) []byte
gets the prefix keyspace for redelegations from a delegator
func GetREDsToValDstIndexKey ¶
func GetREDsToValDstIndexKey(validatorDstAddr sdk.AccAddress) []byte
gets the prefix keyspace for all redelegations redelegating towards a destination validator
func GetTendermintUpdatesKey ¶
func GetTendermintUpdatesKey(ownerAddr sdk.AccAddress) []byte
get the key for the accumulated update validators VALUE: abci.Validator note records using these keys should never persist between blocks
func GetUBDByValIndexKey ¶
func GetUBDByValIndexKey(delegatorAddr, validatorAddr sdk.AccAddress) []byte
gets the index-key for an unbonding delegation, stored by validator-index VALUE: none (key rearrangement used)
func GetUBDKey ¶
func GetUBDKey(delegatorAddr, validatorAddr sdk.AccAddress) []byte
gets the key for an unbonding delegation by delegator and validator addr VALUE: stake/types.UnbondingDelegation
func GetUBDKeyFromValIndexKey ¶
rearranges the ValIndexKey to get the UBDKey
func GetUBDsByValIndexKey ¶
func GetUBDsByValIndexKey(validatorAddr sdk.AccAddress) []byte
gets the prefix keyspace for the indexes of unbonding delegations for a validator
func GetUBDsKey ¶
func GetUBDsKey(delegatorAddr sdk.AccAddress) []byte
gets the prefix for all unbonding delegations from a delegator
func GetValidatorByPubKeyIndexKey ¶
gets the key for the validator with pubkey VALUE: validator owner address ([]byte)
func GetValidatorKey ¶
func GetValidatorKey(ownerAddr sdk.AccAddress) []byte
gets the key for the validator with address VALUE: stake/types.Validator
func GetValidatorsBondedIndexKey ¶
func GetValidatorsBondedIndexKey(ownerAddr sdk.AccAddress) []byte
gets the key for the current validator group VALUE: none (key rearrangement with GetValKeyFromValBondedIndexKey)
func GetValidatorsByPowerIndexKey ¶
get the validator by power index. Power index is the key used in the power-store, and represents the relative power ranking of the validator. VALUE: validator owner address ([]byte)
func TestAddr ¶
func TestAddr(addr string, bech string) sdk.AccAddress
for incode address generation
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
keeper of the stake store
func CreateTestInput ¶
func CreateTestInput(t *testing.T, isCheckTx bool, initCoins int64) (sdk.Context, auth.AccountMapper, Keeper)
hogpodge of all sorts of input required for testing
func (Keeper) BeginRedelegation ¶
func (k Keeper) BeginRedelegation(ctx sdk.Context, delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress, sharesAmount sdk.Rat) sdk.Error
complete unbonding an unbonding record
func (Keeper) BeginUnbonding ¶
func (k Keeper) BeginUnbonding(ctx sdk.Context, delegatorAddr, validatorAddr sdk.AccAddress, sharesAmount sdk.Rat) sdk.Error
complete unbonding an unbonding record
func (Keeper) ClearTendermintUpdates ¶
remove all validator update entries after applied to Tendermint
func (Keeper) CompleteRedelegation ¶
func (k Keeper) CompleteRedelegation(ctx sdk.Context, delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.AccAddress) sdk.Error
complete unbonding an ongoing redelegation
func (Keeper) CompleteUnbonding ¶
func (k Keeper) CompleteUnbonding(ctx sdk.Context, delegatorAddr, validatorAddr sdk.AccAddress) sdk.Error
complete unbonding an unbonding record
func (Keeper) Delegate ¶
func (k Keeper) Delegate(ctx sdk.Context, delegatorAddr sdk.AccAddress, bondAmt sdk.Coin, validator types.Validator, subtractAccount bool) (newShares sdk.Rat, err sdk.Error)
Perform a delegation, set/update everything necessary within the store.
func (Keeper) Delegation ¶
func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk.AccAddress) sdk.Delegation
get the delegation for a particular set of delegator and validator addresses
func (Keeper) GetAllDelegations ¶
func (k Keeper) GetAllDelegations(ctx sdk.Context) (delegations []types.Delegation)
load all delegations used during genesis dump
func (Keeper) GetAllValidators ¶
Get the set of all validators with no limits, used during genesis dump
func (Keeper) GetCliffValidator ¶
get the current validator on the cliff
func (Keeper) GetCliffValidatorPower ¶
get the current power of the validator on the cliff
func (Keeper) GetDelegation ¶
func (k Keeper) GetDelegation(ctx sdk.Context, delegatorAddr, validatorAddr sdk.AccAddress) (delegation types.Delegation, found bool)
load a delegation
func (Keeper) GetDelegations ¶
func (k Keeper) GetDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve int16) (delegations []types.Delegation)
load all delegations for a delegator
func (Keeper) GetIntraTxCounter ¶
get the current in-block validator operation counter
func (Keeper) GetRedelegation ¶
func (k Keeper) GetRedelegation(ctx sdk.Context, DelegatorAddr, ValidatorSrcAddr, ValidatorDstAddr sdk.AccAddress) (red types.Redelegation, found bool)
load a redelegation
func (Keeper) GetRedelegationsFromValidator ¶
func (k Keeper) GetRedelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (reds []types.Redelegation)
load all redelegations from a particular validator
func (Keeper) GetTendermintUpdates ¶
get the most recently updated validators
func (Keeper) GetUnbondingDelegation ¶
func (k Keeper) GetUnbondingDelegation(ctx sdk.Context, DelegatorAddr, ValidatorAddr sdk.AccAddress) (ubd types.UnbondingDelegation, found bool)
load a unbonding delegation
func (Keeper) GetUnbondingDelegationsFromValidator ¶
func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (ubds []types.UnbondingDelegation)
load all unbonding delegations from a particular validator
func (Keeper) GetValidator ¶
func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.AccAddress) (validator types.Validator, found bool)
get a single validator
func (Keeper) GetValidatorByPubKey ¶
func (k Keeper) GetValidatorByPubKey(ctx sdk.Context, pubkey crypto.PubKey) (validator types.Validator, found bool)
get a single validator by pubkey
func (Keeper) GetValidatorSet ¶
func (k Keeper) GetValidatorSet() sdk.ValidatorSet
Returns self as it is both a validatorset and delegationset
func (Keeper) GetValidators ¶
Get the set of all validators, retrieve a maxRetrieve number of records
func (Keeper) GetValidatorsBonded ¶
get the group of the bonded validators
func (Keeper) GetValidatorsByPower ¶
get the group of bonded validators sorted by power-rank
TODO: Rename to GetBondedValidatorsByPower or GetValidatorsByPower(ctx, status)
func (Keeper) HasReceivingRedelegation ¶
func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, DelegatorAddr, ValidatorDstAddr sdk.AccAddress) bool
has a redelegation
func (Keeper) InitIntraTxCounter ¶
get the current in-block validator operation counter
func (Keeper) IterateDelegations ¶
func (k Keeper) IterateDelegations(ctx sdk.Context, delAddr sdk.AccAddress, fn func(index int64, delegation sdk.Delegation) (stop bool))
iterate through the active validator set and perform the provided function
func (Keeper) IterateUnbondingDelegations ¶ added in v0.24.0
func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64, ubd types.UnbondingDelegation) (stop bool))
iterate through all of the unbonding delegations
func (Keeper) IterateValidators ¶
func (k Keeper) IterateValidators(ctx sdk.Context, fn func(index int64, validator sdk.Validator) (stop bool))
iterate through the active validator set and perform the provided function
func (Keeper) IterateValidatorsBonded ¶
func (k Keeper) IterateValidatorsBonded(ctx sdk.Context, fn func(index int64, validator sdk.Validator) (stop bool))
iterate through the active validator set and perform the provided function
func (Keeper) RemoveDelegation ¶
func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation)
remove the delegation
func (Keeper) RemoveRedelegation ¶
func (k Keeper) RemoveRedelegation(ctx sdk.Context, red types.Redelegation)
remove a redelegation object and associated index
func (Keeper) RemoveUnbondingDelegation ¶
func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation)
remove the unbonding delegation object and associated index
func (Keeper) RemoveValidator ¶
func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.AccAddress)
remove the validator record and associated indexes
func (Keeper) SetDelegation ¶
func (k Keeper) SetDelegation(ctx sdk.Context, delegation types.Delegation)
set the delegation
func (Keeper) SetIntraTxCounter ¶
set the current in-block validator operation counter
func (Keeper) SetNewParams ¶
Need a distinct function because setParams depends on an existing previous record of params to exist (to check if maxValidators has changed) - and we panic on retrieval if it doesn't exist - hence if we use setParams for the very first params set it will panic.
func (Keeper) SetRedelegation ¶
func (k Keeper) SetRedelegation(ctx sdk.Context, red types.Redelegation)
set a redelegation and associated index
func (Keeper) SetUnbondingDelegation ¶
func (k Keeper) SetUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation)
set the unbonding delegation and associated index
func (Keeper) SetValidator ¶
set the main record holding validator details
func (Keeper) SetValidatorBondedIndex ¶
validator index
func (Keeper) SetValidatorByPowerIndex ¶
func (k Keeper) SetValidatorByPowerIndex(ctx sdk.Context, validator types.Validator, pool types.Pool)
validator index
func (Keeper) SetValidatorByPubKeyIndex ¶
validator index
func (Keeper) Slash ¶
func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight int64, power int64, slashFactor sdk.Rat)
Slash a validator for an infraction committed at a known height Find the contributing stake at that height and burn the specified slashFactor of it, updating unbonding delegation & redelegations appropriately
CONTRACT:
slashFactor is non-negative
CONTRACT:
Infraction committed equal to or less than an unbonding period in the past, so all unbonding delegations and redelegations from that height are stored
CONTRACT:
Infraction committed at the current height or at a past height, not at a height in the future
func (Keeper) TotalPower ¶
total power from the bond
func (Keeper) UpdateBondedValidators ¶
func (k Keeper) UpdateBondedValidators( ctx sdk.Context, affectedValidator types.Validator) ( updatedVal types.Validator, updated bool)
Update the bonded validator group based on a change to the validator affectedValidator. This function potentially adds the affectedValidator to the bonded validator group which kicks out the cliff validator. Under this situation this function returns the updated affectedValidator.
The correct bonded subset of validators is retrieved by iterating through an index of the validators sorted by power, stored using the ValidatorsByPowerIndexKey. Simultaneously the current validator records are updated in store with the ValidatorsBondedIndexKey. This store is used to determine if a validator is a validator without needing to iterate over all validators.
nolint: gocyclo TODO: Remove the above golint
func (Keeper) UpdateBondedValidatorsFull ¶
full update of the bonded validator set, many can be added/kicked
func (Keeper) UpdateValidator ¶
Perform all the necessary steps for when a validator changes its power. This function updates all validator stores as well as tendermint update store. It may kick out validators if a new validator is entering the bonded validator group.
nolint: gocyclo TODO: Remove above nolint, function needs to be simplified!