File tree Expand file tree Collapse file tree 5 files changed +47
-3
lines changed Expand file tree Collapse file tree 5 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,11 @@ impl<T: Config> Pallet<T> {
7676 }
7777 } else {
7878 // Initialize EMA flow, set S(current_block) = min(price, ema_price) * init_factor
79+ let init_factor = I64F64 :: saturating_from_num ( 1_000_000_000 ) ;
7980 let moving_price = I64F64 :: saturating_from_num ( Self :: get_moving_alpha_price ( netuid) ) ;
8081 let current_price =
8182 I64F64 :: saturating_from_num ( T :: SwapInterface :: current_alpha_price ( netuid) ) ;
82- let ema_flow = moving_price. min ( current_price) ;
83+ let ema_flow = init_factor . saturating_mul ( moving_price. min ( current_price) ) ;
8384 SubnetEmaTaoFlow :: < T > :: insert ( netuid, ( current_block, ema_flow) ) ;
8485 ema_flow
8586 }
Original file line number Diff line number Diff line change @@ -159,7 +159,9 @@ mod hooks {
159159 // Migrate Kappa to default (0.5)
160160 . saturating_add ( migrations:: migrate_kappa_map_to_default:: migrate_kappa_map_to_default :: < T > ( ) )
161161 // Remove obsolete map entries
162- . saturating_add ( migrations:: migrate_remove_tao_dividends:: migrate_remove_tao_dividends :: < T > ( ) ) ;
162+ . saturating_add ( migrations:: migrate_remove_tao_dividends:: migrate_remove_tao_dividends :: < T > ( ) )
163+ // Re-init tao flows
164+ . saturating_add ( migrations:: migrate_init_tao_flow:: migrate_init_tao_flow :: < T > ( ) ) ;
163165 weight
164166 }
165167
Original file line number Diff line number Diff line change 1+ use alloc:: string:: String ;
2+
3+ use frame_support:: { traits:: Get , weights:: Weight } ;
4+
5+ use super :: * ;
6+
7+ pub fn migrate_init_tao_flow < T : Config > ( ) -> Weight {
8+ let migration_name = b"migrate_init_tao_flow" . to_vec ( ) ;
9+
10+ // Initialize the weight with one read operation.
11+ let mut weight = T :: DbWeight :: get ( ) . reads ( 1 ) ;
12+
13+ // Check if the migration has already run
14+ if HasMigrationRun :: < T > :: get ( & migration_name) {
15+ log:: info!(
16+ "Migration '{:?}' has already run. Skipping." ,
17+ String :: from_utf8_lossy( & migration_name)
18+ ) ;
19+ return weight;
20+ }
21+ log:: info!(
22+ "Running migration '{}'" ,
23+ String :: from_utf8_lossy( & migration_name)
24+ ) ;
25+
26+ let _ = SubnetEmaTaoFlow :: < T > :: clear ( u32:: MAX , None ) ;
27+ weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
28+
29+ // Mark the migration as completed
30+ HasMigrationRun :: < T > :: insert ( & migration_name, true ) ;
31+ weight = weight. saturating_add ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
32+
33+ log:: info!(
34+ "Migration '{:?}' completed." ,
35+ String :: from_utf8_lossy( & migration_name)
36+ ) ;
37+
38+ // Return the migration weight.
39+ weight
40+ }
Original file line number Diff line number Diff line change @@ -20,6 +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_flow;
2324pub mod migrate_init_total_issuance;
2425pub mod migrate_kappa_map_to_default;
2526pub 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 : 335 ,
223+ spec_version : 336 ,
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