LastEpochBlock
Storage Map v423 → v490 · 1 shape changeBlock at which the subnet last consumed an epoch slot, run or skipped.
Explore chainThe Big Picture
Since v423 epochs are scheduled from this anchor rather than from a modulo of the block number. Together with PendingEpochAt it fully determines when a subnet next attempts an epoch.
Use Cases
- Predict the next epoch block
- Detect an epoch slot in a block without scanning events
- Build epoch timing dashboards
From Chain Metadata
MAP ( netuid ) --> last epoch attempt block (consumed slot). Drives normal-cadence scheduling and the admin freeze window. Advances on every `should_run_epoch == true` slot — including consistency-skipped slots — and on a successful `sudo_set_tempo` (cycle reset).
Purpose & Usage
Purpose
Anchor the stateful epoch scheduler introduced in v423. The next automatic slot is this value plus Tempo.
Common Query Patterns
- Query by netuid
- next_auto_epoch = LastEpochBlock + Tempo
- LastEpochBlock == current block means a slot was consumed this block
Notes
- Advanced unconditionally in drain_pending (run_coinbase.rs L464-L466 at da06f033, v452) whenever should_run_epoch is true, including slots skipped for inconsistent input state and slots deferred by MaxEpochsPerBlock. It therefore marks the slot, not a successful distribution; LastMechansimStepBlock marks the distribution.
- Also reset by a successful sudo_set_tempo, which restarts the cycle.
Migration Notes
key type changed from u16 to NetUid
Update decoders: SCALE encoding is positional, so any signature change (added, removed, or type-changed fields, or storage shape changes) shifts byte offsets and existing decoders will misparse this item. Re-derive types from the new metadata.
Query Keys
| # | Name | Type | Description |
|---|---|---|---|
| 1 | netuid | NetUid u16 | netuid (NetUid, hashed key component) |
Stored Value
last (u64)
RAO -> TAO (/ 10^9)
Default Value
Absent keys read as this value — querying a key that has never been written returns this default, not an error or empty result.
Code Examples
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query LastEpochBlock storage
const netuid = 1;
const result = await api.query.SubtensorModule.LastEpochBlock.getValue(netuid);
console.log("LastEpochBlock:", result);On-Chain Activity
100K to 1M writes
#175 most written storage item
Modified by both user extrinsics and runtime hooks
As of block 9,385,000
Version History
- key :
u16→NetUid
Runtime Info
View Source- Pallet
- SubtensorModule
- Storage Kind
- Map
- First Version
- v423
- Current Version
- v490