Skip to content

Commit 53f574f

Browse files
Remove tests, benchmarks and alter transaction extension.
1 parent d57ebd4 commit 53f574f

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
@@ -98,33 +98,6 @@ mod pallet_benchmarks {
9898
);
9999
}
100100

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

1283-
#[benchmark]
1284-
fn set_tao_weights() {
1285-
let netuid = NetUid::from(1);
1286-
let hotkey: T::AccountId = account("A", 0, 6);
1287-
let dests = vec![0u16];
1288-
let weights = vec![0u16];
1289-
let version: u64 = 1;
1290-
1291-
Subtensor::<T>::init_new_network(netuid, 1);
1292-
1293-
#[extrinsic_call]
1294-
_(
1295-
RawOrigin::None,
1296-
netuid,
1297-
hotkey.clone(),
1298-
dests.clone(),
1299-
weights.clone(),
1300-
version,
1301-
);
1302-
}
1303-
13041256
#[benchmark]
13051257
fn swap_hotkey() {
13061258
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
@@ -398,7 +398,6 @@ impl Contains<RuntimeCall> for SafeModeWhitelistedCalls {
398398
| RuntimeCall::Timestamp(_)
399399
| RuntimeCall::SubtensorModule(
400400
pallet_subtensor::Call::set_weights { .. }
401-
| pallet_subtensor::Call::set_tao_weights { .. }
402401
| pallet_subtensor::Call::serve_axon { .. }
403402
)
404403
| RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. })
@@ -733,7 +732,6 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
733732
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::root_register { .. })
734733
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. })
735734
| RuntimeCall::Triumvirate(..)
736-
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. })
737735
| RuntimeCall::Sudo(..)
738736
),
739737
ProxyType::Triumvirate => matches!(
@@ -771,10 +769,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
771769
RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. })
772770
| RuntimeCall::SubtensorModule(pallet_subtensor::Call::register { .. })
773771
),
774-
ProxyType::RootWeights => matches!(
775-
c,
776-
RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. })
777-
),
772+
ProxyType::RootWeights => false, // deprecated
778773
ProxyType::ChildKeys => matches!(
779774
c,
780775
RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_children { .. })

0 commit comments

Comments
 (0)