batch_commit_weights
Call v216 → v277, v290 → current #100Commits weights on multiple subnets in a single transaction.
View calls on chainCall Workflow
Click items to navigate. Pan and zoom to explore.
The Big Picture
For validators operating across multiple commit-reveal subnets, batch_commit_weights is essential. Instead of N separate commit transactions (with N fees and N confirmations), you submit all commits atomically. This is critical for large validators who might validate on 10+ subnets - the gas savings and operational simplicity are substantial.
Why This Matters
Commit-reveal requires precise timing. Batching commits means one transaction to track, one confirmation to wait for, and one fee to pay. For validators juggling many subnets, this reduces operational complexity and costs significantly.
Example Scenario
You validate on subnets 1, 3, 7, and 18 - all using commit-reveal. After evaluating miners on each, compute hashes: hash1=sha256(weights1+salt1), etc. Call batch_commit_weights(netuids=[1,3,7,18], commits=[hash1,hash2,hash3,hash4]). One transaction, four commits. Now schedule batch_reveal_weights for the reveal windows.
Common Questions
- What if commit-reveal windows differ across subnets?
- You'll need to reveal in separate batches matching each window, or ensure your batch covers subnets with aligned windows. Mismatched timing requires multiple reveals.
- What happens if one commit fails?
- Typically the entire batch fails. Ensure all parameters are valid before submitting. Consider using Utility.batch for partial success if needed.
- Do I need to remember salts for each subnet?
- Yes - each commit has its own salt. Store them securely. Most validator software handles salt management automatically.
Use Cases
- Multi-subnet validators committing evaluations in one transaction
- Synchronized commit across related subnets
- Gas-efficient commit-reveal participation for large validators
- Operational efficiency for validators on many subnets
From Chain Metadata
Allows a hotkey to commit weight hashes for multiple netuids as a batch.
Input Parameters
| # | Name | Type | Description |
|---|---|---|---|
| 0 | netuids | Vec<Compact<u16>> Vec | netuids: list of compact-encoded Subnet ID (u16, 0-65535) |
| 1 | commit_hashes | Vec<H256> Vec | commit_hashes: list of 32-byte hash (Ethereum-compatible) |
Permissions
Permission data inferred from metadata. May be incomplete.
Requirements
- Commit-reveal enabled on target subnets
- Valid commit hashes for each subnet
- Validator registered on all target subnets
Effects
Storage Modified
Postconditions
- Commits stored for all specified subnets
- Commit timestamps recorded
Side Effects
- Must reveal each commit separately or in batch
- Commits expire if not revealed in time
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 batch_commit_weights call (typed, named args)
const netuids = [] as [];
const commit_hashes = [] as [];
const tx = api.tx.SubtensorModule.batch_commit_weights({
netuids,
commit_hashes,
});Version History
Runtime Info
View Source- Pallet Index
- 7
- Call Index
- 100
- First Version
- v216
- Current Version
- v411