Skip to content

Commit fbefae9

Browse files
committed
fix conflict
2 parents b2385bd + 2af7993 commit fbefae9

File tree

9 files changed

+460
-55
lines changed

9 files changed

+460
-55
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ pub mod pallet {
236236
netuid,
237237
&[Hyperparameter::ServingRateLimit.into()],
238238
)?;
239+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
239240
pallet_subtensor::Pallet::<T>::set_serving_rate_limit(netuid, serving_rate_limit);
240241
log::debug!("ServingRateLimitSet( serving_rate_limit: {serving_rate_limit:?} ) ");
241242
pallet_subtensor::Pallet::<T>::record_owner_rl(
@@ -288,6 +289,7 @@ pub mod pallet {
288289
netuid,
289290
&[Hyperparameter::MaxDifficulty.into()],
290291
)?;
292+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
291293

292294
ensure!(
293295
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -322,6 +324,7 @@ pub mod pallet {
322324
netuid,
323325
&[TransactionType::SetWeightsVersionKey],
324326
)?;
327+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
325328

326329
ensure!(
327330
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -413,6 +416,7 @@ pub mod pallet {
413416
netuid,
414417
&[Hyperparameter::AdjustmentAlpha.into()],
415418
)?;
419+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
416420

417421
ensure!(
418422
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -445,6 +449,7 @@ pub mod pallet {
445449
netuid,
446450
&[Hyperparameter::ImmunityPeriod.into()],
447451
)?;
452+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
448453
ensure!(
449454
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
450455
Error::<T>::SubnetDoesNotExist
@@ -479,6 +484,7 @@ pub mod pallet {
479484
netuid,
480485
&[Hyperparameter::MinAllowedWeights.into()],
481486
)?;
487+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
482488

483489
ensure!(
484490
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -513,6 +519,7 @@ pub mod pallet {
513519
netuid,
514520
&[Hyperparameter::MaxAllowedUids.into()],
515521
)?;
522+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
516523
ensure!(
517524
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
518525
Error::<T>::SubnetDoesNotExist
@@ -572,6 +579,7 @@ pub mod pallet {
572579
netuid,
573580
&[Hyperparameter::Rho.into()],
574581
)?;
582+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
575583

576584
ensure!(
577585
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -604,6 +612,7 @@ pub mod pallet {
604612
netuid,
605613
&[Hyperparameter::ActivityCutoff.into()],
606614
)?;
615+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
607616

608617
ensure!(
609618
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -672,6 +681,7 @@ pub mod pallet {
672681
netuid,
673682
&[Hyperparameter::PowRegistrationAllowed.into()],
674683
)?;
684+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
675685

676686
pallet_subtensor::Pallet::<T>::set_network_pow_registration_allowed(
677687
netuid,
@@ -733,6 +743,7 @@ pub mod pallet {
733743
netuid,
734744
&[Hyperparameter::MinBurn.into()],
735745
)?;
746+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
736747
ensure!(
737748
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
738749
Error::<T>::SubnetDoesNotExist
@@ -773,6 +784,7 @@ pub mod pallet {
773784
netuid,
774785
&[Hyperparameter::MaxBurn.into()],
775786
)?;
787+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
776788
ensure!(
777789
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
778790
Error::<T>::SubnetDoesNotExist
@@ -868,6 +880,7 @@ pub mod pallet {
868880
netuid,
869881
&[Hyperparameter::BondsMovingAverage.into()],
870882
)?;
883+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
871884
if maybe_owner.is_some() {
872885
ensure!(
873886
bonds_moving_average <= 975000,
@@ -908,6 +921,7 @@ pub mod pallet {
908921
netuid,
909922
&[Hyperparameter::BondsPenalty.into()],
910923
)?;
924+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
911925

912926
ensure!(
913927
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -1245,6 +1259,7 @@ pub mod pallet {
12451259
netuid,
12461260
&[Hyperparameter::CommitRevealEnabled.into()],
12471261
)?;
1262+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
12481263

12491264
ensure!(
12501265
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -1288,6 +1303,7 @@ pub mod pallet {
12881303
netuid,
12891304
&[Hyperparameter::LiquidAlphaEnabled.into()],
12901305
)?;
1306+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
12911307
pallet_subtensor::Pallet::<T>::set_liquid_alpha_enabled(netuid, enabled);
12921308
log::debug!("LiquidAlphaEnableToggled( netuid: {netuid:?}, Enabled: {enabled:?} ) ");
12931309
pallet_subtensor::Pallet::<T>::record_owner_rl(
@@ -1318,6 +1334,7 @@ pub mod pallet {
13181334
netuid,
13191335
&[Hyperparameter::AlphaValues.into()],
13201336
)?;
1337+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
13211338
let res = pallet_subtensor::Pallet::<T>::do_set_alpha_values(
13221339
origin, netuid, alpha_low, alpha_high,
13231340
);
@@ -1437,6 +1454,7 @@ pub mod pallet {
14371454
netuid,
14381455
&[Hyperparameter::WeightCommitInterval.into()],
14391456
)?;
1457+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
14401458

14411459
ensure!(
14421460
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -1535,6 +1553,7 @@ pub mod pallet {
15351553
netuid,
15361554
&[Hyperparameter::TransferEnabled.into()],
15371555
)?;
1556+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
15381557
let res = pallet_subtensor::Pallet::<T>::toggle_transfer(netuid, toggle);
15391558
if res.is_ok() {
15401559
pallet_subtensor::Pallet::<T>::record_owner_rl(
@@ -1567,6 +1586,7 @@ pub mod pallet {
15671586
netuid,
15681587
&[Hyperparameter::RecycleOrBurn.into()],
15691588
)?;
1589+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
15701590

15711591
pallet_subtensor::Pallet::<T>::set_recycle_or_burn(netuid, recycle_or_burn);
15721592
pallet_subtensor::Pallet::<T>::record_owner_rl(
@@ -1734,6 +1754,7 @@ pub mod pallet {
17341754
netuid,
17351755
&[Hyperparameter::AlphaSigmoidSteepness.into()],
17361756
)?;
1757+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
17371758

17381759
ensure!(
17391760
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
@@ -1784,6 +1805,7 @@ pub mod pallet {
17841805
netuid,
17851806
&[Hyperparameter::Yuma3Enabled.into()],
17861807
)?;
1808+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
17871809
pallet_subtensor::Pallet::<T>::set_yuma3_enabled(netuid, enabled);
17881810

17891811
Self::deposit_event(Event::Yuma3EnableToggled { netuid, enabled });
@@ -1823,6 +1845,7 @@ pub mod pallet {
18231845
netuid,
18241846
&[Hyperparameter::BondsResetEnabled.into()],
18251847
)?;
1848+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
18261849
pallet_subtensor::Pallet::<T>::set_bonds_reset(netuid, enabled);
18271850

18281851
Self::deposit_event(Event::BondsResetToggled { netuid, enabled });
@@ -1948,6 +1971,7 @@ pub mod pallet {
19481971
netuid,
19491972
&[Hyperparameter::ImmuneNeuronLimit.into()],
19501973
)?;
1974+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
19511975
pallet_subtensor::Pallet::<T>::set_owner_immune_neuron_limit(netuid, immune_neurons)?;
19521976
pallet_subtensor::Pallet::<T>::record_owner_rl(
19531977
maybe_owner,
@@ -2021,6 +2045,7 @@ pub mod pallet {
20212045
netuid,
20222046
&[TransactionType::MechanismCountUpdate],
20232047
)?;
2048+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
20242049

20252050
pallet_subtensor::Pallet::<T>::do_set_mechanism_count(netuid, mechanism_count)?;
20262051

@@ -2047,6 +2072,7 @@ pub mod pallet {
20472072
netuid,
20482073
&[TransactionType::MechanismEmission],
20492074
)?;
2075+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
20502076

20512077
pallet_subtensor::Pallet::<T>::do_set_emission_split(netuid, maybe_split)?;
20522078

@@ -2077,6 +2103,7 @@ pub mod pallet {
20772103
netuid,
20782104
&[TransactionType::MaxUidsTrimming],
20792105
)?;
2106+
pallet_subtensor::Pallet::<T>::ensure_admin_window_open(netuid)?;
20802107

20812108
pallet_subtensor::Pallet::<T>::trim_to_max_allowed_uids(netuid, max_n)?;
20822109

pallets/subtensor/src/benchmarks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ mod pallet_benchmarks {
16191619
netuid,
16201620
AlphaCurrency::ZERO,
16211621
pending_root_alpha.into(),
1622+
pending_root_alpha.into(), // alpha out
16221623
AlphaCurrency::ZERO,
16231624
);
16241625

pallets/subtensor/src/coinbase/root.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ impl<T: Config> Pallet<T> {
348348
RAORecycledForRegistration::<T>::remove(netuid);
349349
MaxRegistrationsPerBlock::<T>::remove(netuid);
350350
WeightsVersionKey::<T>::remove(netuid);
351-
PendingRootAlphaDivs::<T>::remove(netuid);
352351

353352
// --- 17. Subtoken / feature flags.
354353
LiquidAlphaOn::<T>::remove(netuid);

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,21 @@ impl<T: Config> Pallet<T> {
6969
if price_i < tao_in_ratio {
7070
tao_in_i = price_i.saturating_mul(U96F32::saturating_from_num(block_emission));
7171
alpha_in_i = block_emission;
72-
let difference_tao: U96F32 = default_tao_in_i.saturating_sub(tao_in_i);
72+
let difference_tao: TaoCurrency =
73+
tou64!(default_tao_in_i.saturating_sub(tao_in_i)).into();
74+
TotalIssuance::<T>::mutate(|total| {
75+
*total = total.saturating_add(difference_tao);
76+
});
7377
// Difference becomes buy.
7478
let buy_swap_result = Self::swap_tao_for_alpha(
7579
*netuid_i,
76-
tou64!(difference_tao).into(),
80+
difference_tao,
7781
T::SwapInterface::max_price(),
7882
true,
7983
);
8084
if let Ok(buy_swap_result_ok) = buy_swap_result {
8185
let bought_alpha = AlphaCurrency::from(buy_swap_result_ok.amount_paid_out);
82-
SubnetAlphaOut::<T>::mutate(*netuid_i, |total| {
83-
*total = total.saturating_sub(bought_alpha);
84-
});
86+
Self::recycle_subnet_alpha(*netuid_i, bought_alpha);
8587
}
8688
is_subsidized.insert(*netuid_i, true);
8789
} else {
@@ -106,6 +108,7 @@ impl<T: Config> Pallet<T> {
106108
alpha_in.insert(*netuid_i, alpha_in_i);
107109
alpha_out.insert(*netuid_i, alpha_out_i);
108110
}
111+
log::debug!("is_subsidized: {is_subsidized:?}");
109112
log::debug!("tao_in: {tao_in:?}");
110113
log::debug!("alpha_in: {alpha_in:?}");
111114
log::debug!("alpha_out: {alpha_out:?}");
@@ -189,21 +192,23 @@ impl<T: Config> Pallet<T> {
189192
.unwrap_or(asfloat!(0.0));
190193
log::debug!("root_proportion: {root_proportion:?}");
191194
// Get root proportion of alpha_out dividends.
192-
let root_alpha: U96F32 = root_proportion
193-
.saturating_mul(alpha_out_i) // Total alpha emission per block remaining.
194-
.saturating_mul(asfloat!(0.5)); // 50% to validators.
195-
// Remove root alpha from alpha_out.
196-
log::debug!("root_alpha: {root_alpha:?}");
197-
// Get pending alpha as original alpha_out - root_alpha.
198-
let pending_alpha: U96F32 = alpha_out_i.saturating_sub(root_alpha);
199-
log::debug!("pending_alpha: {pending_alpha:?}");
200-
195+
let mut root_alpha: U96F32 = asfloat!(0.0);
201196
let subsidized: bool = *is_subsidized.get(netuid_i).unwrap_or(&false);
202197
if !subsidized {
198+
// Only give root alpha if not being subsidized.
199+
root_alpha = root_proportion
200+
.saturating_mul(alpha_out_i) // Total alpha emission per block remaining.
201+
.saturating_mul(asfloat!(0.5)); // 50% to validators.
203202
PendingRootAlphaDivs::<T>::mutate(*netuid_i, |total| {
204203
*total = total.saturating_add(tou64!(root_alpha).into());
205204
});
206205
}
206+
// Remove root alpha from alpha_out.
207+
log::debug!("root_alpha: {root_alpha:?}");
208+
209+
// Get pending alpha as original alpha_out - root_alpha.
210+
let pending_alpha: U96F32 = alpha_out_i.saturating_sub(root_alpha);
211+
log::debug!("pending_alpha: {pending_alpha:?}");
207212

208213
// Accumulate alpha emission in pending.
209214
PendingEmission::<T>::mutate(*netuid_i, |total| {
@@ -246,7 +251,13 @@ impl<T: Config> Pallet<T> {
246251
PendingOwnerCut::<T>::insert(netuid, AlphaCurrency::ZERO);
247252

248253
// Drain pending root alpha divs, alpha emission, and owner cut.
249-
Self::drain_pending_emission(netuid, pending_alpha, pending_root_alpha, owner_cut);
254+
Self::drain_pending_emission(
255+
netuid,
256+
pending_alpha,
257+
pending_root_alpha,
258+
pending_alpha.saturating_add(pending_root_alpha),
259+
owner_cut,
260+
);
250261
} else {
251262
// Increment
252263
BlocksSinceLastStep::<T>::mutate(netuid, |total| *total = total.saturating_add(1));
@@ -482,6 +493,7 @@ impl<T: Config> Pallet<T> {
482493
let destination = maybe_dest.clone().unwrap_or(hotkey.clone());
483494

484495
if let Some(dest) = maybe_dest {
496+
log::debug!("incentives: auto staking {incentive:?} to {dest:?}");
485497
Self::deposit_event(Event::<T>::AutoStakeAdded {
486498
netuid,
487499
destination: dest,
@@ -490,6 +502,9 @@ impl<T: Config> Pallet<T> {
490502
incentive,
491503
});
492504
}
505+
log::debug!(
506+
"incentives: increasing stake for {hotkey:?} to {incentive:?} with owner {owner:?}"
507+
);
493508
Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
494509
&destination,
495510
&owner,
@@ -604,6 +619,7 @@ impl<T: Config> Pallet<T> {
604619
netuid: NetUid,
605620
pending_alpha: AlphaCurrency,
606621
pending_root_alpha: AlphaCurrency,
622+
total_alpha: AlphaCurrency,
607623
owner_cut: AlphaCurrency,
608624
) {
609625
log::debug!(
@@ -614,7 +630,7 @@ impl<T: Config> Pallet<T> {
614630

615631
// Run the epoch.
616632
let hotkey_emission: Vec<(T::AccountId, AlphaCurrency, AlphaCurrency)> =
617-
Self::epoch_with_mechanisms(netuid, pending_alpha.saturating_add(pending_root_alpha));
633+
Self::epoch_with_mechanisms(netuid, total_alpha);
618634
log::debug!("hotkey_emission: {hotkey_emission:?}");
619635

620636
// Compute the pending validator alpha.
@@ -630,8 +646,7 @@ impl<T: Config> Pallet<T> {
630646
log::debug!("incentive_sum: {incentive_sum:?}");
631647

632648
let pending_validator_alpha = if !incentive_sum.is_zero() {
633-
pending_alpha
634-
.saturating_add(pending_root_alpha)
649+
total_alpha
635650
.saturating_div(2.into())
636651
.saturating_sub(pending_root_alpha)
637652
} else {

0 commit comments

Comments
 (0)