Skip to content

Commit 645689d

Browse files
committed
Double-size SubnetVolume to u128
1 parent ccf6b68 commit 645689d

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ pub mod pallet {
234234
}
235235
#[pallet::type_value]
236236
/// Default value for zero.
237+
pub fn DefaultZeroU128<T: Config>() -> u128 {
238+
0
239+
}
240+
#[pallet::type_value]
241+
/// Default value for zero.
237242
pub fn DefaultZeroU16<T: Config>() -> u16 {
238243
0
239244
}
@@ -907,7 +912,7 @@ pub mod pallet {
907912
pub type DynamicBlock<T> = StorageValue<_, u64, ValueQuery>;
908913
#[pallet::storage] // --- MAP ( netuid ) --> total_volume | The total amount of TAO bought and sold since the start of the network.
909914
pub type SubnetVolume<T: Config> =
910-
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultZeroU64<T>>;
915+
StorageMap<_, Identity, u16, u128, ValueQuery, DefaultZeroU128<T>>;
911916
#[pallet::storage] // --- MAP ( netuid ) --> tao_in_subnet | Returns the amount of TAO in the subnet.
912917
pub type SubnetTAO<T: Config> =
913918
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultZeroU64<T>>;

pallets/subtensor/src/rpc_info/dynamic_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use codec::Compact;
44
use frame_support::pallet_prelude::{Decode, Encode};
55
use subtensor_macros::freeze_struct;
66

7-
#[freeze_struct("1be5a1e26a82082f")]
7+
#[freeze_struct("a5cdc80d655398e9")]
88
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
99
pub struct DynamicInfo<T: Config> {
1010
netuid: Compact<u16>,
@@ -24,7 +24,7 @@ pub struct DynamicInfo<T: Config> {
2424
tao_in_emission: Compact<u64>,
2525
pending_alpha_emission: Compact<u64>,
2626
pending_root_emission: Compact<u64>,
27-
subnet_volume: Compact<u64>,
27+
subnet_volume: Compact<u128>,
2828
network_registered_at: Compact<u64>,
2929
subnet_identity: Option<SubnetIdentity>,
3030
}

pallets/subtensor/src/rpc_info/metagraph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use frame_support::pallet_prelude::{Decode, Encode};
66
use substrate_fixed::types::I64F64;
77
use subtensor_macros::freeze_struct;
88

9-
#[freeze_struct("fa24d156067e5eb9")]
9+
#[freeze_struct("7c5fe907490c5d5e")]
1010
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
1111
pub struct Metagraph<T: Config> {
1212
// Subnet index
@@ -38,7 +38,7 @@ pub struct Metagraph<T: Config> {
3838
tao_in_emission: Compact<u64>, // amount of tao injected per block
3939
pending_alpha_emission: Compact<u64>, // pending alpha to be distributed
4040
pending_root_emission: Compact<u64>, // panding tao for root divs to be distributed
41-
subnet_volume: Compact<u64>, // volume of the subnet in TAO
41+
subnet_volume: Compact<u128>, // volume of the subnet in TAO
4242

4343
// Hparams for epoch
4444
rho: Compact<u16>, // subnet rho param

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ impl<T: Config> Pallet<T> {
557557
TotalStake::<T>::mutate(|total| {
558558
*total = total.saturating_add(tao);
559559
});
560-
// Step 8. Decrease Alpha reserves.
560+
// Step 8. Increase total subnet TAO volume.
561561
SubnetVolume::<T>::mutate(netuid, |total| {
562-
*total = total.saturating_add(tao);
562+
*total = total.saturating_add(tao.into());
563563
});
564564
// Step 9. Return the alpha received.
565565
alpha
@@ -589,9 +589,9 @@ impl<T: Config> Pallet<T> {
589589
TotalStake::<T>::mutate(|total| {
590590
*total = total.saturating_sub(tao);
591591
});
592-
// Step 8. Decrease Alpha reserves.
592+
// Step 8. Increase total subnet TAO volume.
593593
SubnetVolume::<T>::mutate(netuid, |total| {
594-
*total = total.saturating_add(tao);
594+
*total = total.saturating_add(tao.into());
595595
});
596596
// Step 9. Return the tao received.
597597
tao

0 commit comments

Comments
 (0)