commit_weights

Call v151 → v277, v290 → current #96

Commits a hash of weights for later reveal.

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsdevelopers

The Big Picture

Commit-reveal prevents weight copying. Without it, validators could wait to see others' weights and copy them. With commit-reveal, you first submit a hash (commit), then reveal the actual weights later. Since you can't change weights after committing, and can't see others' commits, everyone must evaluate miners independently. This ensures honest consensus.

Why This Matters

If validators can copy weights, lazy validators profit from others' work. Commit-reveal forces everyone to do their own evaluations. The hash locks you in before anyone sees your choices.

Example Scenario

Subnet 18 requires commit-reveal. After evaluating miners, you compute hash = sha256(weights + salt). Call commit_weights(netuid=18, commit_hash=hash). Wait for the reveal window (usually next epoch). Then call reveal_weights with your actual weights and salt. The chain verifies hash(weights, salt) == your commit.

Common Questions

What happens if I don't reveal in time?
Your commitment expires, and you miss that epoch's weight update. No penalty beyond lost opportunity, but your weights won't affect miner rankings.
What's the salt for?
Randomness. Without salt, someone could try hashing common weight patterns to guess your weights from the hash. Salt makes this impossible.
How long between commit and reveal?
Subnet-configurable. Typically one epoch (360 blocks / ~72 minutes). Check CommitRevealPeriod for the subnet.

Use Cases

  • Submit weight evaluations on subnets requiring commit-reveal
  • Prevent weight copying by other validators
  • Participate in MEV-resistant consensus mechanisms
  • Ensure fair weight aggregation without front-running

From Chain Metadata

- Used to commit a hash of your weight values to later be revealed.

Input Parameters

#NameTypeDescription
0
netuid
u16 NetUidnetuid: Subnet ID (u16, 0-65535)
1
commit_hash
H256 commit_hash: 32-byte hash (Ethereum-compatible)

Permissions

Origin
Signed
Required Role
Authorization Checks
  • Hotkey must be registered on the target subnet

Requirements

  • Caller is registered validator on subnet
  • Commit-reveal enabled for subnet
  • Valid commitment hash provided

Effects

Events Emitted

Storage Modified

Postconditions

  • Weight commitment recorded
  • Commit timestamp recorded

Side Effects

  • Must reveal weights before commitment expires

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 commit_weights call (typed, named args)
const netuid = 1;
const commit_hash = "0x0000000000000000000000000000000000000000000000000000000000000000";

const tx = api.tx.SubtensorModule.commit_weights({
  netuid,
  commit_hash,
});

On-Chain Activity

Usage Frequency
●●●○○○ Moderate 10K–100K extrinsics

Occasional use

#36 most used call

Success Rate Challenging

20–50% of submissions succeed

As of block 7,429,232

Version History

v151 block 3,157,274 2 args
v290 block 5,947,548 2 args Current

Runtime Info

View Source
Pallet Index
7
Call Index
96
First Version
v151
Current Version
v411