Skip to content

Commit 249fa62

Browse files
authored
Merge pull request #2141 from opentensor/disable-max-weight-limit
Remove hyperparameter max_weight_limit
2 parents 4b5be6c + 23e1bf9 commit 249fa62

File tree

28 files changed

+28
-345
lines changed

28 files changed

+28
-345
lines changed

evm-tests/src/contracts/subnet.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -663,24 +663,6 @@ export const ISubnetABI = [
663663
stateMutability: "payable",
664664
type: "function",
665665
},
666-
{
667-
inputs: [
668-
{
669-
internalType: "uint16",
670-
name: "netuid",
671-
type: "uint16",
672-
},
673-
{
674-
internalType: "uint16",
675-
name: "maxWeightLimit",
676-
type: "uint16",
677-
},
678-
],
679-
name: "setMaxWeightLimit",
680-
outputs: [],
681-
stateMutability: "payable",
682-
type: "function",
683-
},
684666
{
685667
inputs: [
686668
{

evm-tests/test/subnet.precompile.hyperparameter.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,17 @@ describe("Test the Subnet precompile contract", () => {
208208
assert.equal(valueFromContract, onchainValue);
209209
})
210210

211-
it("Can set maxWeightLimit parameter", async () => {
211+
it("Returns constant maxWeightLimit", async () => {
212212

213213
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
214214
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
215215
const netuid = totalNetwork - 1;
216216

217-
const newValue = 106;
218-
const tx = await contract.setMaxWeightLimit(netuid, newValue);
219-
await tx.wait();
220-
221-
let onchainValue = await api.query.SubtensorModule.MaxWeightsLimit.getValue(netuid)
222-
223-
224-
let valueFromContract = Number(
217+
const valueFromContract = Number(
225218
await contract.getMaxWeightLimit(netuid)
226219
);
227220

228-
assert.equal(valueFromContract, newValue)
229-
assert.equal(valueFromContract, onchainValue);
221+
assert.equal(valueFromContract, 0xFFFF)
230222
})
231223

232224
it("Can set immunityPeriod parameter", async () => {

hyperparameters.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
```rust
33
DefaultTake: u16 = 11_796; // 18% honest number.
44
TxRateLimit: u64 = 1; // [1 @ 64,888]
5+
MaxWeightsLimit: u16 = u16::MAX; // constant limit
56
```
67

78
### netuid 1 (text_prompting)
@@ -13,7 +14,6 @@ MaxAllowedUids: u16 = 1024;
1314
Issuance: u64 = 0;
1415
MinAllowedWeights: u16 = 8;
1516
EmissionValue: u64 = 142_223_000;
16-
MaxWeightsLimit: 455; // 455/2^16 = 0.0069
1717
ValidatorBatchSize: u16 = 1;
1818
ValidatorSequenceLen: u16 = 2048; // 2048
1919
ValidatorEpochLen: u16 = 100;
@@ -54,7 +54,6 @@ MaxAllowedUids: u16 = 4096;
5454
Issuance: u64 = 0;
5555
MinAllowedWeights: u16 = 50;
5656
EmissionValue: u64 = 857_777_000;
57-
MaxWeightsLimit: u16 = 655; // 655/2^16 = 0.01 [655 @ 7,160]
5857
ValidatorBatchSize: u16 = 32; // 32
5958
ValidatorSequenceLen: u16 = 256; // 256
6059
ValidatorEpochLen: u16 = 250; // [250 @ 7,161]

pallets/admin-utils/src/benchmarking.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,6 @@ mod benchmarks {
292292
_(RawOrigin::Root, 1u16.into()/*netuid*/, 100u16/*immunity_period*/)/*sudo_set_immunity_period*/;
293293
}
294294

295-
#[benchmark]
296-
fn sudo_set_max_weight_limit() {
297-
// disable admin freeze window
298-
pallet_subtensor::Pallet::<T>::set_admin_freeze_window(0);
299-
pallet_subtensor::Pallet::<T>::init_new_network(
300-
1u16.into(), /*netuid*/
301-
1u16, /*tempo*/
302-
);
303-
304-
#[extrinsic_call]
305-
_(RawOrigin::Root, 1u16.into()/*netuid*/, 100u16/*max_weight_limit*/)/*sudo_set_max_weight_limit*/;
306-
}
307-
308295
#[benchmark]
309296
fn sudo_set_max_registrations_per_block() {
310297
// disable admin freeze window

pallets/admin-utils/src/lib.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -426,40 +426,6 @@ pub mod pallet {
426426
Ok(())
427427
}
428428

429-
/// The extrinsic sets the adjustment beta for a subnet.
430-
/// It is only callable by the root account or subnet owner.
431-
/// The extrinsic will call the Subtensor pallet to set the adjustment beta.
432-
#[pallet::call_index(12)]
433-
#[pallet::weight(Weight::from_parts(26_890_000, 0)
434-
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(3_u64))
435-
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
436-
pub fn sudo_set_max_weight_limit(
437-
origin: OriginFor<T>,
438-
netuid: NetUid,
439-
max_weight_limit: u16,
440-
) -> DispatchResult {
441-
let maybe_owner = pallet_subtensor::Pallet::<T>::ensure_sn_owner_or_root_with_limits(
442-
origin,
443-
netuid,
444-
&[Hyperparameter::MaxWeightLimit.into()],
445-
)?;
446-
447-
ensure!(
448-
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
449-
Error::<T>::SubnetDoesNotExist
450-
);
451-
pallet_subtensor::Pallet::<T>::set_max_weight_limit(netuid, max_weight_limit);
452-
pallet_subtensor::Pallet::<T>::record_owner_rl(
453-
maybe_owner,
454-
netuid,
455-
&[Hyperparameter::MaxWeightLimit.into()],
456-
);
457-
log::debug!(
458-
"MaxWeightLimitSet( netuid: {netuid:?} max_weight_limit: {max_weight_limit:?} ) "
459-
);
460-
Ok(())
461-
}
462-
463429
/// The extrinsic sets the immunity period for a subnet.
464430
/// It is only callable by the root account or subnet owner.
465431
/// The extrinsic will call the Subtensor pallet to set the immunity period.

pallets/admin-utils/src/tests/mock.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ pub type UncheckedExtrinsic = TestXt<RuntimeCall, ()>;
7777
parameter_types! {
7878
pub const InitialMinAllowedWeights: u16 = 0;
7979
pub const InitialEmissionValue: u16 = 0;
80-
pub const InitialMaxWeightsLimit: u16 = u16::MAX;
8180
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::with_sensible_defaults(
8281
Weight::from_parts(2_000_000_000_000, u64::MAX),
8382
Perbill::from_percent(75),
@@ -162,7 +161,6 @@ impl pallet_subtensor::Config for Test {
162161
type Scheduler = Scheduler;
163162
type InitialMinAllowedWeights = InitialMinAllowedWeights;
164163
type InitialEmissionValue = InitialEmissionValue;
165-
type InitialMaxWeightsLimit = InitialMaxWeightsLimit;
166164
type InitialTempo = InitialTempo;
167165
type InitialDifficulty = InitialDifficulty;
168166
type InitialAdjustmentInterval = InitialAdjustmentInterval;

pallets/admin-utils/src/tests/mod.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -391,39 +391,6 @@ fn test_sudo_subnet_owner_cut() {
391391
});
392392
}
393393

394-
#[test]
395-
fn test_sudo_set_max_weight_limit() {
396-
new_test_ext().execute_with(|| {
397-
let netuid = NetUid::from(1);
398-
let to_be_set: u16 = 10;
399-
add_network(netuid, 10);
400-
let init_value: u16 = SubtensorModule::get_max_weight_limit(netuid);
401-
assert_eq!(
402-
AdminUtils::sudo_set_max_weight_limit(
403-
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
404-
netuid,
405-
to_be_set
406-
),
407-
Err(DispatchError::BadOrigin)
408-
);
409-
assert_eq!(
410-
AdminUtils::sudo_set_max_weight_limit(
411-
<<Test as Config>::RuntimeOrigin>::root(),
412-
netuid.next(),
413-
to_be_set
414-
),
415-
Err(Error::<Test>::SubnetDoesNotExist.into())
416-
);
417-
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), init_value);
418-
assert_ok!(AdminUtils::sudo_set_max_weight_limit(
419-
<<Test as Config>::RuntimeOrigin>::root(),
420-
netuid,
421-
to_be_set
422-
));
423-
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), to_be_set);
424-
});
425-
}
426-
427394
#[test]
428395
fn test_sudo_set_issuance() {
429396
new_test_ext().execute_with(|| {

pallets/subtensor/src/coinbase/root.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ impl<T: Config> Pallet<T> {
284284
MaxAllowedUids::<T>::remove(netuid);
285285
ImmunityPeriod::<T>::remove(netuid);
286286
ActivityCutoff::<T>::remove(netuid);
287-
MaxWeightsLimit::<T>::remove(netuid);
288287
MinAllowedWeights::<T>::remove(netuid);
289288
RegistrationsThisInterval::<T>::remove(netuid);
290289
POWRegistrationsThisInterval::<T>::remove(netuid);

pallets/subtensor/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,6 @@ pub mod pallet {
650650
T::InitialActivityCutoff::get()
651651
}
652652
#[pallet::type_value]
653-
/// Default maximum weights limit.
654-
pub fn DefaultMaxWeightsLimit<T: Config>() -> u16 {
655-
T::InitialMaxWeightsLimit::get()
656-
}
657-
#[pallet::type_value]
658653
/// Default weights version key.
659654
pub fn DefaultWeightsVersionKey<T: Config>() -> u64 {
660655
T::InitialWeightsVersionKey::get()
@@ -1402,6 +1397,11 @@ pub mod pallet {
14021397
/// --- MAP ( netuid ) --> activity_cutoff
14031398
pub type ActivityCutoff<T> =
14041399
StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultActivityCutoff<T>>;
1400+
#[pallet::type_value]
1401+
/// Default maximum weights limit.
1402+
pub fn DefaultMaxWeightsLimit<T: Config>() -> u16 {
1403+
u16::MAX
1404+
}
14051405
#[pallet::storage]
14061406
/// --- MAP ( netuid ) --> max_weight_limit
14071407
pub type MaxWeightsLimit<T> =

pallets/subtensor/src/macros/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ mod config {
7272
/// Initial Emission Ratio.
7373
#[pallet::constant]
7474
type InitialEmissionValue: Get<u16>;
75-
/// Initial max weight limit.
76-
#[pallet::constant]
77-
type InitialMaxWeightsLimit: Get<u16>;
7875
/// Tempo for each network.
7976
#[pallet::constant]
8077
type InitialTempo: Get<u16>;

0 commit comments

Comments
 (0)