Epoch Processing
ConsensusPer-subnet periodic processing that runs Yuma Consensus, distributes emissions, and updates metagraph state.
Epoch Processing Pipeline
Epoch Processing
- PendingEpochAt(netuid) is non-zero and current_block ≥ PendingEpochAt
- current_block − LastEpochBlock(netuid) ≥ Tempo(netuid)
- BlocksSinceLastStep(netuid) > Tempo(netuid) (safety net)
Click items to navigate to their reference pages.
The Big Picture
Epoch processing is the bridge between block-by-block emission accumulation and stake landing on hotkeys. When a slot is due, the subnet runs Yuma Consensus on its weight matrix and pays out the four pending buckets: miners by incentive, validators by dividend split into alpha-weighted and root-weighted legs, the owner cut, and the root share. Every payout is a stake increase on the subnet; nothing is paid to free balance. The path emits AutoStakeAdded, EpochDeferred and EpochSkipped, plus SubnetLeaseDividendsDistributed on leased subnets; the dividend and take credits themselves are silent.
Why This Matters
Understanding epochs is key to knowing when you get paid. Emission accumulates every block but only becomes stake at the epoch. The recorded dividend maps are net of the validator take, so an indexer that subtracts take again undercounts nominators.
Example Scenario
A subnet with Tempo=360 (~72 min at 12s blocks) accumulates emissions for 360 blocks. If the subnet earns 0.02 TAO/block, the epoch distributes 7.2 TAO worth of alpha. A miner with 10% incentive receives 0.36 TAO worth of alpha as stake at the epoch, not per block.
Common Questions
- What is Tempo?
- The number of blocks per epoch for a given subnet. Shorter Tempo means more frequent consensus and distribution. The subnet owner can configure it.
- What happens if no validators set weights?
- The epoch still runs. If Yuma produces zero total incentive, distribute_emission adds the whole miner bucket to the validator bucket, so validators receive both halves that epoch. Nothing stays pending on that account.
- Why did my subnet run its epoch a block late, or not at all?
- Late: more than MaxEpochsPerBlock subnets were due in the same block and yours was deferred (EpochDeferred). Not at all: the input state was inconsistent and the slot was consumed without running (EpochSkipped); the pending buckets carry into the next successful epoch.
Use Cases
- Predicting when emissions will be distributed
- Understanding per-epoch earnings
- Debugging stale metagraph data
- Monitoring subnet epoch health
Each subnet has a Tempo parameter defining how many blocks constitute an epoch. When a slot is due, the runtime runs Yuma Consensus on the weight matrix, distributes the pending emission to validators, miners, the owner and root stakers, updates bonds, and refreshes metagraph metadata.
Epoch processing bridges per-block Alpha injection and UID-level reward distribution. Each block, run_coinbase injects TAO into subnet Alpha pools and accumulates alpha into four pending buckets: PendingServerEmission (miners), PendingValidatorEmission, PendingRootAlphaDivs and PendingOwnerCut. From v488 the burn and recycle slots of SubnetEmissionWeights are burned and recycled in the same block and never accumulate; from v490 the gamma shares of SubnetGammaEmission accumulate in a fifth bucket, PendingGammaEmission (coinbase/run_coinbase.rs L300-L368 at d967d1358, runtime v490). At the epoch, drain_pending zeroes the first four and distribute_emission pays them out: the owner cut is staked to the owner hotkey; incentive is staked to each miner (or its AutoStakeDestination), except owner-hotkey incentive which is withheld and recycled or burned; dividends are split per hotkey between the root-weighted and alpha-weighted legs, then between the validator take, staked to the owner coldkey, and the nominator amount written to AlphaDividendsPerSubnet and RootAlphaDividendsPerSubnet. From v490 mint_gamma_emission runs for the subnet right after distribute_emission: it allots PendingGammaEmission to the gamma shares in proportion to their size (UnconvertedGammaEmission) and converts each share in its own storage layer, selling the alpha on the subnet pool, buying and burning the target subnet alpha with all of the TAO, and crediting gamma to the deposit of the subnet owner at the subnet owner hotkey on the target (GammaEmissionMinted). A share that cannot convert keeps its alpha for a later epoch (run_coinbase.rs L549, subnets/gamma.rs L258-L341).
Scheduling has been stateful since v423. A slot is due when PendingEpochAt is reached, or current_block − LastEpochBlock ≥ Tempo, or BlocksSinceLastStep exceeds Tempo. At most MaxEpochsPerBlock subnets run per block; the rest are deferred one block (EpochDeferred). A subnet whose input state is inconsistent consumes the slot without running (EpochSkipped) and its pending buckets carry over to the next successful epoch.
Triggers
- PendingEpochAt(netuid) is non-zero and current_block ≥ PendingEpochAt
- current_block − LastEpochBlock(netuid) ≥ Tempo(netuid)
- BlocksSinceLastStep(netuid) > Tempo(netuid) (safety net)
Inputs (10)
| Item | Type | Role |
|---|---|---|
| Tempo SubtensorModule | storage | Blocks per epoch for this subnet |
| LastEpochBlock SubtensorModule | storage | Anchor for the next automatic slot (LastEpochBlock + Tempo) |
| PendingEpochAt SubtensorModule | storage | Out-of-cycle slot from an owner trigger or a capacity deferral |
| MaxEpochsPerBlock SubtensorModule | storage | Cap on epochs run per block; excess subnets are deferred |
| PendingServerEmission SubtensorModule | storage | Accumulated miner alpha, drained at the epoch |
| PendingValidatorEmission SubtensorModule | storage | Accumulated validator alpha, drained at the epoch |
| PendingRootAlphaDivs SubtensorModule | storage | Accumulated root-share alpha, drained at the epoch |
| PendingOwnerCut SubtensorModule | storage | Accumulated owner cut, drained at the epoch |
| PendingGammaEmission SubtensorModule | storage | Accumulated gamma-share alpha, allotted to the shares at the epoch (from v490) |
| SubnetGammaEmission SubtensorModule | storage | Gamma shares the pending amount is allotted by (from v490) |
Outputs (14)
| Item | Type | Role |
|---|---|---|
| Emission SubtensorModule | storage | Per-UID emission record of the epoch; from v482 not the miner payout on a non-default split (IncentiveAlphaEmittedToMiners is) |
| AlphaDividendsPerSubnet SubtensorModule | storage | Nominator dividend per hotkey, net of take, cleared and rewritten each epoch |
| RootAlphaDividendsPerSubnet SubtensorModule | storage | Root-weighted dividend per hotkey, net of take, cleared and rewritten each epoch |
| TotalHotkeyAlphaLastEpoch SubtensorModule | storage | Denominator snapshot for nominator shares |
| MinerBurned SubtensorModule | storage | Fraction of incentive withheld from owner hotkeys this epoch |
| LastEpochBlock SubtensorModule | storage | Set to the current block whenever a slot is consumed |
| SubnetEpochIndex SubtensorModule | storage | Incremented once per consumed slot |
| LastMechansimStepBlock SubtensorModule | storage | Set to the current block only when the distribution actually ran |
| LastUpdate SubtensorModule | storage | Per-UID last update block numbers |
| EpochDeferred SubtensorModule | event | Slot pushed one block by MaxEpochsPerBlock |
| EpochSkipped SubtensorModule | event | Slot consumed without running because input state was inconsistent |
| AutoStakeAdded SubtensorModule | event | Miner incentive redirected to an AutoStakeDestination |
| UnconvertedGammaEmission SubtensorModule | storage | Alpha allotted to a gamma share and not yet converted (from v490) |
| GammaEmissionMinted SubtensorModule | event | A gamma share converted into gamma on its target subnet (from v490) |
Source Files
pallets/subtensor/src/coinbase/block_step.rs pallets/subtensor/src/coinbase/run_coinbase.rs pallets/subtensor/src/epoch/run_epoch.rs pallets/subtensor/src/subnets/gamma.rs Formulas
Epoch Trigger
Since v423 a slot is due from a stored anchor plus tempo, with an override block and a safety net. Before v423 it was (block_number + netuid + 1) % (tempo + 1) == 0.
if tempo == 0: never due = (PendingEpochAt > 0 and block >= PendingEpochAt) or BlocksSinceLastStep > tempo or block - LastEpochBlock >= tempo // per block: at most MaxEpochsPerBlock subnets run; the rest get // PendingEpochAt = block + 1 and EpochDeferred // a due slot with inconsistent input state is consumed (LastEpochBlock = block, // SubnetEpochIndex += 1) but not run: EpochSkipped, pending buckets carry over
Dividend Split
How one hotkey dividend from Yuma becomes the amounts written to AlphaDividendsPerSubnet and RootAlphaDividendsPerSubnet.
// per hotkey, after parent/child redistribution weighted_root = root_stake * TaoWeight alpha_divs = dividend * alpha_stake / (alpha_stake + weighted_root) root_divs = dividend - alpha_divs if hotkey has a root UID, else 0 // pools are then shared by proportion alpha_amount = PendingValidatorEmission * alpha_divs / sum(alpha_divs) root_amount = PendingRootAlphaDivs * root_divs / sum(root_divs) // each leg: take to owner coldkey, remainder recorded take = hotkey_take * amount // staked to (hotkey, Owner(hotkey)), no event AlphaDividendsPerSubnet[netuid, hotkey] = alpha_amount - take_alpha RootAlphaDividendsPerSubnet[netuid, hotkey] = root_amount - take_root // queued to basket
Per-Block Alpha Injection
Each block, run_coinbase injects TAO into subnet Alpha pools. At epoch, accumulated Alpha is distributed across UIDs.
// Each block: TAO injected into subnet pool via run_coinbase SubnetTAO[subnet] += emission_share SubnetAlphaIn[subnet] += minted_alpha // At epoch: distribute accumulated alpha → per-UID amounts