diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index cdb37bb0dd..2acc99a89e 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -123,8 +123,8 @@ mod events { MinChildKeyTakeSet(u16), /// maximum childkey take set MaxChildKeyTakeSet(u16), - /// childkey take set - ChildKeyTakeSet(T::AccountId, u16), + /// childkey take set for a specific (hotkey, netuid) pair + ChildKeyTakeSet(T::AccountId, NetUid, u16), /// a sudo call is done. Sudid(DispatchResult), /// registration is allowed/disallowed for a subnet. diff --git a/pallets/subtensor/src/staking/set_children.rs b/pallets/subtensor/src/staking/set_children.rs index 9b63024c17..2333e98b61 100644 --- a/pallets/subtensor/src/staking/set_children.rs +++ b/pallets/subtensor/src/staking/set_children.rs @@ -771,8 +771,8 @@ impl Pallet { ); // Emit the event - Self::deposit_event(Event::ChildKeyTakeSet(hotkey.clone(), take)); - log::debug!("Childkey take set for hotkey: {hotkey:?} and take: {take:?}"); + Self::deposit_event(Event::ChildKeyTakeSet(hotkey.clone(), netuid, take)); + log::debug!("Childkey take set for hotkey: {hotkey:?} netuid: {netuid:?} take: {take:?}"); Ok(()) } diff --git a/pallets/subtensor/src/tests/children.rs b/pallets/subtensor/src/tests/children.rs index a7d4b1b273..243b90b75b 100644 --- a/pallets/subtensor/src/tests/children.rs +++ b/pallets/subtensor/src/tests/children.rs @@ -4635,3 +4635,45 @@ fn test_register_network_schedules_root_validators_auto_parent_delegation_flag() )); }); } + +// Regression: ChildkeyTake is stored per-(hotkey, netuid), and the +// `set_childkey_take` dispatch accepts a netuid argument. The +// ChildKeyTakeSet event historically carried only (hotkey, take), giving +// off-chain consumers no way to correlate the take change to its subnet +// without re-deriving from extrinsic args. The event must include netuid. +#[test] +fn test_set_childkey_take_event_includes_netuid() { + new_test_ext(1).execute_with(|| { + let coldkey = U256::from(101); + let hotkey = U256::from(102); + let netuid = NetUid::from(7); + + add_network(netuid, 13, 0); + register_ok_neuron(netuid, hotkey, coldkey, 0); + + let new_take: u16 = SubtensorModule::get_max_childkey_take() / 2; + + assert_ok!(SubtensorModule::set_childkey_take( + RuntimeOrigin::signed(coldkey), + hotkey, + netuid, + new_take, + )); + + let matches: Vec<(U256, NetUid, u16)> = System::events() + .iter() + .filter_map(|e| match &e.event { + RuntimeEvent::SubtensorModule(Event::ChildKeyTakeSet(hk, net, take)) => { + Some((*hk, *net, *take)) + } + _ => None, + }) + .collect(); + + assert_eq!( + matches, + vec![(hotkey, netuid, new_take)], + "ChildKeyTakeSet event should carry (hotkey, netuid, take)" + ); + }); +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00d3839fa7..85a35d21c8 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -272,7 +272,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 406, + spec_version: 407, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,