fix(weights): include netuid in BatchWeightItemFailed event#2654
Open
RUNECTZ33 wants to merge 1 commit into
Open
fix(weights): include netuid in BatchWeightItemFailed event#2654RUNECTZ33 wants to merge 1 commit into
RUNECTZ33 wants to merge 1 commit into
Conversation
When `do_batch_commit_weights` / `do_batch_set_weights` process a
per-subnet weight batch, any item that fails currently emits
BatchWeightItemFailed(DispatchError)
which carries the error but **not the netuid** that produced it.
Downstream consumers (block explorers, validator monitors, indexers)
that watch batch submissions cannot correlate failures → subnet
without re-deriving from iteration order, which is fragile across
runtime upgrades and not available to event-only subscribers.
Change the event signature to
BatchWeightItemFailed(NetUid, DispatchError)
and thread the netuid through both emission sites by zipping
`(NetUid, DispatchResult)` tuples out of the per-item map.
Shape parallels opentensor#2614 (Add netuid to TransactionFeePaidWithAlpha
event) which made the same observability fix on a different event.
Adds two regression tests in `tests/weights.rs` covering both
emission paths; the dispatches were previously untested at the
batch-event layer. Bumps `spec_version` 406 → 407.
11 tasks
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
do_batch_commit_weightsanddo_batch_set_weightsaccept a list of(netuid, payload)pairs and forward each one to the per-item dispatch. When an item fails, the chain emitswhich carries the
DispatchErrorbut not the netuid that produced it. Downstream consumers (block explorers, validator monitors, indexers) watching a batch see that an item failed and what error variant fired, but cannot tell which subnet without re-deriving from iteration order — fragile across runtime upgrades and not available to event-only subscribers.The call site already has
netuidin scope at the time of emission, so plumbing it through is mechanical.Fix
subnets/weights.rsnow collectVec<(NetUid, DispatchResult)>from the per-item map and emitBatchWeightItemFailed(netuid, err)for each failing item.spec_version406 → 407.Shape mirrors #2614 ("Add netuid to TransactionFeePaidWithAlpha event") which made the same observability improvement on a different event.
Tests
Adds two regression tests in
pallets/subtensor/src/tests/weights.rs. The batch-event layer had no prior coverage (grepon the test tree for either event returned no hits).test_batch_commit_weights_item_failure_event_includes_netuid— submits a 2-item batch where both items hitCommitRevealDisabled, asserts the emittedBatchWeightItemFailedevents carry[netuid_a, netuid_b]in iteration order.test_batch_set_weights_item_failure_event_includes_netuid— same shape for the set-path, usingCommitRevealEnabledas the failure trigger.Both pass locally:
Type of Change
Breaking Change
The event signature is extended by one positional argument. Consumers that decode events by position (Polkadot.js Apps, indexer libraries, off-chain workers) will need to update their parsers — same compatibility surface as #2614. No on-chain storage change; no migration required.
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyRelated