BatchWeightItemFailed

Event v216 → v247, v252 → v265, v273 → v277, v290 → v315, v320 → v326, v334 → v367, v372 → v377, v385 → v402, v411 → current Changed in v411 #89

Emitted when an individual weight set within a batch fails.

View events on chain
Useful for: validatorsdevelopersanalytics

The Big Picture

When you batch weight operations, individual items might fail even if others succeed. This event provides granular failure information - which subnet failed and why. It's your debug signal for batch operations. Without this, you'd only know 'something failed' but not what specifically.

Why This Matters

If your batch weights succeeded but one subnet got skipped, you want to know which one and why. This event tells you exactly that. Maybe you're not registered on that subnet, or the weights were invalid - the error details explain the failure.

Example Scenario

You batch weights for subnets 1, 3, 5. Subnets 1 and 3 succeed, but 5 fails. BatchWeightItemFailed fires with netuid 5 and error 'NotRegistered'. You forgot to register on subnet 5. The other subnets got their weights, but you need to fix subnet 5 separately.

Common Questions

Do other items still succeed if one fails?
It depends on the batch implementation. Some batches are atomic (all or nothing), others are best-effort (succeeds what it can). Check BatchCompletedWithErrors for partial success.
Should I retry just the failed items?
Yes, if the error is transient or you can fix the issue. For permanent errors (not registered, invalid weights), fix the root cause first.
How do I know which error happened?
The event includes error information. Parse the error code/message to understand what went wrong with that specific subnet's weights.

Use Cases

  • Debug which specific subnet weights failed in a batch
  • Track failure patterns across batch operations
  • Build retry logic for failed items
  • Monitor batch operation reliability

How to Use This Event

  • Monitor batch operations for item-level failures
  • Build failure tracking and retry systems
  • Analyze failure patterns for operational improvements

From Chain Metadata

A weight set among a batch of weights failed. **netuid**: The netuid of the batch item that failed. **error**: The dispatch error emitted by the failed item.

Migration Notes

v402 v411 Breaking

arg0 changed from DispatchError to u16; added field arg1 (DispatchError)

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.

Triggers

Effects

Postconditions

  • Failed item not applied
  • Other items may still succeed

Side Effects

  • Error details available in event

Event Data

#NameTypeDescription
0
arg0
→ netuid
u16 NetUidSubnet ID (u16, 0-65535)
1
arg1
DispatchError sp_runtime::DispatchErrorEvent field #1 (DispatchError)

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

// Subscribe to BatchWeightItemFailed events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SubtensorModule.BatchWeightItemFailed.get(block.hash);
  for (const evt of events) {
    console.log("BatchWeightItemFailed:", evt.payload);
  }
});

Version History

v216 block 4,510,996 1 args
v252 block 5,163,656 1 args
v273 block 5,659,032 1 args
v290 block 5,947,548 1 args
v320 block 6,523,566 1 args
v334 block 6,811,690 1 args
v372 block 7,430,358 1 args
v385 block 7,782,670 1 args
v411 block 8,283,784 2 args Current

Runtime Info

View Source
Pallet Index
7
Event Index
89
First Version
v216
Current Version
v411