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
18 changes: 0 additions & 18 deletions evm-tests/src/contracts/subnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,24 +663,6 @@ export const ISubnetABI = [
stateMutability: "payable",
type: "function",
},
{
inputs: [
{
internalType: "uint16",
name: "netuid",
type: "uint16",
},
{
internalType: "uint16",
name: "maxWeightLimit",
type: "uint16",
},
],
name: "setMaxWeightLimit",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{
Expand Down
14 changes: 3 additions & 11 deletions evm-tests/test/subnet.precompile.hyperparameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,17 @@ describe("Test the Subnet precompile contract", () => {
assert.equal(valueFromContract, onchainValue);
})

it("Can set maxWeightLimit parameter", async () => {
it("Returns constant maxWeightLimit", async () => {

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

const newValue = 106;
const tx = await contract.setMaxWeightLimit(netuid, newValue);
await tx.wait();

let onchainValue = await api.query.SubtensorModule.MaxWeightsLimit.getValue(netuid)


let valueFromContract = Number(
const valueFromContract = Number(
await contract.getMaxWeightLimit(netuid)
);

assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
assert.equal(valueFromContract, 0xFFFF)
})

it("Can set immunityPeriod parameter", async () => {
Expand Down
3 changes: 1 addition & 2 deletions hyperparameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
```rust
DefaultTake: u16 = 11_796; // 18% honest number.
TxRateLimit: u64 = 1; // [1 @ 64,888]
MaxWeightsLimit: u16 = u16::MAX; // constant limit
```

### netuid 1 (text_prompting)
Expand All @@ -13,7 +14,6 @@ MaxAllowedUids: u16 = 1024;
Issuance: u64 = 0;
MinAllowedWeights: u16 = 8;
EmissionValue: u64 = 142_223_000;
MaxWeightsLimit: 455; // 455/2^16 = 0.0069
ValidatorBatchSize: u16 = 1;
ValidatorSequenceLen: u16 = 2048; // 2048
ValidatorEpochLen: u16 = 100;
Expand Down Expand Up @@ -54,7 +54,6 @@ MaxAllowedUids: u16 = 4096;
Issuance: u64 = 0;
MinAllowedWeights: u16 = 50;
EmissionValue: u64 = 857_777_000;
MaxWeightsLimit: u16 = 655; // 655/2^16 = 0.01 [655 @ 7,160]
ValidatorBatchSize: u16 = 32; // 32
ValidatorSequenceLen: u16 = 256; // 256
ValidatorEpochLen: u16 = 250; // [250 @ 7,161]
Expand Down
13 changes: 0 additions & 13 deletions pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,6 @@ mod benchmarks {
_(RawOrigin::Root, 1u16.into()/*netuid*/, 100u16/*immunity_period*/)/*sudo_set_immunity_period*/;
}

#[benchmark]
fn sudo_set_max_weight_limit() {
// disable admin freeze window
pallet_subtensor::Pallet::<T>::set_admin_freeze_window(0);
pallet_subtensor::Pallet::<T>::init_new_network(
1u16.into(), /*netuid*/
1u16, /*tempo*/
);

#[extrinsic_call]
_(RawOrigin::Root, 1u16.into()/*netuid*/, 100u16/*max_weight_limit*/)/*sudo_set_max_weight_limit*/;
}

#[benchmark]
fn sudo_set_max_registrations_per_block() {
// disable admin freeze window
Expand Down
34 changes: 0 additions & 34 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,40 +426,6 @@ pub mod pallet {
Ok(())
}

/// The extrinsic sets the adjustment beta for a subnet.
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the adjustment beta.
#[pallet::call_index(12)]
#[pallet::weight(Weight::from_parts(26_890_000, 0)
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(3_u64))
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
pub fn sudo_set_max_weight_limit(
origin: OriginFor<T>,
netuid: NetUid,
max_weight_limit: u16,
) -> DispatchResult {
let maybe_owner = pallet_subtensor::Pallet::<T>::ensure_sn_owner_or_root_with_limits(
origin,
netuid,
&[Hyperparameter::MaxWeightLimit.into()],
)?;

ensure!(
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
Error::<T>::SubnetDoesNotExist
);
pallet_subtensor::Pallet::<T>::set_max_weight_limit(netuid, max_weight_limit);
pallet_subtensor::Pallet::<T>::record_owner_rl(
maybe_owner,
netuid,
&[Hyperparameter::MaxWeightLimit.into()],
);
log::debug!(
"MaxWeightLimitSet( netuid: {netuid:?} max_weight_limit: {max_weight_limit:?} ) "
);
Ok(())
}

/// The extrinsic sets the immunity period for a subnet.
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the immunity period.
Expand Down
2 changes: 0 additions & 2 deletions pallets/admin-utils/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub type UncheckedExtrinsic = TestXt<RuntimeCall, ()>;
parameter_types! {
pub const InitialMinAllowedWeights: u16 = 0;
pub const InitialEmissionValue: u16 = 0;
pub const InitialMaxWeightsLimit: u16 = u16::MAX;
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::with_sensible_defaults(
Weight::from_parts(2_000_000_000_000, u64::MAX),
Perbill::from_percent(75),
Expand Down Expand Up @@ -162,7 +161,6 @@ impl pallet_subtensor::Config for Test {
type Scheduler = Scheduler;
type InitialMinAllowedWeights = InitialMinAllowedWeights;
type InitialEmissionValue = InitialEmissionValue;
type InitialMaxWeightsLimit = InitialMaxWeightsLimit;
type InitialTempo = InitialTempo;
type InitialDifficulty = InitialDifficulty;
type InitialAdjustmentInterval = InitialAdjustmentInterval;
Expand Down
33 changes: 0 additions & 33 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,39 +391,6 @@ fn test_sudo_subnet_owner_cut() {
});
}

#[test]
fn test_sudo_set_max_weight_limit() {
new_test_ext().execute_with(|| {
let netuid = NetUid::from(1);
let to_be_set: u16 = 10;
add_network(netuid, 10);
let init_value: u16 = SubtensorModule::get_max_weight_limit(netuid);
assert_eq!(
AdminUtils::sudo_set_max_weight_limit(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
netuid,
to_be_set
),
Err(DispatchError::BadOrigin)
);
assert_eq!(
AdminUtils::sudo_set_max_weight_limit(
<<Test as Config>::RuntimeOrigin>::root(),
netuid.next(),
to_be_set
),
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_max_weight_limit(
<<Test as Config>::RuntimeOrigin>::root(),
netuid,
to_be_set
));
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), to_be_set);
});
}

#[test]
fn test_sudo_set_issuance() {
new_test_ext().execute_with(|| {
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/src/coinbase/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ impl<T: Config> Pallet<T> {
MaxAllowedUids::<T>::remove(netuid);
ImmunityPeriod::<T>::remove(netuid);
ActivityCutoff::<T>::remove(netuid);
MaxWeightsLimit::<T>::remove(netuid);
MinAllowedWeights::<T>::remove(netuid);
RegistrationsThisInterval::<T>::remove(netuid);
POWRegistrationsThisInterval::<T>::remove(netuid);
Expand Down
10 changes: 5 additions & 5 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,6 @@ pub mod pallet {
T::InitialActivityCutoff::get()
}
#[pallet::type_value]
/// Default maximum weights limit.
pub fn DefaultMaxWeightsLimit<T: Config>() -> u16 {
T::InitialMaxWeightsLimit::get()
}
#[pallet::type_value]
/// Default weights version key.
pub fn DefaultWeightsVersionKey<T: Config>() -> u64 {
T::InitialWeightsVersionKey::get()
Expand Down Expand Up @@ -1402,6 +1397,11 @@ pub mod pallet {
/// --- MAP ( netuid ) --> activity_cutoff
pub type ActivityCutoff<T> =
StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultActivityCutoff<T>>;
#[pallet::type_value]
/// Default maximum weights limit.
pub fn DefaultMaxWeightsLimit<T: Config>() -> u16 {
u16::MAX
}
#[pallet::storage]
/// --- MAP ( netuid ) --> max_weight_limit
pub type MaxWeightsLimit<T> =
Expand Down
3 changes: 0 additions & 3 deletions pallets/subtensor/src/macros/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ mod config {
/// Initial Emission Ratio.
#[pallet::constant]
type InitialEmissionValue: Get<u16>;
/// Initial max weight limit.
#[pallet::constant]
type InitialMaxWeightsLimit: Get<u16>;
/// Tempo for each network.
#[pallet::constant]
type InitialTempo: Get<u16>;
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/macros/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod errors {
/// The supplied PoW hash seal does not match the supplied work.
InvalidSeal,
/// The dispatch is attempting to set weights on chain with weight value exceeding the
/// MaxWeightLimit (max_weight_limit subnet hyperparameter).
/// configured max weight limit (currently `u16::MAX`).
MaxWeightExceeded,
/// The hotkey is attempting to become a delegate when the hotkey is already a delegate.
HotKeyAlreadyDelegate,
Expand Down
3 changes: 2 additions & 1 deletion pallets/subtensor/src/macros/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ mod events {
BulkBalancesSet(u16, u16),
/// max allowed uids has been set for a subnetwork.
MaxAllowedUidsSet(NetUid, u16),
/// the max weight limit has been set for a subnetwork.
#[deprecated(note = "Max weight limit is now a constant and this event is unused")]
/// DEPRECATED: max weight limit updates are no longer supported.
MaxWeightLimitSet(NetUid, u16),
/// the difficulty has been set for a subnet.
DifficultySet(NetUid, u64),
Expand Down
4 changes: 0 additions & 4 deletions pallets/subtensor/src/macros/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ mod genesis {
// Set the min allowed weights to zero, no weights restrictions.
MinAllowedWeights::<T>::insert(NetUid::ROOT, 0);

// Set the max weight limit to infitiy, no weight restrictions.
MaxWeightsLimit::<T>::insert(NetUid::ROOT, u16::MAX);

// Add default root tempo.
Tempo::<T>::insert(NetUid::ROOT, 100);

Expand Down Expand Up @@ -59,7 +56,6 @@ mod genesis {
MaxAllowedUids::<T>::insert(netuid, 256u16);
MaxAllowedValidators::<T>::insert(netuid, 64u16);
MinAllowedWeights::<T>::insert(netuid, 0);
MaxWeightsLimit::<T>::insert(netuid, u16::MAX);
Tempo::<T>::insert(netuid, 100);
NetworkRegistrationAllowed::<T>::insert(netuid, true);
SubnetOwner::<T>::insert(netuid, hotkey.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ pub fn migrate_create_root_network<T: Config>() -> Weight {
// Set the minimum allowed weights to zero (no weight restrictions)
MinAllowedWeights::<T>::insert(NetUid::ROOT, 0);

// Set the maximum weight limit to u16::MAX (no weight restrictions)
MaxWeightsLimit::<T>::insert(NetUid::ROOT, u16::MAX);

// Set default root tempo
Tempo::<T>::insert(NetUid::ROOT, 100);

Expand All @@ -80,7 +77,7 @@ pub fn migrate_create_root_network<T: Config>() -> Weight {
// WeightsSetRateLimit::<T>::insert(NetUid::ROOT, 7200);

// Accrue weight for database writes
weight.saturating_accrue(T::DbWeight::get().writes(8));
weight.saturating_accrue(T::DbWeight::get().writes(7));

// Remove all existing triumvirate votes and senate members
remove_prefix::<T>("Triumvirate", "Votes", &mut weight);
Expand Down
3 changes: 1 addition & 2 deletions pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@ pub fn migrate_delete_subnet_21<T: Config>() -> Weight {
MaxAllowedUids::<T>::remove(netuid);
ImmunityPeriod::<T>::remove(netuid);
ActivityCutoff::<T>::remove(netuid);
MaxWeightsLimit::<T>::remove(netuid);
MinAllowedWeights::<T>::remove(netuid);
RegistrationsThisInterval::<T>::remove(netuid);
POWRegistrationsThisInterval::<T>::remove(netuid);
BurnRegistrationsThisInterval::<T>::remove(netuid);

weight.saturating_accrue(T::DbWeight::get().writes(12));
weight.saturating_accrue(T::DbWeight::get().writes(10));

// Update storage version
StorageVersion::new(new_storage_version).put::<Pallet<T>>();
Expand Down
3 changes: 1 addition & 2 deletions pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ pub fn migrate_delete_subnet_3<T: Config>() -> Weight {
MaxAllowedUids::<T>::remove(netuid);
ImmunityPeriod::<T>::remove(netuid);
ActivityCutoff::<T>::remove(netuid);
MaxWeightsLimit::<T>::remove(netuid);
MinAllowedWeights::<T>::remove(netuid);
RegistrationsThisInterval::<T>::remove(netuid);
POWRegistrationsThisInterval::<T>::remove(netuid);
BurnRegistrationsThisInterval::<T>::remove(netuid);

weight.saturating_accrue(T::DbWeight::get().writes(12));
weight.saturating_accrue(T::DbWeight::get().writes(10));

// Update storage version
StorageVersion::new(new_storage_version).put::<Pallet<T>>();
Expand Down
4 changes: 0 additions & 4 deletions pallets/subtensor/src/subnets/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ impl<T: Config> Pallet<T> {
Self::set_max_allowed_uids(netuid, 256);
Self::set_max_allowed_validators(netuid, 64);
Self::set_min_allowed_weights(netuid, 1);
Self::set_max_weight_limit(netuid, u16::MAX);
Self::set_adjustment_interval(netuid, 360);
Self::set_target_registrations_per_interval(netuid, 1);
Self::set_adjustment_alpha(netuid, 17_893_341_751_498_265_066); // 18_446_744_073_709_551_615 * 0.97 = 17_893_341_751_498_265_066
Expand All @@ -302,9 +301,6 @@ impl<T: Config> Pallet<T> {
if !ActivityCutoff::<T>::contains_key(netuid) {
ActivityCutoff::<T>::insert(netuid, ActivityCutoff::<T>::get(netuid));
}
if !MaxWeightsLimit::<T>::contains_key(netuid) {
MaxWeightsLimit::<T>::insert(netuid, MaxWeightsLimit::<T>::get(netuid));
}
if !MinAllowedWeights::<T>::contains_key(netuid) {
MinAllowedWeights::<T>::insert(netuid, MinAllowedWeights::<T>::get(netuid));
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/subtensor/src/subnets/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,14 +1203,14 @@ impl<T: Config> Pallet<T> {
weights
}

/// Returns False if the weights exceed the max_weight_limit for this network.
/// Returns False if the weights exceed the configured max weight limit for this network.
pub fn max_weight_limited(netuid: NetUid, uid: u16, uids: &[u16], weights: &[u16]) -> bool {
// Allow self weights to exceed max weight limit.
if Self::is_self_weight(uid, uids, weights) {
return true;
}

// If the max weight limit it u16 max, return true.
// If the max weight limit it u16 max, return true (current constant).
let max_weight_limit: u16 = Self::get_max_weight_limit(netuid);
if max_weight_limit == u16::MAX {
return true;
Expand Down
Loading
Loading