Documentation ¶
Index ¶
- Variables
- func AddStakeClaim(ctx *abciAPI.Context, addr staking.Address, claim staking.StakeClaim, ...) error
- func AuthenticateAndPayFees(ctx *abciAPI.Context, signer signature.PublicKey, nonce uint64, ...) error
- func BlockFees(ctx *abciAPI.Context) quantity.Quantity
- func BlockProposer(ctx *abciAPI.Context) *signature.PublicKey
- func CheckStakeClaims(ctx *abciAPI.Context, addr staking.Address) error
- func RemoveStakeClaim(ctx *abciAPI.Context, addr staking.Address, claim staking.StakeClaim) error
- func SetBlockProposer(ctx *abciAPI.Context, p *signature.PublicKey)
- type DebondingQueueEntry
- type EpochSigning
- type ImmutableState
- func (s *ImmutableState) Account(ctx context.Context, address staking.Address) (*staking.Account, error)
- func (s *ImmutableState) Addresses(ctx context.Context) ([]staking.Address, error)
- func (s *ImmutableState) CommissionScheduleAddresses(ctx context.Context) ([]staking.Address, error)
- func (s *ImmutableState) CommissionScheduleRules(ctx context.Context) (*staking.CommissionScheduleRules, error)
- func (s *ImmutableState) CommonPool(ctx context.Context) (*quantity.Quantity, error)
- func (s *ImmutableState) ConsensusParameters(ctx context.Context) (*staking.ConsensusParameters, error)
- func (s *ImmutableState) DebondingDelegation(ctx context.Context, delegatorAddr, escrowAddr staking.Address, ...) (*staking.DebondingDelegation, error)
- func (s *ImmutableState) DebondingDelegations(ctx context.Context) (map[staking.Address]map[staking.Address][]*staking.DebondingDelegation, error)
- func (s *ImmutableState) DebondingDelegationsFor(ctx context.Context, delegatorAddr staking.Address) (map[staking.Address][]*staking.DebondingDelegation, error)
- func (s *ImmutableState) DebondingDelegationsTo(ctx context.Context, destAddr staking.Address) (map[staking.Address][]*staking.DebondingDelegation, error)
- func (s *ImmutableState) DebondingInterval(ctx context.Context) (beacon.EpochTime, error)
- func (s *ImmutableState) Delegation(ctx context.Context, delegatorAddr, escrowAddr staking.Address) (*staking.Delegation, error)
- func (s *ImmutableState) Delegations(ctx context.Context) (map[staking.Address]map[staking.Address]*staking.Delegation, error)
- func (s *ImmutableState) DelegationsFor(ctx context.Context, delegatorAddr staking.Address) (map[staking.Address]*staking.Delegation, error)
- func (s *ImmutableState) DelegationsTo(ctx context.Context, destAddr staking.Address) (map[staking.Address]*staking.Delegation, error)
- func (s *ImmutableState) EpochSigning(ctx context.Context) (*EpochSigning, error)
- func (s *ImmutableState) EscrowBalance(ctx context.Context, address staking.Address) (*quantity.Quantity, error)
- func (s *ImmutableState) ExpiredDebondingQueue(ctx context.Context, epoch beacon.EpochTime) ([]*DebondingQueueEntry, error)
- func (s *ImmutableState) GovernanceDeposits(ctx context.Context) (*quantity.Quantity, error)
- func (s *ImmutableState) LastBlockFees(ctx context.Context) (*quantity.Quantity, error)
- func (s *ImmutableState) RewardSchedule(ctx context.Context) ([]staking.RewardStep, error)
- func (s *ImmutableState) Slashing(ctx context.Context) (map[staking.SlashReason]staking.Slash, error)
- func (s *ImmutableState) Thresholds(ctx context.Context) (map[staking.ThresholdKind]quantity.Quantity, error)
- func (s *ImmutableState) TotalSupply(ctx context.Context) (*quantity.Quantity, error)
- type MutableState
- func (s *MutableState) AddRewardSingleAttenuated(ctx *abciAPI.Context, time beacon.EpochTime, factor *quantity.Quantity, ...) error
- func (s *MutableState) AddRewards(ctx *abciAPI.Context, time beacon.EpochTime, factor *quantity.Quantity, ...) error
- func (s *MutableState) ClearEpochSigning(ctx context.Context) error
- func (s *MutableState) DiscardGovernanceDeposit(ctx *abciAPI.Context, amount *quantity.Quantity) error
- func (s *MutableState) RemoveFromDebondingQueue(ctx context.Context, epoch beacon.EpochTime, ...) error
- func (s *MutableState) SetAccount(ctx context.Context, addr staking.Address, account *staking.Account) error
- func (s *MutableState) SetAccountHook(ctx context.Context, addr staking.Address, kind staking.HookKind, ...) error
- func (s *MutableState) SetCommonPool(ctx context.Context, q *quantity.Quantity) error
- func (s *MutableState) SetConsensusParameters(ctx context.Context, params *staking.ConsensusParameters) error
- func (s *MutableState) SetDebondingDelegation(ctx context.Context, delegatorAddr, escrowAddr staking.Address, ...) error
- func (s *MutableState) SetDelegation(ctx context.Context, delegatorAddr, escrowAddr staking.Address, ...) error
- func (s *MutableState) SetEpochSigning(ctx context.Context, es *EpochSigning) error
- func (s *MutableState) SetGovernanceDeposits(ctx context.Context, q *quantity.Quantity) error
- func (s *MutableState) SetLastBlockFees(ctx context.Context, q *quantity.Quantity) error
- func (s *MutableState) SetTotalSupply(ctx context.Context, q *quantity.Quantity) error
- func (s *MutableState) SlashEscrow(ctx *abciAPI.Context, fromAddr staking.Address, amount *quantity.Quantity) (*quantity.Quantity, error)
- func (s *MutableState) Transfer(ctx *abciAPI.Context, fromAddr, toAddr staking.Address, ...) error
- func (s *MutableState) TransferFromCommon(ctx *abciAPI.Context, toAddr staking.Address, amount *quantity.Quantity, ...) (bool, error)
- func (s *MutableState) TransferFromGovernanceDeposits(ctx *abciAPI.Context, toAddr staking.Address, amount *quantity.Quantity) error
- func (s *MutableState) TransferToGovernanceDeposits(ctx *abciAPI.Context, fromAddr staking.Address, amount *quantity.Quantity) error
- type StakeAccumulatorCache
- func (c *StakeAccumulatorCache) AddStakeClaim(addr staking.Address, claim staking.StakeClaim, ...) error
- func (c *StakeAccumulatorCache) CheckStakeClaims(addr staking.Address) error
- func (c *StakeAccumulatorCache) Commit() error
- func (c *StakeAccumulatorCache) Discard()
- func (c *StakeAccumulatorCache) GetEscrowBalance(addr staking.Address) (*quantity.Quantity, error)
- func (c *StakeAccumulatorCache) RemoveStakeClaim(addr staking.Address, claim staking.StakeClaim) error
Constants ¶
This section is empty.
Variables ¶
var (
// AppName is the ABCI application name.
AppName = "100_staking"
)
Functions ¶
func AddStakeClaim ¶
func AddStakeClaim( ctx *abciAPI.Context, addr staking.Address, claim staking.StakeClaim, thresholds []staking.StakeThreshold, ) error
AddStakeClaim is a convenience function for adding a single stake claim to an entity.
In case there is no errors, the added claim is automatically committed. The caller must ensure that this does not overwrite any outstanding account updates.
func AuthenticateAndPayFees ¶
func AuthenticateAndPayFees( ctx *abciAPI.Context, signer signature.PublicKey, nonce uint64, fee *transaction.Fee, ) error
AuthenticateAndPayFees authenticates the message signer and makes sure that any gas fees are paid.
This method transfers the fees to the per-block fee accumulator which is persisted at the end of the block.
func CheckStakeClaims ¶
CheckStakeClaims is a convenience function for checking a single entity's stake claims.
func RemoveStakeClaim ¶
RemoveStakeClaim is a convenience function for removing a single stake claim from an entity.
In case there is no errors, the removed claim is automatically committed. The caller must ensure that this does not overwrite any outstanding account updates.
Types ¶
type DebondingQueueEntry ¶
type EpochSigning ¶
func (*EpochSigning) EligibleEntities ¶
func (es *EpochSigning) EligibleEntities(thresholdNumerator, thresholdDenominator uint64) ([]signature.PublicKey, error)
type ImmutableState ¶
type ImmutableState struct {
// contains filtered or unexported fields
}
ImmutableState is the immutable staking state wrapper.
func NewImmutableState ¶
func NewImmutableState(ctx context.Context, state abciAPI.ApplicationQueryState, version int64) (*ImmutableState, error)
func (*ImmutableState) Account ¶
func (s *ImmutableState) Account(ctx context.Context, address staking.Address) (*staking.Account, error)
Account returns the staking account for the given account address.
func (*ImmutableState) Addresses ¶
Addresses returns the non-empty addresses from the staking ledger.
func (*ImmutableState) CommissionScheduleAddresses ¶
func (s *ImmutableState) CommissionScheduleAddresses(ctx context.Context) ([]staking.Address, error)
CommissionScheduleAddresses returns addresses that have a non empty commission schedule configured.
func (*ImmutableState) CommissionScheduleRules ¶
func (s *ImmutableState) CommissionScheduleRules(ctx context.Context) (*staking.CommissionScheduleRules, error)
func (*ImmutableState) CommonPool ¶
CommonPool returns the balance of the global common pool.
func (*ImmutableState) ConsensusParameters ¶
func (s *ImmutableState) ConsensusParameters(ctx context.Context) (*staking.ConsensusParameters, error)
ConsensusParameters returns the consensus parameters.
func (*ImmutableState) DebondingDelegation ¶
func (s *ImmutableState) DebondingDelegation( ctx context.Context, delegatorAddr, escrowAddr staking.Address, epoch beacon.EpochTime, ) (*staking.DebondingDelegation, error)
func (*ImmutableState) DebondingDelegations ¶
func (s *ImmutableState) DebondingDelegations( ctx context.Context, ) (map[staking.Address]map[staking.Address][]*staking.DebondingDelegation, error)
func (*ImmutableState) DebondingDelegationsFor ¶
func (s *ImmutableState) DebondingDelegationsFor( ctx context.Context, delegatorAddr staking.Address, ) (map[staking.Address][]*staking.DebondingDelegation, error)
func (*ImmutableState) DebondingDelegationsTo ¶
func (s *ImmutableState) DebondingDelegationsTo( ctx context.Context, destAddr staking.Address, ) (map[staking.Address][]*staking.DebondingDelegation, error)
func (*ImmutableState) DebondingInterval ¶
func (*ImmutableState) Delegation ¶
func (s *ImmutableState) Delegation( ctx context.Context, delegatorAddr, escrowAddr staking.Address, ) (*staking.Delegation, error)
Delegation returns the delegation descriptor.
func (*ImmutableState) Delegations ¶
func (s *ImmutableState) Delegations( ctx context.Context, ) (map[staking.Address]map[staking.Address]*staking.Delegation, error)
Delegations returns all active delegations.
func (*ImmutableState) DelegationsFor ¶
func (s *ImmutableState) DelegationsFor( ctx context.Context, delegatorAddr staking.Address, ) (map[staking.Address]*staking.Delegation, error)
func (*ImmutableState) DelegationsTo ¶
func (s *ImmutableState) DelegationsTo( ctx context.Context, destAddr staking.Address, ) (map[staking.Address]*staking.Delegation, error)
func (*ImmutableState) EpochSigning ¶
func (s *ImmutableState) EpochSigning(ctx context.Context) (*EpochSigning, error)
func (*ImmutableState) EscrowBalance ¶
func (s *ImmutableState) EscrowBalance(ctx context.Context, address staking.Address) (*quantity.Quantity, error)
EscrowBalance returns the escrow balance for the given account address.
func (*ImmutableState) ExpiredDebondingQueue ¶
func (s *ImmutableState) ExpiredDebondingQueue(ctx context.Context, epoch beacon.EpochTime) ([]*DebondingQueueEntry, error)
func (*ImmutableState) GovernanceDeposits ¶
GovernanceDeposits returns the governance deposits balance.
func (*ImmutableState) LastBlockFees ¶
LastBlockFees returns the last block fees balance.
func (*ImmutableState) RewardSchedule ¶
func (s *ImmutableState) RewardSchedule(ctx context.Context) ([]staking.RewardStep, error)
func (*ImmutableState) Slashing ¶
func (s *ImmutableState) Slashing(ctx context.Context) (map[staking.SlashReason]staking.Slash, error)
func (*ImmutableState) Thresholds ¶
func (s *ImmutableState) Thresholds(ctx context.Context) (map[staking.ThresholdKind]quantity.Quantity, error)
Thresholds returns the currently configured thresholds if any.
func (*ImmutableState) TotalSupply ¶
TotalSupply returns the total supply balance.
type MutableState ¶
type MutableState struct { *ImmutableState // contains filtered or unexported fields }
MutableState is a mutable staking state wrapper.
func NewMutableState ¶
func NewMutableState(tree mkvs.KeyValueTree) *MutableState
NewMutableState creates a new mutable staking state wrapper.
func (*MutableState) AddRewardSingleAttenuated ¶
func (s *MutableState) AddRewardSingleAttenuated( ctx *abciAPI.Context, time beacon.EpochTime, factor *quantity.Quantity, attenuationNumerator, attenuationDenominator int, address staking.Address, ) error
AddRewardSingleAttenuated computes, scales, and transfers a staking reward to an active escrow account.
func (*MutableState) AddRewards ¶
func (s *MutableState) AddRewards( ctx *abciAPI.Context, time beacon.EpochTime, factor *quantity.Quantity, addresses []staking.Address, ) error
AddRewards computes and transfers a staking reward to active escrow accounts. If the common pool runs out, the rewards that are too big to be paid out are skipped and no error is returned.
func (*MutableState) ClearEpochSigning ¶
func (s *MutableState) ClearEpochSigning(ctx context.Context) error
func (*MutableState) DiscardGovernanceDeposit ¶
func (s *MutableState) DiscardGovernanceDeposit( ctx *abciAPI.Context, amount *quantity.Quantity, ) error
DiscardGovernanceDeposit discards the amount from the governance deposits pool to the common pool.
func (*MutableState) RemoveFromDebondingQueue ¶
func (*MutableState) SetAccount ¶
func (*MutableState) SetAccountHook ¶ added in v0.2400.0
func (s *MutableState) SetAccountHook(ctx context.Context, addr staking.Address, kind staking.HookKind, dst *staking.HookDestination) error
func (*MutableState) SetCommonPool ¶
func (*MutableState) SetConsensusParameters ¶
func (s *MutableState) SetConsensusParameters(ctx context.Context, params *staking.ConsensusParameters) error
SetConsensusParameters sets staking consensus parameters.
NOTE: This method must only be called from InitChain/EndBlock contexts.
func (*MutableState) SetDebondingDelegation ¶
func (s *MutableState) SetDebondingDelegation( ctx context.Context, delegatorAddr, escrowAddr staking.Address, epoch beacon.EpochTime, d *staking.DebondingDelegation, ) error
func (*MutableState) SetDelegation ¶
func (s *MutableState) SetDelegation( ctx context.Context, delegatorAddr, escrowAddr staking.Address, d *staking.Delegation, ) error
func (*MutableState) SetEpochSigning ¶
func (s *MutableState) SetEpochSigning(ctx context.Context, es *EpochSigning) error
func (*MutableState) SetGovernanceDeposits ¶
func (*MutableState) SetLastBlockFees ¶
func (*MutableState) SetTotalSupply ¶
func (*MutableState) SlashEscrow ¶
func (s *MutableState) SlashEscrow( ctx *abciAPI.Context, fromAddr staking.Address, amount *quantity.Quantity, ) (*quantity.Quantity, error)
SlashEscrow slashes the escrow balance and the escrow-but-undergoing-debonding balance of the account, transferring it to the global common pool, returning the amount actually slashed.
WARNING: This is an internal routine to be used to implement staking policy, and MUST NOT be exposed outside of backend implementations.
func (*MutableState) Transfer ¶
func (s *MutableState) Transfer(ctx *abciAPI.Context, fromAddr, toAddr staking.Address, amount *quantity.Quantity) error
Transfer performs a transfer between two general account balances.
func (*MutableState) TransferFromCommon ¶
func (s *MutableState) TransferFromCommon( ctx *abciAPI.Context, toAddr staking.Address, amount *quantity.Quantity, escrow bool, ) (bool, error)
TransferFromCommon transfers up to the amount from the global common pool to the general balance of the account, returning true iff the amount transferred is > 0.
If the escrow flag is true then the amount is escrowed instead of being transferred. The escrow operation takes the entity's commission rate into account and the rest is distributed to all delegators equally.
WARNING: This is an internal routine to be used to implement incentivization policy, and MUST NOT be exposed outside of backend implementations.
func (*MutableState) TransferFromGovernanceDeposits ¶
func (s *MutableState) TransferFromGovernanceDeposits( ctx *abciAPI.Context, toAddr staking.Address, amount *quantity.Quantity, ) error
TransferFromGovernanceDeposits transfers the amount from the governance deposits pool to the specified address.
func (*MutableState) TransferToGovernanceDeposits ¶
func (s *MutableState) TransferToGovernanceDeposits( ctx *abciAPI.Context, fromAddr staking.Address, amount *quantity.Quantity, ) error
TransferToGovernanceDeposits transfers the amount from the submitter to the governance deposits pool.
type StakeAccumulatorCache ¶
type StakeAccumulatorCache struct {
// contains filtered or unexported fields
}
StakeAccumulatorCache is a thin wrapper around an underlying escrow accounts which caches some values (like the threshold map) between operations.
func NewStakeAccumulatorCache ¶
func NewStakeAccumulatorCache(ctx *abciAPI.Context) (*StakeAccumulatorCache, error)
NewStakeAccumulatorCache creates a new stake accumulator cache.
func (*StakeAccumulatorCache) AddStakeClaim ¶
func (c *StakeAccumulatorCache) AddStakeClaim( addr staking.Address, claim staking.StakeClaim, thresholds []staking.StakeThreshold, ) error
AddStakeClaim attempts to add a stake claim to the given escrow account.
In case there is insufficient stake to cover the claim or an error occurs, no modifications are made to the stake accumulator.
func (*StakeAccumulatorCache) CheckStakeClaims ¶
func (c *StakeAccumulatorCache) CheckStakeClaims(addr staking.Address) error
CheckStakeClaims checks whether the escrow account balance satisfies all the stake claims.
func (*StakeAccumulatorCache) Commit ¶
func (c *StakeAccumulatorCache) Commit() error
Commit commits the stake accumulator changes. The caller must ensure that this does not overwrite any outstanding account updates.
func (*StakeAccumulatorCache) Discard ¶
func (c *StakeAccumulatorCache) Discard()
Discard discards any stake accumulator changes.
func (*StakeAccumulatorCache) GetEscrowBalance ¶
GetEscrowBalance returns a given account's escrow balance.
func (*StakeAccumulatorCache) RemoveStakeClaim ¶
func (c *StakeAccumulatorCache) RemoveStakeClaim( addr staking.Address, claim staking.StakeClaim, ) error
RemoveStakeClaim removes a given stake claim.
It is an error if the stake claim does not exist.