set_mechanism_weights
Call v320 → v424, v432 → current #119Directly sets mechanism weights without commit-reveal .
View calls on chainCall Workflow
Click items to navigate. Pan and zoom to explore.
The Big Picture
The direct-setting version of mechanism weights - no commit-reveal ceremony, just set and go. This is simpler but less secure against weight copying. Used when the subnet has other anti-copying measures (reputation, rate limiting) or when copying isn't a concern.
Why This Matters
Commit-reveal adds latency and complexity. If a subnet doesn't need it (perhaps it's a testing subnet, or has alternative protections), direct setting is simpler. Your weights apply immediately, no waiting for reveal windows.
Example Scenario
Subnet 99 uses mechanism weights but allows direct setting (no commit-reveal required). After evaluating miners, call set_mechanism_weights(netuid=99, uids=[5,12,23], weights=[0.3,0.4,0.3]). Weights apply immediately, affecting next epoch's mechanism consensus.
Common Questions
- Why would a subnet allow direct setting?
- Lower complexity, faster updates, or alternative protections. Some subnets trust their validators or have other mechanisms preventing manipulation.
- Can other validators copy my weights immediately?
- Yes - that's the tradeoff. Without commit-reveal, your weights are public as soon as they're set. Only use this on subnets where that's acceptable.
- How do I know if a subnet requires commit-reveal?
- Check the subnet's CommitRevealEnabled or similar parameter. If false, use direct setting. If true, you must use the commit/reveal cycle.
Use Cases
- Set mechanism weights on subnets not requiring commit-reveal
- Quick weight updates when hiding isn't needed
- Testing and development on permissive subnets
- Subnets with alternative anti-copying measures
From Chain Metadata
Sets the caller weights for the incentive mechanism for mechanisms. The call can be made from the hotkey account so is potentially insecure, however, the damage of changing weights is minimal if caught early. This function includes all the checks that the passed weights meet the requirements. Stored weights are u16s max-upscaled by the pallet, so the largest non-zero supplied weight is stored as `u16::MAX`. The weights determine how inflation propagates outward from this peer.
Migration Notes
netuid changed from u16 to NetUid; mecid changed from u8 to MechId
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.
Input Parameters
Permissions
Permission data inferred from metadata. May be incomplete.
Requirements
- Mechanism weights enabled on subnet
- Validator registered with sufficient stake
- Commit-reveal not required (direct setting allowed)
Effects
Events Emitted
Storage Modified
Postconditions
- Mechanism weights updated immediately
- Weight version incremented
Side Effects
- Affects mechanism-specific calculations
- Weights visible immediately (no hiding period)
Possible Errors
Code Examples
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
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);
// Build set_mechanism_weights call (typed, named args)
const netuid = 1;
const mecid = undefined as any /* MechId — replace with real value */;
const dests = [] as [];
const weights = [] as [];
const version_key = 0n;
const tx = api.tx.SubtensorModule.set_mechanism_weights({
netuid,
mecid,
dests,
weights,
version_key,
});On-Chain Activity
Primary protocol calls
#20 most used call
80–95% of submissions succeed
As of block 9,385,000
Version History
Runtime Info
View Source- Pallet Index
- 7
- Call Index
- 119
- First Version
- v320
- Current Version
- v490