ConsensusByMechanism
Storage Map v446 → currentThe previous epoch 's consensus vector, held per subnet mechanism .
Explore chainThe Big Picture
Liquid alpha adjusts how fast validator bonds move toward the current weights, and it needs a consensus vector to do that. Using the live vector couples bond movement to the same epoch that produced it. Keeping the previous epoch here lets a subnet choose the more stable input, and keeping it per mechanism lets subnets that split into several mechanisms price each one on its own consensus.
Why This Matters
If you are working out why a bond moved the way it did, the consensus that drove it may not be the consensus you can read right now. This is where the earlier one lives.
Example Scenario
Subnet 1 with a single mechanism reads at storage index 1. The same subnet's mechanism 2 reads at 1 + 2 * 4096 = 8193. Both return a Vec<PerU16> indexed by UID.
Common Questions
- Why is the key not just a netuid?
- Subnets can run several mechanisms, and each needs its own epoch vectors. Packing netuid and mechanism id into one u16 index keeps the single-mechanism case reading at the bare netuid, so nothing had to migrate.
- How does this differ from SubtensorModule.Consensus?
- Consensus holds the current epoch for a subnet. This holds the previous epoch, per mechanism.
Use Cases
- Reconstruct the consensus a bond calculation actually used, rather than the current epoch value
- Compare consensus across mechanisms on a multi-mechanism subnet
- Attribute a change in validator bonds to a change in consensus
- Chart consensus drift epoch over epoch
From Chain Metadata
MAP ( netuid storage index ) --> previous epoch consensus for each mechanism
Purpose & Usage
Purpose
Carries each mechanism's consensus forward one epoch so liquid alpha can price bonds against what consensus was, rather than only against what it is now. SubtensorModule.LiquidAlphaConsensusMode selects which of the two a subnet uses.
Common Query Patterns
- Query by storage index to read one mechanism
- Read alongside SubtensorModule.Consensus to compare the previous epoch against the current one
Notes
- The key is a NetUidStorageIndex, not a netuid. It packs both values as `netuid + mechanism_id * 4096` (GLOBAL_MAX_SUBNET_COUNT), so mechanism 0 indexes at the bare netuid and a subnet with one mechanism reads exactly where a netuid-keyed map would.
- The value is a Vec<PerU16> indexed by UID, the same shape and scale as SubtensorModule.Consensus.
Query Keys
| # | Name | Type | Description |
|---|---|---|---|
| 1 | netuid storage index | NetUidStorageIndex u16 | netuid storage index (NetUidStorageIndex, hashed key component) |
Stored Value
previous (Vec<PerU16>)
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 ConsensusByMechanism storage
const netuid_storage_index = 1;
const result = await api.query.SubtensorModule.ConsensusByMechanism.getValue(netuid_storage_index);
console.log("ConsensusByMechanism:", result);On-Chain Activity
100K to 1M writes
#178 most written storage item
Modified by both user extrinsics and runtime hooks
As of block 9,385,000
Runtime Info
View Source- Pallet
- SubtensorModule
- Storage Kind
- Map
- First Version
- v446
- Current Version
- v490