Skip to content

Commit d39a6ea

Browse files
committed
Reformat
1 parent a7fffd8 commit d39a6ea

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

pallets/subtensor/src/macros/hooks.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ use frame_support::pallet_macros::pallet_section;
44
/// This can later be imported into the pallet using [`import_section`].
55
#[pallet_section]
66
mod hooks {
7-
#[cfg(feature = "try-runtime")]
8-
use crate::utils::try_state::TryState;
9-
107
// ================
118
// ==== Hooks =====
129
// ================
@@ -85,9 +82,9 @@ mod hooks {
8582

8683
#[cfg(feature = "try-runtime")]
8784
fn try_state(_n: BlockNumberFor<T>) -> Result<(), sp_runtime::TryRuntimeError> {
88-
TryState::<T>::check_total_issuance()?;
89-
// Disabled: https://github.com/opentensor/subtensor/pull/1166
90-
// TryState::<T>::check_total_stake()?;
85+
Self::check_total_issuance()?;
86+
// Disabled: https://github.com/opentensor/subtensor/pull/1166
87+
// Self::check_total_stake()?;
9188
Ok(())
9289
}
9390
}

pallets/subtensor/src/migrations/migrate_init_total_issuance.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ pub mod initialise_total_issuance {
5555
use frame_support::pallet_prelude::Weight;
5656
use frame_support::traits::OnRuntimeUpgrade;
5757

58-
#[cfg(feature = "try-runtime")]
59-
use crate::utils::try_state::TryState;
6058
use crate::*;
6159

6260
pub struct Migration<T: Config>(PhantomData<T>);
@@ -80,7 +78,7 @@ pub mod initialise_total_issuance {
8078
#[cfg(feature = "try-runtime")]
8179
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
8280
// Verify that all accounting invariants are satisfied after the migration
83-
TryState::<T>::check_total_issuance()?;
81+
crate::Pallet::<T>::check_total_issuance()?;
8482
Ok(())
8583
}
8684
}

pallets/subtensor/src/utils/try_state.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
use core::marker::PhantomData;
2-
use frame_support::traits::fungible::Inspect;
1+
use frame_support::traits::fungible::Inspect;
32

4-
use crate::subnets::subnet::POOL_INITIAL_TAO;
53
use super::*;
4+
use crate::subnets::subnet::POOL_INITIAL_TAO;
65

7-
pub(crate) struct TryState<T: Config>(PhantomData<T>);
8-
9-
impl<T: Config> TryState<T> {
10-
/// Checks [`TotalIssuance`] equals the sum of currency issuance, total stake, and total subnet
11-
/// locked.
6+
impl<T: Config> Pallet<T> {
7+
/// Checks [`TotalIssuance`] equals the sum of currency issuance, total stake, and total subnet
8+
/// locked.
129
pub(crate) fn check_total_issuance() -> Result<(), sp_runtime::TryRuntimeError> {
1310
// Get the total subnet locked amount
14-
let total_subnet_locked = Pallet::<T>::get_total_subnet_locked();
11+
let total_subnet_locked = Self::get_total_subnet_locked();
1512

1613
// Get the total currency issuance
1714
let currency_issuance = T::Currency::total_issuance();
@@ -40,31 +37,36 @@ impl<T: Config> TryState<T> {
4037
"TotalIssuance diff greater than allowable delta",
4138
);
4239

43-
Ok(())
40+
Ok(())
4441
}
4542

46-
/// Checks the sum of all stakes matches the [`TotalStake`].
43+
/// Checks the sum of all stakes matches the [`TotalStake`].
44+
#[allow(dead_code)]
4745
pub(crate) fn check_total_stake() -> Result<(), sp_runtime::TryRuntimeError> {
4846
// Calculate the total staked amount
4947
let total_staked = SubnetTAO::<T>::iter().fold(0u64, |acc, (netuid, stake)| {
5048
let acc = acc.saturating_add(stake);
5149

52-
if netuid == Pallet::<T>::get_root_netuid() {
50+
if netuid == Self::get_root_netuid() {
5351
// root network doesn't have initial pool TAO
5452
acc
5553
} else {
5654
acc.saturating_sub(POOL_INITIAL_TAO)
5755
}
5856
});
5957

60-
log::warn!("total_staked: {}, TotalStake: {}", total_staked, TotalStake::<T>::get());
58+
log::warn!(
59+
"total_staked: {}, TotalStake: {}",
60+
total_staked,
61+
TotalStake::<T>::get()
62+
);
6163

6264
// Verify that the calculated total stake matches the stored TotalStake
6365
ensure!(
6466
total_staked == TotalStake::<T>::get(),
6567
"TotalStake does not match total staked",
6668
);
6769

68-
Ok(())
69-
}
70+
Ok(())
71+
}
7072
}

scripts/try-runtime-upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ do_try_runtime() {
4949
fi
5050

5151
eval "try-runtime --runtime $runtime_wasm_path on-runtime-upgrade \
52-
--disable-spec-version-check --disable-idempotency-checks --checks=all \
52+
--no-weight-warnings --disable-spec-version-check --disable-idempotency-checks --checks=all \
5353
$chain_state"
5454
}
5555

0 commit comments

Comments
 (0)