Module that facilitates consensus layer staking-related logic
x/evmstaking
module of the Story blockchain.
In Story blockchain, the gas token resides on the execution layer (EL) to pay for transactions and interact with smart contracts. However, the consensus layer (CL) manages the consensus staking, slashing, and rewarding. This module exists to facilitate CL-level staking-related logic, such as delegating to validators with custom lock periods.
Queue[types.Withdrawal]
The (stake) withdrawal queue stores the pending unbonded stakes to be burned on CL and minted on EL. Stakes that are unbonded after 14 days of unstaking period are added to the queue to be processed.
Queue[types.Withdrawal]
The reward withdrawal queue stores the pending rewards from stakes to be burned on CL and minted on EL. All rewards above a threshold are eligible to be queued in this queue, but there exists a parameter of maximum additions per block.
max_withdrawal_per_block
is the maximum number of withdrawals (reward and unstakes, each) to process per block. This parameter prevents nodes from processing a large amount of withdrawals at once, which could exceed the max chain timeout.max_sweep_per_block
is the maximum number of validator-delegator delegations to sweep per block. This parameter prevents nodes from processing a large amount of delegations at once.min_partial_withdrawal_amount
is the minimum amount required for rewards to get added to the reward withdrawal queue.ubi_withdrawal_address
is the UBI contract address to which UBI withdrawals should be deposited.Map[string, string]
The delegator-withdraw address mapping tracks the address to which a delegator receives their withdrawn stakes. The (stake) withdrawal queue uses this map to determine the execution_address
in the Withdrawal
struct used in building an EVM block payload.
While the delegator can change the withdraw address at any time, existing stake withdraw requests in the (stake) withdrawal queue will maintain their original values.
Map[string, string]
Map[string, string]
The delegator-operator address mapping tracks the address to which a delegator has given the privilege to delegate (stake), undelegate (unstake), and redelegate on behalf of themselves.
*bindings.IPTokenStaking
IPTokenStaking contract is used to filter and parse staking-related events from EL.
evmstaking
module is in charge of parsing, processing, and inserting withdrawal requests to two queues, while the evmengine
module is in charge of validating and dequeuing withdrawal requests, as well as depositing them to corresponding withdrawal addresses in EL.
EndBlock
ABCI2 call is responsible for fetching the unbonded entries (stakes that have unbonded after 14 days) from the staking module and inserting them into the (stake) withdrawal queue. Furthermore, it processes stake reward withdrawals into the reward withdrawal queue and UBI withdrawals into the (stake) withdrawal queue.
If the network is in the Singularity period, the End Block is skipped as there are no staking rewards and withdrawals available during this period. Otherwise, refer to Withdrawing Delegations and Withdrawing Rewards for detailed withdrawal processes.
creation_height
is the block height at which the withdrawal is created.execution_address
is the EVM address receiving the withdrawn fund, which is burned in CL.amount
is the amount to burn on CL and mint on EL.withdrawal_type
is the type of withdrawal: for unstakes, for reward, and for UBI.validator_address
is the EVM validator address.