BatchWeightItemFailed

Event Re-added v216 → v247, v252 → v265, v273 → v277, v290 → v315, v320 → v326, v334 → v367, v372 → v377, v385 → current #88

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. **error**: The dispatch error emitted by the failed item.

Triggers

Effects

Postconditions

  • Failed item not applied
  • Other items may still succeed

Side Effects

  • Error details available in event

Event Data

#NameTypeDescription
0
arg0
DispatchError Event field #0 (DispatchError)

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

// Subscribe to BatchWeightItemFailed events
api.query.system.events((events) => {
  events
    .filter(({ event }) =>
      event.section === stringCamelCase("SubtensorModule") &&
      event.method === "BatchWeightItemFailed"
    )
    .forEach(({ event }) => {
      console.log("BatchWeightItemFailed:", event.data.toHuman());
    });
});

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 Current

Runtime Info

View Source
Pallet Index
7
Event Index
88
First Version
v216
Current Version
v393