Skip to content

Commit ed8ebee

Browse files
committed
Apply childkeys even if sn registration is disabled
1 parent e118499 commit ed8ebee

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<T: Config> Pallet<T> {
6565
// --- 3. Drain the subnet block emission and accumulate it as subnet emission, which increases until the tempo is reached in #4.
6666
// subnet_blockwise_emission -> subnet_pending_emission
6767
for netuid in subnets.clone().iter() {
68-
if *netuid == 0 || !Self::is_registration_allowed(*netuid) {
68+
if *netuid == 0 || !Self::get_network_registration_allowed(*netuid) {
6969
continue;
7070
}
7171
// --- 3.1 Get the network's block-wise emission amount.
@@ -121,7 +121,7 @@ impl<T: Config> Pallet<T> {
121121
Self::set_blocks_since_last_step(*netuid, 0);
122122
Self::set_last_mechanism_step_block(*netuid, current_block);
123123

124-
if *netuid == 0 || !Self::is_registration_allowed(*netuid) {
124+
if *netuid == 0 || !Self::get_network_registration_allowed(*netuid) {
125125
// Skip netuid 0 payouts
126126
continue;
127127
}

pallets/subtensor/src/tests/children.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3805,7 +3805,7 @@ fn test_revoke_child_no_min_stake_check() {
38053805
add_network(netuid, 13, 0);
38063806
register_ok_neuron(netuid, parent, coldkey, 0);
38073807

3808-
// Set below minimum stake for setting children
3808+
// Set minimum stake for setting children
38093809
let parent_total_stake_original = TotalHotkeyStake::<Test>::get(parent);
38103810
StakeThreshold::<Test>::put(1_000_000_000_000);
38113811
TotalHotkeyStake::<Test>::insert(parent, StakeThreshold::<Test>::get());
@@ -3856,3 +3856,42 @@ fn test_revoke_child_no_min_stake_check() {
38563856
assert_eq!(children_after, vec![]);
38573857
});
38583858
}
3859+
3860+
// Test that setting childkeys works even if subnet registration is disabled
3861+
#[test]
3862+
fn test_do_set_child_registration_disabled() {
3863+
new_test_ext(1).execute_with(|| {
3864+
let coldkey = U256::from(1);
3865+
let parent = U256::from(2);
3866+
let child = U256::from(3);
3867+
let netuid: u16 = 1;
3868+
let proportion: u64 = 1000;
3869+
3870+
// Add network and register hotkey
3871+
add_network(netuid, 13, 0);
3872+
register_ok_neuron(netuid, parent, coldkey, 0);
3873+
3874+
// Set minimum stake for setting children
3875+
let parent_total_stake_original = TotalHotkeyStake::<Test>::get(parent);
3876+
StakeThreshold::<Test>::put(1_000_000_000_000);
3877+
TotalHotkeyStake::<Test>::insert(parent, StakeThreshold::<Test>::get());
3878+
3879+
// Disable subnet registrations
3880+
NetworkRegistrationAllowed::<Test>::insert(netuid, false);
3881+
3882+
// Schedule parent-child relationship
3883+
assert_ok!(SubtensorModule::do_schedule_children(
3884+
RuntimeOrigin::signed(coldkey),
3885+
parent,
3886+
netuid,
3887+
vec![(proportion, child)],
3888+
));
3889+
3890+
wait_and_set_pending_children(netuid);
3891+
TotalHotkeyStake::<Test>::insert(parent, parent_total_stake_original);
3892+
3893+
// Ensure the childkeys are applied
3894+
let children_after = SubtensorModule::get_children(&parent, netuid);
3895+
assert_eq!(children_after, vec![(proportion, child)]);
3896+
});
3897+
}

0 commit comments

Comments
 (0)