batch_commit_weights
Call v216 → 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 (Vec<Compact<u16>>) |
| 1 | commit_hashes | Vec<H256> Vec | commit_hashes (Vec<H256>) |
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 { 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 batch_commit_weights call
const netuids = 1;
const commit_hashes = 0 as any /* Vec<H256> */;
const call = api.tx[stringCamelCase("SubtensorModule")][stringCamelCase("batch_commit_weights")](
netuids,
commit_hashes
);Runtime Info
View Source- Pallet Index
- 7
- Call Index
- 100
- First Version
- v216
- Current Version
- v393