set_mechanism_weights
Call v320 → 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 as u16s they represent rational values in the range [0,1] which sum to 1 and can be interpreted as probabilities. The specific weights determine how inflation propagates outward from this peer. Note: The 16 bit integers weights should represent 1.0 as the max u16. However, the function normalizes all integers to u16_max anyway. This means that if the sum of all elements is larger or smaller than the amount of elements * u16_max, all elements will be corrected for this deviation.
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
import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";
const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });
// Build set_mechanism_weights call
const netuid = 1;
const mecid = 0;
const dests = 0;
const weights = 0;
const version_key = 0;
const call = api.tx[stringCamelCase("SubtensorModule")][stringCamelCase("set_mechanism_weights")](
netuid,
mecid,
dests,
weights,
version_key
);On-Chain Activity
Significant regular use
#25 most used call
20–50% of submissions succeed
As of block 7,429,232
Runtime Info
View Source- Pallet Index
- 7
- Call Index
- 119
- First Version
- v320
- Current Version
- v393