set_weights

Call v101 โ†’ v277, v290 โ†’ current #0

Sets validator weights for neurons on a subnet .

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorssubnet ownersdevelopers

The Big Picture

Weight setting is the core job of a validator. You evaluate miners, score their work, and publish those scores as weights. The Yuma consensus aggregates all validators' weights to determine miner rankings and emissions. Good validators set honest weights and earn higher trust scores.

Why This Matters

Your weights directly control where emissions go. By evaluating miners honestly, you help the network reward quality work. Your own earnings depend on agreeing with consensus - validators who set accurate weights earn more.

Example Scenario

Your validator queries 100 miners on subnet 1, scoring their responses. You call set_weights with your evaluation: [UID 5: 0.3, UID 23: 0.5, UID 67: 0.2, ...]. Next epoch, Yuma consensus combines your weights with other validators to rank miners.

Common Questions

How often should I set weights?
As often as the rate limit allows. More frequent updates = more accurate miner rankings = better network performance.
What if my weights differ from consensus?
The Yuma consensus penalizes outliers. If you consistently disagree with the majority, your validator trust decreases and you earn less.

Use Cases

  • Submit miner evaluations after validation
  • Participate in Yuma consensus
  • Influence emission distribution on your subnet

From Chain Metadata

Sets the caller weights for the incentive mechanism. 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.

Part of: Weight Management

Input Parameters

#NameTypeDescription
0
netuid
u16 NetUidSubnet ID to set weights on
1
dests
Vec<u16> Vec Target neuron UIDs to assign weights to
2
weights
Vec<u16> Vec Weight values as u16 (รท65535 for [0,1] range)
3
version_key
u64 Version key to verify validator is up-to-date

Permissions

Origin
Signed
Required Role
Authorization Checks
  • Hotkey must be registered on the target subnet
  • Hotkey must have a validator permit

Requirements

  • Caller is registered validator on subnet
  • Validator has sufficient stake
  • Weight setting not rate limited
  • Valid weight vector (correct UIDs and values)

Effects

Events Emitted

Storage Modified

Postconditions

  • Validator's weights updated
  • Weight version incremented
  • LastUpdate timestamp updated

Side Effects

  • Affects next epoch's incentive/dividend calculations
  • Impacts ranking and emissions for target neurons

Possible Errors

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);

// Build set_weights call (typed, named args)
const netuid = 1;
const dests = [] as [];
const weights = [] as [];
const version_key = 0n;

const tx = api.tx.SubtensorModule.set_weights({
  netuid,
  dests,
  weights,
  version_key,
});

On-Chain Activity

Usage Frequency
โ—โ—โ—โ—โ—โ— Dominant >10M extrinsics

Highest-volume operations

#1 most used call

Success Rate Moderate

50โ€“80% of submissions succeed

As of block 7,429,232

Version History

v101 block 1 4 args
v290 block 5,947,548 4 args Current

Runtime Info

View Source
Pallet Index
7
Call Index
0
First Version
v101
Current Version
v411