Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
41d67e5
add new maps
JohnReedV Jan 23, 2026
8d3d6bc
add events
JohnReedV Jan 23, 2026
115c420
delete burn and pow registration methods
JohnReedV Jan 23, 2026
f9cfd25
add fn `do_register`
JohnReedV Jan 23, 2026
c5ad8bc
update dispatches
JohnReedV Jan 23, 2026
a137ae1
add helpers
JohnReedV Jan 23, 2026
e6b5294
add `update_registration_prices_for_networks`
JohnReedV Jan 23, 2026
5114167
remove mut
JohnReedV Jan 23, 2026
006f948
add doc comments
JohnReedV Jan 23, 2026
edc2b10
remove `adjust_registration_terms_for_networks`
JohnReedV Jan 23, 2026
e352bc7
fix benchmarks
JohnReedV Jan 24, 2026
1e50174
prevent stuck at zero
JohnReedV Jan 24, 2026
85216e6
remove clamp_burn
JohnReedV Jan 24, 2026
f68c837
add migrate_clear_deprecated_registration_maps
JohnReedV Jan 24, 2026
98498d6
plug in migration
JohnReedV Jan 24, 2026
f248aae
update subnet registration init
JohnReedV Jan 24, 2026
ab5a754
update subnet dereg for new maps
JohnReedV Jan 24, 2026
7bf30c1
fmt
JohnReedV Jan 24, 2026
00420c8
add error `NotPermittedOnRootSubnet`
JohnReedV Jan 24, 2026
28997eb
add sudo setters
JohnReedV Jan 24, 2026
b1b21a7
remove error I placed in the wrong spot
JohnReedV Jan 24, 2026
66e5ab5
fix the sudo setters & add events
JohnReedV Jan 24, 2026
8d33e01
actually construct the events
JohnReedV Jan 24, 2026
4e1767e
fix compile
JohnReedV Jan 28, 2026
434c9a1
update mock functions
JohnReedV Jan 28, 2026
82dbbce
update admin-utils tests
JohnReedV Jan 28, 2026
a8051de
update mock helpers
JohnReedV Jan 29, 2026
6cfb222
update registration tests
JohnReedV Jan 29, 2026
da3de15
Merge branch 'devnet-ready' into neuron-registration
JohnReedV Jan 29, 2026
e1fcb9d
fix benchmarks post-merge
JohnReedV Feb 3, 2026
5af6a9f
Merge branch 'devnet-ready' into neuron-registration
JohnReedV Feb 3, 2026
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
77 changes: 77 additions & 0 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ pub mod pallet {
/// Indicates if the Bonds Reset was enabled or disabled.
enabled: bool,
},
/// Event emitted when the burn half-life parameter is set for a subnet.
BurnHalfLifeSet {
/// The network identifier.
netuid: NetUid,
/// The new burn half-life value.
burn_half_life: u16,
},
/// Event emitted when the burn increase multiplier is set for a subnet.
BurnIncreaseMultSet {
/// The network identifier.
netuid: NetUid,
/// The new burn increase multiplier.
burn_increase_mult: u64,
},
}

// Errors inform users that something went wrong.
Expand Down Expand Up @@ -117,6 +131,8 @@ pub mod pallet {
MaxAllowedUidsGreaterThanDefaultMaxAllowedUids,
/// Bad parameter value
InvalidValue,
/// Operation is not permitted on the root network.
NotPermittedOnRootSubnet,
}
/// Enum for specifying the type of precompile operation.
#[derive(
Expand Down Expand Up @@ -2259,6 +2275,67 @@ pub mod pallet {
log::trace!("ColdkeySwapReannouncementDelaySet( duration: {duration:?} )");
Ok(())
}
/// Set BurnHalfLife for a subnet.
#[pallet::call_index(88)]
#[pallet::weight((
Weight::from_parts(25_000_000, 0)
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)),
DispatchClass::Operational,
Pays::Yes,
))]
pub fn sudo_set_burn_half_life(
origin: OriginFor<T>,
netuid: NetUid,
burn_half_life: u16,
) -> DispatchResult {
ensure_root(origin)?;

ensure!(
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
Error::<T>::SubnetDoesNotExist
);
ensure!(!netuid.is_root(), Error::<T>::NotPermittedOnRootSubnet);
ensure!(burn_half_life > 0, Error::<T>::InvalidValue);

pallet_subtensor::BurnHalfLife::<T>::insert(netuid, burn_half_life);
Self::deposit_event(Event::BurnHalfLifeSet {
netuid,
burn_half_life,
});
Ok(())
}

/// Set BurnIncreaseMult for a subnet.
#[pallet::call_index(89)]
#[pallet::weight((
Weight::from_parts(25_000_000, 0)
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)),
DispatchClass::Operational,
Pays::Yes,
))]
pub fn sudo_set_burn_increase_mult(
origin: OriginFor<T>,
netuid: NetUid,
burn_increase_mult: u64,
) -> DispatchResult {
ensure_root(origin)?;

ensure!(
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
Error::<T>::SubnetDoesNotExist
);
ensure!(!netuid.is_root(), Error::<T>::NotPermittedOnRootSubnet);
ensure!(burn_increase_mult >= 1, Error::<T>::InvalidValue);

pallet_subtensor::BurnIncreaseMult::<T>::insert(netuid, burn_increase_mult);
Self::deposit_event(Event::BurnIncreaseMultSet {
netuid,
burn_increase_mult,
});
Ok(())
}
}
}

Expand Down
56 changes: 40 additions & 16 deletions pallets/admin-utils/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,33 +502,57 @@ pub fn register_ok_neuron(
netuid: NetUid,
hotkey_account_id: U256,
coldkey_account_id: U256,
start_nonce: u64,
_start_nonce: u64,
) {
let block_number: u64 = SubtensorModule::get_current_block_as_u64();
let (nonce, work): (u64, Vec<u8>) = SubtensorModule::create_work_for_block_number(
netuid,
block_number,
start_nonce,
&hotkey_account_id,
);
let result = SubtensorModule::register(
<<Test as frame_system::Config>::RuntimeOrigin>::signed(hotkey_account_id),
// Ensure reserves exist for swap/burn path.
let reserve: u64 = 1_000_000_000_000;
setup_reserves(netuid, reserve.into(), reserve.into());

// Ensure coldkey has enough to pay the current burn.
let burn: TaoCurrency = SubtensorModule::get_burn(netuid);
let burn_u64: u64 = burn.into();
let bal = SubtensorModule::get_coldkey_balance(&coldkey_account_id);

if bal < burn_u64 {
SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, burn_u64 - bal + 10);
}

let result = SubtensorModule::burned_register(
<<Test as frame_system::Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid,
block_number,
nonce,
work,
hotkey_account_id,
coldkey_account_id,
);
assert_ok!(result);
log::info!(
"Register ok neuron: netuid: {netuid:?}, coldkey: {hotkey_account_id:?}, hotkey: {coldkey_account_id:?}"
"Register ok neuron: netuid: {netuid:?}, coldkey: {coldkey_account_id:?}, hotkey: {hotkey_account_id:?}"
);
}

#[allow(dead_code)]
pub fn add_network(netuid: NetUid, tempo: u16) {
SubtensorModule::init_new_network(netuid, tempo);
SubtensorModule::set_network_registration_allowed(netuid, true);
SubtensorModule::set_network_pow_registration_allowed(netuid, true);

pallet_subtensor::FirstEmissionBlockNumber::<Test>::insert(netuid, 1);
pallet_subtensor::SubtokenEnabled::<Test>::insert(netuid, true);

// make interval 1 block so tests can register by stepping 1 block.
pallet_subtensor::BurnHalfLife::<Test>::insert(netuid, 1);
pallet_subtensor::BurnIncreaseMult::<Test>::insert(netuid, 1);
pallet_subtensor::BurnLastHalvingBlock::<Test>::insert(
netuid,
SubtensorModule::get_current_block_as_u64(),
);
}

use subtensor_runtime_common::AlphaCurrency;
pub(crate) fn setup_reserves(netuid: NetUid, tao: TaoCurrency, alpha: AlphaCurrency) {
pallet_subtensor::SubnetTAO::<Test>::set(netuid, tao);
pallet_subtensor::SubnetAlphaIn::<Test>::set(netuid, alpha);
}

/// Convenience wrapper for tests that need to advance blocks incrementally.
pub fn step_block(n: u64) {
let current: u64 = frame_system::Pallet::<Test>::block_number().into();
run_to_block(current + n);
}
Loading
Loading