Skip to content

Commit fe70e19

Browse files
committed
Merge branch 'devnet-ready' into kappa-sudo-only
2 parents e6e7b8a + 4a01966 commit fe70e19

File tree

31 files changed

+81
-369
lines changed

31 files changed

+81
-369
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/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ pub mod block_step;
44
pub mod reveal_commits;
55
pub mod root;
66
pub mod run_coinbase;
7+
pub mod subnet_emissions;

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/coinbase/run_coinbase.rs

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,10 @@ impl<T: Config> Pallet<T> {
3030
.filter(|netuid| *netuid != NetUid::ROOT)
3131
.collect();
3232
log::debug!("All subnet netuids: {subnets:?}");
33-
// Filter out subnets with no first emission block number.
34-
let subnets_to_emit_to: Vec<NetUid> = subnets
35-
.clone()
36-
.into_iter()
37-
.filter(|netuid| FirstEmissionBlockNumber::<T>::get(*netuid).is_some())
38-
.collect();
39-
log::debug!("Subnets to emit to: {subnets_to_emit_to:?}");
4033

41-
// --- 2. Get sum of tao reserves ( in a later version we will switch to prices. )
42-
let mut acc_total_moving_prices = U96F32::saturating_from_num(0.0);
43-
// Only get price EMA for subnets that we emit to.
44-
for netuid_i in subnets_to_emit_to.iter() {
45-
// Get and update the moving price of each subnet adding the total together.
46-
acc_total_moving_prices =
47-
acc_total_moving_prices.saturating_add(Self::get_moving_alpha_price(*netuid_i));
48-
}
49-
let total_moving_prices = acc_total_moving_prices;
50-
log::debug!("total_moving_prices: {total_moving_prices:?}");
34+
// 2. Get subnets to emit to and emissions
35+
let subnet_emissions = Self::get_subnet_block_emissions(&subnets, block_emission);
36+
let subnets_to_emit_to: Vec<NetUid> = subnet_emissions.keys().copied().collect();
5137

5238
// --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out)
5339
// Computation is described in detail in the dtao whitepaper.
@@ -60,14 +46,11 @@ impl<T: Config> Pallet<T> {
6046
// Get subnet price.
6147
let price_i = T::SwapInterface::current_alpha_price((*netuid_i).into());
6248
log::debug!("price_i: {price_i:?}");
63-
// Get subnet TAO.
64-
let moving_price_i: U96F32 = Self::get_moving_alpha_price(*netuid_i);
65-
log::debug!("moving_price_i: {moving_price_i:?}");
6649
// Emission is price over total.
67-
let default_tao_in_i: U96F32 = block_emission
68-
.saturating_mul(moving_price_i)
69-
.checked_div(total_moving_prices)
70-
.unwrap_or(asfloat!(0.0));
50+
let default_tao_in_i: U96F32 = subnet_emissions
51+
.get(netuid_i)
52+
.copied()
53+
.unwrap_or(asfloat!(0));
7154
log::debug!("default_tao_in_i: {default_tao_in_i:?}");
7255
// Get alpha_emission total
7356
let alpha_emission_i: U96F32 = asfloat!(

0 commit comments

Comments
 (0)