Skip to content
Merged
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
19 changes: 1 addition & 18 deletions pallets/subtensor/src/subnets/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,21 @@ impl<T: Config> Pallet<T> {
TokenSymbol::<T>::insert(netuid_to_register, symbol);

// Keep the locked TAO in the pool instead of recycling the excess.
// Mint the owner alpha separately at the median subnet alpha price.
// Size the pool alpha reserve from the total TAO reserve at that same price.
let pool_initial_tao: TaoBalance = Self::get_network_min_lock();
let total_pool_tao: TaoBalance = if actual_tao_lock_amount >= pool_initial_tao {
actual_tao_lock_amount
} else {
pool_initial_tao
};
let owner_alpha_tao_equivalent: TaoBalance =
total_pool_tao.saturating_sub(pool_initial_tao);

let total_pool_alpha: AlphaBalance = U96F32::saturating_from_num(total_pool_tao.to_u64())
.safe_div(median_subnet_alpha_price)
.saturating_floor()
.saturating_to_num::<u64>()
.into();

let owner_alpha_stake: AlphaBalance =
U96F32::saturating_from_num(owner_alpha_tao_equivalent.to_u64())
.safe_div(median_subnet_alpha_price)
.saturating_floor()
.saturating_to_num::<u64>()
.into();
let owner_alpha_stake = AlphaBalance::ZERO;

// With the full lock retained in the reserve, this will normally be zero.
let tao_recycled_for_registration = actual_tao_lock_amount.saturating_sub(total_pool_tao);
Expand All @@ -250,15 +242,6 @@ impl<T: Config> Pallet<T> {
SubnetVolume::<T>::insert(netuid_to_register, 0u128);
RAORecycledForRegistration::<T>::insert(netuid_to_register, tao_recycled_for_registration);

if !owner_alpha_stake.is_zero() {
Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
hotkey,
&coldkey,
netuid_to_register,
owner_alpha_stake,
);
}

if tao_recycled_for_registration > TaoBalance::ZERO {
Self::recycle_tao(tao_recycled_for_registration);
}
Expand Down
37 changes: 37 additions & 0 deletions pallets/subtensor/src/tests/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,3 +909,40 @@ fn test_update_symbol_fails_if_symbol_already_in_use() {
);
});
}

#[test]
fn test_register_network_gives_owner_no_initial_alpha_distribution() {
new_test_ext(1).execute_with(|| {
let owner_coldkey = U256::from(5001);
let owner_hotkey = U256::from(5002);
let lock_cost = SubtensorModule::get_network_lock_cost();
let netuids_before = SubtensorModule::get_all_subnet_netuids();

SubtensorModule::add_balance_to_coldkey_account(
&owner_coldkey,
ExistentialDeposit::get() + lock_cost.into(),
);

assert_ok!(SubtensorModule::register_network(
<<Test as Config>::RuntimeOrigin>::signed(owner_coldkey),
owner_hotkey
));

let netuid = SubtensorModule::get_all_subnet_netuids()
.into_iter()
.find(|netuid| !netuids_before.contains(netuid))
.unwrap();

assert_eq!(SubnetOwner::<Test>::get(netuid), owner_coldkey);
assert_eq!(SubnetOwnerHotkey::<Test>::get(netuid), owner_hotkey);
assert_eq!(SubnetAlphaOut::<Test>::get(netuid), AlphaBalance::ZERO);
assert_eq!(
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
&owner_hotkey,
&owner_coldkey,
netuid
),
AlphaBalance::ZERO
);
});
}
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: 401,
spec_version: 402,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
Loading