-
Notifications
You must be signed in to change notification settings - Fork 31
Slashing Notes
- New
Validatorentry is created and written in store. - New
Delegationentry is added in store. - Tokens are transfered from Delegator account to module account (
BondedPoolmodule account orNotBondedPoolmodule acount). - Delegation amount is added to
Validator.Tokens.
x/staking/keeper/msg_server.go CreateValidator()
x/staking/keeper/delegation.go Delegate()
-
Find/Create
Delegationfrom store, identifier (DelegatorAddr,ValidatorOperator) -
subtractAccount == true
-
k.bankKeeper.DelegateCoinsFromAccountToModule(): Remove tokens from Delegator, add tokens to module account-
Validator.IsBonded: Tokens from Delegator account sent toBondedPoolmodule account -
Validator.IsUnbondedORValidator.IsUnbonding(Validator Not Bonded): Tokens from Delegator account sent toNotBondedPoolmodule account
-
-
k.AddValidatorTokensAndShares(): add tokens and shares onValidatorin store -
Update
Delegationin store
Pretty much the same as the MsgCreateValidator. Except not doing Validator initial setup.
- New
Delegationentry is added in store. - Tokens are transfered from Delegator account to module account (
BondedPoolmodule account orNotBondedPoolmodule acount). - Delegation amount is added to
Validator.Tokens(AKAValidatorOperatoraccount).
- Delete/Update existing
Delegationentry on SrcValidator in store. - Create/Update
Delegationentry on DstValidator in store. - Tokens are still in module accounts, transfer may happen between these module accounts (
BondedPoolmodule account orNotBondedPoolmodule acount). - Redelegation amount is removed from source
Validator.Tokens. - Redelegation amount is added to destination
Validator.Tokens. - Redelegation entry is inserted to
RedelegationQueue.
x/staking/keeper/delegation.go BeginRedelegation()
- Get
Delegationentry from store, identifier (DelegatorAddr,SrcValidatorOperator) - Get
SrcValidatorfrom store. - Delete shares on
Delegationentry. - Delete/Update
Delegationin store. -
k.RemoveValidatorTokensAndShares(): remove tokens and shares onSrcValidator, updateSrcValidatorin store.
-
Find/Create
Delegationfrom store, identifier (DelegatorAddr,DstValidatorOperator) -
subtractAccount == false:
-
SrcValidatorNot Bonded ->DstValidatorBonded: sent tokens fromNotBondedPooltoBondedPoolmodule account -
SrcValidatorBonded ->DstValidatorNot Bonded: sent tokens fromBondedPooltoNotBondedPoolmodule account - Other cases, do nothing
- Undefined case, panic
-
k.AddValidatorTokensAndShares(): add tokens and shares onDstValidatorin store -
Update
Delegationin store
Calculate completion time for RedelegationQueueEntry
-
Validator.IsBonded: Wait for A full unbonding time (longest wait) -
Validator.IsUnbonded: Complete right away -
Validator.IsUnbonding: Wait until validator's unbonding is done
- Add
Redelegationentry toRedelegationQueue.
- Delete/Update existing
Delegationentry on Validator in store. - Tokens are still in module accounts, transfer may happen between these module accounts (
BondedPoolmodule account orNotBondedPoolmodule acount). - Undelegation amount is removed from
Validator.Tokens. - UnbondingDelegation entry is inserted to
UnbondingDelegationQueue.
The tokens are removed from Validator (instantly). But only when it is complete (mature), the tokens will be sent back to delegator.
x/staking/keeper/msg_server.go Undelegate()
-
k.Keeper.Undelegate():x/staking/keeper/delegation.go Undelegate()
- Get
Delegationentry from store, identifier (DelegatorAddr,ValidatorOperator) - Get
Validatorin store. - Delete shares on
Delegationentry. - Delete/Update
DelegationonValidatorin store. -
k.RemoveValidatorTokensAndShares(): remove tokens and shares onValidator, updateValidatorin store.
k.bondedTokensToNotBonded(): sent tokens from BondedPool module account to NotBondedPool module account.
Add UnbondingDelegation entry to UnbondingDelegationQueue.
x/staking/abci.go EndBlocker()
x/staking/keeper/val_state_change.go BlockValidatorUpdates()
Mature UnBonding Entry will trigger transfer of tokens, from NotBondedPool module account to Delegator account.
x/staking/keeper/delegation.go CompleteUnbonding()
k.bankKeeper.UndelegateCoinsFromModuleToAccount()
It is just deleting those entries, not moving funds in any account.
x/staking/keeper/delegation.go CompleteRedelegation()