reveal_mechanism_weights

Call v320 → v424, v432 → current #116

Reveals weights committed via mechanism commit.

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsdevelopers

The Big Picture

Completes the mechanism weight commit-reveal cycle. After committing with commit_mechanism_weights and waiting for the reveal window, this call publishes your actual weights. The chain verifies they match your commit, then applies them to the mechanism-specific consensus calculations.

Why This Matters

Without revealing, your commitment expires unused. Reveal on time to have your weights count toward the mechanism's consensus. The reveal proves you committed to these specific weights before seeing others' commits.

Example Scenario

You committed mechanism weights for subnet 15. Reveal window opens at block 500,000. Call reveal_mechanism_weights(netuid=15, uids=[...], weights=[...], salt='your_salt'). Chain verifies hash(weights, salt) == your commit. Weights applied to mechanism consensus.

Common Questions

What if I miss the reveal window?
Your commit expires. You don't get penalized, but your weights don't count for that epoch. Set alerts to ensure timely reveals.
Can I use reveal_weights instead of reveal_mechanism_weights?
No - mechanism commits must be revealed with mechanism reveal. The calls are paired by type. Mismatched reveal calls will fail.

Use Cases

  • Complete mechanism weight commit-reveal cycle
  • Publish mechanism weights after commit window closes
  • Participate in mechanism-based subnet consensus

From Chain Metadata

Used to reveal the weights for a previously committed hash for mechanisms.

Migration Notes

v424 v432 Breaking

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

#NameTypeDescription
0
netuid
NetUid netuid: Subnet ID (u16, 0-65535)
1
mecid
MechId mecid: Mechanism identifier
2
uids
Vec<u16> Vec uids (Vec<u16>)
3
values
Vec<u16> Vec values (Vec<u16>)
4
salt
Vec<u16> Vec salt (Vec<u16>)
5
version_key
u64 version_key (u64)

Permissions

Origin
Signed
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • Mechanism commit exists for this validator
  • Reveal matches commitment hash
  • Within reveal window

Effects

Postconditions

  • Mechanism weights applied
  • Commit cleared
  • Weight version incremented

Side Effects

  • Clears mechanism commit
  • Affects mechanism-specific consensus calculations

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 reveal_mechanism_weights call (typed, named args)
const netuid = 1;
const mecid = undefined as any /* MechId — replace with real value */;
const uids = [] as [];
const values = [] as [];
const salt = [] as [];
const version_key = 0n;

const tx = api.tx.SubtensorModule.reveal_mechanism_weights({
  netuid,
  mecid,
  uids,
  values,
  salt,
  version_key,
});

Version History

v320 block 6,523,566 6 args
v432 block 8,636,190 6 args Current

Runtime Info

View Source
Pallet Index
7
Call Index
116
First Version
v320
Current Version
v472