Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pallets/subtensor/src/macros/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/staking/set_children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,8 @@ impl<T: Config> Pallet<T> {
);

// 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(())
}

Expand Down
42 changes: 42 additions & 0 deletions pallets/subtensor/src/tests/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
);
});
}
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading