state

package
v0.2403.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 BlockFees

func BlockFees(ctx *abciAPI.Context) quantity.Quantity

BlockFees returns the accumulated fee balance for the current block.

func BlockProposer

func BlockProposer(ctx *abciAPI.Context) *signature.PublicKey

func CheckStakeClaims

func CheckStakeClaims(ctx *abciAPI.Context, addr staking.Address) error

CheckStakeClaims is a convenience function for checking a single entity's stake claims.

func RemoveStakeClaim

func RemoveStakeClaim(ctx *abciAPI.Context, addr staking.Address, claim staking.StakeClaim) error

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.

func SetBlockProposer

func SetBlockProposer(ctx *abciAPI.Context, p *signature.PublicKey)

Types

type DebondingQueueEntry

type DebondingQueueEntry struct {
	Epoch         beacon.EpochTime
	DelegatorAddr staking.Address
	EscrowAddr    staking.Address
	Delegation    *staking.DebondingDelegation
}

type EpochSigning

type EpochSigning struct {
	Total    uint64
	ByEntity map[signature.PublicKey]uint64
}

func (*EpochSigning) EligibleEntities

func (es *EpochSigning) EligibleEntities(thresholdNumerator, thresholdDenominator uint64) ([]signature.PublicKey, error)

func (*EpochSigning) Update

func (es *EpochSigning) Update(signingEntities []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

func (s *ImmutableState) Addresses(ctx context.Context) ([]staking.Address, error)

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

func (s *ImmutableState) CommonPool(ctx context.Context) (*quantity.Quantity, error)

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 (s *ImmutableState) DebondingInterval(ctx context.Context) (beacon.EpochTime, error)

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

func (s *ImmutableState) GovernanceDeposits(ctx context.Context) (*quantity.Quantity, error)

GovernanceDeposits returns the governance deposits balance.

func (*ImmutableState) LastBlockFees

func (s *ImmutableState) LastBlockFees(ctx context.Context) (*quantity.Quantity, error)

LastBlockFees returns the last block fees balance.

func (*ImmutableState) RewardSchedule

func (s *ImmutableState) RewardSchedule(ctx context.Context) ([]staking.RewardStep, error)

func (*ImmutableState) Slashing

func (*ImmutableState) Thresholds

Thresholds returns the currently configured thresholds if any.

func (*ImmutableState) TotalSupply

func (s *ImmutableState) TotalSupply(ctx context.Context) (*quantity.Quantity, error)

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 (s *MutableState) RemoveFromDebondingQueue(
	ctx context.Context,
	epoch beacon.EpochTime,
	delegatorAddr, escrowAddr staking.Address,
) error

func (*MutableState) SetAccount

func (s *MutableState) SetAccount(ctx context.Context, addr staking.Address, account *staking.Account) error

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 (s *MutableState) SetCommonPool(ctx context.Context, q *quantity.Quantity) error

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 (s *MutableState) SetGovernanceDeposits(ctx context.Context, q *quantity.Quantity) error

func (*MutableState) SetLastBlockFees

func (s *MutableState) SetLastBlockFees(ctx context.Context, q *quantity.Quantity) error

func (*MutableState) SetTotalSupply

func (s *MutableState) SetTotalSupply(ctx context.Context, q *quantity.Quantity) error

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

func (c *StakeAccumulatorCache) GetEscrowBalance(addr staking.Address) (*quantity.Quantity, error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL