Skip to content

fix(staking): include netuid in ChildKeyTakeSet event#2655

Open
RUNECTZ33 wants to merge 1 commit into
opentensor:devnet-readyfrom
RUNECTZ33:fix/child-key-take-set-include-netuid
Open

fix(staking): include netuid in ChildKeyTakeSet event#2655
RUNECTZ33 wants to merge 1 commit into
opentensor:devnet-readyfrom
RUNECTZ33:fix/child-key-take-set-include-netuid

Conversation

@RUNECTZ33
Copy link
Copy Markdown

Description

ChildkeyTake is a StorageDoubleMap<_, hotkey, _, netuid, u16> — per-(hotkey, netuid). The set_childkey_take dispatch accepts a netuid parameter:

pub fn do_set_childkey_take(
    coldkey: T::AccountId,
    hotkey: T::AccountId,
    netuid: NetUid,
    take: u16,
) -> DispatchResult { ... }

and the storage write at set_children.rs:764 uses that netuid:

ChildkeyTake::<T>::insert(hotkey.clone(), netuid, take);

But the emitted event at set_children.rs:774 carries only (hotkey, take):

Self::deposit_event(Event::ChildKeyTakeSet(hotkey.clone(), take));

Off-chain consumers (block explorers, validator monitors, takes-rate trackers) watching ChildKeyTakeSet have no way to correlate a take change to its subnet without re-deriving from the extrinsic args — fragile across runtime upgrades and not available to event-only subscribers.

The dispatch already has netuid in scope, so threading it through is mechanical.

Fix

Change the event signature to ChildKeyTakeSet(T::AccountId, NetUid, u16) and pass netuid at the single emission site in do_set_childkey_take.

Shape mirrors #2614 ("Add netuid to TransactionFeePaidWithAlpha event") which made the same observability fix on a different event.

Bumps spec_version 406 → 407.

Tests

Adds test_set_childkey_take_event_includes_netuid in pallets/subtensor/src/tests/children.rs. The event had no prior coverage (grep on the test tree returned no hits for ChildKeyTakeSet).

SKIP_WASM_BUILD=1 cargo test -p pallet-subtensor --lib -- \
  tests::children::test_set_childkey_take_event_includes_netuid
running 1 test
test tests::children::test_set_childkey_take_event_includes_netuid ... ok
test result: ok. 1 passed; 0 failed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

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

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix

Related

`ChildkeyTake` is stored as a `StorageDoubleMap<_, hotkey, _, netuid, u16>`
and the `set_childkey_take` dispatch accepts `netuid` as an argument
(`do_set_childkey_take(coldkey, hotkey, netuid, take)` in
`pallets/subtensor/src/staking/set_children.rs`). The emitted event,
however, carried only `(hotkey, take)` — leaving off-chain consumers
(block explorers, validator monitors, takes-rate trackers) unable to
correlate a take change to its subnet without re-deriving from the
extrinsic args.

Change the event signature to `ChildKeyTakeSet(T::AccountId, NetUid, u16)`
and pass the dispatch's `netuid` through at the single emission site.
Mirrors PR opentensor#2614 (\"Add netuid to TransactionFeePaidWithAlpha event\")
which made the same observability fix on a different event.

Adds `test_set_childkey_take_event_includes_netuid` in
`pallets/subtensor/src/tests/children.rs` — the event had no prior
coverage. Bumps `spec_version` 406 → 407.
Copy link
Copy Markdown
Contributor

@open-junius open-junius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@open-junius open-junius added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants