diff --git a/common/src/lib.rs b/common/src/lib.rs index a3882a88fc..67fe4be51b 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -154,7 +154,7 @@ pub enum ProxyType { Registration, Transfer, SmallTransfer, - RootWeights, + RootWeights, // deprecated ChildKeys, SudoUncheckedSetCode, SwapHotkey, diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 03a20a5f21..abc5e7a443 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -957,21 +957,6 @@ pub mod pallet { Ok(()) } - /// The extrinsic sets the subnet limit for the network. - /// It is only callable by the root account. - /// The extrinsic will call the Subtensor pallet to set the subnet limit. - #[pallet::call_index(37)] - #[pallet::weight(( - Weight::from_parts(14_000_000, 0) - .saturating_add(::DbWeight::get().writes(1)), - DispatchClass::Operational, - Pays::No - ))] - pub fn sudo_set_subnet_limit(origin: OriginFor, _max_subnets: u16) -> DispatchResult { - ensure_root(origin)?; - Ok(()) - } - /// The extrinsic sets the lock reduction interval for the network. /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the lock reduction interval. @@ -1076,26 +1061,6 @@ pub mod pallet { Ok(()) } - // The extrinsic sets the target stake per interval. - // It is only callable by the root account. - // The extrinsic will call the Subtensor pallet to set target stake per interval. - // #[pallet::call_index(47)] - // #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - // pub fn sudo_set_target_stakes_per_interval( - // origin: OriginFor, - // target_stakes_per_interval: u64, - // ) -> DispatchResult { - // ensure_root(origin)?; - // pallet_subtensor::Pallet::::set_target_stakes_per_interval( - // target_stakes_per_interval, - // ); - // log::debug!( - // "TxTargetStakesPerIntervalSet( set_target_stakes_per_interval: {:?} ) ", - // target_stakes_per_interval - // ); (DEPRECATED) - // Ok(()) - // } (DEPRECATED) - /// The extrinsic enabled/disables commit/reaveal for a given subnet. /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the value. @@ -1157,62 +1122,6 @@ pub mod pallet { ) } - // DEPRECATED - // #[pallet::call_index(52)] - // #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - // pub fn sudo_set_hotkey_emission_tempo( - // origin: OriginFor, - // emission_tempo: u64, - // ) -> DispatchResult { - // ensure_root(origin)?; - // pallet_subtensor::Pallet::::set_hotkey_emission_tempo(emission_tempo); - // log::debug!( - // "HotkeyEmissionTempoSet( emission_tempo: {:?} )", - // emission_tempo - // ); - // Ok(()) - // } - - /// Sets the maximum stake allowed for a specific network. - /// - /// This function allows the root account to set the maximum stake for a given network. - /// It updates the network's maximum stake value and logs the change. - /// - /// # Arguments - /// - /// * `origin` - The origin of the call, which must be the root account. - /// * `netuid` - The unique identifier of the network. - /// * `max_stake` - The new maximum stake value to set. - /// - /// # Returns - /// - /// Returns `Ok(())` if the operation is successful, or an error if it fails. - /// - /// # Example - /// - /// - /// # Notes - /// - /// - This function can only be called by the root account. - /// - The `netuid` should correspond to an existing network. - /// - /// # TODO - /// - // - Consider adding a check to ensure the `netuid` corresponds to an existing network. - // - Implement a mechanism to gradually adjust the max stake to prevent sudden changes. - // #[pallet::weight(::WeightInfo::sudo_set_network_max_stake())] - #[pallet::call_index(53)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - pub fn sudo_set_network_max_stake( - origin: OriginFor, - _netuid: NetUid, - _max_stake: u64, - ) -> DispatchResult { - // Ensure the call is made by the root account - ensure_root(origin)?; - Ok(()) - } - /// Sets the duration of the coldkey swap schedule. /// /// This extrinsic allows the root account to set the duration for the coldkey swap schedule. diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 34192b6fa2..a7d887b877 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -325,21 +325,6 @@ pub mod pallet { Ok(()) } - /// *DEPRECATED* Sudo-set the commitment rate limit - #[pallet::call_index(1)] - #[pallet::weight(( - Weight::from_parts(3_596_000, 0) - .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)), - DispatchClass::Operational, - Pays::No - ))] - pub fn set_rate_limit(origin: OriginFor, _rate_limit_blocks: u32) -> DispatchResult { - ensure_root(origin)?; - // RateLimit::::set(rate_limit_blocks.into()); - Ok(()) - } - /// Sudo-set MaxSpace #[pallet::call_index(2)] #[pallet::weight(( diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 31040649ef..42e3d79a23 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -98,33 +98,6 @@ mod pallet_benchmarks { ); } - #[benchmark] - fn become_delegate() { - let netuid = NetUid::from(1); - let tempo: u16 = 1; - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1.into()); - Subtensor::::set_max_allowed_uids(netuid, 4096); - Subtensor::::set_network_registration_allowed(netuid, true); - - let seed: u32 = 1; - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - let amount_to_be_staked: u64 = 1_000_000_000; - - Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); - assert_ok!(Subtensor::::do_burned_registration( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone() - )); - - #[extrinsic_call] - _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); - } - #[benchmark] fn add_stake() { let netuid = NetUid::from(1); @@ -1280,27 +1253,6 @@ mod pallet_benchmarks { ); } - #[benchmark] - fn set_tao_weights() { - let netuid = NetUid::from(1); - let hotkey: T::AccountId = account("A", 0, 6); - let dests = vec![0u16]; - let weights = vec![0u16]; - let version: u64 = 1; - - Subtensor::::init_new_network(netuid, 1); - - #[extrinsic_call] - _( - RawOrigin::None, - netuid, - hotkey.clone(), - dests.clone(), - weights.clone(), - version, - ); - } - #[benchmark] fn swap_hotkey() { let coldkey: T::AccountId = whitelisted_caller(); diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 46b4aaf92b..0383f3edee 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(19_330_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(95_460_000, 0) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, @@ -352,118 +352,6 @@ mod dispatches { ) } - /// # Args: - /// * `origin`: (Origin): - /// - The caller, a hotkey who wishes to set their weights. - /// - /// * `netuid` (u16): - /// - The network uid we are setting these weights on. - /// - /// * `hotkey` (T::AccountId): - /// - The hotkey associated with the operation and the calling coldkey. - /// - /// * `dests` (Vec): - /// - The edge endpoint for the weight, i.e. j for w_ij. - /// - /// * 'weights' (Vec): - /// - The u16 integer encoded weights. Interpreted as rational - /// values in the range [0,1]. They must sum to in32::MAX. - /// - /// * 'version_key' ( u64 ): - /// - The network version key to check if the validator is up to date. - /// - /// # Event: - /// - /// * WeightsSet; - /// - On successfully setting the weights on chain. - /// - /// # Raises: - /// - /// * NonAssociatedColdKey; - /// - Attempting to set weights on a non-associated cold key. - /// - /// * 'SubNetworkDoesNotExist': - /// - Attempting to set weights on a non-existent network. - /// - /// * 'NotRootSubnet': - /// - Attempting to set weights on a subnet that is not the root network. - /// - /// * 'WeightVecNotEqualSize': - /// - Attempting to set weights with uids not of same length. - /// - /// * 'UidVecContainInvalidOne': - /// - Attempting to set weights with invalid uids. - /// - /// * 'NotRegistered': - /// - Attempting to set weights from a non registered account. - /// - /// * 'WeightVecLengthIsLow': - /// - Attempting to set weights with fewer weights than min. - /// - /// * 'IncorrectWeightVersionKey': - /// - Attempting to set weights with the incorrect network version key. - /// - /// * 'SettingWeightsTooFast': - /// - Attempting to set weights too fast. - /// - /// * 'WeightVecLengthIsLow': - /// - Attempting to set weights with fewer weights than min. - /// - /// * 'MaxWeightExceeded': - /// - Attempting to set weights with max value exceeding limit. - /// - #[pallet::call_index(8)] - #[pallet::weight((Weight::from_parts(3_176_000, 0) - .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] - pub fn set_tao_weights( - _origin: OriginFor, - _netuid: NetUid, - _hotkey: T::AccountId, - _dests: Vec, - _weights: Vec, - _version_key: u64, - ) -> DispatchResult { - // DEPRECATED - // Self::do_set_root_weights(origin, netuid, hotkey, dests, weights, version_key) - // Self::do_set_tao_weights(origin, netuid, hotkey, dests, weights, version_key) - Ok(()) - } - - /// --- Sets the key as a delegate. - /// - /// # Args: - /// * 'origin': (Origin): - /// - The signature of the caller's coldkey. - /// - /// * 'hotkey' (T::AccountId): - /// - The hotkey we are delegating (must be owned by the coldkey.) - /// - /// * 'take' (u64): - /// - The stake proportion that this hotkey takes from delegations. - /// - /// # Event: - /// * DelegateAdded; - /// - On successfully setting a hotkey as a delegate. - /// - /// # Raises: - /// * 'NotRegistered': - /// - The hotkey we are delegating is not registered on the network. - /// - /// * 'NonAssociatedColdKey': - /// - The hotkey we are delegating is not owned by the calling coldket. - /// - #[pallet::call_index(1)] - #[pallet::weight((Weight::from_parts(3_406_000, 0) - .saturating_add(T::DbWeight::get().reads(0)) - .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::Yes))] - pub fn become_delegate(_origin: OriginFor, _hotkey: T::AccountId) -> DispatchResult { - // DEPRECATED - // Self::do_become_delegate(origin, hotkey, Self::get_default_delegate_take()) - - Ok(()) - } - /// --- Allows delegates to decrease its take value. /// /// # Args: @@ -1386,64 +1274,6 @@ mod dispatches { Ok(().into()) } - /// Schedule the dissolution of a network at a specified block number. - /// - /// # Arguments - /// - /// * `origin` - The origin of the call, must be signed by the sender. - /// * `netuid` - The u16 network identifier to be dissolved. - /// - /// # Returns - /// - /// Returns a `DispatchResultWithPostInfo` indicating success or failure of the operation. - /// - /// # Weight - /// - /// Weight is calculated based on the number of database reads and writes. - - #[pallet::call_index(74)] - #[pallet::weight((Weight::from_parts(119_000_000, 0) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(31)), DispatchClass::Normal, Pays::Yes))] - pub fn schedule_dissolve_network( - _origin: OriginFor, - _netuid: NetUid, - ) -> DispatchResultWithPostInfo { - Err(Error::::CallDisabled.into()) - - // let who = ensure_signed(origin)?; - - // let current_block: BlockNumberFor = >::block_number(); - // let duration: BlockNumberFor = DissolveNetworkScheduleDuration::::get(); - // let when: BlockNumberFor = current_block.saturating_add(duration); - - // let call = Call::::dissolve_network { - // coldkey: who.clone(), - // netuid, - // }; - - // let bound_call = T::Preimages::bound(LocalCallOf::::from(call.clone())) - // .map_err(|_| Error::::FailedToSchedule)?; - - // T::Scheduler::schedule( - // DispatchTime::At(when), - // None, - // 63, - // frame_system::RawOrigin::Root.into(), - // bound_call, - // ) - // .map_err(|_| Error::::FailedToSchedule)?; - - // // Emit the SwapScheduled event - // Self::deposit_event(Event::DissolveNetworkScheduled { - // account: who.clone(), - // netuid, - // execution_block: when, - // }); - - // Ok(().into()) - } - /// ---- Set prometheus information for the neuron. /// # Args: /// * 'origin': (Origin): diff --git a/pallets/subtensor/src/tests/weights.rs b/pallets/subtensor/src/tests/weights.rs index 4784c6b00e..d25a3eb34f 100644 --- a/pallets/subtensor/src/tests/weights.rs +++ b/pallets/subtensor/src/tests/weights.rs @@ -62,119 +62,6 @@ fn test_set_weights_dispatch_info_ok() { }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_set_rootweights_validate --exact --show-output --nocapture -#[test] -fn test_set_rootweights_validate() { - // Testing the signed extension validate function - // correctly filters this transaction. - - new_test_ext(0).execute_with(|| { - let dests = vec![1, 1]; - let weights = vec![1, 1]; - let netuid = NetUid::from(1); - let version_key: u64 = 0; - let coldkey = U256::from(0); - let hotkey: U256 = U256::from(1); // Add the hotkey field - assert_ne!(hotkey, coldkey); // Ensure hotkey is NOT the same as coldkey !!! - let fee: u64 = 0; // FIXME: DefaultStakingFee is deprecated - - let who = coldkey; // The coldkey signs this transaction - - let call = RuntimeCall::SubtensorModule(SubtensorCall::set_tao_weights { - netuid, - dests, - weights, - version_key, - hotkey, // Include the hotkey field - }); - - // Create netuid - add_network(netuid, 1, 0); - // Register the hotkey - SubtensorModule::append_neuron(netuid, &hotkey, 0); - crate::Owner::::insert(hotkey, coldkey); - - SubtensorModule::add_balance_to_coldkey_account(&hotkey, u64::MAX); - - let min_stake = TaoCurrency::from(500_000_000_000); - // Set the minimum stake - SubtensorModule::set_stake_threshold(min_stake.into()); - - // Verify stake is less than minimum - assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) < min_stake); - let info: DispatchInfo = - DispatchInfoOf::<::RuntimeCall>::default(); - - let extension = SubtensorTransactionExtension::::new(); - // Submit to the signed extension validate function - let result_no_stake = extension.validate( - RawOrigin::Signed(who).into(), - &call.clone(), - &info, - 10, - (), - &TxBaseImplication(()), - TransactionSource::External, - ); - // Should fail - assert_eq!( - // Should get an invalid transaction error - result_no_stake.unwrap_err(), - CustomTransactionError::StakeAmountTooLow.into() - ); - - // Increase the stake to be equal to the minimum - assert_ok!(SubtensorModule::do_add_stake( - RuntimeOrigin::signed(hotkey), - hotkey, - netuid, - min_stake + fee.into() - )); - - // Verify stake is equal to minimum - assert_eq!( - SubtensorModule::get_total_stake_for_hotkey(&hotkey), - min_stake - ); - - // Submit to the signed extension validate function - let result_min_stake = extension.validate( - RawOrigin::Signed(who).into(), - &call.clone(), - &info, - 10, - (), - &TxBaseImplication(()), - TransactionSource::External, - ); - // Now the call should pass - assert_ok!(result_min_stake); - - // Try with more stake than minimum - assert_ok!(SubtensorModule::do_add_stake( - RuntimeOrigin::signed(hotkey), - hotkey, - netuid, - DefaultMinStake::::get() * 10.into() - )); - - // Verify stake is more than minimum - assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); - - let result_more_stake = extension.validate( - RawOrigin::Signed(who).into(), - &call.clone(), - &info, - 10, - (), - &TxBaseImplication(()), - TransactionSource::External, - ); - // The call should still pass - assert_ok!(result_more_stake); - }); -} - // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_commit_weights_dispatch_info_ok --exact --show-output --nocapture #[test] fn test_commit_weights_dispatch_info_ok() { diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index 99749032ad..537562fab7 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -223,13 +223,6 @@ where Err(CustomTransactionError::StakeAmountTooLow.into()) } } - Some(Call::set_tao_weights { netuid, hotkey, .. }) => { - if Self::check_weights_min_stake(hotkey, *netuid) { - Ok((Default::default(), Some(who.clone()), origin)) - } else { - Err(CustomTransactionError::StakeAmountTooLow.into()) - } - } Some(Call::commit_crv3_weights { netuid, reveal_round, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00cc24b411..7675c962c6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -398,7 +398,6 @@ impl Contains for SafeModeWhitelistedCalls { | RuntimeCall::Timestamp(_) | RuntimeCall::SubtensorModule( pallet_subtensor::Call::set_weights { .. } - | pallet_subtensor::Call::set_tao_weights { .. } | pallet_subtensor::Call::serve_axon { .. } ) | RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. }) @@ -733,7 +732,6 @@ impl InstanceFilter for ProxyType { | RuntimeCall::SubtensorModule(pallet_subtensor::Call::root_register { .. }) | RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. }) | RuntimeCall::Triumvirate(..) - | RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. }) | RuntimeCall::Sudo(..) ), ProxyType::Triumvirate => matches!( @@ -771,10 +769,7 @@ impl InstanceFilter for ProxyType { RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. }) | RuntimeCall::SubtensorModule(pallet_subtensor::Call::register { .. }) ), - ProxyType::RootWeights => matches!( - c, - RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. }) - ), + ProxyType::RootWeights => false, // deprecated ProxyType::ChildKeys => matches!( c, RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_children { .. })