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
168 changes: 0 additions & 168 deletions pallets/subtensor/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,174 +156,6 @@ mod pallet_benchmarks {
);
}

// #[benchmark]
// fn add_stake_aggregate() {
// let netuid: u16 = 1;
// let tempo: u16 = 1;
//
// Subtensor::<T>::init_new_network(netuid, tempo);
// SubtokenEnabled::<T>::insert(netuid, true);
// Subtensor::<T>::set_burn(netuid, 1);
// Subtensor::<T>::set_network_registration_allowed(netuid, true);
// Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
//
// let seed: u32 = 1;
// let coldkey: T::AccountId = account("Test", 0, seed);
// let hotkey: T::AccountId = account("Alice", 0, seed);
// let total_stake: u64 = 1_000_000_000;
// let amount: u64 = 600_000;
//
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, total_stake);
// assert_ok!(Subtensor::<T>::do_burned_registration(
// RawOrigin::Signed(coldkey.clone()).into(),
// netuid,
// hotkey.clone()
// ));
//
// #[extrinsic_call]
// _(
// RawOrigin::Signed(coldkey.clone()),
// hotkey.clone(),
// netuid,
// amount,
// );
// }
//
// #[benchmark]
// fn remove_stake_limit_aggregate() {
// let netuid: u16 = 1;
//
// Subtensor::<T>::increase_total_stake(1_000_000_000_000);
// Subtensor::<T>::init_new_network(netuid, 1);
// Subtensor::<T>::set_network_registration_allowed(netuid, true);
// SubtokenEnabled::<T>::insert(netuid, true);
// Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
//
// let seed: u32 = 1;
// let coldkey: T::AccountId = account("Test", 0, seed);
// let hotkey: T::AccountId = account("Alice", 0, seed);
// Subtensor::<T>::set_burn(netuid, 1);
//
// let limit: u64 = 1_000_000_000;
// let tao_reserve: u64 = 150_000_000_000;
// let alpha_in: u64 = 100_000_000_000;
// SubnetTAO::<T>::insert(netuid, tao_reserve);
// SubnetAlphaIn::<T>::insert(netuid, alpha_in);
//
// let wallet_bal: u64 = 1_000_000;
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, wallet_bal);
//
// assert_ok!(Subtensor::<T>::do_burned_registration(
// RawOrigin::Signed(coldkey.clone()).into(),
// netuid,
// hotkey.clone()
// ));
//
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, 100_000_000_000u64);
// assert_ok!(Subtensor::<T>::add_stake(
// RawOrigin::Signed(coldkey.clone()).into(),
// hotkey.clone(),
// netuid,
// 100_000_000_000u64
// ));
//
// let amount_unstaked: u64 = 30_000_000_000;
//
// #[extrinsic_call]
// _(
// RawOrigin::Signed(coldkey.clone()),
// hotkey.clone(),
// netuid,
// amount_unstaked,
// limit,
// false,
// );
// }
//
// #[benchmark]
// fn remove_stake_aggregate() {
// let netuid: u16 = 1;
//
// Subtensor::<T>::increase_total_stake(1_000_000_000_000);
// Subtensor::<T>::init_new_network(netuid, 1);
// Subtensor::<T>::set_network_registration_allowed(netuid, true);
// SubtokenEnabled::<T>::insert(netuid, true);
// Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
//
// let seed: u32 = 1;
// let coldkey: T::AccountId = account("Test", 0, seed);
// let hotkey: T::AccountId = account("Alice", 0, seed);
// Subtensor::<T>::set_burn(netuid, 1);
//
// let wallet_bal: u64 = 1_000_000;
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, wallet_bal);
//
// assert_ok!(Subtensor::<T>::do_burned_registration(
// RawOrigin::Signed(coldkey.clone()).into(),
// netuid,
// hotkey.clone()
// ));
//
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, 100_000_000_000u64);
// assert_ok!(Subtensor::<T>::add_stake(
// RawOrigin::Signed(coldkey.clone()).into(),
// hotkey.clone(),
// netuid,
// 100_000_000_000u64
// ));
//
// let amount_unstaked: u64 = 600_000;
//
// #[extrinsic_call]
// _(
// RawOrigin::Signed(coldkey.clone()),
// hotkey.clone(),
// netuid,
// amount_unstaked,
// );
// }
//
// #[benchmark]
// fn add_stake_limit_aggregate() {
// let netuid: u16 = 1;
//
// Subtensor::<T>::init_new_network(netuid, 1);
// SubtokenEnabled::<T>::insert(netuid, true);
// Subtensor::<T>::set_burn(netuid, 1);
// Subtensor::<T>::set_network_registration_allowed(netuid, true);
// Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
//
// let seed: u32 = 1;
// let coldkey: T::AccountId = account("Test", 0, seed);
// let hotkey: T::AccountId = account("Alice", 0, seed);
//
// let amount: u64 = 900_000_000_000;
// let limit: u64 = 6_000_000_000;
// let stake_amt: u64 = 440_000_000_000;
// Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, amount);
//
// let tao_reserve: u64 = 150_000_000_000;
// let alpha_in: u64 = 100_000_000_000;
// SubnetTAO::<T>::insert(netuid, tao_reserve);
// SubnetAlphaIn::<T>::insert(netuid, alpha_in);
//
// assert_ok!(Subtensor::<T>::do_burned_registration(
// RawOrigin::Signed(coldkey.clone()).into(),
// netuid,
// hotkey.clone()
// ));
//
// #[extrinsic_call]
// _(
// RawOrigin::Signed(coldkey.clone()),
// hotkey.clone(),
// netuid,
// stake_amt,
// limit,
// false,
// );
// }

#[benchmark]
fn serve_axon() {
let netuid: u16 = 1;
Expand Down
190 changes: 0 additions & 190 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,79 +270,6 @@ pub mod pallet {
pub additional: Vec<u8>,
}

/// Data structure for stake related jobs.
#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, Eq, Debug)]
pub enum StakeJob<AccountId> {
/// Represents a job for "add_stake" operation
AddStake {
/// Hotkey account
hotkey: AccountId,
/// Coldkey account
coldkey: AccountId,
/// Subnet ID
netuid: u16,
/// The amount of stake to be added to the hotkey staking account.
stake_to_be_added: u64,
},
/// Represents a job for "remove_stake" operation
RemoveStake {
/// Hotkey account
hotkey: AccountId,
/// Coldkey account
coldkey: AccountId,
/// Subnet ID
netuid: u16,
/// Alpha value
alpha_unstaked: u64,
},
/// Represents a job for "add_stake_limit" operation
AddStakeLimit {
/// Coldkey account
coldkey: AccountId,
/// Hotkey account
hotkey: AccountId,
/// Subnet ID
netuid: u16,
/// The amount of stake to be added to the hotkey staking account.
stake_to_be_added: u64,
/// The limit price expressed in units of RAO per one Alpha.
limit_price: u64,
/// Allows partial execution of the amount. If set to false, this becomes
/// fill or kill type or order.
allow_partial: bool,
},
/// Represents a job for "remove_stake_limit" operation
RemoveStakeLimit {
/// Coldkey account
coldkey: AccountId,
/// Hotkey account
hotkey: AccountId,
/// Subnet ID
netuid: u16,
/// The amount of stake to be added to the hotkey staking account.
alpha_unstaked: u64,
/// The limit price
limit_price: u64,
/// Allows partial execution of the amount. If set to false, this becomes
/// fill or kill type or order.
allow_partial: bool,
},
/// Represents a job for "unstake_all" operation
UnstakeAll {
/// Coldkey account
coldkey: AccountId,
/// Hotkey account
hotkey: AccountId,
},
/// Represents a job for "unstake_all_alpha" operation
UnstakeAllAlpha {
/// Coldkey account
coldkey: AccountId,
/// Hotkey account
hotkey: AccountId,
},
}

/// ============================
/// ==== Staking + Accounts ====
/// ============================
Expand Down Expand Up @@ -929,17 +856,6 @@ pub mod pallet {
pub type SenateRequiredStakePercentage<T> =
StorageValue<_, u64, ValueQuery, DefaultSenateRequiredStakePercentage<T>>;

#[pallet::storage]
pub type StakeJobs<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
BlockNumberFor<T>, // first key: current block number
Twox64Concat,
u64, // second key: unique job ID
StakeJob<T::AccountId>,
OptionQuery,
>;

#[pallet::storage]
/// --- DMap ( netuid, coldkey ) --> blocknumber | last hotkey swap on network.
pub type LastHotkeySwapOnNetuid<T: Config> = StorageDoubleMap<
Expand Down Expand Up @@ -2207,112 +2123,6 @@ where
Self::get_priority_staking(who, hotkey, *amount_unstaked),
)
}
// Some(Call::add_stake_aggregate {
// hotkey,
// netuid,
// amount_staked,
// }) => {
// if ColdkeySwapScheduled::<T>::contains_key(who) {
// return InvalidTransaction::Custom(
// CustomTransactionError::ColdkeyInSwapSchedule.into(),
// )
// .into();
// }
// // Fully validate the user input
// Self::result_to_validity(
// Pallet::<T>::validate_add_stake(
// who,
// hotkey,
// *netuid,
// *amount_staked,
// *amount_staked,
// false,
// ),
// Self::get_priority_staking(who, hotkey, *amount_staked),
// )
// }
// Some(Call::add_stake_limit_aggregate {
// hotkey,
// netuid,
// amount_staked,
// limit_price,
// allow_partial,
// }) => {
// if ColdkeySwapScheduled::<T>::contains_key(who) {
// return InvalidTransaction::Custom(
// CustomTransactionError::ColdkeyInSwapSchedule.into(),
// )
// .into();
// }
//
// // Calculate the maximum amount that can be executed with price limit
// let Ok(max_amount) = Pallet::<T>::get_max_amount_add(*netuid, *limit_price) else {
// return InvalidTransaction::Custom(
// CustomTransactionError::ZeroMaxAmount.into(),
// )
// .into();
// };
//
// // Fully validate the user input
// Self::result_to_validity(
// Pallet::<T>::validate_add_stake(
// who,
// hotkey,
// *netuid,
// *amount_staked,
// max_amount,
// *allow_partial,
// ),
// Self::get_priority_staking(who, hotkey, *amount_staked),
// )
// }
// Some(Call::remove_stake_aggregate {
// hotkey,
// netuid,
// amount_unstaked,
// }) => {
// // Fully validate the user input
// Self::result_to_validity(
// Pallet::<T>::validate_remove_stake(
// who,
// hotkey,
// *netuid,
// *amount_unstaked,
// *amount_unstaked,
// false,
// ),
// Self::get_priority_staking(who, hotkey, *amount_unstaked),
// )
// }
// Some(Call::remove_stake_limit_aggregate {
// hotkey,
// netuid,
// amount_unstaked,
// limit_price,
// allow_partial,
// }) => {
// // Calculate the maximum amount that can be executed with price limit
// let Ok(max_amount) = Pallet::<T>::get_max_amount_remove(*netuid, *limit_price)
// else {
// return InvalidTransaction::Custom(
// CustomTransactionError::ZeroMaxAmount.into(),
// )
// .into();
// };
//
// // Fully validate the user input
// Self::result_to_validity(
// Pallet::<T>::validate_remove_stake(
// who,
// hotkey,
// *netuid,
// *amount_unstaked,
// max_amount,
// *allow_partial,
// ),
// Self::get_priority_staking(who, hotkey, *amount_unstaked),
// )
// }
Some(Call::unstake_all { hotkey }) => {
// Fully validate the user input
Self::result_to_validity(
Expand Down
Loading
Loading