# Staking
WARNING
Paloma's staking module inherits from the Cosmos SDK's staking (opens new window) module. This document is a stub and covers mainly important Paloma-specific notes about how it is used.
The staking module enables Paloma's proof-of-stake functionality by requiring validators to bond GRAIN, the native staking asset.
# Message types
# MsgDelegate
type MsgDelegate struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
	Amount           sdk.Coin       `json:"amount" yaml:"amount"`
}
# MsgUndelegate
type MsgUndelegate struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
	Amount           sdk.Coin       `json:"amount" yaml:"amount"`
}
# MsgBeginRedelegate
type MsgBeginRedelegate struct {
	DelegatorAddress    sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
	ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"`
	ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"`
	Amount              sdk.Coin       `json:"amount" yaml:"amount"`
}
# MsgEditValidator
type MsgEditValidator struct {
	Description      Description    `json:"description" yaml:"description"`
	ValidatorAddress sdk.ValAddress `json:"address" yaml:"address"`
	CommissionRate    *sdk.Dec `json:"commission_rate" yaml:"commission_rate"`
	MinSelfDelegation *sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"`
}
# MsgCreateValidator
type MsgCreateValidator struct {
	Description       Description     `json:"description" yaml:"description"`
	Commission        CommissionRates `json:"commission" yaml:"commission"`
	MinSelfDelegation sdk.Int         `json:"min_self_delegation" yaml:"min_self_delegation"`
	DelegatorAddress  sdk.AccAddress  `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress  sdk.ValAddress  `json:"validator_address" yaml:"validator_address"`
	PubKey            crypto.PubKey   `json:"pubkey" yaml:"pubkey"`
	Value             sdk.Coin        `json:"value" yaml:"value"`
}
# Transitions
# End-Block
This section was taken from the official Cosmos SDK docs, and placed here for your convenience to understand the Staking module's parameters.
Each abci end block call, the operations to update queues and validator set changes are specified to execute.
# Validator set changes
The staking validator set is updated during this process by state transitions that run at the end of every block. As a part of this process, any updated validators are also returned back to Tendermint for inclusion in the Tendermint validator set, which is responsible for validating Tendermint messages at the consensus layer. The following operations are done:
- The new validator set is taken as the top params.MaxValidatorsnumber of validators retrieved from the ValidatorsByPower index.
- The previous validator set is compared with the new validator set:
- Missing validators begin unbonding, and their Tokensare transferred from theBondedPoolto theNotBondedPoolModuleAccount.
- New validators are instantly bonded, and their Tokensare transferred from theNotBondedPoolto theBondedPoolModuleAccount.
 
- Missing validators begin unbonding, and their 
In all cases, any validators leaving or entering the bonded validator set or changing balances and staying within the bonded validator set incur an update message that is passed back to Tendermint.
# Queues
Within staking, certain state transitions are not instantaneous but happen over a duration of time, typically the unbonding period. When these transitions are mature, certain operations must take place to complete the state operation. It is achieved through the use of queues that are checked and processed at the end of each block.
# Unbonding validators
When a validator is kicked out of the bonded validator set, because either they are jailed or they don't have sufficient bonded tokens, it begins the unbonding process along with all its delegations begin unbonding, while still being delegated to this validator. At this point, the validator is said to be an unbonding validator, whereby it matures to become an unbonded validator after the unbonding period has passed.
Each block the validator queue is to be checked for mature unbonding validators, namely with a completion time <= current time. At this point, any mature validators that do not have any remaining delegations are deleted from state. For all other mature unbonding validators that still have remaining
delegations, the validator.Status is switched from sdk.Unbonding to
sdk.Unbonded.
# Unbonding delegations
Complete the unbonding of all mature UnbondingDelegations.Entries within the
UnbondingDelegations queue with the following procedure:
- Transfer the balance coins to the delegator's wallet address.
- Remove the mature entry from UnbondingDelegation.Entries.
- Remove the UnbondingDelegationobject from the store, if there are no remaining entries.
# Redelegations
Complete the unbonding of all mature Redelegation.Entries within the
Redelegations queue with the following procedure:
- Remove the mature entry from Redelegation.Entries.
- Remove the Redelegationobject from the store, if there are no remaining entries.
# Parameters
The subspace for the Staking module is staking.
type Params struct {
	UnbondingTime time.Duration `json:"unbonding_time" yaml:"unbonding_time"`
	MaxValidators uint16        `json:"max_validators" yaml:"max_validators"`
	MaxEntries    uint16        `json:"max_entries" yaml:"max_entries"`
	BondDenom string `json:"bond_denom" yaml:"bond_denom"`
}
The genesis parameters for the staking module outlined in the Genesis Builder Script (opens new window) are as follows:
    # Staking: change bond_denom to ugrain and max validators to 130
    genesis['app_state']['staking']['params'] = {
        'unbonding_time': '1814400s',  # 21 days
        'max_validators': 130,
        'max_entries': 7,
        'historical_entries': 10000,
        'bond_denom': DENOM_GRAIN
# unbonding_time
 - type: time.Duration
- default: 3 weeks
Time duration of unbonding in seconds.
# max_validators
 - type: uint16
- default: 130
Maximum number of active validators.
# max_entries
 - type: uint16
- default: 7
Maximum entries for either unbonding delegation or redelegation per pair or trio. Be aware of potential overflow because this is user-determined.
# bond_denom
 - type: string
- default: ugrain
Denomination of the asset required for staking.