File tree Expand file tree Collapse file tree 5 files changed +8
-24
lines changed Expand file tree Collapse file tree 5 files changed +8
-24
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,11 @@ impl<T: Config> Pallet<T> {
7575 }
7676 } else {
7777 // Initialize EMA flow, set S(current_block) = min(price, ema_price) * init_factor
78+ let init_factor = I64F64 :: saturating_from_num ( 1_000_000_000 ) ;
7879 let moving_price = I64F64 :: saturating_from_num ( Self :: get_moving_alpha_price ( netuid) ) ;
7980 let current_price =
8081 I64F64 :: saturating_from_num ( T :: SwapInterface :: current_alpha_price ( netuid) ) ;
81- let ema_flow = moving_price. min ( current_price) ;
82+ let ema_flow = init_factor . saturating_mul ( moving_price. min ( current_price) ) ;
8283 SubnetEmaTaoFlow :: < T > :: insert ( netuid, ( current_block, ema_flow) ) ;
8384 ema_flow
8485 }
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ mod hooks {
161161 // Remove obsolete map entries
162162 . saturating_add ( migrations:: migrate_remove_tao_dividends:: migrate_remove_tao_dividends :: < T > ( ) )
163163 // Re-init tao flows
164- . saturating_add ( migrations:: migrate_init_tao_flows :: migrate_init_tao_flows :: < T > ( ) ) ;
164+ . saturating_add ( migrations:: migrate_init_tao_flow :: migrate_init_tao_flow :: < T > ( ) ) ;
165165 weight
166166 }
167167
Original file line number Diff line number Diff line change 11use alloc:: string:: String ;
22
3- use frame_support:: IterableStorageMap ;
43use frame_support:: { traits:: Get , weights:: Weight } ;
5- use subtensor_runtime_common:: NetUid ;
64
75use super :: * ;
86
9- pub fn migrate_init_tao_flows < T : Config > ( ) -> Weight {
7+ pub fn migrate_init_tao_flow < T : Config > ( ) -> Weight {
108 let migration_name = b"migrate_init_tao_flow" . to_vec ( ) ;
119
1210 // Initialize the weight with one read operation.
@@ -25,23 +23,8 @@ pub fn migrate_init_tao_flows<T: Config>() -> Weight {
2523 String :: from_utf8_lossy( & migration_name)
2624 ) ;
2725
28- let netuids: Vec < NetUid > = <NetworksAdded < T > as IterableStorageMap < NetUid , bool > >:: iter ( )
29- . map ( |( netuid, _) | netuid)
30- . collect ( ) ;
31- weight = weight. saturating_add ( T :: DbWeight :: get ( ) . reads ( netuids. len ( ) as u64 ) ) ;
32-
33- for netuid in netuids. iter ( ) {
34- if netuid. is_root ( ) {
35- continue ;
36- }
37- // Set SubnetEmaTaoFlow
38- SubnetEmaTaoFlow :: < T > :: insert ( * netuid, I64F64 :: saturating_from_num ( 0 ) ) ;
39-
40-
41-
42-
43- weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
44- }
26+ let _ = SubnetEmaTaoFlow :: < T > :: clear ( u32:: MAX , None ) ;
27+ weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
4528
4629 // Mark the migration as completed
4730 HasMigrationRun :: < T > :: insert ( & migration_name, true ) ;
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ pub mod migrate_fix_is_network_member;
2020pub mod migrate_fix_root_subnet_tao;
2121pub mod migrate_fix_root_tao_and_alpha_in;
2222pub mod migrate_identities_v2;
23- pub mod migrate_init_tao_flows ;
23+ pub mod migrate_init_tao_flow ;
2424pub mod migrate_init_total_issuance;
2525pub mod migrate_kappa_map_to_default;
2626pub mod migrate_network_immunity_period;
Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
220220 // `spec_version`, and `authoring_version` are the same between Wasm and native.
221221 // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
222222 // the compatible custom types.
223- spec_version : 334 ,
223+ spec_version : 335 ,
224224 impl_version : 1 ,
225225 apis : RUNTIME_API_VERSIONS ,
226226 transaction_version : 1 ,
You can’t perform that action at this time.
0 commit comments