Skip to content

Commit 1c7442d

Browse files
Remove tests, benchmarks and alter transaction extension.
1 parent 1e420f2 commit 1c7442d

File tree

5 files changed

+2
-175
lines changed

5 files changed

+2
-175
lines changed

common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub enum ProxyType {
154154
Registration,
155155
Transfer,
156156
SmallTransfer,
157-
RootWeights,
157+
RootWeights, // deprecated
158158
ChildKeys,
159159
SudoUncheckedSetCode,
160160
SwapHotkey,

pallets/subtensor/src/benchmarks.rs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,6 @@ mod pallet_benchmarks {
9797
);
9898
}
9999

100-
#[benchmark]
101-
fn become_delegate() {
102-
let netuid = NetUid::from(1);
103-
let tempo: u16 = 1;
104-
105-
Subtensor::<T>::init_new_network(netuid, tempo);
106-
SubtokenEnabled::<T>::insert(netuid, true);
107-
Subtensor::<T>::set_burn(netuid, 1.into());
108-
Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
109-
Subtensor::<T>::set_network_registration_allowed(netuid, true);
110-
111-
let seed: u32 = 1;
112-
let coldkey: T::AccountId = account("Test", 0, seed);
113-
let hotkey: T::AccountId = account("Alice", 0, seed);
114-
let amount_to_be_staked: u64 = 1_000_000_000;
115-
116-
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked);
117-
assert_ok!(Subtensor::<T>::do_burned_registration(
118-
RawOrigin::Signed(coldkey.clone()).into(),
119-
netuid,
120-
hotkey.clone()
121-
));
122-
123-
#[extrinsic_call]
124-
_(RawOrigin::Signed(coldkey.clone()), hotkey.clone());
125-
}
126-
127100
#[benchmark]
128101
fn add_stake() {
129102
let netuid = NetUid::from(1);
@@ -1278,27 +1251,6 @@ mod pallet_benchmarks {
12781251
);
12791252
}
12801253

1281-
#[benchmark]
1282-
fn set_tao_weights() {
1283-
let netuid = NetUid::from(1);
1284-
let hotkey: T::AccountId = account("A", 0, 6);
1285-
let dests = vec![0u16];
1286-
let weights = vec![0u16];
1287-
let version: u64 = 1;
1288-
1289-
Subtensor::<T>::init_new_network(netuid, 1);
1290-
1291-
#[extrinsic_call]
1292-
_(
1293-
RawOrigin::None,
1294-
netuid,
1295-
hotkey.clone(),
1296-
dests.clone(),
1297-
weights.clone(),
1298-
version,
1299-
);
1300-
}
1301-
13021254
#[benchmark]
13031255
fn swap_hotkey() {
13041256
let coldkey: T::AccountId = whitelisted_caller();

pallets/subtensor/src/tests/weights.rs

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -62,119 +62,6 @@ fn test_set_weights_dispatch_info_ok() {
6262
});
6363
}
6464

65-
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_set_rootweights_validate --exact --show-output --nocapture
66-
#[test]
67-
fn test_set_rootweights_validate() {
68-
// Testing the signed extension validate function
69-
// correctly filters this transaction.
70-
71-
new_test_ext(0).execute_with(|| {
72-
let dests = vec![1, 1];
73-
let weights = vec![1, 1];
74-
let netuid = NetUid::from(1);
75-
let version_key: u64 = 0;
76-
let coldkey = U256::from(0);
77-
let hotkey: U256 = U256::from(1); // Add the hotkey field
78-
assert_ne!(hotkey, coldkey); // Ensure hotkey is NOT the same as coldkey !!!
79-
let fee: u64 = 0; // FIXME: DefaultStakingFee is deprecated
80-
81-
let who = coldkey; // The coldkey signs this transaction
82-
83-
let call = RuntimeCall::SubtensorModule(SubtensorCall::set_tao_weights {
84-
netuid,
85-
dests,
86-
weights,
87-
version_key,
88-
hotkey, // Include the hotkey field
89-
});
90-
91-
// Create netuid
92-
add_network(netuid, 1, 0);
93-
// Register the hotkey
94-
SubtensorModule::append_neuron(netuid, &hotkey, 0);
95-
crate::Owner::<Test>::insert(hotkey, coldkey);
96-
97-
SubtensorModule::add_balance_to_coldkey_account(&hotkey, u64::MAX);
98-
99-
let min_stake = TaoCurrency::from(500_000_000_000);
100-
// Set the minimum stake
101-
SubtensorModule::set_stake_threshold(min_stake.into());
102-
103-
// Verify stake is less than minimum
104-
assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) < min_stake);
105-
let info: DispatchInfo =
106-
DispatchInfoOf::<<Test as frame_system::Config>::RuntimeCall>::default();
107-
108-
let extension = SubtensorTransactionExtension::<Test>::new();
109-
// Submit to the signed extension validate function
110-
let result_no_stake = extension.validate(
111-
RawOrigin::Signed(who).into(),
112-
&call.clone(),
113-
&info,
114-
10,
115-
(),
116-
&TxBaseImplication(()),
117-
TransactionSource::External,
118-
);
119-
// Should fail
120-
assert_eq!(
121-
// Should get an invalid transaction error
122-
result_no_stake.unwrap_err(),
123-
CustomTransactionError::StakeAmountTooLow.into()
124-
);
125-
126-
// Increase the stake to be equal to the minimum
127-
assert_ok!(SubtensorModule::do_add_stake(
128-
RuntimeOrigin::signed(hotkey),
129-
hotkey,
130-
netuid,
131-
min_stake + fee.into()
132-
));
133-
134-
// Verify stake is equal to minimum
135-
assert_eq!(
136-
SubtensorModule::get_total_stake_for_hotkey(&hotkey),
137-
min_stake
138-
);
139-
140-
// Submit to the signed extension validate function
141-
let result_min_stake = extension.validate(
142-
RawOrigin::Signed(who).into(),
143-
&call.clone(),
144-
&info,
145-
10,
146-
(),
147-
&TxBaseImplication(()),
148-
TransactionSource::External,
149-
);
150-
// Now the call should pass
151-
assert_ok!(result_min_stake);
152-
153-
// Try with more stake than minimum
154-
assert_ok!(SubtensorModule::do_add_stake(
155-
RuntimeOrigin::signed(hotkey),
156-
hotkey,
157-
netuid,
158-
DefaultMinStake::<Test>::get() * 10.into()
159-
));
160-
161-
// Verify stake is more than minimum
162-
assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake);
163-
164-
let result_more_stake = extension.validate(
165-
RawOrigin::Signed(who).into(),
166-
&call.clone(),
167-
&info,
168-
10,
169-
(),
170-
&TxBaseImplication(()),
171-
TransactionSource::External,
172-
);
173-
// The call should still pass
174-
assert_ok!(result_more_stake);
175-
});
176-
}
177-
17865
// 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
17966
#[test]
18067
fn test_commit_weights_dispatch_info_ok() {

pallets/subtensor/src/transaction_extension.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,6 @@ where
223223
Err(CustomTransactionError::StakeAmountTooLow.into())
224224
}
225225
}
226-
Some(Call::set_tao_weights { netuid, hotkey, .. }) => {
227-
if Self::check_weights_min_stake(hotkey, *netuid) {
228-
Ok((Default::default(), Some(who.clone()), origin))
229-
} else {
230-
Err(CustomTransactionError::StakeAmountTooLow.into())
231-
}
232-
}
233226
Some(Call::commit_crv3_weights {
234227
netuid,
235228
reveal_round,

runtime/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ impl Contains<RuntimeCall> for SafeModeWhitelistedCalls {
396396
| RuntimeCall::Timestamp(_)
397397
| RuntimeCall::SubtensorModule(
398398
pallet_subtensor::Call::set_weights { .. }
399-
| pallet_subtensor::Call::set_tao_weights { .. }
400399
| pallet_subtensor::Call::serve_axon { .. }
401400
)
402401
| RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. })
@@ -731,7 +730,6 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
731730
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::root_register { .. })
732731
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. })
733732
| RuntimeCall::Triumvirate(..)
734-
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. })
735733
| RuntimeCall::Sudo(..)
736734
),
737735
ProxyType::Triumvirate => matches!(
@@ -769,10 +767,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
769767
RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. })
770768
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::register { .. })
771769
),
772-
ProxyType::RootWeights => matches!(
773-
c,
774-
RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. })
775-
),
770+
ProxyType::RootWeights => false, // deprecated
776771
ProxyType::ChildKeys => matches!(
777772
c,
778773
RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_children { .. })

0 commit comments

Comments
 (0)