From cd6992285e01d6132a6bfad6362176cd957a8f46 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 2 Apr 2025 18:20:19 -0400 Subject: [PATCH 001/226] remove unused SubnetName map and use identity instead --- pallets/subtensor/src/lib.rs | 3 - pallets/subtensor/src/macros/hooks.rs | 4 +- .../migrate_remove_subnet_name_map.rs | 65 + pallets/subtensor/src/migrations/mod.rs | 1 + pallets/subtensor/src/subnets/symbols.rs | 1050 +++++++++-------- 5 files changed, 597 insertions(+), 526 deletions(-) create mode 100644 pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index e360c307e1..043fabeeac 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1061,9 +1061,6 @@ pub mod pallet { #[pallet::storage] // --- MAP ( netuid ) --> token_symbol | Returns the token symbol for a subnet. pub type TokenSymbol = StorageMap<_, Identity, u16, Vec, ValueQuery, DefaultUnicodeVecU8>; - #[pallet::storage] // --- MAP ( netuid ) --> subnet_name | Returns the name of the subnet. - pub type SubnetName = - StorageMap<_, Identity, u16, Vec, ValueQuery, DefaultUnicodeVecU8>; /// ============================ /// ==== Global Parameters ===== diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 49fc4ccfe5..303228a568 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -87,7 +87,9 @@ mod hooks { // Remove all zero value entries in TotalHotkeyAlpha .saturating_add(migrations::migrate_remove_zero_total_hotkey_alpha::migrate_remove_zero_total_hotkey_alpha::()) // Wipe existing items to prevent bad decoding for new type - .saturating_add(migrations::migrate_upgrade_revealed_commitments::migrate_upgrade_revealed_commitments::()); + .saturating_add(migrations::migrate_upgrade_revealed_commitments::migrate_upgrade_revealed_commitments::()) + // Wipe unused SubnetName map + .saturating_add(migrations::migrate_remove_subnet_name_map::migrate_remove_subnet_name_map::()); weight } diff --git a/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs b/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs new file mode 100644 index 0000000000..b7259325d4 --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs @@ -0,0 +1,65 @@ +use super::*; +use crate::HasMigrationRun; +use frame_support::{traits::Get, weights::Weight}; +use scale_info::prelude::string::String; +use sp_io::{ + KillStorageResult, + hashing::twox_128, + storage::{clear, clear_prefix}, +}; + +fn remove_prefix(old_map: &str, weight: &mut Weight) { + let mut prefix = Vec::new(); + prefix.extend_from_slice(&twox_128("SubtensorModule".as_bytes())); + prefix.extend_from_slice(&twox_128(old_map.as_bytes())); + + let removal_results = clear_prefix(&prefix, Some(u32::MAX)); + + let removed_entries_count = match removal_results { + KillStorageResult::AllRemoved(removed) => removed as u64, + KillStorageResult::SomeRemaining(removed) => { + log::info!("Failed To Remove Some Items During migration"); + removed as u64 + } + }; + + log::info!( + "Removed {:?} entries from {:?} map.", + removed_entries_count, + old_map + ); + + *weight = (*weight).saturating_add(T::DbWeight::get().writes(removed_entries_count)); +} + +pub fn migrate_remove_subnet_name_map() -> Weight { + let migration_name = b"migrate_remove_subnet_name_map".to_vec(); + let mut weight = T::DbWeight::get().reads(1); + + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); + return weight; + } + + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + // Remove SubnetName + remove_prefix::("SubnetName", &mut weight); + + // Mark Migration as Completed + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed successfully.", + String::from_utf8_lossy(&migration_name) + ); + + weight +} diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index 23fb3cde1f..9fadd4a2f4 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -10,6 +10,7 @@ pub mod migrate_init_total_issuance; pub mod migrate_populate_owned_hotkeys; pub mod migrate_rao; pub mod migrate_remove_stake_map; +pub mod migrate_remove_subnet_name_map; pub mod migrate_remove_unused_maps_and_values; pub mod migrate_remove_zero_total_hotkey_alpha; pub mod migrate_set_first_emission_block_number; diff --git a/pallets/subtensor/src/subnets/symbols.rs b/pallets/subtensor/src/subnets/symbols.rs index 6350c303e5..7642909706 100644 --- a/pallets/subtensor/src/subnets/symbols.rs +++ b/pallets/subtensor/src/subnets/symbols.rs @@ -3,528 +3,534 @@ use super::*; /// Returns the Unicode symbol as a Vec for a given netuid. impl Pallet { pub fn get_name_for_subnet(netuid: u16) -> Vec { - if SubnetName::::contains_key(netuid) { - SubnetName::::get(netuid) - } else { - match netuid { - 0 => b"root".to_vec(), // Τ (Upper case Tau) - 1 => b"apex".to_vec(), // α (Alpha) - 2 => b"omron".to_vec(), // β (Beta) - 3 => b"templar".to_vec(), // γ (Gamma) - 4 => b"targon".to_vec(), // δ (Delta) - 5 => b"kaito".to_vec(), // ε (Epsilon) - 6 => b"infinite".to_vec(), // ζ (Zeta) - 7 => b"subvortex".to_vec(), // η (Eta) - 8 => b"ptn".to_vec(), // θ (Theta) - 9 => b"pretrain".to_vec(), // ι (Iota) - 10 => b"sturdy".to_vec(), // κ (Kappa) - 11 => b"dippy".to_vec(), // λ (Lambda) - 12 => b"horde".to_vec(), // μ (Mu) - 13 => b"dataverse".to_vec(), // ν (Nu) - 14 => b"palaidn".to_vec(), // ξ (Xi) - 15 => b"deval".to_vec(), // ο (Omicron) - 16 => b"bitads".to_vec(), // π (Pi) - 17 => b"3gen".to_vec(), // ρ (Rho) - 18 => b"cortex".to_vec(), // σ (Sigma) - 19 => b"inference".to_vec(), // t (Tau) - 20 => b"bitagent".to_vec(), // υ (Upsilon) - 21 => b"any-any".to_vec(), // φ (Phi) - 22 => b"meta".to_vec(), // χ (Chi) - 23 => b"social".to_vec(), // ψ (Psi) - 24 => b"omega".to_vec(), // ω (Omega) - 25 => b"protein".to_vec(), // א (Aleph) - 26 => b"alchemy".to_vec(), // ב (Bet) - 27 => b"compute".to_vec(), // ג (Gimel) - 28 => b"oracle".to_vec(), // ד (Dalet) - 29 => b"coldint".to_vec(), // ה (He) - 30 => b"bet".to_vec(), // ו (Vav) - 31 => b"naschain".to_vec(), // ז (Zayin) - 32 => b"itsai".to_vec(), // ח (Het) - 33 => b"ready".to_vec(), // ט (Tet) - 34 => b"mind".to_vec(), // י (Yod) - 35 => b"logic".to_vec(), // ך (Final Kaf) - 36 => b"automata".to_vec(), // כ (Kaf) - 37 => b"tuning".to_vec(), // ל (Lamed) - 38 => b"distributed".to_vec(), // ם (Final Mem) - 39 => b"edge".to_vec(), // מ (Mem) - 40 => b"chunk".to_vec(), // ן (Final Nun) - 41 => b"sportsensor".to_vec(), // נ (Nun) - 42 => b"masa".to_vec(), // ס (Samekh) - 43 => b"graphite".to_vec(), // ע (Ayin) - 44 => b"score".to_vec(), // ף (Final Pe) - 45 => b"gen42".to_vec(), // פ (Pe) - 46 => b"neural".to_vec(), // ץ (Final Tsadi) - 47 => b"condense".to_vec(), // צ (Tsadi) - 48 => b"nextplace".to_vec(), // ק (Qof) - 49 => b"automl".to_vec(), // ר (Resh) - 50 => b"audio".to_vec(), // ש (Shin) - 51 => b"celium".to_vec(), // ת (Tav) - 52 => b"dojo".to_vec(), // ا (Alif) - 53 => b"frontier".to_vec(), // ب (Ba) - 54 => b"safescan".to_vec(), // ت (Ta) - 55 => b"unknown".to_vec(), // ث (Tha) - 56 => b"gradients".to_vec(), // ج (Jim) - 57 => b"gaia".to_vec(), // ح (Ha) - 58 => b"dippy-speach".to_vec(), // خ (Kha) - 59 => b"agent-arena".to_vec(), // د (Dal) - 60 => b"unknown".to_vec(), // ذ (Dhal) - 61 => b"red team".to_vec(), // ر (Ra) - 62 => b"agentao".to_vec(), // ز (Zay) - 63 => b"lean-in".to_vec(), // س (Sin) - 64 => b"chutes".to_vec(), // ش (Shin) - 65 => b"sad".to_vec(), - 66 => b"dad".to_vec(), - 67 => b"ta".to_vec(), - 68 => b"dha".to_vec(), - 69 => b"ain".to_vec(), - 70 => b"ghayn".to_vec(), - 71 => b"fa".to_vec(), - 72 => b"qaf".to_vec(), - 73 => b"kaf".to_vec(), - 74 => b"lam".to_vec(), - 75 => b"mim".to_vec(), - 76 => b"nun".to_vec(), - 77 => b"ha".to_vec(), - 78 => b"waw".to_vec(), - 79 => b"ya".to_vec(), - 80 => b"alef".to_vec(), - 81 => b"ya".to_vec(), - 82 => b"fehu".to_vec(), - 83 => b"uruz".to_vec(), - 84 => b"thurisaz".to_vec(), - 85 => b"ansuz".to_vec(), - 86 => b"raidho".to_vec(), - 87 => b"kaunan".to_vec(), - 88 => b"eihwaz".to_vec(), - 89 => b"algiz".to_vec(), - 90 => b"berkanan".to_vec(), - 91 => b"ogham".to_vec(), - 92 => b"beith".to_vec(), - 93 => b"luis".to_vec(), - 94 => b"fearn".to_vec(), - 95 => b"sail".to_vec(), - 96 => b"nion".to_vec(), - 97 => b"forfeda".to_vec(), - 98 => b"ani".to_vec(), - 99 => b"bani".to_vec(), - 100 => b"gani".to_vec(), - 101 => b"doni".to_vec(), - 102 => b"eni".to_vec(), - 103 => b"vini".to_vec(), - 104 => b"ayp".to_vec(), - 105 => b"ben".to_vec(), - 106 => b"gim".to_vec(), - 107 => b"da".to_vec(), - 108 => b"ech".to_vec(), - 109 => b"za".to_vec(), - 110 => b"armeni".to_vec(), - 111 => b"grave".to_vec(), - 112 => b"io".to_vec(), - 113 => b"dje".to_vec(), - 114 => b"gje".to_vec(), - 115 => b"ie".to_vec(), - 116 => b"dze".to_vec(), - 117 => b"alfa".to_vec(), - 118 => b"alfas".to_vec(), - 119 => b"vida".to_vec(), // Ⲃ (Vida, 119) - 120 => b"vida_small".to_vec(), // ⲃ (Small Vida, 120) - 121 => b"gamma".to_vec(), // Ⲅ (Gamma, 121) - 122 => b"gamma_small".to_vec(), // ⲅ (Small Gamma, 122) - 123 => b"brahmi_a".to_vec(), // 𑀀 (A, 123) - 124 => b"brahmi_aa".to_vec(), // 𑀁 (Aa, 124) - 125 => b"brahmi_i".to_vec(), // 𑀂 (I, 125) - 126 => b"brahmi_ii".to_vec(), // 𑀃 (Ii, 126) - 127 => b"brahmi_u".to_vec(), // 𑀅 (U, 127) - 128 => b"tifinagh_ya".to_vec(), // ⴰ (Ya, 128) - 129 => b"tifinagh_yab".to_vec(), // ⴱ (Yab, 129) - 130 => b"tifinagh_yabh".to_vec(), // ⴲ (Yabh, 130) - 131 => b"tifinagh_yag".to_vec(), // ⴳ (Yag, 131) - 132 => b"tifinagh_yagh".to_vec(), // ⴴ (Yagh, 132) - 133 => b"tifinagh_yaj".to_vec(), // ⴵ (Yaj, 133) - 134 => b"glagolitic_az".to_vec(), // Ⰰ (Az, 134) - 135 => b"glagolitic_buky".to_vec(), // Ⰱ (Buky, 135) - 136 => b"glagolitic_vede".to_vec(), // Ⰲ (Vede, 136) - 137 => b"glagolitic_glagoli".to_vec(), // Ⰳ (Glagoli, 137) - 138 => b"glagolitic_dobro".to_vec(), // Ⰴ (Dobro, 138) - 139 => b"glagolitic_yest".to_vec(), // Ⰵ (Yest, 139) - 140 => b"glagolitic_zhivete".to_vec(), // Ⰶ (Zhivete, 140) - 141 => b"glagolitic_zemlja".to_vec(), // Ⰷ (Zemlja, 141) - 142 => b"glagolitic_izhe".to_vec(), // Ⰸ (Izhe, 142) - 143 => b"glagolitic_initial_izhe".to_vec(), // Ⰹ (Initial Izhe, 143) - 144 => b"glagolitic_i".to_vec(), // Ⰺ (I, 144) - 145 => b"glagolitic_djerv".to_vec(), // Ⰻ (Djerv, 145) - 146 => b"glagolitic_kako".to_vec(), // Ⰼ (Kako, 146) - 147 => b"glagolitic_ljudije".to_vec(), // Ⰽ (Ljudije, 147) - 148 => b"glagolitic_myse".to_vec(), // Ⰾ (Myse, 148) - 149 => b"glagolitic_nash".to_vec(), // Ⰿ (Nash, 149) - 150 => b"glagolitic_on".to_vec(), // Ⱀ (On, 150) - 151 => b"glagolitic_pokoj".to_vec(), // Ⱁ (Pokoj, 151) - 152 => b"glagolitic_rtsy".to_vec(), // Ⱂ (Rtsy, 152) - 153 => b"glagolitic_slovo".to_vec(), // Ⱃ (Slovo, 153) - 154 => b"glagolitic_tvrido".to_vec(), // Ⱄ (Tvrido, 154) - 155 => b"glagolitic_uku".to_vec(), // Ⱅ (Uku, 155) - 156 => b"glagolitic_fert".to_vec(), // Ⱆ (Fert, 156) - 157 => b"glagolitic_xrivi".to_vec(), // Ⱇ (Xrivi, 157) - 158 => b"glagolitic_ot".to_vec(), // Ⱈ (Ot, 158) - 159 => b"glagolitic_cy".to_vec(), // Ⱉ (Cy, 159) - 160 => b"glagolitic_shcha".to_vec(), // Ⱊ (Shcha, 160) - 161 => b"glagolitic_er".to_vec(), // Ⱋ (Er, 161) - 162 => b"glagolitic_yeru".to_vec(), // Ⱌ (Yeru, 162) - 163 => b"glagolitic_small_yer".to_vec(), // Ⱍ (Small Yer, 163) - 164 => b"glagolitic_yo".to_vec(), // Ⱎ (Yo, 164) - 165 => b"glagolitic_yu".to_vec(), // Ⱏ (Yu, 165) - 166 => b"glagolitic_ja".to_vec(), // Ⱐ (Ja, 166) - 167 => b"thai_ko_kai".to_vec(), // ก (Ko Kai, 167) - 168 => b"thai_kho_khai".to_vec(), // ข (Kho Khai, 168) - 169 => b"thai_kho_khuat".to_vec(), // ฃ (Kho Khuat, 169) - 170 => b"thai_kho_khon".to_vec(), // ค (Kho Khon, 170) - 171 => b"thai_kho_rakhang".to_vec(), // ฅ (Kho Rakhang, 171) - 172 => b"thai_kho_khwai".to_vec(), // ฆ (Kho Khwai, 172) - 173 => b"thai_ngo_ngu".to_vec(), // ง (Ngo Ngu, 173) - 174 => b"thai_cho_chan".to_vec(), // จ (Cho Chan, 174) - 175 => b"thai_cho_ching".to_vec(), // ฉ (Cho Ching, 175) - 176 => b"thai_cho_chang".to_vec(), // ช (Cho Chang, 176) - 177 => b"thai_so_so".to_vec(), // ซ (So So, 177) - 178 => b"thai_cho_choe".to_vec(), // ฌ (Cho Choe, 178) - 179 => b"thai_yo_ying".to_vec(), // ญ (Yo Ying, 179) - 180 => b"thai_do_chada".to_vec(), // ฎ (Do Chada, 180) - 181 => b"thai_to_patak".to_vec(), // ฏ (To Patak, 181) - 182 => b"thai_tho_than".to_vec(), // ฐ (Tho Than, 182) - 183 => b"thai_tho_nangmontho".to_vec(), // ฑ (Tho Nangmontho, 183) - 184 => b"thai_tho_phuthao".to_vec(), // ฒ (Tho Phuthao, 184) - 185 => b"thai_no_nen".to_vec(), // ณ (No Nen, 185) - 186 => b"thai_do_dek".to_vec(), // ด (Do Dek, 186) - 187 => b"thai_to_tao".to_vec(), // ต (To Tao, 187) - 188 => b"thai_tho_thung".to_vec(), // ถ (Tho Thung, 188) - 189 => b"thai_tho_thahan".to_vec(), // ท (Tho Thahan, 189) - 190 => b"thai_tho_thong".to_vec(), // ธ (Tho Thong, 190) - 191 => b"thai_no_nu".to_vec(), // น (No Nu, 191) - 192 => b"thai_bo_baimai".to_vec(), // บ (Bo Baimai, 192) - 193 => b"thai_po_pla".to_vec(), // ป (Po Pla, 193) - 194 => b"thai_pho_phung".to_vec(), // ผ (Pho Phung, 194) - 195 => b"thai_fo_fa".to_vec(), // ฝ (Fo Fa, 195) - 196 => b"thai_pho_phan".to_vec(), // พ (Pho Phan, 196) - 197 => b"thai_fo_fan".to_vec(), // ฟ (Fo Fan, 197) - 198 => b"thai_pho_samphao".to_vec(), // ภ (Pho Samphao, 198) - 199 => b"thai_mo_ma".to_vec(), // ม (Mo Ma, 199) - 200 => b"thai_yo_yak".to_vec(), // ย (Yo Yak, 200) - 201 => b"thai_ro_rua".to_vec(), // ร (Ro Rua, 201) - 202 => b"thai_lo_ling".to_vec(), // ล (Lo Ling, 202) - 203 => b"thai_wo_waen".to_vec(), // ว (Wo Waen, 203) - 204 => b"thai_so_sala".to_vec(), // ศ (So Sala, 204) - 205 => b"thai_so_rusi".to_vec(), // ษ (So Rusi, 205) - 206 => b"thai_so_sua".to_vec(), // ส (So Sua, 206) - 207 => b"thai_ho_hip".to_vec(), // ห (Ho Hip, 207) - 208 => b"thai_lo_chula".to_vec(), // ฬ (Lo Chula, 208) - 209 => b"thai_o_ang".to_vec(), // อ (O Ang, 209) - 210 => b"thai_ho_nokhuk".to_vec(), // ฮ (Ho Nokhuk, 210) - 211 => b"hangul_giyeok".to_vec(), // ㄱ (Giyeok, 211) - 212 => b"hangul_nieun".to_vec(), // ㄴ (Nieun, 212) - 213 => b"hangul_digeut".to_vec(), // ㄷ (Digeut, 213) - 214 => b"hangul_rieul".to_vec(), // ㄹ (Rieul, 214) - 215 => b"hangul_mieum".to_vec(), // ㅁ (Mieum, 215) - 216 => b"hangul_bieup".to_vec(), // ㅂ (Bieup, 216) - 217 => b"hangul_siot".to_vec(), // ㅅ (Siot, 217) - 218 => b"hangul_ieung".to_vec(), // ㅇ (Ieung, 218) - 219 => b"hangul_jieut".to_vec(), // ㅈ (Jieut, 219) - 220 => b"hangul_chieut".to_vec(), // ㅊ (Chieut, 220) - 221 => b"hangul_kieuk".to_vec(), // ㅋ (Kieuk, 221) - 222 => b"hangul_tieut".to_vec(), // ㅌ (Tieut, 222) - 223 => b"hangul_pieup".to_vec(), // ㅍ (Pieup, 223) - 224 => b"hangul_hieut".to_vec(), // ㅎ (Hieut, 224) - 225 => b"hangul_a".to_vec(), // ㅏ (A, 225) - 226 => b"hangul_ae".to_vec(), // ㅐ (Ae, 226) - 227 => b"hangul_ya".to_vec(), // ㅑ (Ya, 227) - 228 => b"hangul_yae".to_vec(), // ㅒ (Yae, 228) - 229 => b"hangul_eo".to_vec(), // ㅓ (Eo, 229) - 230 => b"hangul_e".to_vec(), // ㅔ (E, 230) - 231 => b"hangul_yeo".to_vec(), // ㅕ (Yeo, 231) - 232 => b"hangul_ye".to_vec(), // ㅖ (Ye, 232) - 233 => b"hangul_o".to_vec(), // ㅗ (O, 233) - 234 => b"hangul_wa".to_vec(), // ㅘ (Wa, 234) - 235 => b"hangul_wae".to_vec(), // ㅙ (Wae, 235) - 236 => b"hangul_oe".to_vec(), // ㅚ (Oe, 236) - 237 => b"hangul_yo".to_vec(), // ㅛ (Yo, 237) - 238 => b"hangul_u".to_vec(), // ㅜ (U, 238) - 239 => b"hangul_weo".to_vec(), // ㅝ (Weo, 239) - 240 => b"hangul_we".to_vec(), // ㅞ (We, 240) - 241 => b"hangul_wi".to_vec(), // ㅟ (Wi, 241) - 242 => b"hangul_yu".to_vec(), // ㅠ (Yu, 242) - 243 => b"hangul_eu".to_vec(), // ㅡ (Eu, 243) - 244 => b"hangul_ui".to_vec(), // ㅢ (Ui, 244) - 245 => b"hangul_i".to_vec(), // ㅣ (I, 245) - 246 => b"ethiopic_glottal_a".to_vec(), // አ (Glottal A, 246) - 247 => b"ethiopic_glottal_u".to_vec(), // ኡ (Glottal U, 247) - 248 => b"ethiopic_glottal_i".to_vec(), // ኢ (Glottal I, 248) - 249 => b"ethiopic_glottal_aa".to_vec(), // ኣ (Glottal Aa, 249) - 250 => b"ethiopic_glottal_e".to_vec(), // ኤ (Glottal E, 250) - 251 => b"ethiopic_glottal_ie".to_vec(), // እ (Glottal Ie, 251) - 252 => b"ethiopic_glottal_o".to_vec(), // ኦ (Glottal O, 252) - 253 => b"ethiopic_glottal_wa".to_vec(), // ኧ (Glottal Wa, 253) - 254 => b"ethiopic_wa".to_vec(), // ወ (Wa, 254) - 255 => b"ethiopic_wu".to_vec(), // ዉ (Wu, 255) - 256 => b"ethiopic_wi".to_vec(), // ዊ (Wi, 256) - 257 => b"ethiopic_waa".to_vec(), // ዋ (Waa, 257) - 258 => b"ethiopic_we".to_vec(), // ዌ (We, 258) - 259 => b"ethiopic_wye".to_vec(), // ው (Wye, 259) - 260 => b"ethiopic_wo".to_vec(), // ዎ (Wo, 260) - 261 => b"ethiopic_ko".to_vec(), // ኰ (Ko, 261) - 262 => b"ethiopic_ku".to_vec(), // ኱ (Ku, 262) - 263 => b"ethiopic_ki".to_vec(), // ኲ (Ki, 263) - 264 => b"ethiopic_kua".to_vec(), // ኳ (Kua, 264) - 265 => b"ethiopic_ke".to_vec(), // ኴ (Ke, 265) - 266 => b"ethiopic_kwe".to_vec(), // ኵ (Kwe, 266) - 267 => b"ethiopic_ko_alt".to_vec(), // ኶ (Ko, 267) - 268 => b"ethiopic_go".to_vec(), // ጐ (Go, 268) - 269 => b"ethiopic_gu".to_vec(), // ጑ (Gu, 269) - 270 => b"ethiopic_gi".to_vec(), // ጒ (Gi, 270) - 271 => b"ethiopic_gua".to_vec(), // መ (Gua, 271) - 272 => b"ethiopic_ge".to_vec(), // ጔ (Ge, 272) - 273 => b"ethiopic_gwe".to_vec(), // ጕ (Gwe, 273) - 274 => b"ethiopic_go_alt".to_vec(), // ጖ (Go, 274) - 275 => b"devanagari_a".to_vec(), // अ (A, 275) - 276 => b"devanagari_aa".to_vec(), // आ (Aa, 276) - 277 => b"devanagari_i".to_vec(), // इ (I, 277) - 278 => b"devanagari_ii".to_vec(), // ई (Ii, 278) - 279 => b"devanagari_u".to_vec(), // उ (U, 279) - 280 => b"devanagari_uu".to_vec(), // ऊ (Uu, 280) - 281 => b"devanagari_r".to_vec(), // ऋ (R, 281) - 282 => b"devanagari_e".to_vec(), // ए (E, 282) - 283 => b"devanagari_ai".to_vec(), // ऐ (Ai, 283) - 284 => b"devanagari_o".to_vec(), // ओ (O, 284) - 285 => b"devanagari_au".to_vec(), // औ (Au, 285) - 286 => b"devanagari_ka".to_vec(), // क (Ka, 286) - 287 => b"devanagari_kha".to_vec(), // ख (Kha, 287) - 288 => b"devanagari_ga".to_vec(), // ग (Ga, 288) - 289 => b"devanagari_gha".to_vec(), // घ (Gha, 289) - 290 => b"devanagari_nga".to_vec(), // ङ (Nga, 290) - 291 => b"devanagari_cha".to_vec(), // च (Cha, 291) - 292 => b"devanagari_chha".to_vec(), // छ (Chha, 292) - 293 => b"devanagari_ja".to_vec(), // ज (Ja, 293) - 294 => b"devanagari_jha".to_vec(), // झ (Jha, 294) - 295 => b"devanagari_nya".to_vec(), // ञ (Nya, 295) - 296 => b"devanagari_ta".to_vec(), // ट (Ta, 296) - 297 => b"devanagari_tha".to_vec(), // ठ (Tha, 297) - 298 => b"devanagari_da".to_vec(), // ड (Da, 298) - 299 => b"devanagari_dha".to_vec(), // ढ (Dha, 299) - 300 => b"devanagari_na".to_vec(), // ण (Na, 300) - 301 => b"devanagari_ta_alt".to_vec(), // त (Ta, 301) - 302 => b"devanagari_tha_alt".to_vec(), // थ (Tha, 302) - 303 => b"devanagari_da_alt".to_vec(), // द (Da, 303) - 304 => b"devanagari_dha_alt".to_vec(), // ध (Dha, 304) - 305 => b"devanagari_na_alt".to_vec(), // न (Na, 305) - 306 => b"devanagari_pa".to_vec(), // प (Pa, 306) - 307 => b"devanagari_pha".to_vec(), // फ (Pha, 307) - 308 => b"devanagari_ba".to_vec(), // ब (Ba, 308) - 309 => b"devanagari_bha".to_vec(), // भ (Bha, 309) - 310 => b"devanagari_ma".to_vec(), // म (Ma, 310) - 311 => b"devanagari_ya".to_vec(), // य (Ya, 311) - 312 => b"devanagari_ra".to_vec(), // र (Ra, 312) - 313 => b"devanagari_la".to_vec(), // ल (La, 313) - 314 => b"devanagari_va".to_vec(), // व (Va, 314) - 315 => b"devanagari_sha".to_vec(), // श (Sha, 315) - 316 => b"devanagari_ssa".to_vec(), // ष (Ssa, 316) - 317 => b"devanagari_sa".to_vec(), // स (Sa, 317) - 318 => b"devanagari_ha".to_vec(), // ह (Ha, 318) - 319 => b"katakana_a".to_vec(), // ア (A, 319) - 320 => b"kana_i".to_vec(), - 321 => b"kana_u".to_vec(), - 322 => b"kana_e".to_vec(), - 323 => b"kana_o".to_vec(), - 324 => b"kana_a".to_vec(), - 325 => b"kana_ki".to_vec(), - 326 => b"kana_ku".to_vec(), - 327 => b"kana_ke".to_vec(), - 328 => b"kana_ko".to_vec(), - 329 => b"kana_sa".to_vec(), - 330 => b"kana_shi".to_vec(), - 331 => b"kana_su".to_vec(), - 332 => b"kana_se".to_vec(), - 333 => b"kana_so".to_vec(), - 334 => b"kana_ta".to_vec(), - 335 => b"kana_chi".to_vec(), - 336 => b"kana_tsu".to_vec(), - 337 => b"kana_te".to_vec(), - 338 => b"kana_to".to_vec(), - 339 => b"kana_na".to_vec(), - 340 => b"kana_ni".to_vec(), - 341 => b"kana_nu".to_vec(), - 342 => b"kana_ne".to_vec(), - 343 => b"kana_no".to_vec(), - 344 => b"kana_ha".to_vec(), - 345 => b"kana_hi".to_vec(), - 346 => b"kana_fu".to_vec(), - 347 => b"kana_he".to_vec(), - 348 => b"kana_ho".to_vec(), - 349 => b"kana_ma".to_vec(), - 350 => b"kana_mi".to_vec(), - 351 => b"kana_mu".to_vec(), - 352 => b"kana_me".to_vec(), - 353 => b"kana_mo".to_vec(), - 354 => b"kana_ya".to_vec(), - 355 => b"kana_yu".to_vec(), - 356 => b"kana_yo".to_vec(), - 357 => b"kana_ra".to_vec(), - 358 => b"kana_ri".to_vec(), - 359 => b"kana_ru".to_vec(), - 360 => b"kana_re".to_vec(), - 361 => b"kana_ro".to_vec(), - 362 => b"kana_wa".to_vec(), - 363 => b"kana_wo".to_vec(), - 364 => b"kana_n".to_vec(), - 365 => b"ya".to_vec(), - 366 => b"yab".to_vec(), - 367 => b"yabh".to_vec(), - 368 => b"yag".to_vec(), - 369 => b"yagh".to_vec(), - 370 => b"yaj".to_vec(), - 371 => b"yach".to_vec(), - 372 => b"yad".to_vec(), - 373 => b"yadh".to_vec(), - 374 => b"yadhe".to_vec(), - 375 => b"yaz".to_vec(), - 376 => b"yazh".to_vec(), - 377 => b"yaf".to_vec(), - 378 => b"yak".to_vec(), - 379 => b"yakv".to_vec(), - 380 => b"yaq".to_vec(), - 381 => b"yah".to_vec(), - 382 => b"yahh".to_vec(), - 383 => b"yahl".to_vec(), - 384 => b"yahm".to_vec(), - 385 => b"yayn".to_vec(), - 386 => b"yakh".to_vec(), - 387 => b"yakl".to_vec(), - 388 => b"yahq".to_vec(), - 389 => b"yash".to_vec(), - 390 => b"yi".to_vec(), - 391 => b"yij".to_vec(), - 392 => b"yizh".to_vec(), - 393 => b"yink".to_vec(), - 394 => b"yal".to_vec(), - 395 => b"yam".to_vec(), - 396 => b"yan".to_vec(), - 397 => b"yang".to_vec(), - 398 => b"yany".to_vec(), - 399 => b"yap".to_vec(), - 400 => b"yu".to_vec(), - 401 => b"a".to_vec(), - 402 => b"aa".to_vec(), - 403 => b"i".to_vec(), - 404 => b"ii".to_vec(), - 405 => b"u".to_vec(), - 406 => b"uu".to_vec(), - 407 => b"r".to_vec(), - 408 => b"rr".to_vec(), - 409 => b"l".to_vec(), - 410 => b"ll".to_vec(), - 411 => b"e".to_vec(), - 412 => b"ee".to_vec(), - 413 => b"ai".to_vec(), - 414 => b"o".to_vec(), - 415 => b"oo".to_vec(), - 416 => b"au".to_vec(), - 417 => b"ka".to_vec(), - 418 => b"kha".to_vec(), - 419 => b"ga".to_vec(), - 420 => b"gha".to_vec(), - 421 => b"nga".to_vec(), - 422 => b"cha".to_vec(), - 423 => b"chha".to_vec(), - 424 => b"ja".to_vec(), - 425 => b"jha".to_vec(), - 426 => b"nya".to_vec(), - 427 => b"ta".to_vec(), - 428 => b"tha".to_vec(), - 429 => b"da".to_vec(), - 430 => b"dha".to_vec(), - 431 => b"na".to_vec(), - 432 => b"pa".to_vec(), - 433 => b"pha".to_vec(), - 434 => b"ba".to_vec(), - 435 => b"bha".to_vec(), - 436 => b"ma".to_vec(), - 437 => b"ya".to_vec(), - 438 => b"ra".to_vec(), - 439 => b"la".to_vec(), - 440 => b"va".to_vec(), - 441 => b"sha".to_vec(), - 442 => b"ssa".to_vec(), - 443 => b"sa".to_vec(), - 444 => b"ha".to_vec(), - _ => b"unknown".to_vec(), - } - // match netuid { - // // Greek Alphabet (Lowercase) - // 0 => b"root".to_vec(), // Τ (Upper case Tau) - // 1 => b"apex".to_vec(), // α (Alpha) - // 2 => b"omron".to_vec(), // β (Beta) - // 3 => b"templar".to_vec(), // γ (Gamma) - // 4 => b"targon".to_vec(), // δ (Delta) - // 5 => b"kaito".to_vec(), // ε (Epsilon) - // 6 => b"infinite".to_vec(), // ζ (Zeta) - // 7 => b"subvortex".to_vec(), // η (Eta) - // 8 => b"ptn".to_vec(), // θ (Theta) - // 9 => b"pretrain".to_vec(), // ι (Iota) - // 10 => b"sturdy".to_vec(), // κ (Kappa) - // 11 => b"dippy".to_vec(), // λ (Lambda) - // 12 => b"horde".to_vec(), // μ (Mu) - // 13 => b"dataverse".to_vec(), // ν (Nu) - // 14 => b"palaidn".to_vec(), // ξ (Xi) - // 15 => b"deval".to_vec(), // ο (Omicron) - // 16 => b"bitads".to_vec(), // π (Pi) - // 17 => b"3gen".to_vec(), // ρ (Rho) - // 18 => b"cortex".to_vec(), // σ (Sigma) - // 19 => b"inference".to_vec(), // t (Tau) - // 20 => b"bitagent".to_vec(), // υ (Upsilon) - // 21 => b"any-any".to_vec(), // φ (Phi) - // 22 => b"meta".to_vec(), // χ (Chi) - // 23 => b"social".to_vec(), // ψ (Psi) - // 24 => b"omega".to_vec(), // ω (Omega) - // 25 => b"protein".to_vec(), // א (Aleph) - // 26 => b"alchemy".to_vec(), // ב (Bet) - // 27 => b"compute".to_vec(), // ג (Gimel) - // 28 => b"oracle".to_vec(), // ד (Dalet) - // 29 => b"coldint".to_vec(), // ה (He) - // 30 => b"bet".to_vec(), // ו (Vav) - // 31 => b"naschain".to_vec(), // ז (Zayin) - // 32 => b"itsai".to_vec(), // ח (Het) - // 33 => b"ready".to_vec(), // ט (Tet) - // 34 => b"mind".to_vec(), // י (Yod) - // 35 => b"logic".to_vec(), // ך (Final Kaf) - // 36 => b"automata".to_vec(), // כ (Kaf) - // 37 => b"tuning".to_vec(), // ל (Lamed) - // 38 => b"distributed".to_vec(), // ם (Final Mem) - // 39 => b"edge".to_vec(), // מ (Mem) - // 40 => b"chunk".to_vec(), // ן (Final Nun) - // 41 => b"sportsensor".to_vec(), // נ (Nun) - // 42 => b"masa".to_vec(), // ס (Samekh) - // 43 => b"graphite".to_vec(), // ע (Ayin) - // 44 => b"score".to_vec(), // ף (Final Pe) - // 45 => b"gen42".to_vec(), // פ (Pe) - // 46 => b"neural".to_vec(), // ץ (Final Tsadi) - // 47 => b"condense".to_vec(), // צ (Tsadi) - // 48 => b"nextplace".to_vec(), // ק (Qof) - // 49 => b"automl".to_vec(), // ר (Resh) - // 50 => b"audio".to_vec(), // ש (Shin) - // 51 => b"celium".to_vec(), // ת (Tav) - // 52 => b"dojo".to_vec(), // ا (Alif) - // 53 => b"frontier".to_vec(), // ب (Ba) - // 54 => b"safescan".to_vec(), // ت (Ta) - // 55 => b"unknown".to_vec(), // ث (Tha) - // 56 => b"gradients".to_vec(), // ج (Jim) - // 57 => b"gaia".to_vec(), // ح (Ha) - // 58 => b"dippy-speach".to_vec(), // خ (Kha) - // 59 => b"agent-arena".to_vec(), // د (Dal) - // 60 => b"unknown".to_vec(), // ذ (Dhal) - // 61 => b"red team".to_vec(), // ر (Ra) - // 62 => b"agentao".to_vec(), // ز (Zay) - // 63 => b"lean-in".to_vec(), // س (Sin) - // 64 => b"chutes".to_vec(), // ش (Shin) - // // Default case - // _ => b"unknown".to_vec(), // unknown subnet. - // } - } + SubnetIdentitiesV2::::try_get(netuid) + .and_then(|identity| { + if !identity.subnet_name.is_empty() { + Ok(identity.subnet_name) + } else { + Err(()) + } + }) + .unwrap_or_else(|_| { + match netuid { + 0 => b"root".to_vec(), // Τ (Upper case Tau) + 1 => b"apex".to_vec(), // α (Alpha) + 2 => b"omron".to_vec(), // β (Beta) + 3 => b"templar".to_vec(), // γ (Gamma) + 4 => b"targon".to_vec(), // δ (Delta) + 5 => b"kaito".to_vec(), // ε (Epsilon) + 6 => b"infinite".to_vec(), // ζ (Zeta) + 7 => b"subvortex".to_vec(), // η (Eta) + 8 => b"ptn".to_vec(), // θ (Theta) + 9 => b"pretrain".to_vec(), // ι (Iota) + 10 => b"sturdy".to_vec(), // κ (Kappa) + 11 => b"dippy".to_vec(), // λ (Lambda) + 12 => b"horde".to_vec(), // μ (Mu) + 13 => b"dataverse".to_vec(), // ν (Nu) + 14 => b"palaidn".to_vec(), // ξ (Xi) + 15 => b"deval".to_vec(), // ο (Omicron) + 16 => b"bitads".to_vec(), // π (Pi) + 17 => b"3gen".to_vec(), // ρ (Rho) + 18 => b"cortex".to_vec(), // σ (Sigma) + 19 => b"inference".to_vec(), // t (Tau) + 20 => b"bitagent".to_vec(), // υ (Upsilon) + 21 => b"any-any".to_vec(), // φ (Phi) + 22 => b"meta".to_vec(), // χ (Chi) + 23 => b"social".to_vec(), // ψ (Psi) + 24 => b"omega".to_vec(), // ω (Omega) + 25 => b"protein".to_vec(), // א (Aleph) + 26 => b"alchemy".to_vec(), // ב (Bet) + 27 => b"compute".to_vec(), // ג (Gimel) + 28 => b"oracle".to_vec(), // ד (Dalet) + 29 => b"coldint".to_vec(), // ה (He) + 30 => b"bet".to_vec(), // ו (Vav) + 31 => b"naschain".to_vec(), // ז (Zayin) + 32 => b"itsai".to_vec(), // ח (Het) + 33 => b"ready".to_vec(), // ט (Tet) + 34 => b"mind".to_vec(), // י (Yod) + 35 => b"logic".to_vec(), // ך (Final Kaf) + 36 => b"automata".to_vec(), // כ (Kaf) + 37 => b"tuning".to_vec(), // ל (Lamed) + 38 => b"distributed".to_vec(), // ם (Final Mem) + 39 => b"edge".to_vec(), // מ (Mem) + 40 => b"chunk".to_vec(), // ן (Final Nun) + 41 => b"sportsensor".to_vec(), // נ (Nun) + 42 => b"masa".to_vec(), // ס (Samekh) + 43 => b"graphite".to_vec(), // ע (Ayin) + 44 => b"score".to_vec(), // ף (Final Pe) + 45 => b"gen42".to_vec(), // פ (Pe) + 46 => b"neural".to_vec(), // ץ (Final Tsadi) + 47 => b"condense".to_vec(), // צ (Tsadi) + 48 => b"nextplace".to_vec(), // ק (Qof) + 49 => b"automl".to_vec(), // ר (Resh) + 50 => b"audio".to_vec(), // ש (Shin) + 51 => b"celium".to_vec(), // ת (Tav) + 52 => b"dojo".to_vec(), // ا (Alif) + 53 => b"frontier".to_vec(), // ب (Ba) + 54 => b"safescan".to_vec(), // ت (Ta) + 55 => b"unknown".to_vec(), // ث (Tha) + 56 => b"gradients".to_vec(), // ج (Jim) + 57 => b"gaia".to_vec(), // ح (Ha) + 58 => b"dippy-speach".to_vec(), // خ (Kha) + 59 => b"agent-arena".to_vec(), // د (Dal) + 60 => b"unknown".to_vec(), // ذ (Dhal) + 61 => b"red team".to_vec(), // ر (Ra) + 62 => b"agentao".to_vec(), // ز (Zay) + 63 => b"lean-in".to_vec(), // س (Sin) + 64 => b"chutes".to_vec(), // ش (Shin) + 65 => b"sad".to_vec(), + 66 => b"dad".to_vec(), + 67 => b"ta".to_vec(), + 68 => b"dha".to_vec(), + 69 => b"ain".to_vec(), + 70 => b"ghayn".to_vec(), + 71 => b"fa".to_vec(), + 72 => b"qaf".to_vec(), + 73 => b"kaf".to_vec(), + 74 => b"lam".to_vec(), + 75 => b"mim".to_vec(), + 76 => b"nun".to_vec(), + 77 => b"ha".to_vec(), + 78 => b"waw".to_vec(), + 79 => b"ya".to_vec(), + 80 => b"alef".to_vec(), + 81 => b"ya".to_vec(), + 82 => b"fehu".to_vec(), + 83 => b"uruz".to_vec(), + 84 => b"thurisaz".to_vec(), + 85 => b"ansuz".to_vec(), + 86 => b"raidho".to_vec(), + 87 => b"kaunan".to_vec(), + 88 => b"eihwaz".to_vec(), + 89 => b"algiz".to_vec(), + 90 => b"berkanan".to_vec(), + 91 => b"ogham".to_vec(), + 92 => b"beith".to_vec(), + 93 => b"luis".to_vec(), + 94 => b"fearn".to_vec(), + 95 => b"sail".to_vec(), + 96 => b"nion".to_vec(), + 97 => b"forfeda".to_vec(), + 98 => b"ani".to_vec(), + 99 => b"bani".to_vec(), + 100 => b"gani".to_vec(), + 101 => b"doni".to_vec(), + 102 => b"eni".to_vec(), + 103 => b"vini".to_vec(), + 104 => b"ayp".to_vec(), + 105 => b"ben".to_vec(), + 106 => b"gim".to_vec(), + 107 => b"da".to_vec(), + 108 => b"ech".to_vec(), + 109 => b"za".to_vec(), + 110 => b"armeni".to_vec(), + 111 => b"grave".to_vec(), + 112 => b"io".to_vec(), + 113 => b"dje".to_vec(), + 114 => b"gje".to_vec(), + 115 => b"ie".to_vec(), + 116 => b"dze".to_vec(), + 117 => b"alfa".to_vec(), + 118 => b"alfas".to_vec(), + 119 => b"vida".to_vec(), // Ⲃ (Vida, 119) + 120 => b"vida_small".to_vec(), // ⲃ (Small Vida, 120) + 121 => b"gamma".to_vec(), // Ⲅ (Gamma, 121) + 122 => b"gamma_small".to_vec(), // ⲅ (Small Gamma, 122) + 123 => b"brahmi_a".to_vec(), // 𑀀 (A, 123) + 124 => b"brahmi_aa".to_vec(), // 𑀁 (Aa, 124) + 125 => b"brahmi_i".to_vec(), // 𑀂 (I, 125) + 126 => b"brahmi_ii".to_vec(), // 𑀃 (Ii, 126) + 127 => b"brahmi_u".to_vec(), // 𑀅 (U, 127) + 128 => b"tifinagh_ya".to_vec(), // ⴰ (Ya, 128) + 129 => b"tifinagh_yab".to_vec(), // ⴱ (Yab, 129) + 130 => b"tifinagh_yabh".to_vec(), // ⴲ (Yabh, 130) + 131 => b"tifinagh_yag".to_vec(), // ⴳ (Yag, 131) + 132 => b"tifinagh_yagh".to_vec(), // ⴴ (Yagh, 132) + 133 => b"tifinagh_yaj".to_vec(), // ⴵ (Yaj, 133) + 134 => b"glagolitic_az".to_vec(), // Ⰰ (Az, 134) + 135 => b"glagolitic_buky".to_vec(), // Ⰱ (Buky, 135) + 136 => b"glagolitic_vede".to_vec(), // Ⰲ (Vede, 136) + 137 => b"glagolitic_glagoli".to_vec(), // Ⰳ (Glagoli, 137) + 138 => b"glagolitic_dobro".to_vec(), // Ⰴ (Dobro, 138) + 139 => b"glagolitic_yest".to_vec(), // Ⰵ (Yest, 139) + 140 => b"glagolitic_zhivete".to_vec(), // Ⰶ (Zhivete, 140) + 141 => b"glagolitic_zemlja".to_vec(), // Ⰷ (Zemlja, 141) + 142 => b"glagolitic_izhe".to_vec(), // Ⰸ (Izhe, 142) + 143 => b"glagolitic_initial_izhe".to_vec(), // Ⰹ (Initial Izhe, 143) + 144 => b"glagolitic_i".to_vec(), // Ⰺ (I, 144) + 145 => b"glagolitic_djerv".to_vec(), // Ⰻ (Djerv, 145) + 146 => b"glagolitic_kako".to_vec(), // Ⰼ (Kako, 146) + 147 => b"glagolitic_ljudije".to_vec(), // Ⰽ (Ljudije, 147) + 148 => b"glagolitic_myse".to_vec(), // Ⰾ (Myse, 148) + 149 => b"glagolitic_nash".to_vec(), // Ⰿ (Nash, 149) + 150 => b"glagolitic_on".to_vec(), // Ⱀ (On, 150) + 151 => b"glagolitic_pokoj".to_vec(), // Ⱁ (Pokoj, 151) + 152 => b"glagolitic_rtsy".to_vec(), // Ⱂ (Rtsy, 152) + 153 => b"glagolitic_slovo".to_vec(), // Ⱃ (Slovo, 153) + 154 => b"glagolitic_tvrido".to_vec(), // Ⱄ (Tvrido, 154) + 155 => b"glagolitic_uku".to_vec(), // Ⱅ (Uku, 155) + 156 => b"glagolitic_fert".to_vec(), // Ⱆ (Fert, 156) + 157 => b"glagolitic_xrivi".to_vec(), // Ⱇ (Xrivi, 157) + 158 => b"glagolitic_ot".to_vec(), // Ⱈ (Ot, 158) + 159 => b"glagolitic_cy".to_vec(), // Ⱉ (Cy, 159) + 160 => b"glagolitic_shcha".to_vec(), // Ⱊ (Shcha, 160) + 161 => b"glagolitic_er".to_vec(), // Ⱋ (Er, 161) + 162 => b"glagolitic_yeru".to_vec(), // Ⱌ (Yeru, 162) + 163 => b"glagolitic_small_yer".to_vec(), // Ⱍ (Small Yer, 163) + 164 => b"glagolitic_yo".to_vec(), // Ⱎ (Yo, 164) + 165 => b"glagolitic_yu".to_vec(), // Ⱏ (Yu, 165) + 166 => b"glagolitic_ja".to_vec(), // Ⱐ (Ja, 166) + 167 => b"thai_ko_kai".to_vec(), // ก (Ko Kai, 167) + 168 => b"thai_kho_khai".to_vec(), // ข (Kho Khai, 168) + 169 => b"thai_kho_khuat".to_vec(), // ฃ (Kho Khuat, 169) + 170 => b"thai_kho_khon".to_vec(), // ค (Kho Khon, 170) + 171 => b"thai_kho_rakhang".to_vec(), // ฅ (Kho Rakhang, 171) + 172 => b"thai_kho_khwai".to_vec(), // ฆ (Kho Khwai, 172) + 173 => b"thai_ngo_ngu".to_vec(), // ง (Ngo Ngu, 173) + 174 => b"thai_cho_chan".to_vec(), // จ (Cho Chan, 174) + 175 => b"thai_cho_ching".to_vec(), // ฉ (Cho Ching, 175) + 176 => b"thai_cho_chang".to_vec(), // ช (Cho Chang, 176) + 177 => b"thai_so_so".to_vec(), // ซ (So So, 177) + 178 => b"thai_cho_choe".to_vec(), // ฌ (Cho Choe, 178) + 179 => b"thai_yo_ying".to_vec(), // ญ (Yo Ying, 179) + 180 => b"thai_do_chada".to_vec(), // ฎ (Do Chada, 180) + 181 => b"thai_to_patak".to_vec(), // ฏ (To Patak, 181) + 182 => b"thai_tho_than".to_vec(), // ฐ (Tho Than, 182) + 183 => b"thai_tho_nangmontho".to_vec(), // ฑ (Tho Nangmontho, 183) + 184 => b"thai_tho_phuthao".to_vec(), // ฒ (Tho Phuthao, 184) + 185 => b"thai_no_nen".to_vec(), // ณ (No Nen, 185) + 186 => b"thai_do_dek".to_vec(), // ด (Do Dek, 186) + 187 => b"thai_to_tao".to_vec(), // ต (To Tao, 187) + 188 => b"thai_tho_thung".to_vec(), // ถ (Tho Thung, 188) + 189 => b"thai_tho_thahan".to_vec(), // ท (Tho Thahan, 189) + 190 => b"thai_tho_thong".to_vec(), // ธ (Tho Thong, 190) + 191 => b"thai_no_nu".to_vec(), // น (No Nu, 191) + 192 => b"thai_bo_baimai".to_vec(), // บ (Bo Baimai, 192) + 193 => b"thai_po_pla".to_vec(), // ป (Po Pla, 193) + 194 => b"thai_pho_phung".to_vec(), // ผ (Pho Phung, 194) + 195 => b"thai_fo_fa".to_vec(), // ฝ (Fo Fa, 195) + 196 => b"thai_pho_phan".to_vec(), // พ (Pho Phan, 196) + 197 => b"thai_fo_fan".to_vec(), // ฟ (Fo Fan, 197) + 198 => b"thai_pho_samphao".to_vec(), // ภ (Pho Samphao, 198) + 199 => b"thai_mo_ma".to_vec(), // ม (Mo Ma, 199) + 200 => b"thai_yo_yak".to_vec(), // ย (Yo Yak, 200) + 201 => b"thai_ro_rua".to_vec(), // ร (Ro Rua, 201) + 202 => b"thai_lo_ling".to_vec(), // ล (Lo Ling, 202) + 203 => b"thai_wo_waen".to_vec(), // ว (Wo Waen, 203) + 204 => b"thai_so_sala".to_vec(), // ศ (So Sala, 204) + 205 => b"thai_so_rusi".to_vec(), // ษ (So Rusi, 205) + 206 => b"thai_so_sua".to_vec(), // ส (So Sua, 206) + 207 => b"thai_ho_hip".to_vec(), // ห (Ho Hip, 207) + 208 => b"thai_lo_chula".to_vec(), // ฬ (Lo Chula, 208) + 209 => b"thai_o_ang".to_vec(), // อ (O Ang, 209) + 210 => b"thai_ho_nokhuk".to_vec(), // ฮ (Ho Nokhuk, 210) + 211 => b"hangul_giyeok".to_vec(), // ㄱ (Giyeok, 211) + 212 => b"hangul_nieun".to_vec(), // ㄴ (Nieun, 212) + 213 => b"hangul_digeut".to_vec(), // ㄷ (Digeut, 213) + 214 => b"hangul_rieul".to_vec(), // ㄹ (Rieul, 214) + 215 => b"hangul_mieum".to_vec(), // ㅁ (Mieum, 215) + 216 => b"hangul_bieup".to_vec(), // ㅂ (Bieup, 216) + 217 => b"hangul_siot".to_vec(), // ㅅ (Siot, 217) + 218 => b"hangul_ieung".to_vec(), // ㅇ (Ieung, 218) + 219 => b"hangul_jieut".to_vec(), // ㅈ (Jieut, 219) + 220 => b"hangul_chieut".to_vec(), // ㅊ (Chieut, 220) + 221 => b"hangul_kieuk".to_vec(), // ㅋ (Kieuk, 221) + 222 => b"hangul_tieut".to_vec(), // ㅌ (Tieut, 222) + 223 => b"hangul_pieup".to_vec(), // ㅍ (Pieup, 223) + 224 => b"hangul_hieut".to_vec(), // ㅎ (Hieut, 224) + 225 => b"hangul_a".to_vec(), // ㅏ (A, 225) + 226 => b"hangul_ae".to_vec(), // ㅐ (Ae, 226) + 227 => b"hangul_ya".to_vec(), // ㅑ (Ya, 227) + 228 => b"hangul_yae".to_vec(), // ㅒ (Yae, 228) + 229 => b"hangul_eo".to_vec(), // ㅓ (Eo, 229) + 230 => b"hangul_e".to_vec(), // ㅔ (E, 230) + 231 => b"hangul_yeo".to_vec(), // ㅕ (Yeo, 231) + 232 => b"hangul_ye".to_vec(), // ㅖ (Ye, 232) + 233 => b"hangul_o".to_vec(), // ㅗ (O, 233) + 234 => b"hangul_wa".to_vec(), // ㅘ (Wa, 234) + 235 => b"hangul_wae".to_vec(), // ㅙ (Wae, 235) + 236 => b"hangul_oe".to_vec(), // ㅚ (Oe, 236) + 237 => b"hangul_yo".to_vec(), // ㅛ (Yo, 237) + 238 => b"hangul_u".to_vec(), // ㅜ (U, 238) + 239 => b"hangul_weo".to_vec(), // ㅝ (Weo, 239) + 240 => b"hangul_we".to_vec(), // ㅞ (We, 240) + 241 => b"hangul_wi".to_vec(), // ㅟ (Wi, 241) + 242 => b"hangul_yu".to_vec(), // ㅠ (Yu, 242) + 243 => b"hangul_eu".to_vec(), // ㅡ (Eu, 243) + 244 => b"hangul_ui".to_vec(), // ㅢ (Ui, 244) + 245 => b"hangul_i".to_vec(), // ㅣ (I, 245) + 246 => b"ethiopic_glottal_a".to_vec(), // አ (Glottal A, 246) + 247 => b"ethiopic_glottal_u".to_vec(), // ኡ (Glottal U, 247) + 248 => b"ethiopic_glottal_i".to_vec(), // ኢ (Glottal I, 248) + 249 => b"ethiopic_glottal_aa".to_vec(), // ኣ (Glottal Aa, 249) + 250 => b"ethiopic_glottal_e".to_vec(), // ኤ (Glottal E, 250) + 251 => b"ethiopic_glottal_ie".to_vec(), // እ (Glottal Ie, 251) + 252 => b"ethiopic_glottal_o".to_vec(), // ኦ (Glottal O, 252) + 253 => b"ethiopic_glottal_wa".to_vec(), // ኧ (Glottal Wa, 253) + 254 => b"ethiopic_wa".to_vec(), // ወ (Wa, 254) + 255 => b"ethiopic_wu".to_vec(), // ዉ (Wu, 255) + 256 => b"ethiopic_wi".to_vec(), // ዊ (Wi, 256) + 257 => b"ethiopic_waa".to_vec(), // ዋ (Waa, 257) + 258 => b"ethiopic_we".to_vec(), // ዌ (We, 258) + 259 => b"ethiopic_wye".to_vec(), // ው (Wye, 259) + 260 => b"ethiopic_wo".to_vec(), // ዎ (Wo, 260) + 261 => b"ethiopic_ko".to_vec(), // ኰ (Ko, 261) + 262 => b"ethiopic_ku".to_vec(), // ኱ (Ku, 262) + 263 => b"ethiopic_ki".to_vec(), // ኲ (Ki, 263) + 264 => b"ethiopic_kua".to_vec(), // ኳ (Kua, 264) + 265 => b"ethiopic_ke".to_vec(), // ኴ (Ke, 265) + 266 => b"ethiopic_kwe".to_vec(), // ኵ (Kwe, 266) + 267 => b"ethiopic_ko_alt".to_vec(), // ኶ (Ko, 267) + 268 => b"ethiopic_go".to_vec(), // ጐ (Go, 268) + 269 => b"ethiopic_gu".to_vec(), // ጑ (Gu, 269) + 270 => b"ethiopic_gi".to_vec(), // ጒ (Gi, 270) + 271 => b"ethiopic_gua".to_vec(), // መ (Gua, 271) + 272 => b"ethiopic_ge".to_vec(), // ጔ (Ge, 272) + 273 => b"ethiopic_gwe".to_vec(), // ጕ (Gwe, 273) + 274 => b"ethiopic_go_alt".to_vec(), // ጖ (Go, 274) + 275 => b"devanagari_a".to_vec(), // अ (A, 275) + 276 => b"devanagari_aa".to_vec(), // आ (Aa, 276) + 277 => b"devanagari_i".to_vec(), // इ (I, 277) + 278 => b"devanagari_ii".to_vec(), // ई (Ii, 278) + 279 => b"devanagari_u".to_vec(), // उ (U, 279) + 280 => b"devanagari_uu".to_vec(), // ऊ (Uu, 280) + 281 => b"devanagari_r".to_vec(), // ऋ (R, 281) + 282 => b"devanagari_e".to_vec(), // ए (E, 282) + 283 => b"devanagari_ai".to_vec(), // ऐ (Ai, 283) + 284 => b"devanagari_o".to_vec(), // ओ (O, 284) + 285 => b"devanagari_au".to_vec(), // औ (Au, 285) + 286 => b"devanagari_ka".to_vec(), // क (Ka, 286) + 287 => b"devanagari_kha".to_vec(), // ख (Kha, 287) + 288 => b"devanagari_ga".to_vec(), // ग (Ga, 288) + 289 => b"devanagari_gha".to_vec(), // घ (Gha, 289) + 290 => b"devanagari_nga".to_vec(), // ङ (Nga, 290) + 291 => b"devanagari_cha".to_vec(), // च (Cha, 291) + 292 => b"devanagari_chha".to_vec(), // छ (Chha, 292) + 293 => b"devanagari_ja".to_vec(), // ज (Ja, 293) + 294 => b"devanagari_jha".to_vec(), // झ (Jha, 294) + 295 => b"devanagari_nya".to_vec(), // ञ (Nya, 295) + 296 => b"devanagari_ta".to_vec(), // ट (Ta, 296) + 297 => b"devanagari_tha".to_vec(), // ठ (Tha, 297) + 298 => b"devanagari_da".to_vec(), // ड (Da, 298) + 299 => b"devanagari_dha".to_vec(), // ढ (Dha, 299) + 300 => b"devanagari_na".to_vec(), // ण (Na, 300) + 301 => b"devanagari_ta_alt".to_vec(), // त (Ta, 301) + 302 => b"devanagari_tha_alt".to_vec(), // थ (Tha, 302) + 303 => b"devanagari_da_alt".to_vec(), // द (Da, 303) + 304 => b"devanagari_dha_alt".to_vec(), // ध (Dha, 304) + 305 => b"devanagari_na_alt".to_vec(), // न (Na, 305) + 306 => b"devanagari_pa".to_vec(), // प (Pa, 306) + 307 => b"devanagari_pha".to_vec(), // फ (Pha, 307) + 308 => b"devanagari_ba".to_vec(), // ब (Ba, 308) + 309 => b"devanagari_bha".to_vec(), // भ (Bha, 309) + 310 => b"devanagari_ma".to_vec(), // म (Ma, 310) + 311 => b"devanagari_ya".to_vec(), // य (Ya, 311) + 312 => b"devanagari_ra".to_vec(), // र (Ra, 312) + 313 => b"devanagari_la".to_vec(), // ल (La, 313) + 314 => b"devanagari_va".to_vec(), // व (Va, 314) + 315 => b"devanagari_sha".to_vec(), // श (Sha, 315) + 316 => b"devanagari_ssa".to_vec(), // ष (Ssa, 316) + 317 => b"devanagari_sa".to_vec(), // स (Sa, 317) + 318 => b"devanagari_ha".to_vec(), // ह (Ha, 318) + 319 => b"katakana_a".to_vec(), // ア (A, 319) + 320 => b"kana_i".to_vec(), + 321 => b"kana_u".to_vec(), + 322 => b"kana_e".to_vec(), + 323 => b"kana_o".to_vec(), + 324 => b"kana_a".to_vec(), + 325 => b"kana_ki".to_vec(), + 326 => b"kana_ku".to_vec(), + 327 => b"kana_ke".to_vec(), + 328 => b"kana_ko".to_vec(), + 329 => b"kana_sa".to_vec(), + 330 => b"kana_shi".to_vec(), + 331 => b"kana_su".to_vec(), + 332 => b"kana_se".to_vec(), + 333 => b"kana_so".to_vec(), + 334 => b"kana_ta".to_vec(), + 335 => b"kana_chi".to_vec(), + 336 => b"kana_tsu".to_vec(), + 337 => b"kana_te".to_vec(), + 338 => b"kana_to".to_vec(), + 339 => b"kana_na".to_vec(), + 340 => b"kana_ni".to_vec(), + 341 => b"kana_nu".to_vec(), + 342 => b"kana_ne".to_vec(), + 343 => b"kana_no".to_vec(), + 344 => b"kana_ha".to_vec(), + 345 => b"kana_hi".to_vec(), + 346 => b"kana_fu".to_vec(), + 347 => b"kana_he".to_vec(), + 348 => b"kana_ho".to_vec(), + 349 => b"kana_ma".to_vec(), + 350 => b"kana_mi".to_vec(), + 351 => b"kana_mu".to_vec(), + 352 => b"kana_me".to_vec(), + 353 => b"kana_mo".to_vec(), + 354 => b"kana_ya".to_vec(), + 355 => b"kana_yu".to_vec(), + 356 => b"kana_yo".to_vec(), + 357 => b"kana_ra".to_vec(), + 358 => b"kana_ri".to_vec(), + 359 => b"kana_ru".to_vec(), + 360 => b"kana_re".to_vec(), + 361 => b"kana_ro".to_vec(), + 362 => b"kana_wa".to_vec(), + 363 => b"kana_wo".to_vec(), + 364 => b"kana_n".to_vec(), + 365 => b"ya".to_vec(), + 366 => b"yab".to_vec(), + 367 => b"yabh".to_vec(), + 368 => b"yag".to_vec(), + 369 => b"yagh".to_vec(), + 370 => b"yaj".to_vec(), + 371 => b"yach".to_vec(), + 372 => b"yad".to_vec(), + 373 => b"yadh".to_vec(), + 374 => b"yadhe".to_vec(), + 375 => b"yaz".to_vec(), + 376 => b"yazh".to_vec(), + 377 => b"yaf".to_vec(), + 378 => b"yak".to_vec(), + 379 => b"yakv".to_vec(), + 380 => b"yaq".to_vec(), + 381 => b"yah".to_vec(), + 382 => b"yahh".to_vec(), + 383 => b"yahl".to_vec(), + 384 => b"yahm".to_vec(), + 385 => b"yayn".to_vec(), + 386 => b"yakh".to_vec(), + 387 => b"yakl".to_vec(), + 388 => b"yahq".to_vec(), + 389 => b"yash".to_vec(), + 390 => b"yi".to_vec(), + 391 => b"yij".to_vec(), + 392 => b"yizh".to_vec(), + 393 => b"yink".to_vec(), + 394 => b"yal".to_vec(), + 395 => b"yam".to_vec(), + 396 => b"yan".to_vec(), + 397 => b"yang".to_vec(), + 398 => b"yany".to_vec(), + 399 => b"yap".to_vec(), + 400 => b"yu".to_vec(), + 401 => b"a".to_vec(), + 402 => b"aa".to_vec(), + 403 => b"i".to_vec(), + 404 => b"ii".to_vec(), + 405 => b"u".to_vec(), + 406 => b"uu".to_vec(), + 407 => b"r".to_vec(), + 408 => b"rr".to_vec(), + 409 => b"l".to_vec(), + 410 => b"ll".to_vec(), + 411 => b"e".to_vec(), + 412 => b"ee".to_vec(), + 413 => b"ai".to_vec(), + 414 => b"o".to_vec(), + 415 => b"oo".to_vec(), + 416 => b"au".to_vec(), + 417 => b"ka".to_vec(), + 418 => b"kha".to_vec(), + 419 => b"ga".to_vec(), + 420 => b"gha".to_vec(), + 421 => b"nga".to_vec(), + 422 => b"cha".to_vec(), + 423 => b"chha".to_vec(), + 424 => b"ja".to_vec(), + 425 => b"jha".to_vec(), + 426 => b"nya".to_vec(), + 427 => b"ta".to_vec(), + 428 => b"tha".to_vec(), + 429 => b"da".to_vec(), + 430 => b"dha".to_vec(), + 431 => b"na".to_vec(), + 432 => b"pa".to_vec(), + 433 => b"pha".to_vec(), + 434 => b"ba".to_vec(), + 435 => b"bha".to_vec(), + 436 => b"ma".to_vec(), + 437 => b"ya".to_vec(), + 438 => b"ra".to_vec(), + 439 => b"la".to_vec(), + 440 => b"va".to_vec(), + 441 => b"sha".to_vec(), + 442 => b"ssa".to_vec(), + 443 => b"sa".to_vec(), + 444 => b"ha".to_vec(), + _ => b"unknown".to_vec(), + } + // match netuid { + // // Greek Alphabet (Lowercase) + // 0 => b"root".to_vec(), // Τ (Upper case Tau) + // 1 => b"apex".to_vec(), // α (Alpha) + // 2 => b"omron".to_vec(), // β (Beta) + // 3 => b"templar".to_vec(), // γ (Gamma) + // 4 => b"targon".to_vec(), // δ (Delta) + // 5 => b"kaito".to_vec(), // ε (Epsilon) + // 6 => b"infinite".to_vec(), // ζ (Zeta) + // 7 => b"subvortex".to_vec(), // η (Eta) + // 8 => b"ptn".to_vec(), // θ (Theta) + // 9 => b"pretrain".to_vec(), // ι (Iota) + // 10 => b"sturdy".to_vec(), // κ (Kappa) + // 11 => b"dippy".to_vec(), // λ (Lambda) + // 12 => b"horde".to_vec(), // μ (Mu) + // 13 => b"dataverse".to_vec(), // ν (Nu) + // 14 => b"palaidn".to_vec(), // ξ (Xi) + // 15 => b"deval".to_vec(), // ο (Omicron) + // 16 => b"bitads".to_vec(), // π (Pi) + // 17 => b"3gen".to_vec(), // ρ (Rho) + // 18 => b"cortex".to_vec(), // σ (Sigma) + // 19 => b"inference".to_vec(), // t (Tau) + // 20 => b"bitagent".to_vec(), // υ (Upsilon) + // 21 => b"any-any".to_vec(), // φ (Phi) + // 22 => b"meta".to_vec(), // χ (Chi) + // 23 => b"social".to_vec(), // ψ (Psi) + // 24 => b"omega".to_vec(), // ω (Omega) + // 25 => b"protein".to_vec(), // א (Aleph) + // 26 => b"alchemy".to_vec(), // ב (Bet) + // 27 => b"compute".to_vec(), // ג (Gimel) + // 28 => b"oracle".to_vec(), // ד (Dalet) + // 29 => b"coldint".to_vec(), // ה (He) + // 30 => b"bet".to_vec(), // ו (Vav) + // 31 => b"naschain".to_vec(), // ז (Zayin) + // 32 => b"itsai".to_vec(), // ח (Het) + // 33 => b"ready".to_vec(), // ט (Tet) + // 34 => b"mind".to_vec(), // י (Yod) + // 35 => b"logic".to_vec(), // ך (Final Kaf) + // 36 => b"automata".to_vec(), // כ (Kaf) + // 37 => b"tuning".to_vec(), // ל (Lamed) + // 38 => b"distributed".to_vec(), // ם (Final Mem) + // 39 => b"edge".to_vec(), // מ (Mem) + // 40 => b"chunk".to_vec(), // ן (Final Nun) + // 41 => b"sportsensor".to_vec(), // נ (Nun) + // 42 => b"masa".to_vec(), // ס (Samekh) + // 43 => b"graphite".to_vec(), // ע (Ayin) + // 44 => b"score".to_vec(), // ף (Final Pe) + // 45 => b"gen42".to_vec(), // פ (Pe) + // 46 => b"neural".to_vec(), // ץ (Final Tsadi) + // 47 => b"condense".to_vec(), // צ (Tsadi) + // 48 => b"nextplace".to_vec(), // ק (Qof) + // 49 => b"automl".to_vec(), // ר (Resh) + // 50 => b"audio".to_vec(), // ש (Shin) + // 51 => b"celium".to_vec(), // ת (Tav) + // 52 => b"dojo".to_vec(), // ا (Alif) + // 53 => b"frontier".to_vec(), // ب (Ba) + // 54 => b"safescan".to_vec(), // ت (Ta) + // 55 => b"unknown".to_vec(), // ث (Tha) + // 56 => b"gradients".to_vec(), // ج (Jim) + // 57 => b"gaia".to_vec(), // ح (Ha) + // 58 => b"dippy-speach".to_vec(), // خ (Kha) + // 59 => b"agent-arena".to_vec(), // د (Dal) + // 60 => b"unknown".to_vec(), // ذ (Dhal) + // 61 => b"red team".to_vec(), // ر (Ra) + // 62 => b"agentao".to_vec(), // ز (Zay) + // 63 => b"lean-in".to_vec(), // س (Sin) + // 64 => b"chutes".to_vec(), // ش (Shin) + // // Default case + // _ => b"unknown".to_vec(), // unknown subnet. + // } + }) } pub fn get_symbol_for_subnet(netuid: u16) -> Vec { From 3894cf696625715b29bf599acf4de9eb4131c325 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 2 Apr 2025 18:21:43 -0400 Subject: [PATCH 002/226] clippy --- .../src/migrations/migrate_remove_subnet_name_map.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs b/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs index b7259325d4..450929ff90 100644 --- a/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs +++ b/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs @@ -2,11 +2,7 @@ use super::*; use crate::HasMigrationRun; use frame_support::{traits::Get, weights::Weight}; use scale_info::prelude::string::String; -use sp_io::{ - KillStorageResult, - hashing::twox_128, - storage::{clear, clear_prefix}, -}; +use sp_io::{KillStorageResult, hashing::twox_128, storage::clear_prefix}; fn remove_prefix(old_map: &str, weight: &mut Weight) { let mut prefix = Vec::new(); From 4c7e1b60eb8ee94c978ef78550e890b56ee1eaf5 Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 8 Apr 2025 23:01:43 +0900 Subject: [PATCH 003/226] Add precompile to allow for UID lookup when provided with EVM address --- pallets/admin-utils/src/lib.rs | 2 ++ pallets/subtensor/src/utils/evm.rs | 15 ++++++++ precompiles/src/lib.rs | 5 +++ precompiles/src/solidity/uidLookup.abi | 43 +++++++++++++++++++++++ precompiles/src/solidity/uidLookup.sol | 16 +++++++++ precompiles/src/uid_lookup.rs | 48 ++++++++++++++++++++++++++ 6 files changed, 129 insertions(+) create mode 100644 precompiles/src/solidity/uidLookup.abi create mode 100644 precompiles/src/solidity/uidLookup.sol create mode 100644 precompiles/src/uid_lookup.rs diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 19bbbee73b..cc71260483 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -108,6 +108,8 @@ pub mod pallet { Metagraph, /// Enum for neuron precompile Neuron, + /// Enum for UID lookup precompile + UidLookup, } #[pallet::type_value] diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index a34f6afc80..fe6927ffd1 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -71,4 +71,19 @@ impl Pallet { Ok(()) } + + pub fn uid_lookup(netuid: u16, evm_key: H160, limit: u16) -> Vec<(u16, u64)> { + let mut ret_val = AssociatedEvmAddress::::iter_prefix(netuid) + .take(limit as usize) + .filter_map(|(uid, (stored_evm_key, block_associated))| { + if stored_evm_key != evm_key { + return None; + } + + Some((uid, block_associated)) + }) + .collect::>(); + ret_val.sort_by(|(_, block1), (_, block2)| block1.cmp(block2)); + ret_val + } } diff --git a/precompiles/src/lib.rs b/precompiles/src/lib.rs index ed0c2222a2..ca52831323 100644 --- a/precompiles/src/lib.rs +++ b/precompiles/src/lib.rs @@ -26,6 +26,7 @@ use crate::metagraph::*; use crate::neuron::*; use crate::staking::*; use crate::subnet::*; +use crate::uid_lookup::*; mod balance_transfer; mod ed25519; @@ -34,6 +35,7 @@ mod metagraph; mod neuron; mod staking; mod subnet; +mod uid_lookup; pub struct Precompiles(PhantomData); @@ -158,6 +160,9 @@ where a if a == hash(NeuronPrecompile::::INDEX) => { NeuronPrecompile::::try_execute::(handle, PrecompileEnum::Neuron) } + a if a == hash(UidLookupPrecompile::::INDEX) => { + UidLookupPrecompile::::try_execute::(handle, PrecompileEnum::UidLookup) + } _ => None, } } diff --git a/precompiles/src/solidity/uidLookup.abi b/precompiles/src/solidity/uidLookup.abi new file mode 100644 index 0000000000..558358dcaa --- /dev/null +++ b/precompiles/src/solidity/uidLookup.abi @@ -0,0 +1,43 @@ +[ + { + "inputs": [ + { + "internalType": "uint16", + "name": "netuid", + "type": "uint16" + }, + { + "internalType": "address", + "name": "evm_address", + "type": "address" + }, + { + "internalType": "uint16", + "name": "limit", + "type": "uint16" + } + ], + "name":"uidLookup", + "outputs": [ + { + "components": [ + { + "internalType": "uint16", + "name": "uid", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "block_associated", + "type": "uint64" + } + ], + "internalType": "struct LookupItem[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/precompiles/src/solidity/uidLookup.sol b/precompiles/src/solidity/uidLookup.sol new file mode 100644 index 0000000000..4eae98899c --- /dev/null +++ b/precompiles/src/solidity/uidLookup.sol @@ -0,0 +1,16 @@ +pragma solidity ^0.8.0; + +address constant IUID_LOOKUP_ADDRESS = 0x0000000000000000000000000000000000000806; + +struct LookupItem { + uint16 uid; + uint64 block_associated; +} + +interface IUidLookup { + function uidLookup( + uint16 netuid, + address evm_address, + uint16 limit + ) external view returns (LookupItem[] memory); +} diff --git a/precompiles/src/uid_lookup.rs b/precompiles/src/uid_lookup.rs new file mode 100644 index 0000000000..61ada80e32 --- /dev/null +++ b/precompiles/src/uid_lookup.rs @@ -0,0 +1,48 @@ +use core::marker::PhantomData; + +use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; +use pallet_evm::PrecompileHandle; +use precompile_utils::{prelude::Address, EvmResult}; +use sp_runtime::traits::{Dispatchable, StaticLookup}; + +use crate::PrecompileExt; + +pub(crate) struct UidLookupPrecompile(PhantomData); + +impl PrecompileExt for UidLookupPrecompile +where + R: frame_system::Config + pallet_subtensor::Config + pallet_evm::Config, + R::AccountId: From<[u8; 32]>, + ::RuntimeCall: + GetDispatchInfo + Dispatchable, + ::RuntimeCall: From> + + GetDispatchInfo + + Dispatchable, + <::Lookup as StaticLookup>::Source: From, +{ + const INDEX: u64 = 2054; +} + +#[precompile_utils::precompile] +impl UidLookupPrecompile +where + R: frame_system::Config + pallet_subtensor::Config + pallet_evm::Config, + R::AccountId: From<[u8; 32]>, + ::RuntimeCall: + GetDispatchInfo + Dispatchable, + ::RuntimeCall: From> + + GetDispatchInfo + + Dispatchable, + <::Lookup as StaticLookup>::Source: From, +{ + #[precompile::public("uidLookup(uint16,address,uint16)")] + #[precompile::view] + fn uid_lookup( + _handle: &mut impl PrecompileHandle, + netuid: u16, + evm_address: Address, + limit: u16, + ) -> EvmResult> { + Ok(pallet_subtensor::Pallet::::uid_lookup(netuid, evm_address.0, limit)) + } +} From c2d5b1527676080f8aad4f9785e0cc737de26396 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 22 Jan 2025 12:52:27 +0000 Subject: [PATCH 004/226] yuma bonds scale individually --- pallets/subtensor/src/epoch/math.rs | 27 +++++++++++-- pallets/subtensor/src/epoch/run_epoch.rs | 49 ++++++++++-------------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index b4f23ced83..c660b7f02b 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1207,6 +1207,15 @@ pub fn interpolate_sparse( result } +// Element-wise product of two vectors. +#[allow(dead_code)] +pub fn vec_mul(a: &[I32F32], b: &[I32F32]) -> Vec { + a.iter() + .zip(b.iter()) + .map(|(x, y)| x.checked_mul(*y).unwrap_or_default()) + .collect() +} + // Element-wise product of two matrices. #[allow(dead_code)] pub fn hadamard(mat1: &[Vec], mat2: &[Vec]) -> Vec> { @@ -1446,9 +1455,21 @@ pub fn mat_ema_alpha_vec( old_row.get(j), result.get_mut(i).and_then(|row| row.get_mut(j)), ) { - *result_val = alpha_val - .saturating_mul(*new_val) - .saturating_add(one_minus_alpha.saturating_mul(*old_val)); + let decayed_val = one_minus_alpha.saturating_mul(*old_val); + let remaining_capacity = I32F32::from_num(1.0) + .saturating_sub(decayed_val) + .max(I32F32::from_num(0.0)); + + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + let purchase_increment = alpha_val.saturating_mul(*new_val); + + // Ensure that purchase does not exceed remaining capacity + let purchase = purchase_increment.min(remaining_capacity); + + *result_val = decayed_val + .saturating_add(purchase) + .min(I32F32::from_num(1.0)); } } } diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 62027f9636..51283d9b81 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -204,17 +204,25 @@ impl Pallet { inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 log::trace!("B:\n{:?}\n", &bonds); - // Compute bonds delta column normalized. - let mut bonds_delta: Vec> = row_hadamard(&weights_for_bonds, &active_stake); // ΔB = W◦S - inplace_col_normalize(&mut bonds_delta); // sum_i b_ij = 1 - log::trace!("ΔB:\n{:?}\n", &bonds_delta); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds(netuid, consensus.clone(), bonds_delta, bonds); + // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. + let mut ema_bonds = if let Some(clamped_bonds_alpha) = + Self::compute_liquid_alpha(netuid, consensus.clone()) + { + // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + Self::compute_ema_bonds_with_liquid_alpha(&weights.clone(), &bonds, clamped_bonds_alpha) + } else { + log::trace!("Using Bonds Moving Average"); + // Compute the EMA of bonds using a normal alpha value. + Self::compute_ema_bonds_normal(&weights.clone(), &bonds, netuid) + }; + inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); - // Compute dividends: d_i = SUM(j) b_ij * inc_j - let mut dividends: Vec = matmul_transpose(&ema_bonds, &incentive); + // # === Dividend Calculation=== + let total_bonds_per_validator: Vec = matmul_transpose(&ema_bonds, &incentive); + let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); inplace_normalize(&mut dividends); log::trace!("D:\n{:?}\n", ÷nds); @@ -1189,22 +1197,15 @@ impl Pallet { } } - /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting. + /// Compute liquid alphas based on the Liquid Alpha setting. /// /// # Args: /// * `netuid` - The network ID. /// * `consensus` - A vector of consensus values. - /// * `bonds_delta` - A vector of bond deltas. - /// * `bonds` - A vector of bonds. /// /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds( - netuid: u16, - consensus: Vec, - bonds_delta: Vec>, - bonds: Vec>, - ) -> Vec> { + /// A vector of alphas + pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Option> { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) && !consensus.is_empty() @@ -1238,20 +1239,10 @@ impl Pallet { // Clamp the alpha values between alpha_high and alpha_low. let clamped_alpha = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); - // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. - Self::compute_ema_bonds_with_liquid_alpha(&bonds_delta, &bonds, clamped_alpha) - } else { - log::trace!("Using Bonds Moving Average"); - - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal(&bonds_delta, &bonds, netuid) + return Some(clamped_alpha); } - } else { - log::trace!("Using Bonds Moving Average"); - - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal(&bonds_delta, &bonds, netuid) } + None } pub fn do_set_alpha_values( From 447a936a8f3e4fe85fb7d7ca66d0d00be840255d Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 22 Jan 2025 13:16:00 +0000 Subject: [PATCH 005/226] yuma bonds scale individually for sparse --- pallets/subtensor/src/epoch/math.rs | 15 +++- pallets/subtensor/src/epoch/run_epoch.rs | 106 +++++------------------ 2 files changed, 34 insertions(+), 87 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index c660b7f02b..7c00da2587 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1387,7 +1387,20 @@ pub fn mat_ema_alpha_vec_sparse( I32F32::saturating_from_num(1.0).saturating_sub(alpha_val); // Compute the EMA component for the old value and add it to the row using saturating operations. if let Some(row_val) = row.get_mut(*j as usize) { - *row_val = row_val.saturating_add(one_minus_alpha.saturating_mul(*value)); + let decayed_val = one_minus_alpha.saturating_mul(*value); + let remaining_capacity = I32F32::from_num(1.0) + .saturating_sub(decayed_val) + .max(I32F32::from_num(0.0)); + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + let purchase_increment = alpha_val.saturating_mul(*row_val); + + // Ensure that purchase does not exceed remaining capacity + let purchase = purchase_increment.min(remaining_capacity); + + *row_val = decayed_val + .saturating_add(purchase) + .min(I32F32::from_num(1.0)); } log::trace!( "old[{}][{}] * (1 - alpha[{}]) = {} * {} = {}", diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 51283d9b81..4d30832a37 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -216,7 +216,7 @@ impl Pallet { // Compute the EMA of bonds using a normal alpha value. Self::compute_ema_bonds_normal(&weights.clone(), &bonds, netuid) }; - + // Normalize EMA bonds. inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -591,25 +591,30 @@ impl Pallet { inplace_col_normalize_sparse(&mut bonds, n); log::trace!("B (mask+norm): {:?}", &bonds); - // Compute bonds delta column normalized. - let mut bonds_delta: Vec> = - row_hadamard_sparse(&weights_for_bonds, &active_stake); // ΔB = W◦S (outdated W masked) - log::trace!("ΔB: {:?}", &bonds_delta); - - // Normalize bonds delta. - inplace_col_normalize_sparse(&mut bonds_delta, n); // sum_i b_ij = 1 - log::trace!("ΔB (norm): {:?}", &bonds_delta); - // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = - Self::compute_ema_bonds_sparse(netuid, consensus.clone(), bonds_delta, bonds); + let mut ema_bonds = if let Some(clamped_bonds_alpha) = + Self::compute_liquid_alpha(netuid, consensus.clone()) + { + // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + Self::compute_ema_bonds_with_liquid_alpha_sparse( + &weights.clone(), + &bonds, + clamped_bonds_alpha, + ) + } else { + log::trace!("Using Bonds Moving Average"); + // Compute the EMA of bonds using a normal alpha value. + Self::compute_ema_bonds_normal_sparse(&weights.clone(), &bonds, netuid) + }; + // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); - // Compute dividends: d_i = SUM(j) b_ij * inc_j. - // range: I32F32(0, 1) - let mut dividends: Vec = matmul_transpose_sparse(&ema_bonds, &incentive); + // # === Dividend Calculation=== + let total_bonds_per_validator: Vec = + matmul_transpose_sparse(&ema_bonds, &incentive); + let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); inplace_normalize(&mut dividends); log::trace!("Dividends: {:?}", ÷nds); @@ -1126,77 +1131,6 @@ impl Pallet { ema_bonds } - /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting for a sparse matrix. - /// - /// # Args: - /// * `netuid` - The network ID. - /// * `consensus` - A vector of consensus values. - /// * `bonds_delta` - A vector of bond deltas. - /// * `bonds` - A vector of bonds. - /// - /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds_sparse( - netuid: u16, - consensus: Vec, - bonds_delta: Vec>, - bonds: Vec>, - ) -> Vec> { - // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. - // This way we avoid the quantil function panic. - if LiquidAlphaOn::::get(netuid) - && !consensus.is_empty() - && consensus - .iter() - .any(|&c| c != I32F32::saturating_from_num(0)) - { - // Calculate the 75th percentile (high) and 25th percentile (low) of the consensus values. - let consensus_high = quantile(&consensus, 0.75); - let consensus_low = quantile(&consensus, 0.25); - // Further check if the high and low consensus values meet the required conditions. - if (consensus_high > consensus_low) || consensus_high != 0 || consensus_low < 0 { - // if (consensus_high > consensus_low) || consensus_high != 0) || consensus_low != 0 { - // if (consensus_high > consensus_low) || consensus_low != 0 { - log::trace!("Using Liquid Alpha"); - - // Get the high and low alpha values for the network. - let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); - log::trace!("alpha_low: {:?} alpha_high: {:?}", alpha_low, alpha_high); - - // Calculate the logistic function parameters 'a' and 'b' based on alpha and consensus values. - let (a, b) = Self::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Compute the alpha values using the logistic function parameters. - let alpha = Self::compute_alpha_values(&consensus, a, b); - - // Clamp the alpha values between alpha_high and alpha_low. - let clamped_alpha = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); - - // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. - Self::compute_ema_bonds_with_liquid_alpha_sparse( - &bonds_delta, - &bonds, - clamped_alpha, - ) - } else { - log::trace!("Using Bonds Moving Average"); - - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal_sparse(&bonds_delta, &bonds, netuid) - } - } else { - log::trace!("Using Bonds Moving Average"); - - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal_sparse(&bonds_delta, &bonds, netuid) - } - } - /// Compute liquid alphas based on the Liquid Alpha setting. /// /// # Args: From ec9a1ed242fadb717db5affd6efb651b963dfd6c Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 22 Jan 2025 14:45:35 +0000 Subject: [PATCH 006/226] refactor alpha values --- pallets/subtensor/src/epoch/math.rs | 66 +---------- pallets/subtensor/src/epoch/run_epoch.rs | 145 ++++++----------------- pallets/subtensor/src/tests/epoch.rs | 10 +- pallets/subtensor/src/tests/math.rs | 16 +-- 4 files changed, 51 insertions(+), 186 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 7c00da2587..5d17ff9e0b 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1268,66 +1268,6 @@ pub fn hadamard_sparse( result } -// Return matrix exponential moving average: `alpha * a_ij + one_minus_alpha * b_ij`. -// `alpha` is the EMA coefficient, how much to add of the new observation, typically small, -// higher alpha discounts older observations faster. -#[allow(dead_code)] -pub fn mat_ema(new: &[Vec], old: &[Vec], alpha: I32F32) -> Vec> { - let Some(first_row) = new.first() else { - return vec![vec![]]; - }; - if first_row.is_empty() { - return vec![vec![]; 1]; - } - let one_minus_alpha: I32F32 = I32F32::saturating_from_num(1.0).saturating_sub(alpha); - new.iter() - .zip(old) - .map(|(new_row, old_row)| { - new_row - .iter() - .zip(old_row) - .map(|(new_elem, old_elem)| { - alpha - .saturating_mul(*new_elem) - .saturating_add(one_minus_alpha.saturating_mul(*old_elem)) - }) - .collect() - }) - .collect() -} - -// Return sparse matrix exponential moving average: `alpha * a_ij + one_minus_alpha * b_ij`. -// `alpha` is the EMA coefficient, how much to add of the new observation, typically small, -// higher alpha discounts older observations faster. -#[allow(dead_code, clippy::indexing_slicing)] -pub fn mat_ema_sparse( - new: &[Vec<(u16, I32F32)>], - old: &[Vec<(u16, I32F32)>], - alpha: I32F32, -) -> Vec> { - assert!(new.len() == old.len()); - let n = new.len(); // assume square matrix, rows=cols - let zero: I32F32 = I32F32::saturating_from_num(0.0); - let one_minus_alpha: I32F32 = I32F32::saturating_from_num(1.0).saturating_sub(alpha); - let mut result: Vec> = vec![vec![]; n]; - for i in 0..new.len() { - let mut row: Vec = vec![zero; n]; - for (j, value) in new[i].iter() { - row[*j as usize] = row[*j as usize].saturating_add(alpha.saturating_mul(*value)); - } - for (j, value) in old[i].iter() { - row[*j as usize] = - row[*j as usize].saturating_add(one_minus_alpha.saturating_mul(*value)); - } - for (j, value) in row.iter().enumerate() { - if *value > zero { - result[i].push((j as u16, *value)) - } - } - } - result -} - // Return sparse matrix only with elements >= threshold of an input sparse matrix. #[allow(dead_code)] pub fn sparse_threshold(w: &[Vec<(u16, I32F32)>], threshold: I32F32) -> Vec> { @@ -1342,6 +1282,10 @@ pub fn sparse_threshold(w: &[Vec<(u16, I32F32)>], threshold: I32F32) -> Vec], @@ -1430,6 +1374,7 @@ pub fn mat_ema_alpha_vec_sparse( /// Return matrix exponential moving average: `alpha_j * a_ij + one_minus_alpha_j * b_ij`. /// `alpha_` is the EMA coefficient passed as a vector per column. +// if liquid alpha off then the alpha vector will be constant #[allow(dead_code)] pub fn mat_ema_alpha_vec( new: &[Vec], @@ -1454,7 +1399,6 @@ pub fn mat_ema_alpha_vec( // Iterate over each row of the matrices. for (i, (new_row, old_row)) in new.iter().zip(old).enumerate() { - // Ensure the current row of the new and old matrices have the same length. assert!(new_row.len() == old_row.len()); // Iterate over each column of the current row. diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 4d30832a37..ef0f171c34 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -204,18 +204,11 @@ impl Pallet { inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 log::trace!("B:\n{:?}\n", &bonds); + // Get alpha values + let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); + // Compute the Exponential Moving Average (EMA) of bonds. - // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. - let mut ema_bonds = if let Some(clamped_bonds_alpha) = - Self::compute_liquid_alpha(netuid, consensus.clone()) - { - // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. - Self::compute_ema_bonds_with_liquid_alpha(&weights.clone(), &bonds, clamped_bonds_alpha) - } else { - log::trace!("Using Bonds Moving Average"); - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal(&weights.clone(), &bonds, netuid) - }; + let mut ema_bonds = Self::compute_ema_bonds(&weights.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -591,22 +584,11 @@ impl Pallet { inplace_col_normalize_sparse(&mut bonds, n); log::trace!("B (mask+norm): {:?}", &bonds); - // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = if let Some(clamped_bonds_alpha) = - Self::compute_liquid_alpha(netuid, consensus.clone()) - { - // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. - Self::compute_ema_bonds_with_liquid_alpha_sparse( - &weights.clone(), - &bonds, - clamped_bonds_alpha, - ) - } else { - log::trace!("Using Bonds Moving Average"); - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal_sparse(&weights.clone(), &bonds, netuid) - }; + // Get alpha values + let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); + // Compute the Exponential Moving Average (EMA) of bonds. + let mut ema_bonds = Self::compute_ema_bonds_sparse(&weights.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); @@ -1009,16 +991,16 @@ impl Pallet { clamped_alpha } - /// Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values for a sparse matrix. + /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values for a sparse matrix. /// /// # Args: /// * `bonds_delta` - A vector of bond deltas. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values. + /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds_with_liquid_alpha_sparse( + pub fn compute_ema_bonds_sparse( bonds_delta: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], alpha: Vec, @@ -1027,25 +1009,22 @@ impl Pallet { let ema_bonds = mat_ema_alpha_vec_sparse(bonds_delta, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. - log::trace!( - "Exponential Moving Average Bonds Liquid Alpha: {:?}", - ema_bonds - ); + log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); // Return the computed EMA bonds. ema_bonds } - /// Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values. /// /// # Args: /// * `bonds_delta` - A vector of bond deltas. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values. + /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds_with_liquid_alpha( + pub fn compute_ema_bonds( bonds_delta: &[Vec], bonds: &[Vec], alpha: Vec, @@ -1054,78 +1033,7 @@ impl Pallet { let ema_bonds = mat_ema_alpha_vec(bonds_delta, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. - log::trace!( - "Exponential Moving Average Bonds Liquid Alpha: {:?}", - ema_bonds - ); - - // Return the computed EMA bonds. - ema_bonds - } - - /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value for a sparse matrix. - /// - /// # Args: - /// * `bonds_delta` - A vector of bond deltas. - /// * `bonds` - A vector of bonds. - /// * `netuid` - The network ID. - /// - /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds_normal_sparse( - bonds_delta: &[Vec<(u16, I32F32)>], - bonds: &[Vec<(u16, I32F32)>], - netuid: u16, - ) -> Vec> { - // Retrieve the bonds moving average for the given network ID and scale it down. - let bonds_moving_average: I64F64 = - I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) - .safe_div(I64F64::saturating_from_num(1_000_000)); - - // Calculate the alpha value for the EMA calculation. - // Alpha is derived by subtracting the scaled bonds moving average from 1. - let alpha: I32F32 = I32F32::saturating_from_num(1) - .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); - - // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - let ema_bonds = mat_ema_sparse(bonds_delta, bonds, alpha); - - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); - - // Return the computed EMA bonds. - ema_bonds - } - - /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value. - /// - /// # Args: - /// * `bonds_delta` - A vector of bond deltas. - /// * `bonds` - A vector of bonds. - /// * `netuid` - The network ID. - /// - /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds_normal( - bonds_delta: &[Vec], - bonds: &[Vec], - netuid: u16, - ) -> Vec> { - // Retrieve the bonds moving average for the given network ID and scale it down. - let bonds_moving_average: I64F64 = - I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) - .safe_div(I64F64::saturating_from_num(1_000_000)); - - // Calculate the alpha value for the EMA calculation. - // Alpha is derived by subtracting the scaled bonds moving average from 1. - let alpha: I32F32 = I32F32::saturating_from_num(1) - .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); - - // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - let ema_bonds = mat_ema(bonds_delta, bonds, alpha); - - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); + log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); // Return the computed EMA bonds. ema_bonds @@ -1139,7 +1047,7 @@ impl Pallet { /// /// # Returns: /// A vector of alphas - pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Option> { + pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Vec { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) && !consensus.is_empty() @@ -1168,15 +1076,30 @@ impl Pallet { ); // Compute the alpha values using the logistic function parameters. + // alpha = 1 / (1 + math.e ** (-a * C + b)) # alpha to the old weight let alpha = Self::compute_alpha_values(&consensus, a, b); // Clamp the alpha values between alpha_high and alpha_low. let clamped_alpha = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); - return Some(clamped_alpha); + return clamped_alpha; } } - None + + // Liquid Alpha is disabled + // or high and low consensus values do not meet the required conditions. + // return vector of constant alpha + + // Retrieve the bonds moving average for the given network ID and scale it down. + let bonds_moving_average: I64F64 = I64F64::from_num(Self::get_bonds_moving_average(netuid)) + .saturating_div(I64F64::from_num(1_000_000)); + + // Calculate the alpha value for the EMA calculation. + // Alpha is derived by subtracting the scaled bonds moving average from 1. + let alpha: I32F32 = + I32F32::from_num(1).saturating_sub(I32F32::from_num(bonds_moving_average)); + + vec![alpha; consensus.len()] } pub fn do_set_alpha_values( diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index aaaf93e086..6c01ec4aa4 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2706,7 +2706,7 @@ fn test_calculate_logistic_params_edge_cases() { } #[test] -fn test_compute_ema_bonds_with_liquid_alpha_sparse() { +fn test_compute_ema_bonds_sparse() { // Define test inputs let bonds_delta = vec![ vec![(0, I32F32::from_num(0.1)), (1, I32F32::from_num(0.2))], @@ -2735,8 +2735,7 @@ fn test_compute_ema_bonds_with_liquid_alpha_sparse() { ]; // Call the function - let ema_bonds = - SubtensorModule::compute_ema_bonds_with_liquid_alpha_sparse(&bonds_delta, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); // Assert the results with an epsilon for approximate equality let epsilon = I32F32::from_num(1e-6); @@ -2744,7 +2743,7 @@ fn test_compute_ema_bonds_with_liquid_alpha_sparse() { } #[test] -fn test_compute_ema_bonds_with_liquid_alpha_sparse_empty() { +fn test_compute_ema_bonds_sparse_empty() { // Test with empty inputs let bonds_delta: Vec> = vec![]; let bonds: Vec> = vec![]; @@ -2754,8 +2753,7 @@ fn test_compute_ema_bonds_with_liquid_alpha_sparse_empty() { let expected_ema_bonds: Vec> = vec![]; // Call the function - let ema_bonds = - SubtensorModule::compute_ema_bonds_with_liquid_alpha_sparse(&bonds_delta, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); // Assert the results assert_eq!( diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index c70da2c9d2..3500acf589 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -2144,7 +2144,7 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema(&new, &old, I32F32::from_num(0.1)); + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let new: Vec = vec![ @@ -2154,7 +2154,7 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema(&new, &old, I32F32::from_num(0)); + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0); old.len()]); assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let new: Vec = vec![ @@ -2166,7 +2166,7 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema(&new, &old, I32F32::from_num(1)); + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(1); old.len()]); assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); } @@ -2182,7 +2182,7 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_sparse(&new, &old, I32F32::from_num(0.1)); + let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![0., 2., 3., 4., 0., 6., 7., 8., 0., 10., 11., 12.]; let new: Vec = vec![10., 20., 0., 40., 0., 60., 0., 80., 90., 100., 110., 120.]; @@ -2190,7 +2190,7 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_sparse(&new, &old, I32F32::from_num(0.1)); + let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![10., 20., 0., 40., 0., 60., 0., 80., 90., 100., 110., 120.]; @@ -2198,7 +2198,7 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_sparse(&new, &old, I32F32::from_num(0.1)); + let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; @@ -2206,7 +2206,7 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_sparse(&new, &old, I32F32::from_num(0.1)); + let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 2., 0., 0., 0., 0., 0., 0., 0.]; @@ -2214,7 +2214,7 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_sparse(&new, &old, I32F32::from_num(0.1)); + let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); } From 8f95924fd5a8a94f0cd5822d7aabb127f4d60ea8 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Mon, 27 Jan 2025 03:21:02 +0000 Subject: [PATCH 007/226] rebase fix --- pallets/subtensor/src/epoch/run_epoch.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index ef0f171c34..36510532ce 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -208,7 +208,7 @@ impl Pallet { let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds(&weights.clone(), &bonds, alpha); + let mut ema_bonds = Self::compute_ema_bonds(&weights_for_bonds.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -588,7 +588,8 @@ impl Pallet { let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds_sparse(&weights.clone(), &bonds, alpha); + let mut ema_bonds = + Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); From c5af5dbba4b80aa6d9c716415bfdcd95ac8e5bae Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 28 Jan 2025 09:54:30 +0000 Subject: [PATCH 008/226] update tests --- pallets/subtensor/src/tests/epoch.rs | 94 +++++++++++++------------- pallets/subtensor/src/tests/math.rs | 98 +++++++++++++++++----------- 2 files changed, 104 insertions(+), 88 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 6c01ec4aa4..9315eef06f 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -1061,9 +1061,9 @@ fn test_bonds() { P: [0.0499999989, 0.0999999992, 0.1500000006, 0.2000000011, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] emaB: [[(4, 0.2499999937), (5, 0.2499999953), (6, 0.2499999937), (7, 0.2499999937)], [(4, 0.4999999942), (5, 0.499999997), (6, 0.4999999942), (7, 0.4999999942)], [(4, 0.7499999937), (5, 0.7499999981), (6, 0.7499999995), (7, 0.7499999995)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][4], 16383); - assert_eq!(bonds[1][4], 32767); - assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[0][4], 65535); + assert_eq!(bonds[1][4], 65535); + assert_eq!(bonds[2][4], 65535); assert_eq!(bonds[3][4], 65535); // === Set self-weight only on val1 @@ -1109,9 +1109,9 @@ fn test_bonds() { P: [0.0449983515, 0.1011105615, 0.1516672159, 0.2022238704, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] emaB: [[(4, 0.2225175085), (5, 0.2225175085), (6, 0.2225175085), (7, 0.2225175085)], [(4, 0.499993208), (5, 0.4999932083), (6, 0.4999932083), (7, 0.4999932083)], [(4, 0.7499966028), (5, 0.7499966032), (6, 0.7499966032), (7, 0.7499966032)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][4], 14582); - assert_eq!(bonds[1][4], 32767); - assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[0][4], 65245); + assert_eq!(bonds[1][4], 65535); + assert_eq!(bonds[2][4], 65535); assert_eq!(bonds[3][4], 65535); // === Set self-weight only on val2 @@ -1146,9 +1146,9 @@ fn test_bonds() { P: [0.040496806, 0.0909997837, 0.157929636, 0.2105737738, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] emaB: [[(4, 0.192316476), (5, 0.192316476), (6, 0.192316476), (7, 0.192316476)], [(4, 0.4321515555), (5, 0.4321515558), (6, 0.4321515558), (7, 0.4321515558)], [(4, 0.7499967015), (5, 0.7499967027), (6, 0.7499967027), (7, 0.7499967027)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][4], 12603); - assert_eq!(bonds[1][4], 28321); - assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[0][4], 64956); + assert_eq!(bonds[1][4], 65245); + assert_eq!(bonds[2][4], 65535); assert_eq!(bonds[3][4], 65535); // === Set self-weight only on val3 @@ -1183,11 +1183,12 @@ fn test_bonds() { P: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] emaB: [[(4, 0.1923094518), (5, 0.1923094518), (6, 0.1923094518), (7, 0.1923094518)], [(4, 0.4321507583), (5, 0.4321507583), (6, 0.4321507583), (7, 0.4321507583)], [(4, 0.7499961846), (5, 0.7499961846), (6, 0.7499961846), (7, 0.7499961846)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 12602); - assert_eq!(bonds[1][7], 28320); - assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[0][7], 63269); + assert_eq!(bonds[1][7], 64394); + assert_eq!(bonds[2][7], 65535); assert_eq!(bonds[3][7], 65535); + // === Set val3->srv4: 1 assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(2)), netuid, vec![7], vec![u16::MAX], 0)); next_block_no_epoch(netuid); @@ -1219,9 +1220,9 @@ fn test_bonds() { P: [0.0364437331, 0.081898629, 0.1635654932, 0.2180921442, 0, 0, 0, 0.5] emaB: [[(4, 0.1922941932), (5, 0.1922941932), (6, 0.1922941932), (7, 0.1671024568)], [(4, 0.4321354993), (5, 0.4321354993), (6, 0.4321354993), (7, 0.3755230587)], [(4, 0.7499809256), (5, 0.7499809256), (6, 0.7499809256), (7, 0.749983425)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 10951); - assert_eq!(bonds[1][7], 24609); - assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[0][7], 62177); + assert_eq!(bonds[1][7], 63283); + assert_eq!(bonds[2][7], 65535); assert_eq!(bonds[3][7], 65535); next_block_no_epoch(netuid); @@ -1241,9 +1242,9 @@ fn test_bonds() { P: [0.0327994274, 0.0737066122, 0.1686381293, 0.2248558307, 0, 0, 0, 0.5] emaB: [[(4, 0.1922789337), (5, 0.1922789337), (6, 0.1922789337), (7, 0.1458686984)], [(4, 0.4321202405), (5, 0.4321202405), (6, 0.4321202405), (7, 0.3277949789)], [(4, 0.749965667), (5, 0.749965667), (6, 0.749965667), (7, 0.74998335)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 9559); - assert_eq!(bonds[1][7], 21482); - assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[0][7], 61113); + assert_eq!(bonds[1][7], 62200); + assert_eq!(bonds[2][7], 65535); assert_eq!(bonds[3][7], 65535); next_block_no_epoch(netuid); @@ -1263,9 +1264,9 @@ fn test_bonds() { P: [0.029518068, 0.0663361375, 0.1732031347, 0.2309426593, 0, 0, 0, 0.5] emaB: [[(4, 0.192263675), (5, 0.192263675), (6, 0.192263675), (7, 0.1278155716)], [(4, 0.4321049813), (5, 0.4321049813), (6, 0.4321049813), (7, 0.2872407278)], [(4, 0.7499504078), (5, 0.7499504078), (6, 0.7499504078), (7, 0.7499832863)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 8376); - assert_eq!(bonds[1][7], 18824); - assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[0][7], 60076); + assert_eq!(bonds[1][7], 61145); + assert_eq!(bonds[2][7], 65535); assert_eq!(bonds[3][7], 65535); next_block_no_epoch(netuid); @@ -1411,9 +1412,9 @@ fn test_bonds_with_liquid_alpha() { // Normalize ΔB: [0.25/7.5, 1.0/7.5, 2.25/7.5, 4.0/7.5] = [0.0333, 0.1333, 0.3, 0.5333] // Final bonds for netuid: [16383, 32767, 49151, 65535] - assert_eq!(bonds[0][4], 16383); // Note: Calculated as explained above - assert_eq!(bonds[1][4], 32767); // Note: Calculated as explained above - assert_eq!(bonds[2][4], 49151); // Note: Calculated as explained above + assert_eq!(bonds[0][4], 65535); // Note: Calculated as explained above + assert_eq!(bonds[1][4], 65535); // Note: Calculated as explained above + assert_eq!(bonds[2][4], 65535); // Note: Calculated as explained above assert_eq!(bonds[3][4], 65535); // Note: Calculated as explained above // === Set self-weight only on val1 @@ -1433,9 +1434,9 @@ fn test_bonds_with_liquid_alpha() { } let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 2862); - assert_eq!(bonds[1][4], 32767); - assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[0][4], 27572); + assert_eq!(bonds[1][4], 65535); + assert_eq!(bonds[2][4], 65535); assert_eq!(bonds[3][4], 65535); // === Set self-weight only on val2 @@ -1496,9 +1497,9 @@ fn test_bonds_with_liquid_alpha() { Pruning Scores: [0.0016997808, 0.0151777493, 0.2070524206, 0.2760700488, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ - assert_eq!(bonds[0][4], 435); - assert_eq!(bonds[1][4], 4985); - assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[0][4], 12662); + assert_eq!(bonds[1][4], 30097); + assert_eq!(bonds[2][4], 65535); assert_eq!(bonds[3][4], 65535); }); } @@ -1677,22 +1678,16 @@ fn test_active_stake() { P: [0.275, 0.2249999999, 0.25, 0.25] P (u16): [65535, 53619, 59577, 59577] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 36044); // Note D = floor((0.5 * 0.9 + 0.1) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 274999999); // Note E = 0.5 * 0.55 * 1_000_000_000 = 275_000_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 65535); // Note D = floor((0.5 * 0.9 + 0.1) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 500000000); // Note E = 0.5 * 0.55 * 1_000_000_000 = 275_000_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { assert_eq!(bonds[0][server], I32F32::from_num(65_535)); // floor(0.55*(2^16-1))/(2^16-1), then max-upscale } for validator in 1..(n / 2) { - assert_eq!( - SubtensorModule::get_dividends_for_uid(netuid, validator), - 29490 - ); // Note D = floor((0.5 * 0.9) * 65_535) - assert_eq!( - SubtensorModule::get_emission_for_uid(netuid, validator), - 224999999 - ); // Note E = 0.5 * 0.45 * 1_000_000_000 = 225_000_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, validator), 0); // Note D = floor((0.5 * 0.9) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, validator), 0); // Note E = 0.5 * 0.45 * 1_000_000_000 = 225_000_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[validator as usize][server], I32F32::from_num(53619)); + assert_eq!(bonds[validator as usize][server], I32F32::from_num(65535)); // floor(0.45*(2^16-1))/(2^16-1), then max-upscale } } @@ -1738,15 +1733,15 @@ fn test_active_stake() { P: [0.272501133, 0.2274988669, 0.25, 0.25] P (u16): [65535, 54711, 60123, 60123] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 35716); // Note D = floor((0.55 * 0.9 + 0.5 * 0.1) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 272501132); // Note E = 0.5 * (0.55 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 272_500_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); // Note D = floor((0.55 * 0.9 + 0.5 * 0.1) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); // Note E = 0.5 * (0.55 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 272_500_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { assert_eq!(bonds[0][server], I32F32::from_num(65_535)); // floor((0.55 * 0.9 + 0.5 * 0.1)*(2^16-1))/(2^16-1), then max-upscale } - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 29818); // Note D = floor((0.45 * 0.9 + 0.5 * 0.1) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 227498866); // Note E = 0.5 * (0.45 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 227_500_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 32767); // Note D = floor((0.45 * 0.9 + 0.5 * 0.1) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 250000000); // Note E = 0.5 * (0.45 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 227_500_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[1][server], I32F32::from_num(54712)); // floor((0.45 * 0.9 + 0.5 * 0.1)/(0.55 * 0.9 + 0.5 * 0.1)*(2^16-1)) + assert_eq!(bonds[1][server], I32F32::from_num(65_535)); // floor((0.45 * 0.9 + 0.5 * 0.1)/(0.55 * 0.9 + 0.5 * 0.1)*(2^16-1)) } }); } @@ -2730,15 +2725,16 @@ fn test_compute_ema_bonds_sparse() { // For bond (1, 1): // EMA = 0.8 * 0.4 + (1 - 0.8) * 0.8 = 0.32 + 0.16 = 0.48 let expected_ema_bonds = vec![ - vec![(0, I32F32::from_num(0.14)), (1, I32F32::from_num(0.28))], - vec![(0, I32F32::from_num(0.34)), (1, I32F32::from_num(0.48))], + vec![(0, I32F32::from_num(0.1309)), (1, I32F32::from_num(0.2479))], + vec![(0, I32F32::from_num(0.3129)), (1, I32F32::from_num(0.4159))], ]; // Call the function let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); // Assert the results with an epsilon for approximate equality - let epsilon = I32F32::from_num(1e-6); + let epsilon = I32F32::from_num(1e-4); + assert_approx_eq_vec_of_vec(&ema_bonds, &expected_ema_bonds, epsilon); } diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index 3500acf589..51ca7a8fbb 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -2134,72 +2134,92 @@ fn test_math_hadamard_sparse() { #[test] fn test_math_mat_ema() { - let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; - let new: Vec = vec![ - 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., + let old: Vec = vec![ + 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; + let new: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let target: Vec = vec![ - 1.9, 3.8, 5.7, 7.6, 9.5, 11.4, 13.3, 15.2, 17.1, 19., 20.9, 22.8, + 0.19, 0.38, 1., 0.4359, 0.545, 0.6539, 0.763, 0.8719, 0.981, 1., 1., 1., ]; + let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); - let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0.1); 3]); + assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); + let old: Vec = vec![ + 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, + ]; let new: Vec = vec![ 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., ]; - let target: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let target: Vec = vec![ + 0.10, 0.2, 1., 0.0399, 0.05, 0.0599, 0.07, 0.07999, 0.09, 0.1, 0.10999, 0.11999, + ]; let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0); old.len()]); - assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); - let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0); 3]); + assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); + let old: Vec = vec![ + 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, + ]; let new: Vec = vec![ - 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., + 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; let target: Vec = vec![ - 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., + 0.10, 0.2, 1., 0.0399, 0.05, 0.0599, 0.07, 0.07999, 0.09, 0.1, 0.10999, 0.11999, ]; + let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(1); old.len()]); - assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(1); 3]); + assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); } #[test] fn test_math_sparse_mat_ema() { - let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; - let new: Vec = vec![ - 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., + let old: Vec = vec![ + 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; + let new: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let target: Vec = vec![ - 1.9, 3.8, 5.7, 7.6, 9.5, 11.4, 13.3, 15.2, 17.1, 19., 20.9, 22.8, + 0.1, 0.2, 1., 0.0759, 0.095, 0.11399, 0.133, 0.15199, 0.171, 0.19, 0.20899, 0.22799, ]; let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); - let old: Vec = vec![0., 2., 3., 4., 0., 6., 7., 8., 0., 10., 11., 12.]; - let new: Vec = vec![10., 20., 0., 40., 0., 60., 0., 80., 90., 100., 110., 120.]; - let target: Vec = vec![1., 3.8, 2.7, 7.6, 0., 11.4, 6.3, 15.2, 9., 19., 20.9, 22.8]; + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); + let old: Vec = vec![ + 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, + ]; + let new: Vec = vec![ + 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, + ]; + let target: Vec = vec![ + 0.0019, 0.003799, 0.032699, 0.00399, 0.0455, 0.00599, 0.007, 0.008, 0.00899, 0.0099, + 0.01099, 0.01199, + ]; let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; - let new: Vec = vec![10., 20., 0., 40., 0., 60., 0., 80., 90., 100., 110., 120.]; - let target: Vec = vec![1., 2., 0., 4., 0., 6., 0., 8., 9., 10., 11., 12.]; + let new: Vec = vec![ + 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, + ]; + let target: Vec = vec![ + 0.01, 0.02, 0.3, 0.00399, 0.005, 0.00599, 0.007, 0.00799, 0.009, 0.01, 0.011, 0.01199, + ]; + let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let target: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; @@ -2207,7 +2227,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 2., 0., 0., 0., 0., 0., 0., 0.]; let target: Vec = vec![0.9, 0., 0., 0., 0.2, 0., 0., 0., 0., 0., 0., 0.]; @@ -2215,7 +2235,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); } #[test] @@ -2519,7 +2539,7 @@ fn test_mat_ema_alpha_vec_sparse_single_element() { let old: Vec> = vec![vec![(0, I32F32::from_num(2.0))]]; let alpha: Vec = vec![I32F32::from_num(0.5)]; let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); - assert_eq!(result, vec![vec![(0, I32F32::from_num(1.5))]]); + assert_eq!(result, vec![vec![(0, I32F32::from_num(1.0))]]); } #[test] @@ -2535,8 +2555,8 @@ fn test_mat_ema_alpha_vec_sparse_multiple_elements() { let alpha: Vec = vec![I32F32::from_num(0.1), I32F32::from_num(0.2)]; let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); let expected = vec![ - vec![(0, I32F32::from_num(4.6)), (1, I32F32::from_num(5.2))], - vec![(0, I32F32::from_num(6.6)), (1, I32F32::from_num(7.2))], + vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(1.0))], + vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(1.0))], ]; assert_sparse_mat_compare(&result, &expected, I32F32::from_num(0.000001)); } @@ -2547,7 +2567,7 @@ fn test_mat_ema_alpha_vec_sparse_zero_alpha() { let old: Vec> = vec![vec![(0, I32F32::from_num(2.0))]]; let alpha: Vec = vec![I32F32::from_num(0.0)]; let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); - assert_eq!(result, vec![vec![(0, I32F32::from_num(2.0))]]); + assert_eq!(result, vec![vec![(0, I32F32::from_num(1.0))]]); } #[test] @@ -2574,8 +2594,8 @@ fn test_mat_ema_alpha_vec_sparse_mixed_alpha() { assert_sparse_mat_compare( &result, &[ - vec![(0, I32F32::from_num(3.8)), (1, I32F32::from_num(3.2))], - vec![(0, I32F32::from_num(5.8)), (1, I32F32::from_num(5.2))], + vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(1.0))], + vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(1.0))], ], I32F32::from_num(0.000001), ); @@ -2596,8 +2616,8 @@ fn test_mat_ema_alpha_vec_sparse_sparse_matrix() { assert_eq!( result, vec![ - vec![(0, I32F32::from_num(3.0))], - vec![(1, I32F32::from_num(6.0))] + vec![(0, I32F32::from_num(1.0))], + vec![(1, I32F32::from_num(1.0))] ] ); } @@ -2611,7 +2631,7 @@ fn test_mat_ema_alpha_vec_basic() { I32F32::from_num(0.5), I32F32::from_num(0.5), ]; - let expected = mat_to_fixed(&[vec![0.75, 1.75, 2.75], vec![3.75, 4.75, 5.75]]); + let expected = mat_to_fixed(&[vec![0.75, 1.0, 1.0], vec![1.0, 1.0, 1.0]]); let result = mat_ema_alpha_vec(&new, &old, &alpha); assert_eq!(result, expected); } @@ -2625,7 +2645,7 @@ fn test_mat_ema_alpha_vec_varying_alpha() { I32F32::from_num(0.5), I32F32::from_num(0.8), ]; - let expected = mat_to_fixed(&[vec![0.6, 1.75, 2.9], vec![3.6, 4.75, 5.9]]); + let expected = mat_to_fixed(&[vec![0.6, 1.0, 1.0], vec![1.0, 1.0, 1.0]]); let result = mat_ema_alpha_vec(&new, &old, &alpha); assert_mat_approx_eq(&result, &expected, I32F32::from_num(1e-6)); } From f6c062a362943329ed41b50f53be92d1170639ef Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 28 Jan 2025 09:56:13 +0000 Subject: [PATCH 009/226] compute_ema_bonds param rename --- pallets/subtensor/src/epoch/run_epoch.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 36510532ce..26607422ec 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -995,19 +995,19 @@ impl Pallet { /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values for a sparse matrix. /// /// # Args: - /// * `bonds_delta` - A vector of bond deltas. + /// * `weights` - A vector of weights. /// * `bonds` - A vector of bonds. /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. pub fn compute_ema_bonds_sparse( - bonds_delta: &[Vec<(u16, I32F32)>], + weights: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], alpha: Vec, ) -> Vec> { // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec_sparse(bonds_delta, bonds, &alpha); + let ema_bonds = mat_ema_alpha_vec_sparse(weights, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); @@ -1019,19 +1019,19 @@ impl Pallet { /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values. /// /// # Args: - /// * `bonds_delta` - A vector of bond deltas. + /// * `weights` - A vector of weights. /// * `bonds` - A vector of bonds. /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. pub fn compute_ema_bonds( - bonds_delta: &[Vec], + weights: &[Vec], bonds: &[Vec], alpha: Vec, ) -> Vec> { // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec(bonds_delta, bonds, &alpha); + let ema_bonds = mat_ema_alpha_vec(weights, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); From b5963a906e64d20db16a7558c1fead7a4cd75326 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 28 Jan 2025 14:05:37 +0000 Subject: [PATCH 010/226] update tests logs --- pallets/subtensor/src/tests/epoch.rs | 900 +++++++++++++++------------ pallets/subtensor/src/tests/math.rs | 6 +- 2 files changed, 501 insertions(+), 405 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 9315eef06f..6760a552b3 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -987,305 +987,396 @@ fn test_512_graph_random_weights() { #[test] fn test_bonds() { new_test_ext(1).execute_with(|| { - let sparse: bool = true; - let n: u16 = 8; - let netuid: u16 = 1; - let tempo: u16 = 1; - let max_stake: u64 = 4; - let stakes: Vec = vec![1, 2, 3, 4, 0, 0, 0, 0]; + let sparse: bool = true; + let n: u16 = 8; + let netuid: u16 = 1; + let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead + let max_stake: u64 = 4; + let stakes: Vec = vec![1, 2, 3, 4, 0, 0, 0, 0]; let block_number = System::block_number(); - add_network(netuid, tempo, 0); - SubtensorModule::set_max_allowed_uids( netuid, n ); - assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); - SubtensorModule::set_max_registrations_per_block( netuid, n ); - SubtensorModule::set_target_registrations_per_interval(netuid, n); - SubtensorModule::set_weights_set_rate_limit( netuid, 0 ); - SubtensorModule::set_min_allowed_weights( netuid, 1 ); - SubtensorModule::set_max_weight_limit( netuid, u16::MAX ); - SubtensorModule::set_bonds_penalty(netuid, u16::MAX); - - - // === Register [validator1, validator2, validator3, validator4, server1, server2, server3, server4] - for key in 0..n as u64 { - SubtensorModule::add_balance_to_coldkey_account( &U256::from(key), max_stake ); - let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( netuid, block_number, key * 1_000_000, &U256::from(key)); - assert_ok!(SubtensorModule::register(<::RuntimeOrigin>::signed(U256::from(key)), netuid, block_number, nonce, work, U256::from(key), U256::from(key))); - SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( &U256::from(key), &U256::from(key), netuid, stakes[key as usize] ); - } - assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); - assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); - - // === Issue validator permits - SubtensorModule::set_max_allowed_validators(netuid, n); - assert_eq!( SubtensorModule::get_max_allowed_validators(netuid), n); - SubtensorModule::epoch( netuid, 1_000_000_000 ); // run first epoch to set allowed validators - next_block_no_epoch(netuid); // run to next block to ensure weights are set on nodes after their registration block + add_network(netuid, tempo, 0); + SubtensorModule::set_max_allowed_uids(netuid, n); + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + SubtensorModule::set_max_registrations_per_block(netuid, n); + SubtensorModule::set_target_registrations_per_interval(netuid, n); + SubtensorModule::set_weights_set_rate_limit(netuid, 0); + SubtensorModule::set_min_allowed_weights(netuid, 1); + SubtensorModule::set_max_weight_limit(netuid, u16::MAX); + SubtensorModule::set_bonds_penalty(netuid, u16::MAX); - // === Set weights [val->srv1: 0.1, val->srv2: 0.2, val->srv3: 0.3, val->srv4: 0.4] - for uid in 0..(n/2) as u64 { - assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, ((n/2)..n).collect(), vec![ u16::MAX/4, u16::MAX/2, (u16::MAX/4)*3, u16::MAX], 0)); - } - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* n: 8 - current_block: 1; activity_cutoff: 5000; Last update: [1, 1, 1, 1, 0, 0, 0, 0] - Inactive: [false, false, false, false, false, false, false, false] - Block at registration: [0, 0, 0, 0, 0, 0, 0, 0] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] - B: [[], [], [], [], [], [], [], []] - B (outdatedmask): [[], [], [], [], [], [], [], []] - B (mask+norm): [[], [], [], [], [], [], [], []] - ΔB: [[(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992673), (7, 0.0400008543)], [(4, 0.0199995115), (5, 0.040000244), (6, 0.0599985349), (7, 0.0800017088)], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[(4, 0.0999999996), (5, 0.0999999999), (6, 0.0999999994), (7, 0.0999999996)], [(4, 0.1999999995), (5, 0.2), (6, 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] - emaB: [[(4, 0.0999999982), (5, 0.0999999985), (6, 0.099999998), (7, 0.099999998)], [(4, 0.199999999), (5, 0.1999999995), (6, 0.1999999986), (7, 0.1999999986)], [(4, 0.2999999996), (5, 0.3000000003), (6, 0.3000000012), (7, 0.3000000012)], [(4, 0.4000000027), (5, 0.4000000013), (6, 0.4000000018), (7, 0.4000000018)], [], [], [], []] - D: [0.0999999978, 0.1999999983, 0.3000000012, 0.4000000022, 0, 0, 0, 0] - nE: [0.0499999989, 0.0999999992, 0.1500000006, 0.2000000011, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - E: [49999998, 99999999, 150000000, 200000001, 49998779, 100000610, 149996337, 200004272] - P: [0.0499999989, 0.0999999992, 0.1500000006, 0.2000000011, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - emaB: [[(4, 0.2499999937), (5, 0.2499999953), (6, 0.2499999937), (7, 0.2499999937)], [(4, 0.4999999942), (5, 0.499999997), (6, 0.4999999942), (7, 0.4999999942)], [(4, 0.7499999937), (5, 0.7499999981), (6, 0.7499999995), (7, 0.7499999995)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][4], 65535); - assert_eq!(bonds[1][4], 65535); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); - - // === Set self-weight only on val1 - let uid = 0; - assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, vec![uid], vec![u16::MAX], 0)); - next_block_no_epoch(netuid); + // === Register [validator1, validator2, validator3, validator4, server1, server2, server3, server4] + for key in 0..n as u64 { + SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), max_stake); + let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( + netuid, + block_number, + key * 1_000_000, + &U256::from(key), + ); + assert_ok!(SubtensorModule::register( + <::RuntimeOrigin>::signed(U256::from(key)), + netuid, + block_number, + nonce, + work, + U256::from(key), + U256::from(key) + )); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &U256::from(key), + &U256::from(key), + netuid, + stakes[key as usize], + ); + } + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* n: 8 - current_block: 2 - activity_cutoff: 5000 - Last update: [1, 1, 1, 1, 0, 0, 0, 0] - Inactive: [false, false, false, false, false, false, false, false] - Block at registration: [0, 0, 0, 0, 0, 0, 0, 0] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 16383), (5, 16383), (6, 16383), (7, 16383)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 16383), (5, 16383), (6, 16383), (7, 16383)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0999963377), (5, 0.0999963377), (6, 0.0999963377), (7, 0.0999963377)], [(4, 0.1999987792), (5, 0.1999987792), (6, 0.1999987792), (7, 0.1999987792)], [(4, 0.3000012205), (5, 0.3000012205), (6, 0.3000012205), (7, 0.3000012205)], [(4, 0.400003662), (5, 0.400003662), (6, 0.400003662), (7, 0.400003662)], [], [], [], []] - ΔB: [[], [(4, 0.0199995115), (5, 0.040000244), (6, 0.0599985349), (7, 0.0800017088)], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [(4, 0.2222222215), (5, 0.222222222), (6, 0.2222222218), (7, 0.2222222218)], [(4, 0.3333333323), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.4444444457), (5, 0.4444444443), (6, 0.4444444447), (7, 0.4444444445)], [], [], [], []] - emaB: [[(4, 0.0899967037), (5, 0.0899967037), (6, 0.0899967037), (7, 0.0899967037)], [(4, 0.2022211235), (5, 0.2022211235), (6, 0.2022211235), (7, 0.2022211235)], [(4, 0.3033344317), (5, 0.3033344317), (6, 0.3033344317), (7, 0.3033344317)], [(4, 0.4044477409), (5, 0.4044477406), (6, 0.4044477406), (7, 0.4044477406)], [], [], [], []] - D: [0.0899967032, 0.2022211233, 0.303334432, 0.404447741, 0, 0, 0, 0] - nE: [0.0449983515, 0.1011105615, 0.1516672159, 0.2022238704, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [44998351, 101110561, 151667215, 202223870, 49998779, 100000610, 149996337, 200004272] - P: [0.0449983515, 0.1011105615, 0.1516672159, 0.2022238704, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - emaB: [[(4, 0.2225175085), (5, 0.2225175085), (6, 0.2225175085), (7, 0.2225175085)], [(4, 0.499993208), (5, 0.4999932083), (6, 0.4999932083), (7, 0.4999932083)], [(4, 0.7499966028), (5, 0.7499966032), (6, 0.7499966032), (7, 0.7499966032)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][4], 65245); - assert_eq!(bonds[1][4], 65535); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); - - // === Set self-weight only on val2 - let uid = 1; - assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, vec![uid], vec![u16::MAX], 0)); - next_block_no_epoch(netuid); + // === Issue validator permits + SubtensorModule::set_max_allowed_validators(netuid, n); + assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), n); + SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators + next_block(); // run to next block to ensure weights are set on nodes after their registration block - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* current_block: 3 - W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 14582), (5, 14582), (6, 14582), (7, 14582)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 14582), (5, 14582), (6, 14582), (7, 14582)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0899929027), (5, 0.0899929027), (6, 0.0899929027), (7, 0.0899929027)], [(4, 0.2022217421), (5, 0.2022217421), (6, 0.2022217421), (7, 0.2022217421)], [(4, 0.303335699), (5, 0.303335699), (6, 0.303335699), (7, 0.303335699)], [(4, 0.404449656), (5, 0.404449656), (6, 0.404449656), (7, 0.404449656)], [], [], [], []] - ΔB: [[], [], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] - emaB: [[(4, 0.0809936123), (5, 0.0809936123), (6, 0.0809936123), (7, 0.0809936123)], [(4, 0.181999568), (5, 0.181999568), (6, 0.181999568), (7, 0.181999568)], [(4, 0.3158592717), (5, 0.315859272), (6, 0.315859272), (7, 0.315859272)], [(4, 0.4211475477), (5, 0.4211475474), (6, 0.4211475474), (7, 0.4211475474)], [], [], [], []] - D: [0.0809936118, 0.1819995677, 0.3158592721, 0.421147548, 0, 0, 0, 0] - nE: [0.040496806, 0.0909997837, 0.157929636, 0.2105737738, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [40496805, 90999783, 157929636, 210573773, 49998779, 100000610, 149996337, 200004272] - P: [0.040496806, 0.0909997837, 0.157929636, 0.2105737738, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - emaB: [[(4, 0.192316476), (5, 0.192316476), (6, 0.192316476), (7, 0.192316476)], [(4, 0.4321515555), (5, 0.4321515558), (6, 0.4321515558), (7, 0.4321515558)], [(4, 0.7499967015), (5, 0.7499967027), (6, 0.7499967027), (7, 0.7499967027)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][4], 64956); - assert_eq!(bonds[1][4], 65245); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); - - // === Set self-weight only on val3 - let uid = 2; - assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, vec![uid], vec![u16::MAX], 0)); - next_block_no_epoch(netuid); + // === Set weights [val->srv1: 0.1, val->srv2: 0.2, val->srv3: 0.3, val->srv4: 0.4] + for uid in 0..(n / 2) as u64 { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + ((n / 2)..n).collect(), + vec![u16::MAX / 4, u16::MAX / 2, (u16::MAX / 4) * 3, u16::MAX], + 0 + )); + } + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* n: 8 + current_block: 2 + activity_cutoff: 5000 + Last update: [2, 2, 2, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] + B: [[], [], [], [], [], [], [], []] + B (outdatedmask): [[], [], [], [], [], [], [], []] + B (mask+norm): [[], [], [], [], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] + Dividends: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0499999998, 0.0999999999, 0.15, 0.2, 0, 0, 0, 0] + Validator Emission: [49999999, 99999999, 149999999, 199999999, 0, 0, 0, 0] + Normalized Combined Emission: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Combined Emission: [49999999, 99999999, 149999999, 199999999, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + */ + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][4], 65535); + assert_eq!(bonds[1][4], 65535); + assert_eq!(bonds[2][4], 65535); + assert_eq!(bonds[3][4], 65535); - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* current_block: 4 - W: [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.1600034179] - C: [0, 0, 0, 0, 0, 0, 0, 0] - W: [[], [], [], [], [], [], [], []] - Tv: [0, 0, 0, 0, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0] - T: [0, 0, 0, 0, 0, 0, 0, 0] - I (=R): [0, 0, 0, 0, 0, 0, 0, 0] - B: [[(4, 12603), (5, 12603), (6, 12603), (7, 12603)], [(4, 28321), (5, 28321), (6, 28321), (7, 28321)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 12603), (5, 12603), (6, 12603), (7, 12603)], [(4, 28321), (5, 28321), (6, 28321), (7, 28321)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0809909387), (5, 0.0809909387), (6, 0.0809909387), (7, 0.0809909387)], [(4, 0.1819998713), (5, 0.1819998713), (6, 0.1819998713), (7, 0.1819998713)], [(4, 0.3158601632), (5, 0.3158601632), (6, 0.3158601632), (7, 0.3158601632)], [(4, 0.4211490264), (5, 0.4211490264), (6, 0.4211490264), (7, 0.4211490264)], [], [], [], []] - ΔB: [[], [], [], [], [], [], [], []] - ΔB (norm): [[], [], [], [], [], [], [], []] - emaB: [[(4, 0.0809909385), (5, 0.0809909385), (6, 0.0809909385), (7, 0.0809909385)], [(4, 0.1819998713), (5, 0.1819998713), (6, 0.1819998713), (7, 0.1819998713)], [(4, 0.3158601632), (5, 0.3158601632), (6, 0.3158601632), (7, 0.3158601632)], [(4, 0.4211490266), (5, 0.4211490266), (6, 0.4211490266), (7, 0.4211490266)], [], [], [], []] - D: [0, 0, 0, 0, 0, 0, 0, 0] - nE: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - E: [99999999, 199999999, 299999999, 399999999, 0, 0, 0, 0] - P: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - emaB: [[(4, 0.1923094518), (5, 0.1923094518), (6, 0.1923094518), (7, 0.1923094518)], [(4, 0.4321507583), (5, 0.4321507583), (6, 0.4321507583), (7, 0.4321507583)], [(4, 0.7499961846), (5, 0.7499961846), (6, 0.7499961846), (7, 0.7499961846)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 63269); - assert_eq!(bonds[1][7], 64394); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); - - - // === Set val3->srv4: 1 - assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(2)), netuid, vec![7], vec![u16::MAX], 0)); - next_block_no_epoch(netuid); + // === Set self-weight only on val1 + let uid = 0; + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![uid], + vec![u16::MAX], + 0 + )); + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* n: 8 + current_block: 2 + activity_cutoff: 5000 + Last update: [2, 2, 2, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.2491694554), (5, 0.2483443606), (6, 0.2475248124), (7, 0.246710457)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [], [], [], []] + Dividends: [0.0988155114, 0.2002632194, 0.3003948291, 0.4005264398, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0, 0, 0, 0] + Validator Emission: [49407755, 100131609, 150197414, 200263219, 0, 0, 0, 0] + Normalized Combined Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [49407755, 100131609, 150197414, 200263219, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + */ - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* current_block: 5 - W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] - C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - I (=R): [0, 0, 0, 0, 0, 0, 0, 1] - B: [[(4, 12602), (5, 12602), (6, 12602), (7, 12602)], [(4, 28320), (5, 28320), (6, 28320), (7, 28320)], [(4, 49150), (5, 49150), (6, 49150), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 12602), (5, 12602), (6, 12602), (7, 12602)], [(4, 28320), (5, 28320), (6, 28320), (7, 28320)], [(4, 49150), (5, 49150), (6, 49150), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0809860737), (5, 0.0809860737), (6, 0.0809860737), (7, 0.0809860737)], [(4, 0.1819969537), (5, 0.1819969537), (6, 0.1819969537), (7, 0.1819969537)], [(4, 0.3158598263), (5, 0.3158598263), (6, 0.3158598263), (7, 0.3158598263)], [(4, 0.4211571459), (5, 0.4211571459), (6, 0.4211571459), (7, 0.4211571459)], [], [], [], []] - ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[(4, 0.0809860737), (5, 0.0809860737), (6, 0.0809860737), (7, 0.0728874663)], [(4, 0.1819969537), (5, 0.1819969537), (6, 0.1819969537), (7, 0.1637972582)], [(4, 0.3158598263), (5, 0.3158598263), (6, 0.3158598263), (7, 0.3271309866)], [(4, 0.421157146), (5, 0.421157146), (6, 0.421157146), (7, 0.4361842885)], [], [], [], []] - D: [0.0728874663, 0.1637972582, 0.3271309866, 0.4361842885, 0, 0, 0, 0] - nE: [0.0364437331, 0.081898629, 0.1635654932, 0.2180921442, 0, 0, 0, 0.5] - E: [36443733, 81898628, 163565493, 218092144, 0, 0, 0, 500000000] - P: [0.0364437331, 0.081898629, 0.1635654932, 0.2180921442, 0, 0, 0, 0.5] - emaB: [[(4, 0.1922941932), (5, 0.1922941932), (6, 0.1922941932), (7, 0.1671024568)], [(4, 0.4321354993), (5, 0.4321354993), (6, 0.4321354993), (7, 0.3755230587)], [(4, 0.7499809256), (5, 0.7499809256), (6, 0.7499809256), (7, 0.749983425)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 62177); - assert_eq!(bonds[1][7], 63283); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][4], 65245); + assert_eq!(bonds[1][4], 65535); + assert_eq!(bonds[2][4], 65535); + assert_eq!(bonds[3][4], 65535); - next_block_no_epoch(netuid); + // === Set self-weight only on val2 + let uid = 1; + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![uid], + vec![u16::MAX], + 0 + )); + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* current_block: 3 + W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.2491694554), (5, 0.2483443606), (6, 0.2475248124), (7, 0.246710457)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [], [], [], []] + Dividends: [0.0988155114, 0.2002632194, 0.3003948291, 0.4005264398, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0, 0, 0, 0] + Validator Emission: [49407755, 100131609, 150197414, 200263219, 0, 0, 0, 0] + Normalized Combined Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [49407755, 100131609, 150197414, 200263219, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + */ - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* current_block: 6 - B: [[(4, 12601), (5, 12601), (6, 12601), (7, 10951)], [(4, 28319), (5, 28319), (6, 28319), (7, 24609)], [(4, 49149), (5, 49149), (6, 49149), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 12601), (5, 12601), (6, 12601), (7, 10951)], [(4, 28319), (5, 28319), (6, 28319), (7, 24609)], [(4, 49149), (5, 49149), (6, 49149), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0809812085), (5, 0.0809812085), (6, 0.0809812085), (7, 0.0728876167)], [(4, 0.181994036), (5, 0.181994036), (6, 0.181994036), (7, 0.163792472)], [(4, 0.3158594894), (5, 0.3158594894), (6, 0.3158594894), (7, 0.3271323503)], [(4, 0.4211652656), (5, 0.4211652656), (6, 0.4211652656), (7, 0.4361875602)], [], [], [], []] - ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[(4, 0.0809812082), (5, 0.0809812082), (6, 0.0809812082), (7, 0.0655988548)], [(4, 0.181994036), (5, 0.181994036), (6, 0.181994036), (7, 0.1474132247)], [(4, 0.3158594896), (5, 0.3158594896), (6, 0.3158594896), (7, 0.3372762585)], [(4, 0.4211652658), (5, 0.4211652658), (6, 0.4211652658), (7, 0.4497116616)], [], [], [], []] - D: [0.0655988548, 0.1474132247, 0.3372762585, 0.4497116616, 0, 0, 0, 0] - nE: [0.0327994274, 0.0737066122, 0.1686381293, 0.2248558307, 0, 0, 0, 0.5] - E: [32799427, 73706612, 168638129, 224855830, 0, 0, 0, 500000000] - P: [0.0327994274, 0.0737066122, 0.1686381293, 0.2248558307, 0, 0, 0, 0.5] - emaB: [[(4, 0.1922789337), (5, 0.1922789337), (6, 0.1922789337), (7, 0.1458686984)], [(4, 0.4321202405), (5, 0.4321202405), (6, 0.4321202405), (7, 0.3277949789)], [(4, 0.749965667), (5, 0.749965667), (6, 0.749965667), (7, 0.74998335)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 61113); - assert_eq!(bonds[1][7], 62200); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][4], 64956); + assert_eq!(bonds[1][4], 65245); + assert_eq!(bonds[2][4], 65535); + assert_eq!(bonds[3][4], 65535); - next_block_no_epoch(netuid); + // === Set self-weight only on val3 + let uid = 2; + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![uid], + vec![u16::MAX], + 0 + )); + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* current_block: 4 + W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 65245), (5, 64957), (6, 64672), (7, 64390)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 65245), (5, 64957), (6, 64672), (7, 64390)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.2491693716), (5, 0.248342649), (6, 0.247522744), (7, 0.246709707)], [(4, 0.250276876), (5, 0.25055245), (6, 0.2508257518), (7, 0.251096764)], [(4, 0.250276876), (5, 0.25055245), (6, 0.2508257518), (7, 0.251096764)], [(4, 0.250276876), (5, 0.25055245), (6, 0.2508257518), (7, 0.251096764)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.248616903), (5, 0.2472437813), (6, 0.2458835603), (7, 0.2445360073)], [(4, 0.249721952), (5, 0.2494438041), (6, 0.2491646945), (7, 0.248884411)], [(4, 0.2508305723), (5, 0.251656207), (6, 0.2524758724), (7, 0.2532897906)], [(4, 0.2508305723), (5, 0.251656207), (6, 0.2524758724), (7, 0.2532897906)], [], [], [], []] + Dividends: [0.097904461, 0.198416279, 0.3015768253, 0.402102434, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0489522305, 0.0992081393, 0.1507884127, 0.201051217, 0, 0, 0, 0] + Validator Emission: [48952230, 99208139, 150788412, 201051217, 0, 0, 0, 0] + Normalized Combined Emission: [0.0489522305, 0.0992081393, 0.1507884127, 0.201051217, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [48952230, 99208139, 150788412, 201051217, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0489522305, 0.0992081393, 0.1507884127, 0.201051217, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + */ + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][7], 63269); + assert_eq!(bonds[1][7], 64394); + assert_eq!(bonds[2][7], 65535); + assert_eq!(bonds[3][7], 65535); + + // === Set val3->srv4: 1 + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(2)), + netuid, + vec![7], + vec![u16::MAX], + 0 + )); + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* current_block: 5 + W: [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.1600034179] + C: [0, 0, 0, 0, 0, 0, 0, 0] + Clipped Weights: [[], [], [], [], [], [], [], []] + Validator Trust: [0, 0, 0, 0, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0] + T: [0, 0, 0, 0, 0, 0, 0, 0] + I (=R): [0, 0, 0, 0, 0, 0, 0, 0] + B: [[(4, 64956), (5, 64385), (6, 63823), (7, 63270)], [(4, 65245), (5, 64958), (6, 64675), (7, 64395)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 64956), (5, 64385), (6, 63823), (7, 63270)], [(4, 65245), (5, 64958), (6, 64675), (7, 64395)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.2486154223), (5, 0.247241881), (6, 0.2458816185), (7, 0.244535915)], [(4, 0.2497215534), (5, 0.249442232), (6, 0.2491639955), (7, 0.2488839931)], [(4, 0.250831512), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [(4, 0.250831512), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.247241881), (6, 0.2458816185), (7, 0.244535915)], [(4, 0.2497215534), (5, 0.249442232), (6, 0.2491639955), (7, 0.248883993)], [(4, 0.2508315118), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [(4, 0.2508315118), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [], [], [], []] + Dividends: [0, 0, 0, 0, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 0] + Normalized Validator Emission: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Validator Emission: [99999999, 199999999, 299999999, 399999999, 0, 0, 0, 0] + Normalized Combined Emission: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Combined Emission: [99999999, 199999999, 299999999, 399999999, 0, 0, 0, 0] + Pruning Scores: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + */ + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][7], 62177); + assert_eq!(bonds[1][7], 63283); + assert_eq!(bonds[2][7], 65535); + assert_eq!(bonds[3][7], 65535); - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* current_block: 7 - B: [[(4, 12600), (5, 12600), (6, 12600), (7, 9559)], [(4, 28318), (5, 28318), (6, 28318), (7, 21482)], [(4, 49148), (5, 49148), (6, 49148), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 12600), (5, 12600), (6, 12600), (7, 9559)], [(4, 28318), (5, 28318), (6, 28318), (7, 21482)], [(4, 49148), (5, 49148), (6, 49148), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0809763432), (5, 0.0809763432), (6, 0.0809763432), (7, 0.065595707)], [(4, 0.1819911182), (5, 0.1819911182), (6, 0.1819911182), (7, 0.1474136391)], [(4, 0.3158591525), (5, 0.3158591525), (6, 0.3158591525), (7, 0.337276807)], [(4, 0.4211733856), (5, 0.4211733856), (6, 0.4211733856), (7, 0.4497138464)], [], [], [], []] - ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[(4, 0.080976343), (5, 0.080976343), (6, 0.080976343), (7, 0.0590361361)], [(4, 0.181991118), (5, 0.181991118), (6, 0.181991118), (7, 0.1326722752)], [(4, 0.3158591525), (5, 0.3158591525), (6, 0.3158591525), (7, 0.3464062694)], [(4, 0.4211733858), (5, 0.4211733858), (6, 0.4211733858), (7, 0.4618853189)], [], [], [], []] - D: [0.0590361361, 0.1326722752, 0.3464062694, 0.4618853189, 0, 0, 0, 0] - nE: [0.029518068, 0.0663361375, 0.1732031347, 0.2309426593, 0, 0, 0, 0.5] - E: [29518068, 66336137, 173203134, 230942659, 0, 0, 0, 500000000] - P: [0.029518068, 0.0663361375, 0.1732031347, 0.2309426593, 0, 0, 0, 0.5] - emaB: [[(4, 0.192263675), (5, 0.192263675), (6, 0.192263675), (7, 0.1278155716)], [(4, 0.4321049813), (5, 0.4321049813), (6, 0.4321049813), (7, 0.2872407278)], [(4, 0.7499504078), (5, 0.7499504078), (6, 0.7499504078), (7, 0.7499832863)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - let bonds = SubtensorModule::get_bonds( netuid ); - assert_eq!(bonds[0][7], 60076); - assert_eq!(bonds[1][7], 61145); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); - - next_block_no_epoch(netuid); - - if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } - else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } - /* current_block: 8 - B: [[(4, 12599), (5, 12599), (6, 12599), (7, 8376)], [(4, 28317), (5, 28317), (6, 28317), (7, 18824)], [(4, 49147), (5, 49147), (6, 49147), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 12599), (5, 12599), (6, 12599), (7, 8376)], [(4, 28317), (5, 28317), (6, 28317), (7, 18824)], [(4, 49147), (5, 49147), (6, 49147), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0809714776), (5, 0.0809714776), (6, 0.0809714776), (7, 0.0590337245)], [(4, 0.1819882002), (5, 0.1819882002), (6, 0.1819882002), (7, 0.1326708249)], [(4, 0.3158588156), (5, 0.3158588156), (6, 0.3158588156), (7, 0.3464073015)], [(4, 0.421181506), (5, 0.421181506), (6, 0.421181506), (7, 0.4618881487)], [], [], [], []] - ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[(4, 0.0809714776), (5, 0.0809714776), (6, 0.0809714776), (7, 0.053130352)], [(4, 0.1819882002), (5, 0.1819882002), (6, 0.1819882002), (7, 0.1194037423)], [(4, 0.3158588156), (5, 0.3158588156), (6, 0.3158588156), (7, 0.3546237142)], [(4, 0.4211815062), (5, 0.4211815062), (6, 0.4211815062), (7, 0.472842191)], [], [], [], []] - D: [0.053130352, 0.1194037423, 0.3546237142, 0.472842191, 0, 0, 0, 0] - nE: [0.026565176, 0.0597018711, 0.177311857, 0.2364210954, 0, 0, 0, 0.5] - E: [26565175, 59701871, 177311856, 236421095, 0, 0, 0, 500000000] - P: [0.026565176, 0.0597018711, 0.177311857, 0.2364210954, 0, 0, 0, 0.5] - emaB: [[(4, 0.1922484161), (5, 0.1922484161), (6, 0.1922484161), (7, 0.1123638137)], [(4, 0.4320897225), (5, 0.4320897225), (6, 0.4320897225), (7, 0.2525234516)], [(4, 0.7499351487), (5, 0.7499351487), (6, 0.7499351487), (7, 0.7499832308)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ - }); + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* current_block: 6 + B: [[(4, 64956), (5, 64384), (6, 63822), (7, 63269)], [(4, 65245), (5, 64958), (6, 64675), (7, 64394)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 64956), (5, 64384), (6, 63822), (7, 63269)], [(4, 65245), (5, 64958), (6, 64675), (7, 64394)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.2486154223), (5, 0.2472389904), (6, 0.2458787132), (7, 0.2445339402)], [(4, 0.2497215534), (5, 0.24944319), (6, 0.2491649555), (7, 0.248882052)], [(4, 0.250831512), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2532920036)], [(4, 0.250831512), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2532920036)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.2472389904), (6, 0.2458787132), (7, 0.2423794107)], [(4, 0.2497215534), (5, 0.2494431897), (6, 0.2491649555), (7, 0.2466892123)], [(4, 0.2508315118), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2554656884)], [(4, 0.2508315118), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2554656884)], [], [], [], []] + Dividends: [0.0960292057, 0.195473444, 0.3036417211, 0.4048556287, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] + Normalized Validator Emission: [0.0480146029, 0.0977367219, 0.1518208606, 0.2024278142, 0, 0, 0, 0] + Validator Emission: [48014602, 97736721, 151820860, 202427814, 0, 0, 0, 0] + Normalized Combined Emission: [0.0480146029, 0.0977367219, 0.1518208606, 0.2024278142, 0, 0, 0, 0.5] + Combined Emission: [48014602, 97736721, 151820860, 202427814, 0, 0, 0, 500000000] + Pruning Scores: [0.0480146029, 0.0977367219, 0.1518208606, 0.2024278142, 0, 0, 0, 0.5] + */ + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][7], 61113); + assert_eq!(bonds[1][7], 62200); + assert_eq!(bonds[2][7], 65535); + assert_eq!(bonds[3][7], 65535); + + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* current_block: 7 + B: [[(4, 64956), (5, 64383), (6, 63821), (7, 62177)], [(4, 65245), (5, 64957), (6, 64674), (7, 63283)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 64956), (5, 64383), (6, 63821), (7, 62177)], [(4, 65245), (5, 64957), (6, 64674), (7, 63283)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.2486154223), (5, 0.247237049), (6, 0.2458767553), (7, 0.2423771098)], [(4, 0.2497215534), (5, 0.2494412656), (6, 0.2491630227), (7, 0.2466884963)], [(4, 0.250831512), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2554671967)], [(4, 0.250831512), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2554671967)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.2472370488), (6, 0.2458767553), (7, 0.2402415834)], [(4, 0.2497215534), (5, 0.2494412656), (6, 0.2491630227), (7, 0.2445149834)], [(4, 0.2508315118), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2576217165)], [(4, 0.2508315118), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2576217165)], [], [], [], []] + Dividends: [0.0948587805, 0.1930922437, 0.3051638464, 0.4068851292, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] + Normalized Validator Emission: [0.0474293903, 0.0965461219, 0.1525819232, 0.2034425645, 0, 0, 0, 0] + Validator Emission: [47429390, 96546121, 152581923, 203442564, 0, 0, 0, 0] + Normalized Combined Emission: [0.0474293903, 0.0965461219, 0.1525819232, 0.2034425645, 0, 0, 0, 0.5] + Combined Emission: [47429390, 96546121, 152581923, 203442564, 0, 0, 0, 500000000] + Pruning Scores: [0.0474293903, 0.0965461219, 0.1525819232, 0.2034425645, 0, 0, 0, 0.5] + */ + let bonds = SubtensorModule::get_bonds(netuid); + assert_eq!(bonds[0][7], 60076); + assert_eq!(bonds[1][7], 61145); + assert_eq!(bonds[2][7], 65535); + assert_eq!(bonds[3][7], 65535); + + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + /* current_block: 8 + B: [[(4, 64956), (5, 64382), (6, 63821), (7, 61113)], [(4, 65245), (5, 64956), (6, 64674), (7, 62200)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 64956), (5, 64382), (6, 63821), (7, 61113)], [(4, 65245), (5, 64956), (6, 64674), (7, 62200)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.2486154223), (5, 0.247235108), (6, 0.2458767553), (7, 0.2402401103)], [(4, 0.2497215534), (5, 0.2494393412), (6, 0.2491630227), (7, 0.2445131945)], [(4, 0.250831512), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2576233475)], [(4, 0.250831512), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2576233475)], [], [], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.247235108), (6, 0.2458767553), (7, 0.2381234125)], [(4, 0.2497215534), (5, 0.2494393412), (6, 0.2491630227), (7, 0.2423588475)], [(4, 0.2508315118), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2597588697)], [(4, 0.2508315118), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2597588697)], [], [], [], []] + Dividends: [0.0937068302, 0.1907471363, 0.3066625856, 0.4088834478, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] + Normalized Validator Emission: [0.046853415, 0.0953735681, 0.1533312928, 0.2044417239, 0, 0, 0, 0] + Validator Emission: [46853414, 95373568, 153331292, 204441723, 0, 0, 0, 0] + Normalized Combined Emission: [0.046853415, 0.0953735681, 0.1533312928, 0.2044417239, 0, 0, 0, 0.5] + Combined Emission: [46853414, 95373568, 153331292, 204441723, 0, 0, 0, 500000000] + Pruning Scores: [0.046853415, 0.0953735681, 0.1533312928, 0.2044417239, 0, 0, 0, 0.5] + */ + }); } // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::epoch::test_512_graph_random_weights --exact --show-output --nocapture @@ -1362,46 +1453,42 @@ fn test_bonds_with_liquid_alpha() { let bonds = SubtensorModule::get_bonds(netuid); /* n: 8 - current_block: 2; activity_cutoff: 5000; - Last update: [1, 1, 1, 1, 0, 0, 0, 0] + current_block: 3 activity_cutoff: 5000 Last update: [2, 2, 2, 2, 1, 1, 1, 1] Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - Stake: [1, 2, 3, 4, 0, 0, 0, 0] Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 + max_allowed_validators: 64 new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, + Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 327 + Weights (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), + Weights (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] T: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] - B: [[], [], [], [], [], [], [], []] - B (outdatedmask): [[], [], [], [], [], [], [], []] - B (mask+norm): [[], [], [], [], [], [], [], []] - ΔB: [[(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992673), (7, 0.0400008543)], [(4, 0.0199995115), (5, 0.040000244), (6, 0.0599985349), (7, 0.0800017088)], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[(4, 0.0999999996), (5, 0.0999999999), (6, 0.0999999994), (7, 0.0999999996)], [(4, 0.1999999995), (5, 0.2), (6, 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] - Exponential Moving Average Bonds Liquid Alpha: [[(4, 0.0499983232), (5, 0.0899999999), (6, 0.0899999994), (7, 0.0899999996)], [(4, 0.0999966469), (5, 0.18), (6, 0.1799999997), (7, 0.1799999997)], [(4, 0.1499949703), (5, 0.2699999998), (6, 0.2699999998), (7, 0.2699999998)], [(4, 0.199993295), (5, 0.3599999999), (6, 0.36), (7, 0.3599999999)], [], [], [], []] - Exponential Moving Average Bonds: [[(4, 0.0999999992), (5, 0.0999999999), (6, 0.0999999994), (7, 0.0999999996)], [(4, 0.1999999995), (5, 0.2), (6, 0.1999999997), (7, 0.1999999997)], [(4, 0.2999999993), (5, 0.2999999998), (6, 0.3), (7, 0.3)], [(4, 0.4000000015), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] - Dividends: [0.0999999994, 0.1999999997, 0.3, 0.4000000006, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] + alpha values: [0.7000076314, 0.7000076314, 0.7000076314, 0.7000076314, 0.8095842435, 0.8856769793, 0.9000076293, 0.9000076293] + Exponential Moving Average Bonds: [[(4, 0.1229952155), (5, 0.0488576517), (6, 0.0301549898), (7, 0.0233184719)], [(4, 0.292334928), (5, 0.3170474493), (6, 0.32328167), (7, 0.3255605092)], [(4, 0.292334928), (5, 0.3170474493), (6, 0.32328167), (7, 0.3255605092)], [(4, 0.292334928), (5, 0.3170474493), (6, 0.32328167), (7, 0.3255605092)], [], [], [], []] + Dividends: [0.0138551355, 0.2191433029, 0.3287149547, 0.4382866067, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0499999996, 0.0999999999, 0.15, 0.2000000002, 0, 0, 0, 0] - Validator Emission: [49999999, 99999999, 149999999, 200000000, 0, 0, 0, 0] - Normalized Combined Emission: [0.0499999996, 0.0999999999, 0.15, 0.2000000002, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Combined Emission: [49999999, 99999999, 149999999, 200000000, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0499999996, 0.0999999999, 0.15, 0.2000000002, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Normalized Validator Emission: [0.0069275678, 0.1095716513, 0.1643574773, 0.2191433033, 0, 0, 0, 0] + Validator Emission: [6927567, 109571651, 164357477, 219143303, 0, 0, 0, 0] + Normalized Combined Emission: [0.0069275678, 0.1095716513, 0.1643574773, 0.2191433033, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [6927567, 109571651, 164357477, 219143303, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0069275678, 0.1095716513, 0.1643574773, 0.2191433033, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ // Expected bonds calculations @@ -1457,12 +1544,12 @@ fn test_bonds_with_liquid_alpha() { let bonds = SubtensorModule::get_bonds(netuid); /* n: 8 - current_block: 4; activity_cutoff: 5000; + current_block: 4 + activity_cutoff: 5000 Last update: [2, 3, 2, 2, 1, 1, 1, 1] Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - Stake: [1, 2, 3, 4, 0, 0, 0, 0] Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 64 @@ -1473,28 +1560,26 @@ fn test_bonds_with_liquid_alpha() { Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] T: [0, 0, 0, 0, 1, 1, 1, 1] Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 7760), (5, 1489), (6, 1489), (7, 1489)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 7760), (5, 1489), (6, 1489), (7, 1489)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.0499958121), (5, 0.00999718), (6, 0.00999718), (7, 0.00999718)], [(4, 0.211109894), (5, 0.2199983886), (6, 0.2199983886), (7, 0.2199983886)], [(4, 0.3166680625), (5, 0.3300009398), (6, 0.3300009398), (7, 0.3300009398)], [(4, 0.4222262308), (5, 0.4400034912), (6, 0.4400034912), (7, 0.4400034912)], [], [], [], []] - ΔB: [[], [], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] - ΔB (norm): [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] - Exponential Moving Average Bonds Liquid Alpha: [[(4, 0.024998744), (5, 0.000999718), (6, 0.000999718), (7, 0.000999718)], [(4, 0.105558486), (5, 0.0219998388), (6, 0.0219998388), (7, 0.0219998388)], [(4, 0.3726178685), (5, 0.4187143792), (6, 0.4187143792), (7, 0.4187143792)], [(4, 0.4968249004), (5, 0.5582860631), (6, 0.5582860631), (7, 0.5582860631)], [], [], [], []] - Exponential Moving Average Bonds: [[(4, 0.024998744), (5, 0.000999718), (6, 0.000999718), (7, 0.000999718)], [(4, 0.105558486), (5, 0.0219998388), (6, 0.0219998388), (7, 0.0219998388)], [(4, 0.3726178687), (5, 0.4187143794), (6, 0.4187143794), (7, 0.4187143794)], [(4, 0.4968249009), (5, 0.5582860636), (6, 0.5582860636), (7, 0.5582860636)], [], [], [], []] - Dividends: [0.0033995616, 0.030355499, 0.4141048414, 0.5521400978, 0, 0, 0, 0] + B: [[(4, 27572), (5, 10099), (6, 6112), (7, 4693)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 27572), (5, 10099), (6, 6112), (7, 4693)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.1229921), (5, 0.048857303), (6, 0.0301504065), (7, 0.023313694)], [(4, 0.2923359666), (5, 0.3170475655), (6, 0.3232831976), (7, 0.3255621018)], [(4, 0.2923359666), (5, 0.3170475655), (6, 0.3232831976), (7, 0.3255621018)], [(4, 0.2923359666), (5, 0.3170475655), (6, 0.3232831976), (7, 0.3255621018)], [], [], [], []] + alpha values: [0.7000076314, 0.7000076314, 0.7000076314, 0.7000076314, 0.8095842435, 0.8856769793, 0.9000076293, 0.9000076293] + Exponential Moving Average Bonds: [[(4, 0.0728453742), (5, 0.0130473885), (6, 0.0051448268), (7, 0.0031164943)], [(4, 0.1731438267), (5, 0.0846678526), (6, 0.0551646315), (7, 0.0435200238)], [(4, 0.3770053994), (5, 0.4511423793), (6, 0.4698452707), (7, 0.4766817407)], [(4, 0.3770053994), (5, 0.4511423793), (6, 0.4698452707), (7, 0.4766817407)], [], [], [], []] + Dividends: [0.0037682566, 0.0405260534, 0.4095881525, 0.546117537, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0016997808, 0.0151777493, 0.2070524206, 0.2760700488, 0, 0, 0, 0] - Validator Emission: [1699780, 15177749, 207052420, 276070048, 0, 0, 0, 0] - Normalized Combined Emission: [0.0016997808, 0.0151777493, 0.2070524206, 0.2760700488, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [1699780, 15177749, 207052420, 276070048, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0016997808, 0.0151777493, 0.2070524206, 0.2760700488, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Normalized Validator Emission: [0.0018841282, 0.0202630267, 0.2047940763, 0.2730587684, 0, 0, 0, 0] + Validator Emission: [1884128, 20263026, 204794076, 273058768, 0, 0, 0, 0] + Normalized Combined Emission: [0.0018841282, 0.0202630267, 0.2047940763, 0.2730587684, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [1884128, 20263026, 204794076, 273058768, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0018841282, 0.0202630267, 0.2047940763, 0.2730587684, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ assert_eq!(bonds[0][4], 12662); @@ -1652,31 +1737,36 @@ fn test_active_stake() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 5002; activity_cutoff: 5000 - Last update: [5002, 1, 0, 0]; Inactive: [false, true, true, true]; Block at registration: [0, 0, 0, 0] - S: [0.25, 0.25, 0.25, 0.25]; S (mask): [0.25, 0, 0, 0]; S (mask+norm): [1, 0, 0, 0] - validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] - W: [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (permit): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (permit+diag): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (permit+diag+outdate): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - R: [0, 0, 0.5, 0.5] - W (threshold): [[(2, 1), (3, 1)], [(2, 1), (3, 1)], [], []] - T: [0, 0, 1, 1] - C: [0.006693358, 0.006693358, 0.9933076561, 0.9933076561] - I: [0, 0, 0.5, 0.5] - B: [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - B (outdatedmask): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - B (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - ΔB: [[(2, 0.5), (3, 0.5)], [(2, 0), (3, 0)], [], []] - ΔB (norm): [[(2, 1), (3, 1)], [(2, 0), (3, 0)], [], []] - emaB: [[(2, 0.55), (3, 0.55)], [(2, 0.45), (3, 0.45)], [], []] - emaB (max-upscale): [[(2, 1), (3, 1)], [(2, 1), (3, 1)], [], []] - D: [0.55, 0.4499999997, 0, 0] - nE: [0.275, 0.2249999999, 0.25, 0.25] - E: [274999999, 224999999, 250000000, 250000000] - P: [0.275, 0.2249999999, 0.25, 0.25] - P (u16): [65535, 53619, 59577, 59577] */ + Last update: [5002, 1, 0, 0]; Inactive: [false, true, true, true]; Block at registration: [0, 0, 0, 0] + Normalised Stake: [0.25, 0.25, 0.25, 0.25] + validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] + Active Stake: [1, 0, 0, 0] + W: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + R (before): [0, 0, 0.5, 0.5] + C: [0, 0, 0.5, 0.5] + Clipped W: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Validator Trust: [1, 1, 0, 0] + R (after): [0, 0, 0.5, 0.5] + T: [0, 0, 1, 1] + I (=Rank): [0, 0, 0.5, 0.5] + B: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + B (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1] + emaB: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + D: [1, 0, 0, 0] + Normalized Server Emission: [0, 0, 0.25, 0.25] + Server Emission: [0, 0, 250000000, 250000000] + Normalized Validator Emission: [0.5, 0, 0, 0] + Validator Emission: [500000000, 0, 0, 0] + Normalized Combined Emission: [0.5, 0, 0.25, 0.25] + Combined Emission: [500000000, 0, 250000000, 250000000] + Pruning Scores: [0.5, 0, 0.25, 0.25] + */ let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 65535); // Note D = floor((0.5 * 0.9 + 0.1) * 65_535) assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 500000000); // Note E = 0.5 * 0.55 * 1_000_000_000 = 275_000_000 (discrepancy) @@ -1708,30 +1798,41 @@ fn test_active_stake() { } /* current_block: 5003; activity_cutoff: 5000 Last update: [5002, 5002, 0, 0]; Inactive: [false, false, true, true]; Block at registration: [0, 0, 0, 0] - S: [0.25, 0.25, 0.25, 0.25]; S (mask): [0.25, 0.25, 0, 0]; S (mask+norm): [0.5, 0.5, 0, 0] - validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] - W: [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (permit): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (permit+diag): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] - W (permit+diag+outdate): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + Inactive: [false, false, true, true] + Block at registration: [0, 0, 0, 0] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3)] + ls: tao_weight: 0 + Normalised Stake: [0.25, 0.25, 0.25, 0.25] + validator_permits: [true, true, true, true] + max_allowed_validators: 4 + new_validator_permits: [true, true, true, true] + Active Stake: [0.5, 0.5, 0, 0] + W: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + W (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - R: [0, 0, 0.5, 0.5] - W (threshold): [[(2, 1), (3, 1)], [(2, 1), (3, 1)], [], []] + R (before): [0, 0, 0.5, 0.5] + C: [0, 0, 0.5, 0.5] + Clipped W: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Validator Trust: [1, 1, 0, 0] + R (after): [0, 0, 0.5, 0.5] T: [0, 0, 1, 1] - C: [0.006693358, 0.006693358, 0.9933076561, 0.9933076561] - I: [0, 0, 0.5, 0.5] - B: [[(2, 65535), (3, 65535)], [(2, 53619), (3, 53619)], [], []] - B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 53619), (3, 53619)], [], []] - B (mask+norm): [[(2, 0.5500025176), (3, 0.5500025176)], [(2, 0.4499974821), (3, 0.4499974821)], [], []] - ΔB: [[(2, 0.25), (3, 0.25)], [(2, 0.25), (3, 0.25)], [], []] - ΔB (norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - emaB: [[(2, 0.545002266), (3, 0.545002266)], [(2, 0.4549977337), (3, 0.4549977337)], [], []] - emaB (max-upscale): [[(2, 1), (3, 1)], [(2, 0.8348547556), (3, 0.8348547556)], [], []] - D: [0.545002266, 0.4549977337, 0, 0] - nE: [0.272501133, 0.2274988669, 0.25, 0.25] - E: [272501132, 227498866, 250000000, 250000000] - P: [0.272501133, 0.2274988669, 0.25, 0.25] - P (u16): [65535, 54711, 60123, 60123] */ + I (=Rank): [0, 0, 0.5, 0.5] + B: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + B (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + alpha values: [0.1, 0.1, 0.1, 0.1] + EmaB: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + D: [0.5, 0.5, 0, 0] + Normalized Server Emission: [0, 0, 0.25, 0.25] + Server Emission: [0, 0, 250000000, 250000000] + Normalized Validator Emission: [0.25, 0.25, 0, 0] + Validator Emission: [250000000, 250000000, 0, 0] + Normalized Combined Emission: [0.25, 0.25, 0.25, 0.25] + Combined Emission: [250000000, 250000000, 250000000, 250000000] + Pruning Scores: [0.25, 0.25, 0.25, 0.25] + */ let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); // Note D = floor((0.55 * 0.9 + 0.5 * 0.1) * 65_535) assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); // Note E = 0.5 * (0.55 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 272_500_000 (discrepancy) @@ -2703,7 +2804,7 @@ fn test_calculate_logistic_params_edge_cases() { #[test] fn test_compute_ema_bonds_sparse() { // Define test inputs - let bonds_delta = vec![ + let weights = vec![ vec![(0, I32F32::from_num(0.1)), (1, I32F32::from_num(0.2))], vec![(0, I32F32::from_num(0.3)), (1, I32F32::from_num(0.4))], ]; @@ -2713,27 +2814,22 @@ fn test_compute_ema_bonds_sparse() { ]; let alpha = vec![I32F32::from_num(0.9), I32F32::from_num(0.8)]; - // Expected values - // EMA calculation for each bond: - // EMA = alpha * bond_delta + (1 - alpha) * bond - // For bond (0, 0): - // EMA = 0.9 * 0.1 + (1 - 0.9) * 0.5 = 0.09 + 0.05 = 0.14 - // For bond (0, 1): - // EMA = 0.8 * 0.2 + (1 - 0.8) * 0.6 = 0.16 + 0.12 = 0.28 - // For bond (1, 0): - // EMA = 0.9 * 0.3 + (1 - 0.9) * 0.7 = 0.27 + 0.07 = 0.34 - // For bond (1, 1): - // EMA = 0.8 * 0.4 + (1 - 0.8) * 0.8 = 0.32 + 0.16 = 0.48 let expected_ema_bonds = vec![ - vec![(0, I32F32::from_num(0.1309)), (1, I32F32::from_num(0.2479))], - vec![(0, I32F32::from_num(0.3129)), (1, I32F32::from_num(0.4159))], + vec![ + (0, I32F32::from_num(0.130999)), + (1, I32F32::from_num(0.247999)), + ], + vec![ + (0, I32F32::from_num(0.312999)), + (1, I32F32::from_num(0.415999)), + ], ]; // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); // Assert the results with an epsilon for approximate equality - let epsilon = I32F32::from_num(1e-4); + let epsilon = I32F32::from_num(1e-6); assert_approx_eq_vec_of_vec(&ema_bonds, &expected_ema_bonds, epsilon); } @@ -2741,7 +2837,7 @@ fn test_compute_ema_bonds_sparse() { #[test] fn test_compute_ema_bonds_sparse_empty() { // Test with empty inputs - let bonds_delta: Vec> = vec![]; + let weights: Vec> = vec![]; let bonds: Vec> = vec![]; let alpha: Vec = vec![]; @@ -2749,7 +2845,7 @@ fn test_compute_ema_bonds_sparse_empty() { let expected_ema_bonds: Vec> = vec![]; // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); // Assert the results assert_eq!( diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index 51ca7a8fbb..9cf59e96dd 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -2145,7 +2145,7 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0.1); 3]); + let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(0.1); 3]); assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, @@ -2159,7 +2159,7 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0); 3]); + let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(0); 3]); assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![ 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, @@ -2174,7 +2174,7 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(1); 3]); + let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(1); 3]); assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); } From d9902e8fae6b6000be43dc7601d4b2bfc351f8fa Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 4 Feb 2025 08:06:49 +0000 Subject: [PATCH 011/226] add yuma4 scenario test --- pallets/subtensor/src/tests/epoch.rs | 155 +++++++++++++++++++++++++++ pallets/subtensor/src/tests/math.rs | 49 +++------ pallets/subtensor/src/utils/misc.rs | 6 ++ 3 files changed, 174 insertions(+), 36 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 6760a552b3..3316f220a1 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3286,3 +3286,158 @@ fn assert_approx_eq_vec_of_vec( } } } + +// test Yuma 4 scenarios over a sequence of epochs. +fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) { + let block_number = System::block_number(); + let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead + add_network(netuid, tempo, 0); + + SubtensorModule::set_max_allowed_uids(netuid, n); + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + SubtensorModule::set_max_registrations_per_block(netuid, n); + SubtensorModule::set_target_registrations_per_interval(netuid, n); + SubtensorModule::set_weights_set_rate_limit(netuid, 0); + SubtensorModule::set_min_allowed_weights(netuid, 1); + SubtensorModule::set_max_weight_limit(netuid, u16::MAX); + SubtensorModule::set_bonds_penalty(netuid, 0); + + // === Register + for key in 0..n as u64 { + SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), max_stake); + let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( + netuid, + block_number, + key * 1_000_000, + &U256::from(key), + ); + assert_ok!(SubtensorModule::register( + <::RuntimeOrigin>::signed(U256::from(key)), + netuid, + block_number, + nonce, + work, + U256::from(key), + U256::from(key) + )); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &U256::from(key), + &U256::from(key), + netuid, + stakes[key as usize], + ); + } + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); + + // Enable Liquid Alpha + SubtensorModule::set_kappa(netuid, 0); + SubtensorModule::set_liquid_alpha_enabled(netuid, true); + + SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.9), I32F32::from_num(0.99)); + + // === Issue validator permits + SubtensorModule::set_max_allowed_validators(netuid, 3); + assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), 3); + SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators + next_block(); // run to next block to ensure weights are set on nodes after their registration block +} + +fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) { + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + let bonds = SubtensorModule::get_bonds(netuid); + + // server 1 + assert_eq!(bonds[0][3], target_bonds[0][0]); + assert_eq!(bonds[1][3], target_bonds[1][0]); + assert_eq!(bonds[2][3], target_bonds[2][0]); + + // server 2 + assert_eq!(bonds[0][4], target_bonds[0][1]); + assert_eq!(bonds[1][4], target_bonds[1][1]); + assert_eq!(bonds[2][4], target_bonds[2][1]); +} + +#[test] +fn test_yuma_4_kappa_moves_last() { + new_test_ext(1).execute_with(|| { + let sparse: bool = false; + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) - moves last + // Validator B: Small eager validator (0.1) - moves first + // Validator C: Small lazy validator (0.1) - moves second + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_4_scenario(netuid, n, max_stake, stakes); + + // Initially, consensus is achieved by all Validators + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![u16::MAX, 0], + 0 + )); + } + let target = vec![vec![65535, 0], vec![65535, 0], vec![65535, 0]]; + run_epoch_check_bonds(netuid, sparse, target); + + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 1 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + let target = vec![vec![65535, 0], vec![220, 65535], vec![65535, 0]]; + run_epoch_check_bonds(netuid, sparse, target); + + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 2 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + let target = vec![vec![65535, 0], vec![1, 65535], vec![329, 64878]]; + run_epoch_check_bonds(netuid, sparse, target); + + // Subsequent epochs All validators -> Server 2 + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![0, u16::MAX], + 0 + )); + } + let target = vec![vec![65535, 11866], vec![0, 65535], vec![328, 64996]]; + run_epoch_check_bonds(netuid, sparse, target); + }) +} diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index 9cf59e96dd..cea3ca6685 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -1221,42 +1221,19 @@ fn test_math_vec_mask_sparse_matrix() { } #[test] -fn test_math_scalar_vec_mask_sparse_matrix() { - let vector: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9.]; - let target: Vec = vec![0., 2., 3., 0., 5., 6., 0., 8., 9.]; - let mat = vec_to_sparse_mat_fixed(&vector, 3, false); - let scalar: u64 = 1; - let masking_vector: Vec = vec![1, 4, 7]; - let result = scalar_vec_mask_sparse_matrix(&mat, scalar, &masking_vector, &|a, b| a == b); - assert_sparse_mat_compare( - &result, - &vec_to_sparse_mat_fixed(&target, 3, false), - I32F32::from_num(0), - ); - - let vector: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9.]; - let target: Vec = vec![1., 2., 0., 4., 5., 0., 7., 8., 0.]; - let mat = vec_to_sparse_mat_fixed(&vector, 3, false); - let scalar: u64 = 5; - let masking_vector: Vec = vec![1, 4, 7]; - let result = scalar_vec_mask_sparse_matrix(&mat, scalar, &masking_vector, &|a, b| a <= b); - assert_sparse_mat_compare( - &result, - &vec_to_sparse_mat_fixed(&target, 3, false), - I32F32::from_num(0), - ); - - let vector: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9.]; - let target: Vec = vec![0., 0., 3., 0., 0., 6., 0., 0., 9.]; - let mat = vec_to_sparse_mat_fixed(&vector, 3, false); - let scalar: u64 = 5; - let masking_vector: Vec = vec![1, 4, 7]; - let result = scalar_vec_mask_sparse_matrix(&mat, scalar, &masking_vector, &|a, b| a >= b); - assert_sparse_mat_compare( - &result, - &vec_to_sparse_mat_fixed(&target, 3, false), - I32F32::from_num(0), - ); +fn test_math_vec_mul() { + let vector: Vec = vec_to_fixed(&[1., 2., 3., 4.]); + let target: Vec = vec_to_fixed(&[1., 4., 9., 16.]); + let result = vec_mul(&vector, &vector); + assert_vec_compare(&result, &target, I32F32::from_num(0)); + let vector_empty: Vec = vec_to_fixed(&[]); + let result = vec_mul(&vector_empty, &vector); + let target: Vec = vec![]; + assert_vec_compare(&result, &target, I32F32::from_num(0)); + let vector_zero: Vec = vec_to_fixed(&[0., 0., 0., 0., 0., 0., 0., 0.]); + let result = vec_mul(&vector_zero, &vector); + let target: Vec = vec![I32F32::from_num(0); 4]; + assert_vec_compare(&result, &target, I32F32::from_num(0)); } #[test] diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index b375cc66e4..6f2ea1ffa3 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -671,6 +671,12 @@ impl Pallet { AlphaValues::::get(netuid) } + pub fn set_alpha_values_32(netuid: u16, low: I32F32, high: I32F32) { + let low = (low.saturating_mul(I32F32::saturating_from_num(u16::MAX))).to_num::(); + let high = (high.saturating_mul(I32F32::saturating_from_num(u16::MAX))).to_num::(); + AlphaValues::::insert(netuid, (low, high)); + } + pub fn get_alpha_values_32(netuid: u16) -> (I32F32, I32F32) { let (alpha_low, alpha_high): (u16, u16) = AlphaValues::::get(netuid); let converted_low = From a177304f2fa20603529c2fc3a28190dc57ba5fe2 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 22 Jan 2025 12:52:27 +0000 Subject: [PATCH 012/226] yuma bonds scale individually --- pallets/subtensor/src/epoch/run_epoch.rs | 61 ++++++------------------ 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 26607422ec..1a408b85ef 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -204,12 +204,19 @@ impl Pallet { inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 log::trace!("B:\n{:?}\n", &bonds); - // Get alpha values - let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); - // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds(&weights_for_bonds.clone(), &bonds, alpha); - // Normalize EMA bonds. + // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. + let mut ema_bonds = if let Some(clamped_bonds_alpha) = + Self::compute_liquid_alpha(netuid, consensus.clone()) + { + // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + Self::compute_ema_bonds_with_liquid_alpha(&weights.clone(), &bonds, clamped_bonds_alpha) + } else { + log::trace!("Using Bonds Moving Average"); + // Compute the EMA of bonds using a normal alpha value. + Self::compute_ema_bonds_normal(&weights.clone(), &bonds, netuid) + }; + inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -1016,30 +1023,6 @@ impl Pallet { ema_bonds } - /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values. - /// - /// # Args: - /// * `weights` - A vector of weights. - /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. - /// - /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds( - weights: &[Vec], - bonds: &[Vec], - alpha: Vec, - ) -> Vec> { - // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec(weights, bonds, &alpha); - - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); - - // Return the computed EMA bonds. - ema_bonds - } - /// Compute liquid alphas based on the Liquid Alpha setting. /// /// # Args: @@ -1048,7 +1031,7 @@ impl Pallet { /// /// # Returns: /// A vector of alphas - pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Vec { + pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Option> { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) && !consensus.is_empty() @@ -1083,24 +1066,10 @@ impl Pallet { // Clamp the alpha values between alpha_high and alpha_low. let clamped_alpha = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); - return clamped_alpha; + return Some(clamped_alpha); } } - - // Liquid Alpha is disabled - // or high and low consensus values do not meet the required conditions. - // return vector of constant alpha - - // Retrieve the bonds moving average for the given network ID and scale it down. - let bonds_moving_average: I64F64 = I64F64::from_num(Self::get_bonds_moving_average(netuid)) - .saturating_div(I64F64::from_num(1_000_000)); - - // Calculate the alpha value for the EMA calculation. - // Alpha is derived by subtracting the scaled bonds moving average from 1. - let alpha: I32F32 = - I32F32::from_num(1).saturating_sub(I32F32::from_num(bonds_moving_average)); - - vec![alpha; consensus.len()] + None } pub fn do_set_alpha_values( From 2baaa98730058a777ba1e1a339ecc8536f7d3086 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 22 Jan 2025 13:16:00 +0000 Subject: [PATCH 013/226] yuma bonds scale individually for sparse --- pallets/subtensor/src/epoch/run_epoch.rs | 132 ++++++++++++++++++++--- 1 file changed, 120 insertions(+), 12 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 1a408b85ef..5a42024561 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -216,7 +216,7 @@ impl Pallet { // Compute the EMA of bonds using a normal alpha value. Self::compute_ema_bonds_normal(&weights.clone(), &bonds, netuid) }; - + // Normalize EMA bonds. inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -591,12 +591,22 @@ impl Pallet { inplace_col_normalize_sparse(&mut bonds, n); log::trace!("B (mask+norm): {:?}", &bonds); - // Get alpha values - let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); - // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = - Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alpha); + let mut ema_bonds = if let Some(clamped_bonds_alpha) = + Self::compute_liquid_alpha(netuid, consensus.clone()) + { + // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + Self::compute_ema_bonds_with_liquid_alpha_sparse( + &weights.clone(), + &bonds, + clamped_bonds_alpha, + ) + } else { + log::trace!("Using Bonds Moving Average"); + // Compute the EMA of bonds using a normal alpha value. + Self::compute_ema_bonds_normal_sparse(&weights.clone(), &bonds, netuid) + }; + // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); @@ -1002,22 +1012,120 @@ impl Pallet { /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values for a sparse matrix. /// /// # Args: - /// * `weights` - A vector of weights. + /// * `bonds_delta` - A vector of bond deltas. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. + /// * `alpha` - A vector of clamped alpha values. /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds_sparse( - weights: &[Vec<(u16, I32F32)>], + pub fn compute_ema_bonds_with_liquid_alpha_sparse( + bonds_delta: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], alpha: Vec, ) -> Vec> { // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec_sparse(weights, bonds, &alpha); + let ema_bonds = mat_ema_alpha_vec_sparse(bonds_delta, bonds, &alpha); + + // Log the computed EMA bonds for debugging purposes. + log::trace!( + "Exponential Moving Average Bonds Liquid Alpha: {:?}", + ema_bonds + ); + + // Return the computed EMA bonds. + ema_bonds + } + + /// Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + /// + /// # Args: + /// * `bonds_delta` - A vector of bond deltas. + /// * `bonds` - A vector of bonds. + /// * `alpha` - A vector of clamped alpha values. + /// + /// # Returns: + /// A vector of EMA bonds. + pub fn compute_ema_bonds_with_liquid_alpha( + bonds_delta: &[Vec], + bonds: &[Vec], + alpha: Vec, + ) -> Vec> { + // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. + let ema_bonds = mat_ema_alpha_vec(bonds_delta, bonds, &alpha); + + // Log the computed EMA bonds for debugging purposes. + log::trace!( + "Exponential Moving Average Bonds Liquid Alpha: {:?}", + ema_bonds + ); + + // Return the computed EMA bonds. + ema_bonds + } + + /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value for a sparse matrix. + /// + /// # Args: + /// * `bonds_delta` - A vector of bond deltas. + /// * `bonds` - A vector of bonds. + /// * `netuid` - The network ID. + /// + /// # Returns: + /// A vector of EMA bonds. + pub fn compute_ema_bonds_normal_sparse( + bonds_delta: &[Vec<(u16, I32F32)>], + bonds: &[Vec<(u16, I32F32)>], + netuid: u16, + ) -> Vec> { + // Retrieve the bonds moving average for the given network ID and scale it down. + let bonds_moving_average: I64F64 = + I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) + .safe_div(I64F64::saturating_from_num(1_000_000)); + + // Calculate the alpha value for the EMA calculation. + // Alpha is derived by subtracting the scaled bonds moving average from 1. + let alpha: I32F32 = I32F32::saturating_from_num(1) + .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); + + // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. + let ema_bonds = mat_ema_sparse(bonds_delta, bonds, alpha); + + // Log the computed EMA bonds for debugging purposes. + log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); + + // Return the computed EMA bonds. + ema_bonds + } + + /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value. + /// + /// # Args: + /// * `bonds_delta` - A vector of bond deltas. + /// * `bonds` - A vector of bonds. + /// * `netuid` - The network ID. + /// + /// # Returns: + /// A vector of EMA bonds. + pub fn compute_ema_bonds_normal( + bonds_delta: &[Vec], + bonds: &[Vec], + netuid: u16, + ) -> Vec> { + // Retrieve the bonds moving average for the given network ID and scale it down. + let bonds_moving_average: I64F64 = + I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) + .safe_div(I64F64::saturating_from_num(1_000_000)); + + // Calculate the alpha value for the EMA calculation. + // Alpha is derived by subtracting the scaled bonds moving average from 1. + let alpha: I32F32 = I32F32::saturating_from_num(1) + .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); + + // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. + let ema_bonds = mat_ema(bonds_delta, bonds, alpha); // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); + log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); // Return the computed EMA bonds. ema_bonds From 90bafb82bc11ab2df0f3da65b73ecb5cd259c838 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 22 Jan 2025 14:45:35 +0000 Subject: [PATCH 014/226] refactor alpha values --- pallets/subtensor/src/epoch/run_epoch.rs | 142 +++++------------------ pallets/subtensor/src/tests/epoch.rs | 4 +- pallets/subtensor/src/tests/math.rs | 36 ++++-- 3 files changed, 60 insertions(+), 122 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 5a42024561..ef0f171c34 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -204,18 +204,11 @@ impl Pallet { inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 log::trace!("B:\n{:?}\n", &bonds); + // Get alpha values + let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); + // Compute the Exponential Moving Average (EMA) of bonds. - // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. - let mut ema_bonds = if let Some(clamped_bonds_alpha) = - Self::compute_liquid_alpha(netuid, consensus.clone()) - { - // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. - Self::compute_ema_bonds_with_liquid_alpha(&weights.clone(), &bonds, clamped_bonds_alpha) - } else { - log::trace!("Using Bonds Moving Average"); - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal(&weights.clone(), &bonds, netuid) - }; + let mut ema_bonds = Self::compute_ema_bonds(&weights.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -591,22 +584,11 @@ impl Pallet { inplace_col_normalize_sparse(&mut bonds, n); log::trace!("B (mask+norm): {:?}", &bonds); - // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = if let Some(clamped_bonds_alpha) = - Self::compute_liquid_alpha(netuid, consensus.clone()) - { - // Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. - Self::compute_ema_bonds_with_liquid_alpha_sparse( - &weights.clone(), - &bonds, - clamped_bonds_alpha, - ) - } else { - log::trace!("Using Bonds Moving Average"); - // Compute the EMA of bonds using a normal alpha value. - Self::compute_ema_bonds_normal_sparse(&weights.clone(), &bonds, netuid) - }; + // Get alpha values + let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); + // Compute the Exponential Moving Average (EMA) of bonds. + let mut ema_bonds = Self::compute_ema_bonds_sparse(&weights.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); @@ -1014,11 +996,11 @@ impl Pallet { /// # Args: /// * `bonds_delta` - A vector of bond deltas. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values. + /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds_with_liquid_alpha_sparse( + pub fn compute_ema_bonds_sparse( bonds_delta: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], alpha: Vec, @@ -1027,25 +1009,22 @@ impl Pallet { let ema_bonds = mat_ema_alpha_vec_sparse(bonds_delta, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. - log::trace!( - "Exponential Moving Average Bonds Liquid Alpha: {:?}", - ema_bonds - ); + log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); // Return the computed EMA bonds. ema_bonds } - /// Compute the Exponential Moving Average (EMA) of bonds using the clamped alpha values. + /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values. /// /// # Args: /// * `bonds_delta` - A vector of bond deltas. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values. + /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds_with_liquid_alpha( + pub fn compute_ema_bonds( bonds_delta: &[Vec], bonds: &[Vec], alpha: Vec, @@ -1054,78 +1033,7 @@ impl Pallet { let ema_bonds = mat_ema_alpha_vec(bonds_delta, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. - log::trace!( - "Exponential Moving Average Bonds Liquid Alpha: {:?}", - ema_bonds - ); - - // Return the computed EMA bonds. - ema_bonds - } - - /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value for a sparse matrix. - /// - /// # Args: - /// * `bonds_delta` - A vector of bond deltas. - /// * `bonds` - A vector of bonds. - /// * `netuid` - The network ID. - /// - /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds_normal_sparse( - bonds_delta: &[Vec<(u16, I32F32)>], - bonds: &[Vec<(u16, I32F32)>], - netuid: u16, - ) -> Vec> { - // Retrieve the bonds moving average for the given network ID and scale it down. - let bonds_moving_average: I64F64 = - I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) - .safe_div(I64F64::saturating_from_num(1_000_000)); - - // Calculate the alpha value for the EMA calculation. - // Alpha is derived by subtracting the scaled bonds moving average from 1. - let alpha: I32F32 = I32F32::saturating_from_num(1) - .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); - - // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - let ema_bonds = mat_ema_sparse(bonds_delta, bonds, alpha); - - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); - - // Return the computed EMA bonds. - ema_bonds - } - - /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value. - /// - /// # Args: - /// * `bonds_delta` - A vector of bond deltas. - /// * `bonds` - A vector of bonds. - /// * `netuid` - The network ID. - /// - /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds_normal( - bonds_delta: &[Vec], - bonds: &[Vec], - netuid: u16, - ) -> Vec> { - // Retrieve the bonds moving average for the given network ID and scale it down. - let bonds_moving_average: I64F64 = - I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) - .safe_div(I64F64::saturating_from_num(1_000_000)); - - // Calculate the alpha value for the EMA calculation. - // Alpha is derived by subtracting the scaled bonds moving average from 1. - let alpha: I32F32 = I32F32::saturating_from_num(1) - .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); - - // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - let ema_bonds = mat_ema(bonds_delta, bonds, alpha); - - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); + log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); // Return the computed EMA bonds. ema_bonds @@ -1139,7 +1047,7 @@ impl Pallet { /// /// # Returns: /// A vector of alphas - pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Option> { + pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Vec { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) && !consensus.is_empty() @@ -1174,10 +1082,24 @@ impl Pallet { // Clamp the alpha values between alpha_high and alpha_low. let clamped_alpha = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); - return Some(clamped_alpha); + return clamped_alpha; } } - None + + // Liquid Alpha is disabled + // or high and low consensus values do not meet the required conditions. + // return vector of constant alpha + + // Retrieve the bonds moving average for the given network ID and scale it down. + let bonds_moving_average: I64F64 = I64F64::from_num(Self::get_bonds_moving_average(netuid)) + .saturating_div(I64F64::from_num(1_000_000)); + + // Calculate the alpha value for the EMA calculation. + // Alpha is derived by subtracting the scaled bonds moving average from 1. + let alpha: I32F32 = + I32F32::from_num(1).saturating_sub(I32F32::from_num(bonds_moving_average)); + + vec![alpha; consensus.len()] } pub fn do_set_alpha_values( diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 3316f220a1..175b00ab7f 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2826,7 +2826,7 @@ fn test_compute_ema_bonds_sparse() { ]; // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); // Assert the results with an epsilon for approximate equality let epsilon = I32F32::from_num(1e-6); @@ -2845,7 +2845,7 @@ fn test_compute_ema_bonds_sparse_empty() { let expected_ema_bonds: Vec> = vec![]; // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); // Assert the results assert_eq!( diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index cea3ca6685..16a73c5e37 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -2136,11 +2136,19 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(0); 3]); - assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); - let old: Vec = vec![ - 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); + assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); + let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let new: Vec = vec![ + 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., ]; + let target: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let old = vec_to_mat_fixed(&old, 4, false); + let new = vec_to_mat_fixed(&new, 4, false); + let target = vec_to_mat_fixed(&target, 4, false); + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0); old.len()]); + assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); + let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let new: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; @@ -2151,8 +2159,8 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(1); 3]); - assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); + let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(1); old.len()]); + assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); } #[test] @@ -2183,7 +2191,15 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + let old: Vec = vec![0., 2., 3., 4., 0., 6., 7., 8., 0., 10., 11., 12.]; + let new: Vec = vec![10., 20., 0., 40., 0., 60., 0., 80., 90., 100., 110., 120.]; + let target: Vec = vec![1., 3.8, 2.7, 7.6, 0., 11.4, 6.3, 15.2, 9., 19., 20.9, 22.8]; + let old = vec_to_sparse_mat_fixed(&old, 4, false); + let new = vec_to_sparse_mat_fixed(&new, 4, false); + let target = vec_to_sparse_mat_fixed(&target, 4, false); + let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, @@ -2196,7 +2212,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let target: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; @@ -2204,7 +2220,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); let old: Vec = vec![1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 2., 0., 0., 0., 0., 0., 0., 0.]; let target: Vec = vec![0.9, 0., 0., 0., 0.2, 0., 0., 0., 0., 0., 0., 0.]; @@ -2212,7 +2228,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); } #[test] From 475299190c3ddc59955ea35663b2f0e4ecc25406 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Mon, 27 Jan 2025 03:21:02 +0000 Subject: [PATCH 015/226] rebase fix --- pallets/subtensor/src/epoch/run_epoch.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index ef0f171c34..36510532ce 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -208,7 +208,7 @@ impl Pallet { let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds(&weights.clone(), &bonds, alpha); + let mut ema_bonds = Self::compute_ema_bonds(&weights_for_bonds.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 log::trace!("emaB:\n{:?}\n", &ema_bonds); @@ -588,7 +588,8 @@ impl Pallet { let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds_sparse(&weights.clone(), &bonds, alpha); + let mut ema_bonds = + Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); From 1abe9c3c1be2a8f6104f6e4b748de0624983e622 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 28 Jan 2025 09:56:13 +0000 Subject: [PATCH 016/226] compute_ema_bonds param rename --- pallets/subtensor/src/epoch/run_epoch.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 36510532ce..26607422ec 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -995,19 +995,19 @@ impl Pallet { /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values for a sparse matrix. /// /// # Args: - /// * `bonds_delta` - A vector of bond deltas. + /// * `weights` - A vector of weights. /// * `bonds` - A vector of bonds. /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. pub fn compute_ema_bonds_sparse( - bonds_delta: &[Vec<(u16, I32F32)>], + weights: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], alpha: Vec, ) -> Vec> { // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec_sparse(bonds_delta, bonds, &alpha); + let ema_bonds = mat_ema_alpha_vec_sparse(weights, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); @@ -1019,19 +1019,19 @@ impl Pallet { /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values. /// /// # Args: - /// * `bonds_delta` - A vector of bond deltas. + /// * `weights` - A vector of weights. /// * `bonds` - A vector of bonds. /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. /// /// # Returns: /// A vector of EMA bonds. pub fn compute_ema_bonds( - bonds_delta: &[Vec], + weights: &[Vec], bonds: &[Vec], alpha: Vec, ) -> Vec> { // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec(bonds_delta, bonds, &alpha); + let ema_bonds = mat_ema_alpha_vec(weights, bonds, &alpha); // Log the computed EMA bonds for debugging purposes. log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); From 449242f9a7e131f75be57bb0de0ad7a827030098 Mon Sep 17 00:00:00 2001 From: opentaco Date: Mon, 3 Feb 2025 13:15:37 +0200 Subject: [PATCH 017/226] Add consensus test file --- pallets/subtensor/src/tests/consensus.rs | 553 +++++++++++++++++++++++ pallets/subtensor/src/tests/mod.rs | 1 + 2 files changed, 554 insertions(+) create mode 100644 pallets/subtensor/src/tests/consensus.rs diff --git a/pallets/subtensor/src/tests/consensus.rs b/pallets/subtensor/src/tests/consensus.rs new file mode 100644 index 0000000000..e5a7b59b1d --- /dev/null +++ b/pallets/subtensor/src/tests/consensus.rs @@ -0,0 +1,553 @@ +#![allow( + clippy::arithmetic_side_effects, + clippy::indexing_slicing, + clippy::unwrap_used +)] + +use super::mock::*; +use crate::*; + +use frame_support::assert_ok; +use rand::{distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng, Rng, SeedableRng}; +use sp_core::U256; +use std::time::Instant; +use substrate_fixed::types::{I32F32, I64F64}; +use substrate_fixed::transcendental::{cos, ln, sqrt, PI}; + +pub fn fixed(val: f32) -> I32F32 { + I32F32::from_num(val) +} + +pub fn fixed_to_u16(x: I32F32) -> u16 { + x.to_num::() +} + +pub fn fixed_proportion_to_u16(x: I32F32) -> u16 { + fixed_to_u16(x * I32F32::from_num(u16::MAX)) +} + +// Normalizes (sum to 1 except 0) the input vector directly in-place. +#[allow(dead_code)] +pub fn inplace_normalize(x: &mut [I32F32]) { + let x_sum: I32F32 = x.iter().sum(); + if x_sum == I32F32::from_num(0.0_f32) { + return; + } + for i in x.iter_mut() { + *i /= x_sum; + } +} + +// Inplace normalize the passed positive integer weights so that they sum to u16 max value. +fn normalize_weights(mut weights: Vec) -> Vec { + let sum: u64 = weights.iter().map(|x| *x as u64).sum(); + if sum == 0 { + return weights; + } + weights.iter_mut().for_each(|x| { + *x = (*x as u64 * u16::MAX as u64 / sum) as u16; + }); + weights +} + +// Return as usize an I32F32 ratio of a usize input, avoiding the 0% and 100% extremes. +fn non_extreme_fixed_ratio(ratio: I32F32, total: usize) -> usize { + if total == 0 { + return total; + } + let mut subset: usize = (ratio * I32F32::from_num(total)).to_num::(); + if subset == 0 { + subset = 1; + } else if subset == total { + subset = total - 1; + } + return subset; +} + +// Box-Muller Transform converting two uniform random samples to a normal random sample. +fn normal(size: usize, rng: &mut StdRng, dist: &Uniform) -> Vec { + let max: I32F32 = I32F32::from_num(u16::MAX); + let two: I32F32 = I32F32::from_num(2); + let eps: I32F32 = I32F32::from_num(0.000001); + let pi: I32F32 = I32F32::from_num(PI); + + let uniform_u16: Vec = (0..(2 * size)).map(|_| rng.sample(&dist)).collect(); + let uniform: Vec = uniform_u16 + .iter() + .map(|&x| I32F32::from_num(x) / max) + .collect(); + let mut normal: Vec = vec![I32F32::from_num(0); size as usize]; + + for i in 0..size { + let u1: I32F32 = uniform[i] + eps; + let u2: I32F32 = uniform[i + size] + eps; + normal[i] = sqrt::(-two * ln::(u1).expect("")).expect("") + * cos(two * pi * u2); + } + normal +} + +// Returns validators and servers uids with either blockwise, regular, or random interleaving. +fn distribute_nodes( + validators_n: usize, + network_n: usize, + interleave: usize, +) -> (Vec, Vec) { + let mut validators: Vec = vec![]; + let mut servers: Vec = vec![]; + + if interleave == 0 { + // blockwise [validator_block, server_block] + validators = (0..validators_n as u16).collect(); + servers = (validators_n as u16..network_n as u16).collect(); + } else if interleave == 1 { + // regular interleaving [val, srv, srv, ..., srv, val, srv, srv, ..., srv, val, srv, ..., srv] + (validators, servers) = (0..network_n as u16) + .collect::>() + .iter() + .partition(|&i| *i as usize % (network_n / validators_n) == 0); + } else if interleave == 2 { + // random interleaving + let mut permuted_uids: Vec = (0..network_n as u16).collect(); + permuted_uids.shuffle(&mut thread_rng()); + validators = permuted_uids[0..validators_n].into(); + servers = permuted_uids[validators_n..network_n].into(); + } + + (validators, servers) +} + +#[allow(dead_code)] +fn uid_stats(netuid: u16, uid: u16) { + log::info!( + "stake: {:?}", + SubtensorModule::get_total_stake_for_hotkey(&(U256::from(uid))) + ); + log::info!("rank: {:?}", SubtensorModule::get_rank_for_uid(netuid, uid)); + log::info!( + "trust: {:?}", + SubtensorModule::get_trust_for_uid(netuid, uid) + ); + log::info!( + "consensus: {:?}", + SubtensorModule::get_consensus_for_uid(netuid, uid) + ); + log::info!( + "incentive: {:?}", + SubtensorModule::get_incentive_for_uid(netuid, uid) + ); + log::info!( + "dividend: {:?}", + SubtensorModule::get_dividends_for_uid(netuid, uid) + ); + log::info!( + "emission: {:?}", + SubtensorModule::get_emission_for_uid(netuid, uid) + ); +} + +#[allow(clippy::too_many_arguments)] +fn init_run_epochs( + netuid: u16, + n: u16, + validators: &[u16], + servers: &[u16], + epochs: u16, + stake_per_validator: u64, + server_self: bool, + input_stake: &[u64], + use_input_stake: bool, + input_weights: &[Vec<(u16, u16)>], + use_input_weights: bool, + random_weights: bool, + random_seed: u64, + sparse: bool, + bonds_penalty: u16, +) { + // === Create the network + add_network(netuid, u16::MAX - 1, 0); // set higher tempo to avoid built-in epoch, then manual epoch instead + + // === Set bonds penalty + SubtensorModule::set_bonds_penalty(netuid, bonds_penalty); + + // === Register uids + SubtensorModule::set_max_allowed_uids(netuid, n); + for key in 0..n { + let stake = if use_input_stake { + input_stake[key as usize] + } else if validators.contains(&key) { + stake_per_validator + } else { + // only validators receive stake + 0 + }; + + // let stake: u64 = 1; // alternative test: all nodes receive stake, should be same outcome, except stake + SubtensorModule::add_balance_to_coldkey_account(&(U256::from(key)), stake); + SubtensorModule::append_neuron(netuid, &(U256::from(key)), 0); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &U256::from(key), + &U256::from(key), + netuid, + stake, + ); + } + assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); + + // === Issue validator permits + SubtensorModule::set_max_allowed_validators(netuid, validators.len() as u16); + assert_eq!( + SubtensorModule::get_max_allowed_validators(netuid), + validators.len() as u16 + ); + SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators + run_to_block(1); // run to next block to ensure weights are set on nodes after their registration block + + // === Set weights + let mut rng = StdRng::seed_from_u64(random_seed); // constant seed so weights over multiple runs are equal + let range = Uniform::new(0, u16::MAX); + let mut weights: Vec = vec![u16::MAX / n; servers.len()]; + for uid in validators { + if random_weights { + weights = (0..servers.len()).map(|_| rng.sample(range)).collect(); + weights = normalize_weights(weights); + // assert_eq!(weights.iter().map(|x| *x as u64).sum::(), u16::MAX as u64); // normalized weight sum not always u16::MAX + } + if use_input_weights { + let sparse_weights = input_weights[*uid as usize].clone(); + weights = sparse_weights.iter().map(|(_, w)| *w).collect(); + let srvs: Vec = sparse_weights.iter().map(|(s, _)| *s).collect(); + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(*uid as u64)), + netuid, + srvs, + weights.clone(), + 0 + )); + } else { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(*uid as u64)), + netuid, + servers.to_vec(), + weights.clone(), + 0 + )); + } + } + if server_self { + for uid in servers { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(*uid as u64)), + netuid, + vec![*uid], + vec![u16::MAX], + 0 + )); // server self-weight + } + } + + // === Run the epochs. + log::info!("Start {epochs} epoch(s)"); + let start = Instant::now(); + for _ in 0..epochs { + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + } + let duration = start.elapsed(); + log::info!( + "Time elapsed in (sparse={sparse}) epoch() is: {:?}", + duration + ); + + // let bonds = SubtensorModule::get_bonds( netuid ); + // for (uid, node) in vec![ (validators[0], "validator"), (servers[0], "server") ] { + // log::info!("\n{node}" ); + // uid_stats(netuid, uid); + // log::info!("bonds: {:?} (on validator), {:?} (on server)", bonds[uid as usize][0], bonds[uid as usize][servers[0] as usize]); + // } +} + +// Generate a random graph that is split into a major and minor set, each setting specific weight on itself and the complement on the other. +fn split_graph( + major_stake: I32F32, + major_weight: I32F32, + minor_weight: I32F32, + weight_stddev: I32F32, + validators_n: usize, + network_n: usize, + interleave: usize, +) -> ( + Vec, + Vec, + Vec, + Vec, + Vec, + Vec, + Vec, + Vec>, + I32F32, +) { + let servers_n: usize = network_n - validators_n; + let major_servers_n: usize = non_extreme_fixed_ratio(major_stake, servers_n); + let major_validators_n: usize = non_extreme_fixed_ratio(major_stake, validators_n); + + let (validators, servers) = distribute_nodes(validators_n, network_n, interleave as usize); + let major_validators: Vec = (0..major_validators_n).map(|i| validators[i]).collect(); + let minor_validators: Vec = (major_validators_n..validators_n) + .map(|i| validators[i]) + .collect(); + let major_servers: Vec = (0..major_servers_n).map(|i| servers[i]).collect(); + let minor_servers: Vec = (major_servers_n..servers_n).map(|i| servers[i]).collect(); + + let zero: I32F32 = I32F32::from_num(0); + let one: I32F32 = I32F32::from_num(1); + let stddev: I32F32 = I32F32::from_num(0.3); + let total_stake: I64F64 = I64F64::from_num(21_000_000_000_000_000 as u64); + let mut rng = StdRng::seed_from_u64(0); // constant seed so weights over multiple runs are equal + let dist = Uniform::new(0, u16::MAX); + + let mut stake: Vec = vec![0; network_n]; + let mut stake_fixed: Vec = vec![zero; network_n]; + for (ratio, vals) in vec![ + (major_stake, &major_validators), + (one - major_stake, &minor_validators), + ] { + let mut sample: Vec = normal(vals.len(), &mut rng, &dist) + .iter() + .map(|x: &I32F32| { + let v: I32F32 = (stddev * x) + one; + if v < zero { + zero + } else { + v + } + }) + .collect(); + inplace_normalize(&mut sample); + for (i, &val) in vals.iter().enumerate() { + stake[val as usize] = + (I64F64::from_num(ratio) * I64F64::from_num(sample[i]) * total_stake) + .to_num::(); + stake_fixed[val as usize] = + I32F32::from_num(I64F64::from_num(ratio) * I64F64::from_num(sample[i])); + } + } + + let mut weights: Vec> = vec![vec![]; network_n as usize]; + let mut weights_fixed: Vec> = vec![vec![zero; network_n]; network_n]; + for (first, second, vals) in vec![ + (major_weight, one - major_weight, &major_validators), + (one - minor_weight, minor_weight, &minor_validators), + ] { + for &val in vals { + for (weight, srvs) in vec![(first, &major_servers), (second, &minor_servers)] { + let mut sample: Vec = normal(srvs.len(), &mut rng, &dist) + .iter() + .map(|x: &I32F32| { + let v: I32F32 = (weight_stddev * x) + one; + if v < zero { + zero + } else { + v + } + }) + .collect(); + inplace_normalize(&mut sample); + + for (i, &srv) in srvs.iter().enumerate() { + weights[val as usize].push((srv, fixed_proportion_to_u16(weight * sample[i]))); + weights_fixed[val as usize][srv as usize] = weight * sample[i]; + } + } + inplace_normalize(&mut weights_fixed[val as usize]); + } + } + + inplace_normalize(&mut stake_fixed); + + // Calculate stake-weighted mean per server + let mut weight_mean: Vec = vec![zero; network_n]; + for val in 0..network_n { + if stake_fixed[val] > zero { + for srv in 0..network_n { + weight_mean[srv] += stake_fixed[val] * weights_fixed[val][srv]; + } + } + } + + // Calculate stake-weighted absolute standard deviation + let mut weight_dev: Vec = vec![zero; network_n]; + for val in 0..network_n { + if stake_fixed[val] > zero { + for srv in 0..network_n { + weight_dev[srv] += + stake_fixed[val] * (weight_mean[srv] - weights_fixed[val][srv]).abs(); + } + } + } + + // Calculate rank-weighted mean of weight_dev + let avg_weight_dev: I32F32 = + weight_dev.iter().sum::() / weight_mean.iter().sum::(); + + ( + validators, + servers, + major_validators, + minor_validators, + major_servers, + minor_servers, + stake, + weights, + avg_weight_dev, + ) +} + +// Test consensus guarantees with an epoch on a graph with 4096 nodes, of which the first 128 are validators, the graph is split into a major and minor set, each setting specific weight on itself and the complement on the other. Asserts that the major emission ratio >= major stake ratio. +// #[test] +// fn test_consensus_guarantees() { +// let netuid: u16 = 0; +// let network_n: u16 = 512; +// let validators_n: u16 = 64; +// let epochs: u16 = 1; +// let interleave = 2; +// log::info!("test_consensus_guarantees ({network_n:?}, {validators_n:?} validators)"); +// for (major_stake, major_weight, minor_weight, weight_stddev) in vec![ +// (0.51, 1., 1., 0.001), +// (0.51, 0.03, 0., 0.001), +// (0.51, 0.51, 0.49, 0.001), +// (0.51, 0.51, 1., 0.001), +// (0.51, 0.61, 0.8, 0.1), +// (0.6, 0.67, 0.65, 0.2), +// (0.6, 0.74, 0.77, 0.4), +// (0.6, 0.76, 0.8, 0.4), +// (0.6, 0.76, 1., 0.4), +// (0.6, 0.92, 1., 0.4), +// (0.6, 0.94, 1., 0.4), +// (0.65, 0.78, 0.85, 0.6), +// (0.7, 0.81, 0.85, 0.8), +// (0.7, 0.83, 0.85, 1.), +// ] { +// let ( +// validators, +// servers, +// major_validators, +// minor_validators, +// major_servers, +// minor_servers, +// stake, +// weights, +// _avg_weight_dev, +// ) = split_graph( +// fixed(major_stake), +// fixed(major_weight), +// fixed(minor_weight), +// fixed(weight_stddev), +// validators_n as usize, +// network_n as usize, +// interleave as usize, +// ); + +// new_test_ext(1).execute_with(|| { +// init_run_epochs( +// netuid, +// network_n, +// &validators, +// &servers, +// epochs, +// 1, +// true, +// &stake, +// true, +// &weights, +// true, +// false, +// 0, +// false, +// ); + +// let mut major_emission: I64F64 = I64F64::from_num(0); +// let mut minor_emission: I64F64 = I64F64::from_num(0); +// for set in vec![major_validators, major_servers] { +// for uid in set { +// major_emission += +// I64F64::from_num(SubtensorModule::get_emission_for_uid(netuid, uid)); +// } +// } +// for set in vec![minor_validators, minor_servers] { +// for uid in set { +// minor_emission += +// I64F64::from_num(SubtensorModule::get_emission_for_uid(netuid, uid)); +// } +// } +// let major_ratio: I32F32 = +// I32F32::from_num(major_emission / (major_emission + minor_emission)); +// assert!(major_stake <= major_ratio); +// }); +// } +// } + +// Map the retention graph for consensus guarantees with an single epoch on a graph with 512 nodes, of which the first 64 are validators, the graph is split into a major and minor set, each setting specific weight on itself and the complement on the other. +#[test] +fn map_consensus_guarantees() { + let netuid: u16 = 1; + let network_n: u16 = 512; + let validators_n: u16 = 64; + let epochs: u16 = 1; + let interleave = 0; + let weight_stddev: I32F32 = fixed(0.4); + let bonds_penalty: u16 = (std::env::args().nth(2).unwrap().parse::().unwrap() * f32::from(u16::MAX - 1)) as u16; + println!("["); + for _major_stake in vec![0.51, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99] { + let major_stake: I32F32 = I32F32::from_num(_major_stake); + for _major_weight in 0..51 { + let major_weight: I32F32 = I32F32::from_num(50 - _major_weight) / I32F32::from_num(50); + for _minor_weight in 0..51 { + let minor_weight: I32F32 = + I32F32::from_num(50 - _minor_weight) / I32F32::from_num(50); + let ( + validators, + servers, + major_validators, + minor_validators, + major_servers, + minor_servers, + stake, + weights, + avg_weight_dev, + ) = split_graph( + major_stake, + major_weight, + minor_weight, + weight_stddev, + validators_n as usize, + network_n as usize, + interleave as usize, + ); + + new_test_ext(1).execute_with(|| { + init_run_epochs(netuid, network_n, &validators, &servers, epochs, 1, true, &stake, true, &weights, true, false, 0, true, bonds_penalty); + + let mut major_emission: I64F64 = I64F64::from_num(0); + let mut minor_emission: I64F64 = I64F64::from_num(0); + for set in vec![major_validators, major_servers] { + for uid in set { + major_emission += I64F64::from_num(SubtensorModule::get_emission_for_uid( netuid, uid )); + } + } + for set in vec![minor_validators, minor_servers] { + for uid in set { + minor_emission += I64F64::from_num(SubtensorModule::get_emission_for_uid( netuid, uid )); + } + } + let major_ratio: I32F32 = I32F32::from_num(major_emission / (major_emission + minor_emission)); + println!("[{major_stake}, {major_weight:.2}, {minor_weight:.2}, {avg_weight_dev:.3}, {major_ratio:.3}], "); + }); + } + } + } + println!("]"); +} diff --git a/pallets/subtensor/src/tests/mod.rs b/pallets/subtensor/src/tests/mod.rs index ce891e5615..161749a923 100644 --- a/pallets/subtensor/src/tests/mod.rs +++ b/pallets/subtensor/src/tests/mod.rs @@ -1,6 +1,7 @@ mod batch_tx; mod children; mod coinbase; +mod consensus; mod delegate_info; mod difficulty; mod emission; From 7e9258d52643f02223ac99358e141ced1ece3e5e Mon Sep 17 00:00:00 2001 From: opentaco Date: Mon, 3 Feb 2025 13:16:30 +0200 Subject: [PATCH 018/226] Add map_consensus.py script --- scripts/map_consensus.py | 130 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 scripts/map_consensus.py diff --git a/scripts/map_consensus.py b/scripts/map_consensus.py new file mode 100644 index 0000000000..8d022f8e11 --- /dev/null +++ b/scripts/map_consensus.py @@ -0,0 +1,130 @@ +import re +import sys +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.pyplot import cm + + +def extract_data(filepath): + """ + Extracts the emission data from a text file. + + Args: + filepath: Path to the data file. + + Returns: + A list of lists containing the numerical data, or None if an error occurs. + """ + try: + with open(filepath, 'r') as f: + content = f.read() + except FileNotFoundError: + print(f"Error: File not found at {filepath}") + return None + + # Regular expression to extract data rows. Matches strings like "[0.51, 1.00, 1.00, ...]" + # Explanation: + # \[ Matches the opening square bracket. + # (?: ... ) Non-capturing group. + # [0-9.]+ Matches one or more digits or decimal points. + # ,\s* Matches a comma followed by zero or more whitespace characters. + # + Matches the previous group (number and comma) one or more times. + # [0-9.]+ Matches the last number in the list. + # \] Matches the closing square bracket. + + list_pattern = r'\[(?:[0-9.]+,\s*)+[0-9.]+\]' # Regular expression to match data rows + matches = re.findall(list_pattern, content) + + if not matches: + print("Error: No matching data found in the file.") + return None + + data = [] + for match in matches: + try: + # Extract numerical values from the matched string. + # 1. match[1:-1]: Removes the square brackets from the beginning and end. + # 2. .split(','): Splits the string into a list of strings at each comma. + # 3. [float(x.strip()) for x in ...]: Converts each string to a float + # after removing leading/trailing whitespace. + + row = [float(x.strip()) for x in match[1:-1].split(',')] + data.append(row) + except ValueError: + print(f"Warning: Skipping invalid data row: {match}") + + return data + + +def visualize_data(emission_data, output_filename="consensus_plot.svg"): + """ + Generates and saves a contour plot of the retention map. + + Args: + emission_data: The extracted emission data. + output_filename: The name of the output SVG file. + """ + major_ratios = {} + avg_weight_devs = {} + + # Process the data to organize it by major stake + for major_stake, major_weight, minor_weight, avg_weight_dev, major_ratio in emission_data: + major_stake_str = f'{major_stake:.2f}' + maj_idx, min_idx = int(round(50 * major_weight)), int(round(50 * minor_weight)) + + avg_weight_devs.setdefault(major_stake_str, np.zeros((51, 51))) + avg_weight_devs[major_stake_str][maj_idx][min_idx] = avg_weight_dev + + major_ratios.setdefault(major_stake_str, np.zeros((51, 51))) + major_ratios[major_stake_str][maj_idx][min_idx] = major_ratio + + + # Create the meshgrid for the contour plot + x = np.linspace(0, 1, 51) + y = np.linspace(0, 1, 51) + x, y = np.meshgrid(x, y, indexing='ij') + + # Set up the plot + fig = plt.figure(figsize=(6, 6), dpi=70) + ax = fig.gca() + ax.set_xticks(np.arange(0, 1, 0.05)) + ax.set_yticks(np.arange(0, 1., 0.05)) + ax.set_xticklabels([f'{_:.2f}'[1:] for _ in np.arange(0, 1., 0.05)]) + plt.grid(linestyle="dotted", color=[0.85, 0.85, 0.85]) + + + # Define stakes and colors for contour lines + isolate = ['0.60'] # Stakes to highlight + stakes = [0.51, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99] + colors = cm.viridis(np.linspace(0, 1, len(stakes) + 1)) + + # Create contour lines for each stake + for i, stake in enumerate(stakes): + contours = plt.contour(x, y, major_ratios[f'{stake:.2f}'], levels=[0., stake], colors=[colors[i + 1]]) + if f'{stake:.2f}' in isolate: + contours.collections[1].set_linewidth(3) # Highlight isolated stake + plt.clabel(contours, inline=True, fontsize=10) + + # Add title and labels + plt.title(f'Major emission [$stake_{{maj}}=emission_{{maj}}$ retention lines]') + plt.ylabel('Minor self-weight') + plt.xlabel('Major self-weight') + + # Save the plot + plt.savefig(output_filename, format='svg') + print(f"Plot saved to {output_filename}") + + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python scripts/map_consensus.py [optional_output_filename]") + sys.exit(1) + + filepath = sys.argv[1] + output_filename = "consensus_plot.svg" # Default output filename + if len(sys.argv) >= 3: + output_filename = sys.argv[2] # Optional output filename + + extracted_data = extract_data(filepath) + if extracted_data: + visualize_data(extracted_data, output_filename) From b96368dee70293d08802fefe7904ac8d617c9e26 Mon Sep 17 00:00:00 2001 From: opentaco Date: Mon, 3 Feb 2025 13:18:49 +0200 Subject: [PATCH 019/226] Update consensus.md doc --- docs/consensus.md | 200 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 182 insertions(+), 18 deletions(-) diff --git a/docs/consensus.md b/docs/consensus.md index 881b465b48..c3a04c380f 100644 --- a/docs/consensus.md +++ b/docs/consensus.md @@ -17,6 +17,8 @@ Community oversight (as in Steemit) must identify wrongful downvoting, but only High-volume, on-demand generative content (as in Bittensor) demands automated evaluation and divide-and-conquer validation, but introduces subjectivity both in the automated value measures and mutually exclusive task subsets across subnet validators. A coalition of validators can collude to skew scoring of subnet servers in their favour, which is harder to detect because of the inherent subjectivity. Existing consensus mechanisms will fail to deter reward manipulation for such high-volume subjective utility networks, so the need for a more sophisticated consensus arises. +--- + ### Consensus Mechanism Yuma Consensus guarantees long-term network honesty despite persistent adversarial presence in high-volume subjective utility networks. It directly penalizes selfish scoring by down-correction to the majority consensus and slashing of cabal voting stake, and also penalizes low-scoring of honest servers via forfeited validator rewards when cabals don’t score at consensus. @@ -31,6 +33,8 @@ Yuma Consensus is adversarially-resilient when majority stake is honest, via sta **Cabal sets high self-weight**: Cabal servers with poor utility will receive low weights from majority stake, and high self-weight from minority cabals will then get reduced to the low consensus. This means that minority cabals lose voting power as penalty for unfair voting while still receiving low consensus weight despite high self-weight. This consensus mechanism thus protects against selfish weighting if the majority stake is honest. +--- + ### Game-theoretic framework #### Preliminaries @@ -112,6 +116,64 @@ let mut ema_bonds: Vec> = mat_ema( &bonds_delta, &bonds, alpha ); / let mut dividends: Vec = inplace_normalize(matmul_transpose( &ema_bonds, &incentive )); // Validator reward ``` +--- + +### Monte Carlo simulations + +We consider a two-team game between (protagonist) honest stake ($0.5< S_H\le 1$) and (adversarial) cabal stake ($1 - S_H$), with $|H|$ honest and $|C|$ cabal players, that have $S_H = \sum_{i\in H}S_i$ honest stake and $1-S_H = \sum_{i\in C}S_i$ cabal stake. + +#### Network sizing + +A network size of $N=|H|+|C|=(|H_V|+|H_S|)+(|C_V|+|C_S|)=512$ and validator count of $|H_V|+|C_V|=64$ is considered for consensus guarantee experiments, and the honest/cabal ratio $|H|/N=S_H$ reflects the honest stake ratio $S_H$, but modifying extremes to ensure that each subset has at least one validator and at least one server. + +#### Stake sampling + +For the Monte Carlo simulations we use Gaussian distributions for stake and weight assignments, and ensure that the honest/cabal ratios are met. Note that stake is only assigned to validator nodes $H_V$ and $C_V$ and not servers. + +Firstly, we sample initial validator ($i\in H_V\cup C_V$) stake values $S'_i \sim \mathcal{N}(1,\sigma_S^{2})$ with a typical $\sigma_S=0.3$ standard deviation, followed by clamping to avoid negative stake: + +$$S'_i = \begin{cases} +x & \text{if } x \sim \mathcal{N}(1, \sigma_S^2), x \ge 0 \\ +0 & \text{if } x \sim \mathcal{N}(1, \sigma_S^2), x < 0 +\end{cases}$$ + +Then we normalize each honest/cabal subset and multiply by its stake proportion, which thus gives an overall normalized stake and the correct stake ratio for each subset: + +$$S_{i\in H_V} = S_H \cdot S'\_i \left/ \sum_{k\in H_V} S'\_k\right.\qquad\qquad S_{i\in C_V} = (1-S_H)\cdot S'\_i \left/ \sum_{k\in C_V}S'\_k\right.$$ + +#### Weight sampling + +Similarly, we randomize the weights that validators $H_V,C_V$ set on servers $H_S,C_S$. +Specifically, honest players $i\in H$ set $W_H = \sum_{j\in H}W_{ij}$ self-weight and $1-W_H = \sum_{j\in C}W_{ij}$ weight on cabal players, while cabal players $i\in C$ set $W_C = \sum_{j\in C}W_{ij}$ self-weight and $1-W_C = \sum_{j\in H}W_{ij}$ weight on honest players. + +We firstly sample initial weights $W'_{ij} \sim \mathcal{N}(1,\sigma_W^{2})$ with various standard deviations ranging in $0\ge\sigma_W\ge0.4$, but then clamping to avoid negative weights: + +$$W'_{ij} = \begin{cases} +x & \text{if } x \sim \mathcal{N}(1, \sigma_S^2), x \geq 0 \\ +0 & \text{if } x \sim \mathcal{N}(1, \sigma_S^2), x < 0 +\end{cases}$$ + +Weight setting between the two subsets forms quadrants $H_V\rightarrow H_S$, $H_V\rightarrow C_S$, $C_V\rightarrow H_S$, and $C_V\rightarrow C_S$, so we ensure those weight ratios are met by normalizing each weight subset and multiplying by the corresponding quadrant ratio: + +$$W_{i\in H_V, j\in H_S} = W_H\cdot W'\_{ij} \left/ \sum_{k\in H_S}W'\_{ik}\right.\qquad\qquad W_{i\in H_V, j\in C_S} = (1-W_H)\cdot W'\_{ij} \left/ \sum_{k\in C_S}W'\_{ik}\right.$$ + +$$W_{i\in C_V, j\in H_S} = (1-W_C)\cdot W'\_{ij} \left/ \sum_{k\in H_S}W'\_{ik}\right.\qquad\qquad W_{i\in C_V, j\in C_S} = W_C\cdot W'\_{ij} \left/ \sum_{k\in C_S}W'\_{ik}\right.$$ + +#### Emission calculation + +Given the simulation parameters of the network size, validator count, a defined major/honest stake $S_H$, a defined major/honest utility $W_H$, and a defined minor/cabal self-weight $W_C$, we have now instantiated the network with randomly sampled stake and weights and can proceed with an emission calculation. + +We calculate the consensus $\overline{W_j} = \arg \max_w \left( \sum_i S_i \cdot \left\lbrace W_{ij} \ge w \right\rbrace \ge \kappa \right)$ for each server $j$, and calculate consensus-clipped weights $\overline{W_{ij}} = \min( W_{ij}, \overline{W_j} )$. This then gives us the adjusted weights that offers a measure of protection against reward manipulation. + +To calculate emissions for this epoch, we firstly calculate server rank $R_j = \sum_i S_i \cdot \overline{W_{ij}}$ then incentive $I_j = R_j / \sum_k R_k$, as well as validator bonds $\Delta B_{ij} = S_i \cdot \widetilde{W_{ij}} \left/ \left( \sum_k S_k \cdot \widetilde{W_{kj}} \right) \right.$ and rewards $D_i = \sum_j B_{ij} \cdot I_j$. + +Then we add up server incentive and validator bonds over honest nodes to obtain honest emission $E_H = \xi \cdot D_{i\in H} + (1-\xi) \cdot I_{i\in H}$ with a typical validator reward ratio of $\xi=0.5$. +The objective is to prove major stake retention $S_H\ge E_H$ for a single epoch, which by extension proves retention over many epochs due to additive nature of EMA bonds, so we do not bother with validator EMA bonds in these experiments. + +The honest objective $S_H\le E_H$ at least retains scoring power $S_H$ over all action transitions in the game, otherwise when $E_H\le S_H$ honest emission will erode to 0 over time, despite a starting condition of $0.5\lt S_H$. + +--- + ### Consensus guarantees Yuma Consensus guarantees honest majority stake retention $S_H\le E_H$ even under worst-case adversarial attacks, given sufficiently large honest utility $W_H$. The specific honest stake and utility pairs that delineate the guarantees are complicated by natural variances inside large realistic networks. Therefore, we use extensive random sampling simulations (Monte Carlo studies) of large realistic networks and subject them to varying degrees of adversarial attacks, and calculate comprehensive consensus guarantees under representative conditions. @@ -124,9 +186,9 @@ The x-axis is major self-weight and the y-axis is minor self-weight, and each co Major/honest self-weight $W_H$ is the true honest utility, while minor/cabal self-weight $W_C$ is an arbitrary value a self-serving coalition may self-report.

- - - + + +

To understand how we construct these plots, let us first consider contour plot for a single major/honest stake setting $S_H=0.6$. Here each contour value is the honest emission $E_H$, and we highlight at (1) the specific contour $E_H=0.6$ that matches the honest stake. This means that any weight setting on contour $E_H=S_H=0.6$ will retain honest stake, while any setting to the right of it will grow honest stake. @@ -138,18 +200,20 @@ A compound plot then combines all the highlighted $S_H=E_H$ contours from indivi Retention graphs like these comprehensively capture consensus guarantees across all primary conditions, and we utilize these to analyze the effect of consensus hyperparameters. Subtensor integration tests run Monte Carlo simulations of large realistic networks under adversarial conditions, and constructs retention profiles to confirm consensus guarantees of the actual blockchain implementation. -Retention profiles are reproducible by running [`_map_consensus_guarantees`](../pallets/subtensor/tests/epoch.rs) (decorate with `#[test]`). +Retention profiles are reproducible by running test [`map_consensus_guarantees()`](../pallets/subtensor/src/tests/consensus.rs) and plotting with [`map_consensus.py`](../scripts/map_consensus.py). ```bash -RUST_BACKTRACE=1 SKIP_WASM_BUILD=1 cargo test -- _map_consensus_guarantees --exact --nocapture > consensus.txt +RUST_BACKTRACE=1 SKIP_WASM_BUILD=1 RUSTFLAGS="-C opt-level=3" cargo test --manifest-path=pallets/subtensor/Cargo.toml -- tests::consensus::map_consensus_guarantees --exact --nocapture > consensus.txt + +python scripts/map_consensus.py consensus.txt ``` #### Subjectivity variance Yuma Consensus corrects reward manipulation in subjective utility networks, but the extent of subjectivity influences the exact consensus guarantees. In particular, we expect lower subjectivity to offer improved guarantees since there is stronger consensus. However, for higher variance in assigned weights it is easier to hide reward manipulation, we then expect poorer guarantees.

- - - + + +

We assume normally distributed weights originating from a particular side, either honest or cabal, then we modify the weight deviation magnitude $\sigma(W)$ in terms of the mean weight $\mu(W)$. @@ -167,9 +231,9 @@ Increasing $\kappa$ demands greater honest stake, e.g. when $\kappa=0.6$ there i Hence $\kappa=0.5$ is typically the most sensible setting.

- - - + + +

#### Bonds penalty (β) @@ -179,9 +243,9 @@ Lower-stake validators may experience lower service priority, which can result i Full bonds penalty $\beta=1$ may not be desired, due to the presence of non-adversarial cases like these.

- - - + + +

We expect that greater bonds penalty will penalize out-of-consensus validators more, which means less emission going to cabals. Comprehensive simulation with $\beta = 0$, $0.5$, and $1$ respectively show 78%, 76%, and 73% honest utility requirement. This confirms the expectation, that greater bonds penalty means greater inflation going to the honest majority. @@ -191,10 +255,110 @@ Subnet servers need incentive to deliver high utility, and subnet validators nee We expect that more emission going to validators will improve security guarantees, since self-serving validation can then be economically disincentivized.

- - - + + +

We set validation reward ratio at $\xi=0$, $0.25$, and $0.5$ and respectively observe 82%, 78%, 73% honest utility requirement for 60% honest stake preservation. -This means that network security improves as the validation reward ratio is increased, although a significant server incentive ratio still needs to be maintained to ensure overall high utility. \ No newline at end of file +This means that network security improves as the validation reward ratio is increased, although a significant server incentive ratio still needs to be maintained to ensure overall high utility. + +--- + +### Reproduce Consensus Plots (Runpod) + +This guide demonstrates how to reproduce consensus retention profile plots on a minimal Runpod CPU instance. + +#### 1. Deploy Runpod Instance + +Navigate to https://www.runpod.io/console/deploy and select the following: + +* **Pod Type:** CPU Pod, CPU5 (5.7 GHz • DDR5 RAM • NVMe) or equivalent. +* **Instance Configuration:** Compute-Optimized ($0.07/hr, 2 vCPUs, 4GB RAM). + +**Important:** Edit the template and set "Container Disk (Temporary)" to 20GB. This ensures sufficient disk space for the process. + +Retrieve the connection details, including the SSH command and port, under "Connect" -> "SSH over exposed TCP". You can optionally enable Jupyter access (`8888:localhost:8888`) if desired. Connect to your instance via SSH: + +```bash +ssh -L 8888:localhost:8888 root@ -p -i ~/.ssh/id_ed25519 # Replace placeholders +``` + +#### 2. Set up the Environment + +1. **Start a `tmux` session for persistence:** + + ```bash + tmux + ``` + +2. **Update system packages and install prerequisites (Python, Rust, and dependencies):** + + ```bash + sudo apt-get update && sudo apt install -y build-essential clang curl git make libssl-dev llvm libudev-dev protobuf-compiler python3 python3-pip \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ + && source ~/.cargo/env && rustup default stable && rustup update \ + && rustup target add wasm32-unknown-unknown \ + && rustup toolchain install nightly \ + && rustup target add --toolchain nightly wasm32-unknown-unknown + + ``` + +3. **Clone the Subtensor repository and checkout the relevant branch:** + + ```bash + git clone https://github.com/opentensor/subtensor.git + cd subtensor + git checkout main + + ``` + + +#### 3. Simulate Networks and Generate Data + +The Subtensor integration tests simulate large, realistic networks under adversarial conditions to generate retention profiles that validate the blockchain's consensus guarantees. Building takes about 10 minutes, and the actual test itself another 15 minutes approximately. + + +```bash +RUST_BACKTRACE=1 SKIP_WASM_BUILD=1 RUSTFLAGS="-C opt-level=3" cargo test --manifest-path=pallets/subtensor/Cargo.toml -- tests::consensus::map_consensus_guarantees --exact --nocapture > consensus.txt +``` +This command runs the `map_consensus_guarantees` test and saves the output to `consensus.txt`. Replace `` with a float e.g. 1.0 (100% bonds penalty). + +#### 4. Generate Contour Plots + +1. **Create a Python virtual environment and install necessary libraries:** + + ```bash + python3 -m venv .venv + source .venv/bin/activate + pip install numpy matplotlib jupyterlab + + ``` + +2. **Run the plotting script:** + + ```bash + python3 scripts/map_consensus.py consensus.txt + ``` + This generates an SVG file named `consensus_plot.svg` in the current directory. + + +#### 5. Explore and Modify (Optional) + +You can use Jupyter-lab to interactively explore and modify the generated plots: + +1. **Start Jupyter-lab (on VPS):** + ```bash + jupyter-lab --allow-root --port=8888 + ``` + +2. **Connect to Jupyter:** Open the provided URL (e.g., `http://localhost:8888/tree?token=...`) in your local workstation web browser. + +3. **Modify the plotting script:** Edit `scripts/map_consensus.py` to customize the plots, otherwise download the SVG file. + + +#### Disclaimer + +> This reproduction procedure is provided as a guide and may require adjustments depending on your specific VPS environment and configuration. While every effort has been made to ensure accuracy and completeness, variations in system setup, software versions, or network conditions could affect the results. +> +> Please exercise caution when executing commands with root privileges and ensure you understand the potential implications before proceeding. The author assumes no responsibility for any issues arising from the use of this procedure. If you encounter problems or have suggestions for improvement, please open an issue on this repository. From c5a43688ca0dd61dfe132ddd071e894075f0f7e6 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 5 Feb 2025 14:09:34 +0000 Subject: [PATCH 020/226] fix alpha values --- pallets/subtensor/src/epoch/math.rs | 10 ++ pallets/subtensor/src/epoch/run_epoch.rs | 113 +++++++++++++---------- pallets/subtensor/src/tests/consensus.rs | 41 ++++---- pallets/subtensor/src/tests/epoch.rs | 10 +- 4 files changed, 99 insertions(+), 75 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 5d17ff9e0b..f1a4b33c57 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -55,6 +55,11 @@ pub fn u16_proportion_to_fixed(x: u16) -> I32F32 { I32F32::saturating_from_num(x).safe_div(I32F32::saturating_from_num(u16::MAX)) } +#[allow(dead_code)] +pub fn fixed_proportion_to_fixed(x: I32F32) -> I32F32 { + x.safe_div(I32F32::saturating_from_num(u16::MAX)) +} + #[allow(dead_code)] pub fn fixed_proportion_to_u16(x: I32F32) -> u16 { fixed_to_u16(x.saturating_mul(I32F32::saturating_from_num(u16::MAX))) @@ -80,6 +85,11 @@ pub fn vec_fixed64_to_u64(vec: Vec) -> Vec { vec.into_iter().map(fixed64_to_u64).collect() } +#[allow(dead_code)] +pub fn vec_fixed_proportions_to_fixed(vec: Vec) -> Vec { + vec.into_iter().map(fixed_proportion_to_fixed).collect() +} + #[allow(dead_code)] pub fn vec_u16_proportions_to_fixed(vec: Vec) -> Vec { vec.into_iter().map(u16_proportion_to_fixed).collect() diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 26607422ec..dabec2351a 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -12,7 +12,7 @@ impl Pallet { pub fn epoch_dense(netuid: u16, rao_emission: u64) -> Vec<(T::AccountId, u64, u64)> { // Get subnetwork size. let n: u16 = Self::get_subnetwork_n(netuid); - log::trace!("n:\n{:?}\n", n); + log::trace!("n: {:?}", n); // ====================== // == Active & updated == @@ -20,7 +20,7 @@ impl Pallet { // Get current block. let current_block: u64 = Self::get_current_block_as_u64(); - log::trace!("current_block:\n{:?}\n", current_block); + log::trace!("current_block: {:?}", current_block); // Get tempo. let tempo: u64 = Self::get_tempo(netuid).into(); @@ -28,25 +28,25 @@ impl Pallet { // Get activity cutoff. let activity_cutoff: u64 = Self::get_activity_cutoff(netuid) as u64; - log::trace!("activity_cutoff:\n{:?}\n", activity_cutoff); + log::trace!("activity_cutoff: {:?}", activity_cutoff); // Last update vector. let last_update: Vec = Self::get_last_update(netuid); - log::trace!("Last update:\n{:?}\n", &last_update); + log::trace!("Last update: {:?}", &last_update); // Inactive mask. let inactive: Vec = last_update .iter() .map(|updated| updated.saturating_add(activity_cutoff) < current_block) .collect(); - log::trace!("Inactive:\n{:?}\n", inactive.clone()); + log::trace!("Inactive: {:?}", inactive.clone()); // Logical negation of inactive. let active: Vec = inactive.iter().map(|&b| !b).collect(); // Block at registration vector (block when each neuron was most recently registered). let block_at_registration: Vec = Self::get_block_at_registration(netuid); - log::trace!("Block at registration:\n{:?}\n", &block_at_registration); + log::trace!("Block at registration: {:?}", &block_at_registration); // Outdated matrix, outdated_ij=True if i has last updated (weights) after j has last registered. let outdated: Vec> = last_update @@ -58,7 +58,7 @@ impl Pallet { .collect() }) .collect(); - log::trace!("Outdated:\n{:?}\n", &outdated); + log::trace!("Outdated: {:?}", &outdated); // Recently registered matrix, recently_ij=True if last_tempo was *before* j was last registered. // Mask if: the last tempo block happened *before* the registration block @@ -84,7 +84,7 @@ impl Pallet { Self::get_stake_weights_for_network(netuid); inplace_normalize_64(&mut total_stake); let stake: Vec = vec_fixed64_to_fixed32(total_stake); - log::trace!("S:\n{:?}\n", &stake); + log::trace!("S: {:?}", &stake); // ======================= // == Validator permits == @@ -119,7 +119,7 @@ impl Pallet { // Normalize active stake. inplace_normalize(&mut active_stake); - log::trace!("S:\n{:?}\n", &active_stake); + log::trace!("S: {:?}", &active_stake); // ============= // == Weights == @@ -130,7 +130,7 @@ impl Pallet { // Access network weights row unnormalized. let mut weights: Vec> = Self::get_weights(netuid); - log::trace!("W:\n{:?}\n", &weights); + log::trace!("W: {:?}", &weights); // Mask weights that are not from permitted validators. inplace_mask_rows(&validator_forbids, &mut weights); @@ -144,15 +144,15 @@ impl Pallet { } inplace_mask_diag(&mut weights); - log::trace!("W (permit+diag):\n{:?}\n", &weights); + log::trace!("W (permit+diag): {:?}", &weights); // Mask outdated weights: remove weights referring to deregistered neurons. inplace_mask_matrix(&outdated, &mut weights); - log::trace!("W (permit+diag+outdate):\n{:?}\n", &weights); + log::trace!("W (permit+diag+outdate): {:?}", &weights); // Normalize remaining weights. inplace_row_normalize(&mut weights); - log::trace!("W (mask+norm):\n{:?}\n", &weights); + log::trace!("W (mask+norm): {:?}", &weights); // ================================ // == Consensus, Validator Trust == @@ -183,7 +183,7 @@ impl Pallet { inplace_normalize(&mut ranks); let incentive: Vec = ranks.clone(); - log::trace!("I:\n{:?}\n", &incentive); + log::trace!("I: {:?}", &incentive); // ========================= // == Bonds and Dividends == @@ -199,25 +199,31 @@ impl Pallet { // Access network bonds. let mut bonds: Vec> = Self::get_bonds(netuid); - // Remove bonds referring to neurons that have registered since last tempo. - inplace_mask_cols(&recently_registered, &mut bonds); // mask recently registered bonds - inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 - log::trace!("B:\n{:?}\n", &bonds); + inplace_mask_matrix(&outdated, &mut bonds); // mask outdated bonds + for bonds_row in &mut bonds { + *bonds_row = vec_fixed_proportions_to_fixed(bonds_row.clone()); + } + // inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 + log::trace!("B: {:?}", &bonds); // Get alpha values - let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); + let alphas = Self::compute_liquid_alpha(netuid, consensus.clone()); + log::trace!("alphas: {:?}", &alphas); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = Self::compute_ema_bonds(&weights_for_bonds.clone(), &bonds, alpha); + let ema_bonds = Self::compute_ema_bonds(&weights_for_bonds.clone(), &bonds, alphas); + log::trace!("emaB: {:?}", &ema_bonds); + // Normalize EMA bonds. - inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 - log::trace!("emaB:\n{:?}\n", &ema_bonds); + let mut ema_bonds_norm = ema_bonds.clone(); + inplace_col_normalize(&mut ema_bonds_norm); + log::trace!("emaB norm: {:?}", &ema_bonds_norm); // # === Dividend Calculation=== let total_bonds_per_validator: Vec = matmul_transpose(&ema_bonds, &incentive); let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); inplace_normalize(&mut dividends); - log::trace!("D:\n{:?}\n", ÷nds); + log::trace!("D: {:?}", ÷nds); // ================================= // == Emission and Pruning scores == @@ -342,8 +348,6 @@ impl Pallet { ValidatorTrust::::insert(netuid, cloned_validator_trust); ValidatorPermit::::insert(netuid, new_validator_permits.clone()); - // Column max-upscale EMA bonds for storage: max_i w_ij = 1. - inplace_col_max_upscale(&mut ema_bonds); new_validator_permits .iter() .zip(validator_permits) @@ -477,7 +481,7 @@ impl Pallet { // Normalize active stake. inplace_normalize(&mut active_stake); - log::debug!("Active Stake:\n{:?}\n", &active_stake); + log::trace!("Active Stake: {:?}", &active_stake); // ============= // == Weights == @@ -585,14 +589,14 @@ impl Pallet { log::trace!("B (mask+norm): {:?}", &bonds); // Get alpha values - let alpha = Self::compute_liquid_alpha(netuid, consensus.clone()); + let alphas = Self::compute_liquid_alpha(netuid, consensus.clone()); // Compute the Exponential Moving Average (EMA) of bonds. let mut ema_bonds = Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alpha); // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 - log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); + log::trace!("emaB norm: {:?}", &ema_bonds); // # === Dividend Calculation=== let total_bonds_per_validator: Vec = @@ -1057,34 +1061,43 @@ impl Pallet { .any(|&c| c != I32F32::saturating_from_num(0)) { // Calculate the 75th percentile (high) and 25th percentile (low) of the consensus values. - let consensus_high = quantile(&consensus, 0.75); + let mut consensus_high = quantile(&consensus, 0.75); let consensus_low = quantile(&consensus, 0.25); - // Further check if the high and low consensus values meet the required conditions. - if (consensus_high > consensus_low) || consensus_high != 0 || consensus_low < 0 { - log::trace!("Using Liquid Alpha"); - - // Get the high and low alpha values for the network. - let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); - log::trace!("alpha_low: {:?} alpha_high: {:?}", alpha_low, alpha_high); + if consensus_high == consensus_low { + consensus_high = quantile(&consensus, 0.99); + } + if consensus_high == consensus_low { + consensus_high = I32F32::saturating_from_num(1.0); + } + log::trace!( + "consensus_high: {:?}, consensus_low: {:?}", + consensus_high, + consensus_low + ); - // Calculate the logistic function parameters 'a' and 'b' based on alpha and consensus values. - let (a, b) = Self::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); + // Get the high and low alpha values for the network. + let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); + // log::warn!("alpha_high: {:?}, alpha_low: {:?} ", alpha_high, alpha_low); - // Compute the alpha values using the logistic function parameters. - // alpha = 1 / (1 + math.e ** (-a * C + b)) # alpha to the old weight - let alpha = Self::compute_alpha_values(&consensus, a, b); + // Calculate the logistic function parameters 'a' and 'b' based on alpha and consensus values. + let (a, b) = Self::calculate_logistic_params( + alpha_high, + alpha_low, + consensus_high, + consensus_low, + ); - // Clamp the alpha values between alpha_high and alpha_low. - let clamped_alpha = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); + // Compute the alpha values using the logistic function parameters. + // alpha = 1 / (1 + math.e ** (-a * C + b)) # alpha to the old weight + let alpha = Self::compute_alpha_values(&consensus, a, b); - return clamped_alpha; - } + // return 1 - alpha values clamped between alpha_high and alpha_low. + let clamped_alpha: Vec = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); + return clamped_alpha + .iter() + .map(|a| I32F32::saturating_from_num(1.0).saturating_sub(*a)) + .collect(); } // Liquid Alpha is disabled diff --git a/pallets/subtensor/src/tests/consensus.rs b/pallets/subtensor/src/tests/consensus.rs index e5a7b59b1d..bb8175120b 100644 --- a/pallets/subtensor/src/tests/consensus.rs +++ b/pallets/subtensor/src/tests/consensus.rs @@ -11,8 +11,8 @@ use frame_support::assert_ok; use rand::{distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng, Rng, SeedableRng}; use sp_core::U256; use std::time::Instant; -use substrate_fixed::types::{I32F32, I64F64}; use substrate_fixed::transcendental::{cos, ln, sqrt, PI}; +use substrate_fixed::types::{I32F32, I64F64}; pub fn fixed(val: f32) -> I32F32 { I32F32::from_num(val) @@ -61,7 +61,7 @@ fn non_extreme_fixed_ratio(ratio: I32F32, total: usize) -> usize { } else if subset == total { subset = total - 1; } - return subset; + subset } // Box-Muller Transform converting two uniform random samples to a normal random sample. @@ -71,12 +71,12 @@ fn normal(size: usize, rng: &mut StdRng, dist: &Uniform) -> Vec { let eps: I32F32 = I32F32::from_num(0.000001); let pi: I32F32 = I32F32::from_num(PI); - let uniform_u16: Vec = (0..(2 * size)).map(|_| rng.sample(&dist)).collect(); + let uniform_u16: Vec = (0..(2 * size)).map(|_| rng.sample(dist)).collect(); let uniform: Vec = uniform_u16 .iter() .map(|&x| I32F32::from_num(x) / max) .collect(); - let mut normal: Vec = vec![I32F32::from_num(0); size as usize]; + let mut normal: Vec = vec![I32F32::from_num(0); size]; for i in 0..size { let u1: I32F32 = uniform[i] + eps; @@ -263,7 +263,7 @@ fn init_run_epochs( ); // let bonds = SubtensorModule::get_bonds( netuid ); - // for (uid, node) in vec![ (validators[0], "validator"), (servers[0], "server") ] { + // for (uid, node) in [ (validators[0], "validator"), (servers[0], "server") ] { // log::info!("\n{node}" ); // uid_stats(netuid, uid); // log::info!("bonds: {:?} (on validator), {:?} (on server)", bonds[uid as usize][0], bonds[uid as usize][servers[0] as usize]); @@ -294,7 +294,7 @@ fn split_graph( let major_servers_n: usize = non_extreme_fixed_ratio(major_stake, servers_n); let major_validators_n: usize = non_extreme_fixed_ratio(major_stake, validators_n); - let (validators, servers) = distribute_nodes(validators_n, network_n, interleave as usize); + let (validators, servers) = distribute_nodes(validators_n, network_n, interleave); let major_validators: Vec = (0..major_validators_n).map(|i| validators[i]).collect(); let minor_validators: Vec = (major_validators_n..validators_n) .map(|i| validators[i]) @@ -305,13 +305,13 @@ fn split_graph( let zero: I32F32 = I32F32::from_num(0); let one: I32F32 = I32F32::from_num(1); let stddev: I32F32 = I32F32::from_num(0.3); - let total_stake: I64F64 = I64F64::from_num(21_000_000_000_000_000 as u64); + let total_stake: I64F64 = I64F64::from_num(21_000_000_000_000_000_u64); let mut rng = StdRng::seed_from_u64(0); // constant seed so weights over multiple runs are equal let dist = Uniform::new(0, u16::MAX); let mut stake: Vec = vec![0; network_n]; let mut stake_fixed: Vec = vec![zero; network_n]; - for (ratio, vals) in vec![ + for (ratio, vals) in [ (major_stake, &major_validators), (one - major_stake, &minor_validators), ] { @@ -336,14 +336,14 @@ fn split_graph( } } - let mut weights: Vec> = vec![vec![]; network_n as usize]; + let mut weights: Vec> = vec![vec![]; network_n]; let mut weights_fixed: Vec> = vec![vec![zero; network_n]; network_n]; - for (first, second, vals) in vec![ + for (first, second, vals) in [ (major_weight, one - major_weight, &major_validators), (one - minor_weight, minor_weight, &minor_validators), ] { for &val in vals { - for (weight, srvs) in vec![(first, &major_servers), (second, &minor_servers)] { + for (weight, srvs) in [(first, &major_servers), (second, &minor_servers)] { let mut sample: Vec = normal(srvs.len(), &mut rng, &dist) .iter() .map(|x: &I32F32| { @@ -372,8 +372,8 @@ fn split_graph( let mut weight_mean: Vec = vec![zero; network_n]; for val in 0..network_n { if stake_fixed[val] > zero { - for srv in 0..network_n { - weight_mean[srv] += stake_fixed[val] * weights_fixed[val][srv]; + for (srv, weight_mean_row) in weight_mean.iter_mut().enumerate().take(network_n) { + *weight_mean_row += stake_fixed[val] * weights_fixed[val][srv]; } } } @@ -415,7 +415,7 @@ fn split_graph( // let epochs: u16 = 1; // let interleave = 2; // log::info!("test_consensus_guarantees ({network_n:?}, {validators_n:?} validators)"); -// for (major_stake, major_weight, minor_weight, weight_stddev) in vec![ +// for (major_stake, major_weight, minor_weight, weight_stddev) in [ // (0.51, 1., 1., 0.001), // (0.51, 0.03, 0., 0.001), // (0.51, 0.51, 0.49, 0.001), @@ -471,13 +471,13 @@ fn split_graph( // let mut major_emission: I64F64 = I64F64::from_num(0); // let mut minor_emission: I64F64 = I64F64::from_num(0); -// for set in vec![major_validators, major_servers] { +// for set in [major_validators, major_servers] { // for uid in set { // major_emission += // I64F64::from_num(SubtensorModule::get_emission_for_uid(netuid, uid)); // } // } -// for set in vec![minor_validators, minor_servers] { +// for set in [minor_validators, minor_servers] { // for uid in set { // minor_emission += // I64F64::from_num(SubtensorModule::get_emission_for_uid(netuid, uid)); @@ -499,9 +499,10 @@ fn map_consensus_guarantees() { let epochs: u16 = 1; let interleave = 0; let weight_stddev: I32F32 = fixed(0.4); - let bonds_penalty: u16 = (std::env::args().nth(2).unwrap().parse::().unwrap() * f32::from(u16::MAX - 1)) as u16; + let bonds_penalty: u16 = + (std::env::args().nth(2).unwrap().parse::().unwrap() * f32::from(u16::MAX - 1)) as u16; println!("["); - for _major_stake in vec![0.51, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99] { + for _major_stake in [0.51, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99] { let major_stake: I32F32 = I32F32::from_num(_major_stake); for _major_weight in 0..51 { let major_weight: I32F32 = I32F32::from_num(50 - _major_weight) / I32F32::from_num(50); @@ -533,12 +534,12 @@ fn map_consensus_guarantees() { let mut major_emission: I64F64 = I64F64::from_num(0); let mut minor_emission: I64F64 = I64F64::from_num(0); - for set in vec![major_validators, major_servers] { + for set in [major_validators, major_servers] { for uid in set { major_emission += I64F64::from_num(SubtensorModule::get_emission_for_uid( netuid, uid )); } } - for set in vec![minor_validators, minor_servers] { + for set in [minor_validators, minor_servers] { for uid in set { minor_emission += I64F64::from_num(SubtensorModule::get_emission_for_uid( netuid, uid )); } diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 175b00ab7f..8b547fb2a1 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3331,7 +3331,7 @@ fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); // Enable Liquid Alpha - SubtensorModule::set_kappa(netuid, 0); + SubtensorModule::set_kappa(netuid, u16::MAX / 2); SubtensorModule::set_liquid_alpha_enabled(netuid, true); SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.9), I32F32::from_num(0.99)); @@ -3388,7 +3388,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 0], vec![65535, 0], vec![65535, 0]]; + let target = vec![vec![656, 0], vec![656, 0], vec![656, 0]]; run_epoch_check_bonds(netuid, sparse, target); // Validator A -> Server 1 @@ -3406,7 +3406,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 0], vec![220, 65535], vec![65535, 0]]; + let target = vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]]; run_epoch_check_bonds(netuid, sparse, target); // Validator A -> Server 1 @@ -3424,7 +3424,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 0], vec![1, 65535], vec![329, 64878]]; + let target = vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]]; run_epoch_check_bonds(netuid, sparse, target); // Subsequent epochs All validators -> Server 2 @@ -3437,7 +3437,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 11866], vec![0, 65535], vec![328, 64996]]; + let target = vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]]; run_epoch_check_bonds(netuid, sparse, target); }) } From e95b412afd8fdab1c8386d0ad35694efc9184b5b Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 6 Feb 2025 06:37:40 +0000 Subject: [PATCH 021/226] dividents fix --- pallets/subtensor/src/epoch/math.rs | 11 +++++++++++ pallets/subtensor/src/epoch/run_epoch.rs | 8 ++++---- pallets/subtensor/src/tests/epoch.rs | 16 +++++++++++----- pallets/subtensor/src/tests/math.rs | 20 ++++++++++++++++++++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index f1a4b33c57..7bda9c5fd2 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1226,6 +1226,17 @@ pub fn vec_mul(a: &[I32F32], b: &[I32F32]) -> Vec { .collect() } +// Element-wise product of matrix and vector +pub fn mat_vec_mul(matrix: &[Vec], vector: &[I32F32]) -> Vec> { + let Some(first_row) = matrix.first() else { + return vec![vec![]]; + }; + if first_row.is_empty() { + return vec![vec![]]; + } + matrix.iter().map(|row| vec_mul(row, vector)).collect() +} + // Element-wise product of two matrices. #[allow(dead_code)] pub fn hadamard(mat1: &[Vec], mat2: &[Vec]) -> Vec> { diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index dabec2351a..5fd18bea26 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -220,9 +220,9 @@ impl Pallet { log::trace!("emaB norm: {:?}", &ema_bonds_norm); // # === Dividend Calculation=== - let total_bonds_per_validator: Vec = matmul_transpose(&ema_bonds, &incentive); - let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); - inplace_normalize(&mut dividends); + let total_bonds_per_validator: Vec = + row_sum(&mat_vec_mul(&ema_bonds_norm, &incentive)); + let dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); log::trace!("D: {:?}", ÷nds); // ================================= @@ -593,7 +593,7 @@ impl Pallet { // Compute the Exponential Moving Average (EMA) of bonds. let mut ema_bonds = - Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alpha); + Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alphas); // Normalize EMA bonds. inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 log::trace!("emaB norm: {:?}", &ema_bonds); diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 8b547fb2a1..e3e9b1404d 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3288,7 +3288,7 @@ fn assert_approx_eq_vec_of_vec( } // test Yuma 4 scenarios over a sequence of epochs. -fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) { +fn setup_yuma_4_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stakes: Vec) { let block_number = System::block_number(); let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead add_network(netuid, tempo, 0); @@ -3339,17 +3339,23 @@ fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) // === Issue validator permits SubtensorModule::set_max_allowed_validators(netuid, 3); assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), 3); - SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators - next_block(); // run to next block to ensure weights are set on nodes after their registration block + + // run first epoch to set allowed validators + // run to next block to ensure weights are set on nodes after their registration block + run_epoch(netuid, sparse); } -fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) { +fn run_epoch(netuid: u16, sparse: bool) { next_block(); if sparse { SubtensorModule::epoch(netuid, 1_000_000_000); } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } +} + +fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) { + run_epoch(netuid, sparse); let bonds = SubtensorModule::get_bonds(netuid); // server 1 @@ -3376,7 +3382,7 @@ fn test_yuma_4_kappa_moves_last() { // Validator C: Small lazy validator (0.1) - moves second let stakes: Vec = vec![8, 1, 1, 0, 0]; - setup_yuma_4_scenario(netuid, n, max_stake, stakes); + setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); // Initially, consensus is achieved by all Validators for uid in [0, 1, 2] { diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index 16a73c5e37..1ab40869fe 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -1236,6 +1236,26 @@ fn test_math_vec_mul() { assert_vec_compare(&result, &target, I32F32::from_num(0)); } +#[test] +fn test_math_mat_vec_mul() { + let matrix: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let matrix = vec_to_mat_fixed(&matrix, 4, false); + let vector: Vec = vec_to_fixed(&[1., 2., 3.]); + let target: Vec = vec![1., 4., 9., 4., 10., 18., 7., 16., 27., 10., 22., 36.]; + let target = vec_to_mat_fixed(&target, 4, false); + let result = mat_vec_mul(&matrix, &vector); + assert_mat_compare(&result, &target, I32F32::from_num(0)); + let vector_one: Vec = vec_to_fixed(&[1., 0., 0.]); + let target: Vec = vec![1., 0., 0., 4., 0., 0., 7., 0., 0., 10., 0., 0.]; + let target = vec_to_mat_fixed(&target, 4, false); + let result = mat_vec_mul(&matrix, &vector_one); + assert_mat_compare(&result, &target, I32F32::from_num(0)); + let vector_empty: Vec = vec_to_fixed(&[]); + let result = mat_vec_mul(&matrix, &vector_empty); + let target: Vec> = vec![vec![]; 4]; + assert_mat_compare(&result, &target, I32F32::from_num(0)); +} + #[test] fn test_math_row_hadamard() { let vector: Vec = vec_to_fixed(&[1., 2., 3., 4.]); From 388afa9236605788473d96406641eec4917dd17b Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Fri, 7 Feb 2025 07:44:47 +0000 Subject: [PATCH 022/226] update sparse computations --- pallets/subtensor/src/epoch/math.rs | 53 +++++++++++------------- pallets/subtensor/src/epoch/run_epoch.rs | 32 +++++++++----- pallets/subtensor/src/tests/epoch.rs | 4 +- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 7bda9c5fd2..e825f5af53 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1237,6 +1237,21 @@ pub fn mat_vec_mul(matrix: &[Vec], vector: &[I32F32]) -> Vec matrix.iter().map(|row| vec_mul(row, vector)).collect() } +// Element-wise product of matrix and vector +pub fn mat_vec_mul_sparse( + matrix: &[Vec<(u16, I32F32)>], + vector: &[I32F32], +) -> Vec> { + let rows = matrix.len(); + let mut result: Vec> = vec![vec![]; rows]; + for i in 0..rows { + for (j, value) in matrix[i].iter() { + result[i].push((*j, value.saturating_mul(vector[*j as usize]))); + } + } + result +} + // Element-wise product of two matrices. #[allow(dead_code)] pub fn hadamard(mat1: &[Vec], mat2: &[Vec]) -> Vec> { @@ -1325,57 +1340,39 @@ pub fn mat_ema_alpha_vec_sparse( let mut row: Vec = vec![zero; n]; // Process the new matrix values. - for (j, value) in new_row.iter() { + for (j, new_val) in new_row.iter() { // Retrieve the alpha value for the current column. let alpha_val: I32F32 = alpha.get(*j as usize).copied().unwrap_or(zero); // Compute the EMA component for the new value using saturating multiplication. if let Some(row_val) = row.get_mut(*j as usize) { - *row_val = alpha_val.saturating_mul(*value); + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + *row_val = alpha_val.saturating_mul(*new_val); } - log::trace!( - "new[{}][{}] * alpha[{}] = {} * {} = {}", - i, - j, - j, - value, - alpha_val, - row.get(*j as usize).unwrap_or(&zero) - ); } // Process the old matrix values. - for (j, value) in old_row.iter() { + for (j, old_val) in old_row.iter() { // Retrieve the alpha value for the current column. let alpha_val: I32F32 = alpha.get(*j as usize).copied().unwrap_or(zero); // Calculate the complement of the alpha value using saturating subtraction. let one_minus_alpha: I32F32 = I32F32::saturating_from_num(1.0).saturating_sub(alpha_val); // Compute the EMA component for the old value and add it to the row using saturating operations. - if let Some(row_val) = row.get_mut(*j as usize) { - let decayed_val = one_minus_alpha.saturating_mul(*value); + if let Some(purchase_increment) = row.get_mut(*j as usize) { + // *row_val = row_val.saturating_add(one_minus_alpha.saturating_mul(*value)); + let decayed_val = one_minus_alpha.saturating_mul(*old_val); let remaining_capacity = I32F32::from_num(1.0) .saturating_sub(decayed_val) .max(I32F32::from_num(0.0)); - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap - // Validators allocate their purchase across miners based on weights - let purchase_increment = alpha_val.saturating_mul(*row_val); // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.min(remaining_capacity); + let purchase = purchase_increment.clone().min(remaining_capacity); - *row_val = decayed_val + *purchase_increment = decayed_val .saturating_add(purchase) .min(I32F32::from_num(1.0)); } - log::trace!( - "old[{}][{}] * (1 - alpha[{}]) = {} * {} = {}", - i, - j, - j, - value, - one_minus_alpha, - one_minus_alpha.saturating_mul(*value) - ); } // Collect the non-zero values into the result matrix. diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 5fd18bea26..dceec0c06d 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -584,23 +584,37 @@ impl Pallet { ); log::trace!("B (outdatedmask): {:?}", &bonds); - // Normalize remaining bonds: sum_i b_ij = 1. - inplace_col_normalize_sparse(&mut bonds, n); - log::trace!("B (mask+norm): {:?}", &bonds); + let mut result: Vec> = vec![vec![]; bonds.len()]; + for (i, sparse_row) in bonds.iter().enumerate() { + for (j, value) in sparse_row { + result[i].push((*j, fixed_proportion_to_fixed(*value))); + } + } + let bonds = result; + log::trace!("B: (mask+norm) {:?}", &bonds); // Get alpha values let alphas = Self::compute_liquid_alpha(netuid, consensus.clone()); + log::trace!("alphas: {:?}", &alphas); // Compute the Exponential Moving Average (EMA) of bonds. - let mut ema_bonds = - Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alphas); + log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); + let ema_bonds = Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alphas); + log::trace!("emaB: {:?}", &ema_bonds); + // Normalize EMA bonds. - inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 - log::trace!("emaB norm: {:?}", &ema_bonds); + let mut ema_bonds_norm = ema_bonds.clone(); + inplace_col_normalize_sparse(&mut ema_bonds_norm, n); // sum_i b_ij = 1 + log::trace!("emaB norm: {:?}", &ema_bonds_norm); // # === Dividend Calculation=== let total_bonds_per_validator: Vec = - matmul_transpose_sparse(&ema_bonds, &incentive); + row_sum_sparse(&mat_vec_mul_sparse(&ema_bonds_norm, &incentive)); + log::trace!( + "total_bonds_per_validator: {:?}", + &total_bonds_per_validator + ); + let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); inplace_normalize(&mut dividends); log::trace!("Dividends: {:?}", ÷nds); @@ -734,8 +748,6 @@ impl Pallet { ValidatorTrust::::insert(netuid, cloned_validator_trust); ValidatorPermit::::insert(netuid, new_validator_permits.clone()); - // Column max-upscale EMA bonds for storage: max_i w_ij = 1. - inplace_col_max_upscale_sparse(&mut ema_bonds, n); new_validator_permits .iter() .zip(validator_permits) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index e3e9b1404d..e4fb8f7aa0 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2826,7 +2826,7 @@ fn test_compute_ema_bonds_sparse() { ]; // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); // Assert the results with an epsilon for approximate equality let epsilon = I32F32::from_num(1e-6); @@ -2845,7 +2845,7 @@ fn test_compute_ema_bonds_sparse_empty() { let expected_ema_bonds: Vec> = vec![]; // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&bonds_delta, &bonds, alpha); + let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); // Assert the results assert_eq!( From 8cf307bdcdb956ea38160418e9adc22fbf2a45d6 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Fri, 7 Feb 2025 10:01:20 +0000 Subject: [PATCH 023/226] add yuma4 kappa moves tests --- pallets/subtensor/src/tests/epoch.rs | 372 ++++++++++++++++++++++----- 1 file changed, 310 insertions(+), 62 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index e4fb8f7aa0..7f6e57f941 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3354,7 +3354,7 @@ fn run_epoch(netuid: u16, sparse: bool) { } } -fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) { +fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: &Vec>) { run_epoch(netuid, sparse); let bonds = SubtensorModule::get_bonds(netuid); @@ -3370,80 +3370,328 @@ fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) } #[test] -fn test_yuma_4_kappa_moves_last() { +fn test_yuma_4_kappa_moves_first() { new_test_ext(1).execute_with(|| { - let sparse: bool = false; + let sparse: bool = true; let n: u16 = 5; // 3 validators, 2 servers let netuid: u16 = 1; let max_stake: u64 = 8; - // Validator A: kappa / Big validator (0.8) - moves last - // Validator B: Small eager validator (0.1) - moves first - // Validator C: Small lazy validator (0.1) - moves second + // Validator A: kappa / Big validator (0.8) - moves first + // Validator B: Small eager validator (0.1) - moves second + // Validator C: Small lazy validator (0.1) - moves last let stakes: Vec = vec![8, 1, 1, 0, 0]; setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); - - // Initially, consensus is achieved by all Validators - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![u16::MAX, 0], - 0 - )); + let targets_bonds = vec![ + vec![ + vec![656, 0], + vec![656, 0], + vec![656, 0], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![590, 656], + vec![7144, 0], + vec![7144, 0], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![530, 1305], + vec![6429, 656], + vec![12983, 0], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![476, 1947], + vec![5786, 1305], + vec![11684, 656], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![428, 2583], + vec![5207, 1947], + vec![10515, 1305], + vec![0, 0], + vec![0, 0], + ], + ]; + + for epoch in 0..5 { + match epoch { + 0 => { + // Initially, consensus is achieved by all Validators + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![u16::MAX, 0], + 0 + )); + } + } + 1 => { + // Validator A -> Server 2 + // Validator B -> Server 1 + // Validator C -> Server 1 + for (uid, weights) in [vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + } + 2 => { + // Validator A -> Server 2 + // Validator B -> Server 2 + // Validator C -> Server 1 + for (uid, weights) in [vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + } + 3 => { + // Subsequent epochs All validators -> Server 2 + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![0, u16::MAX], + 0 + )); + } + } + _ => {} + }; + run_epoch_check_bonds(netuid, sparse, &targets_bonds[epoch]); } - let target = vec![vec![656, 0], vec![656, 0], vec![656, 0]]; - run_epoch_check_bonds(netuid, sparse, target); + }) +} - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 1 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } - let target = vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]]; - run_epoch_check_bonds(netuid, sparse, target); +#[test] +fn test_yuma_4_kappa_moves_second() { + new_test_ext(1).execute_with(|| { + let sparse: bool = true; + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 2 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); + // Validator A: kappa / Big validator (0.8) - moves second + // Validator B: Small eager validator (0.1) - moves first + // Validator C: Small lazy validator (0.1) - moves last + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + let targets_bonds = vec![ + vec![ + vec![656, 0], + vec![656, 0], + vec![656, 0], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![1305, 0], + vec![649, 6553], + vec![1305, 0], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![1174, 656], + vec![584, 7143], + vec![7728, 0], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![1056, 1305], + vec![525, 7727], + vec![6955, 656], + vec![0, 0], + vec![0, 0], + ], + vec![ + vec![950, 1947], + vec![472, 8305], + vec![6259, 1305], + vec![0, 0], + vec![0, 0], + ], + ]; + + for epoch in 0..5 { + match epoch { + 0 => { + // Initially, consensus is achieved by all Validators + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![u16::MAX, 0], + 0 + )); + } + } + 1 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 1 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + } + 2 => { + // Validator A -> Server 2 + // Validator B -> Server 2 + // Validator C -> Server 1 + for (uid, weights) in [vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + } + 3 => { + // Subsequent epochs All validators -> Server 2 + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![0, u16::MAX], + 0 + )); + } + } + _ => {} + }; + run_epoch_check_bonds(netuid, sparse, &targets_bonds[epoch]); } - let target = vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]]; - run_epoch_check_bonds(netuid, sparse, target); + }) +} - // Subsequent epochs All validators -> Server 2 - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![0, u16::MAX], - 0 - )); +#[test] +fn test_yuma_4_kappa_moves_last() { + new_test_ext(1).execute_with(|| { + let sparse: bool = true; + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) - moves last + // Validator B: Small eager validator (0.1) - moves first + // Validator C: Small lazy validator (0.1) - moves second + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + let targets_bonds = vec![ + vec![vec![656, 0], vec![656, 0], vec![656, 0]], + vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]], + vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]], + vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]], + vec![vec![1576, 1305], vec![519, 13508], vec![1044, 7727]], + ]; + + for epoch in 0..5 { + match epoch { + 0 => { + // Initially, consensus is achieved by all Validators + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![u16::MAX, 0], + 0 + )); + } + } + 1 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 1 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + } + 2 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 2 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + } + 3 => { + // Subsequent epochs All validators -> Server 2 + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![0, u16::MAX], + 0 + )); + } + } + _ => {} + }; + run_epoch_check_bonds(netuid, sparse, &targets_bonds[epoch]); } - let target = vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]]; - run_epoch_check_bonds(netuid, sparse, target); }) } From d1a9d3335d58a0b67ecb8e34f69d8b91ec12a447 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 11 Feb 2025 12:03:40 +0000 Subject: [PATCH 024/226] tests cleanup --- pallets/subtensor/src/epoch/math.rs | 17 +- pallets/subtensor/src/epoch/run_epoch.rs | 18 +- pallets/subtensor/src/tests/epoch.rs | 956 ++++++++++++----------- pallets/subtensor/src/tests/math.rs | 63 +- 4 files changed, 569 insertions(+), 485 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index e825f5af53..0b5c509512 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1238,15 +1238,20 @@ pub fn mat_vec_mul(matrix: &[Vec], vector: &[I32F32]) -> Vec } // Element-wise product of matrix and vector +#[allow(dead_code, clippy::indexing_slicing)] pub fn mat_vec_mul_sparse( matrix: &[Vec<(u16, I32F32)>], vector: &[I32F32], ) -> Vec> { - let rows = matrix.len(); - let mut result: Vec> = vec![vec![]; rows]; - for i in 0..rows { - for (j, value) in matrix[i].iter() { - result[i].push((*j, value.saturating_mul(vector[*j as usize]))); + let mut result: Vec> = vec![vec![]; matrix.len()]; + for (i, matrix_row) in matrix.iter().enumerate() { + for (j, value) in matrix_row.iter() { + if let Some(vector_value) = vector.get(*j as usize) { + let new_value = value.saturating_mul(*vector_value); + if new_value != I32F32::saturating_from_num(0.0) { + result[i].push((*j, new_value)); + } + } } } result @@ -1367,7 +1372,7 @@ pub fn mat_ema_alpha_vec_sparse( .max(I32F32::from_num(0.0)); // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.clone().min(remaining_capacity); + let purchase = (*purchase_increment).min(remaining_capacity); *purchase_increment = decayed_val .saturating_add(purchase) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index dceec0c06d..5cb399039f 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -222,7 +222,13 @@ impl Pallet { // # === Dividend Calculation=== let total_bonds_per_validator: Vec = row_sum(&mat_vec_mul(&ema_bonds_norm, &incentive)); - let dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); + log::trace!( + "total_bonds_per_validator: {:?}", + &total_bonds_per_validator + ); + + let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); + inplace_normalize(&mut dividends); log::trace!("D: {:?}", ÷nds); // ================================= @@ -550,7 +556,7 @@ impl Pallet { // Compute server trust: ratio of rank after vs. rank before. let trust: Vec = vecdiv(&ranks, &preranks); // range: I32F32(0, 1) - log::trace!("T: {:?}", &trust); + log::trace!("Trust: {:?}", &trust); inplace_normalize(&mut ranks); // range: I32F32(0, 1) let incentive: Vec = ranks.clone(); @@ -570,7 +576,7 @@ impl Pallet { // Access network bonds. let mut bonds: Vec> = Self::get_bonds_sparse(netuid); - log::trace!("B: {:?}", &bonds); + log::trace!("Bonds: {:?}", &bonds); // Remove bonds referring to neurons that have registered since last tempo. // Mask if: the last tempo block happened *before* the registration block @@ -582,7 +588,7 @@ impl Pallet { &block_at_registration, &|last_tempo, registered| last_tempo <= registered, ); - log::trace!("B (outdatedmask): {:?}", &bonds); + log::trace!("Bonds (outdatedmask): {:?}", &bonds); let mut result: Vec> = vec![vec![]; bonds.len()]; for (i, sparse_row) in bonds.iter().enumerate() { @@ -591,11 +597,11 @@ impl Pallet { } } let bonds = result; - log::trace!("B: (mask+norm) {:?}", &bonds); + log::trace!("Bonds: (mask+norm) {:?}", &bonds); // Get alpha values let alphas = Self::compute_liquid_alpha(netuid, consensus.clone()); - log::trace!("alphas: {:?}", &alphas); + log::trace!("Alphas: {:?}", &alphas); // Compute the Exponential Moving Average (EMA) of bonds. log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 7f6e57f941..d2a7645b86 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -5,7 +5,7 @@ )] use super::mock::*; -use crate::epoch::math::safe_exp; +use crate::epoch::math::{fixed, safe_exp, u16_proportion_to_fixed}; use crate::*; use approx::assert_abs_diff_eq; @@ -714,8 +714,7 @@ fn test_512_graph() { assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, uid), 1023); // Note D = floor(1 / 64 * 65_535) = 1023 assert_eq!(SubtensorModule::get_emission_for_uid(netuid, uid), 7812500); // Note E = 0.5 / 200 * 1_000_000_000 = 7_812_500 assert_eq!(bonds[uid as usize][validator], 0.0); - assert_eq!(bonds[uid as usize][server], I32F32::from_num(65_535)); - // Note B_ij = floor(1 / 64 * 65_535) / 65_535 = 1023 / 65_535, then max-upscaled to 65_535 + assert_eq!(bonds[uid as usize][server], I32F32::from_num(38)); } for uid in servers { assert_eq!( @@ -1054,48 +1053,42 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* n: 8 - current_block: 2 - activity_cutoff: 5000 - Last update: [2, 2, 2, 2, 1, 1, 1, 1] + current_block: 2, activity_cutoff: 5000, Last update: [2, 2, 2, 2, 1, 1, 1, 1] Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] W: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + W: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] R (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] T: [0, 0, 0, 0, 1, 1, 1, 1] I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] B: [[], [], [], [], [], [], [], []] B (outdatedmask): [[], [], [], [], [], [], [], []] - B (mask+norm): [[], [], [], [], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] - Dividends: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0499999998, 0.0999999999, 0.15, 0.2, 0, 0, 0, 0] - Validator Emission: [49999999, 99999999, 149999999, 199999999, 0, 0, 0, 0] - Normalized Combined Emission: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Combined Emission: [49999999, 99999999, 149999999, 199999999, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + B: [[], [], [], [], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [], [], [], []] + emaB norm: [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] + total_bonds_per_validator: [0.2499999995, 0.2499999995, 0.2499999995, 0.2499999995, 0, 0, 0, 0] + D: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + nE: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + E: [49999999, 99999999, 149999999, 199999999, 49998779, 100000610, 149996337, 200004272] + P: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 65535); - assert_eq!(bonds[1][4], 65535); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); + assert_eq!(bonds[0][4], 655); + assert_eq!(bonds[1][4], 655); + assert_eq!(bonds[2][4], 655); + assert_eq!(bonds[3][4], 655); // === Set self-weight only on val1 let uid = 0; @@ -1113,49 +1106,41 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* n: 8 - current_block: 2 - activity_cutoff: 5000 - Last update: [2, 2, 2, 2, 1, 1, 1, 1] + current_block: 3, activity_cutoff: 5000, Last update: [2, 2, 2, 2, 1, 1, 1, 1] Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + W: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] T: [0, 0, 0, 0, 1, 1, 1, 1] I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.2491694554), (5, 0.2483443606), (6, 0.2475248124), (7, 0.246710457)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [], [], [], []] - Dividends: [0.0988155114, 0.2002632194, 0.3003948291, 0.4005264398, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0, 0, 0, 0] - Validator Emission: [49407755, 100131609, 150197414, 200263219, 0, 0, 0, 0] - Normalized Combined Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [49407755, 100131609, 150197414, 200263219, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + B: [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] + B (outdatedmask): [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] + B: [[(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0089951933), (5, 0.0179903866), (6, 0.0269993132), (7, 0.0359945067)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [], [], [], []] + emaB norm: [[(4, 0.1363320365), (5, 0.1363301442), (6, 0.136363573), (7, 0.1363528532)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [], [], [], []] + total_bonds_per_validator: [0.136349445, 0.2878835173, 0.2878835173, 0.2878835173, 0, 0, 0, 0] + D: [0.0499942757, 0.211112383, 0.3166685747, 0.422224766, 0, 0, 0, 0] + nE: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [24997137, 105556191, 158334287, 211112383, 49998779, 100000610, 149996337, 200004272] + P: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ - - let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 65245); - assert_eq!(bonds[1][4], 65535); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); + assert_eq!(bonds[0][4], 655); + assert_eq!(bonds[1][4], 655); + assert_eq!(bonds[2][4], 655); + assert_eq!(bonds[3][4], 655); // === Set self-weight only on val2 let uid = 1; @@ -1173,41 +1158,45 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 3 - W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + current_block: 4, activity_cutoff: 5000, Last update: [2, 3, 2, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] T: [0, 0, 0, 0, 1, 1, 1, 1] I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.2491694554), (5, 0.2483443606), (6, 0.2475248124), (7, 0.246710457)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [(4, 0.250276848), (5, 0.2505518796), (6, 0.2508250624), (7, 0.2510965143)], [], [], [], []] - Dividends: [0.0988155114, 0.2002632194, 0.3003948291, 0.4005264398, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0, 0, 0, 0] - Validator Emission: [49407755, 100131609, 150197414, 200263219, 0, 0, 0, 0] - Normalized Combined Emission: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [49407755, 100131609, 150197414, 200263219, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0494077557, 0.1001316097, 0.1501974144, 0.20026322, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + B: [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] + B (outdatedmask): [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] + B: [[(4, 0.008987564), (5, 0.0179751278), (6, 0.0269932097), (7, 0.0359807736)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0080888073), (5, 0.016177615), (6, 0.0242938886), (7, 0.0323826962)], [(4, 0.0170840009), (5, 0.0341817348), (6, 0.051293202), (7, 0.068390936)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [], [], [], []] + emaB norm: [[(4, 0.1019507758), (5, 0.10192353), (6, 0.102001434), (7, 0.101974368)], [(4, 0.2153255814), (5, 0.2153545555), (6, 0.2153619886), (7, 0.215365714)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [], [], [], []] + total_bonds_per_validator: [0.1019699604, 0.215358351, 0.3413358429, 0.3413358429, 0, 0, 0, 0] + D: [0.034896868, 0.1474028623, 0.3504429725, 0.4672572967, 0, 0, 0, 0] + nE: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [17448433, 73701431, 175221486, 233628648, 49998779, 100000610, 149996337, 200004272] + P: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ - let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 64956); - assert_eq!(bonds[1][4], 65245); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); + assert_eq!(bonds[0][4], 530); + assert_eq!(bonds[1][4], 1119); + assert_eq!(bonds[2][4], 1774); + assert_eq!(bonds[3][4], 1774); - // === Set self-weight only on val3 - let uid = 2; + // === Set self-weight only on val2 + let uid = 1; assert_ok!(SubtensorModule::set_weights( RuntimeOrigin::signed(U256::from(uid)), netuid, @@ -1222,37 +1211,42 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 4 + current_block: 5, activity_cutoff: 5000, Last update: [2, 4, 2, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] T: [0, 0, 0, 0, 1, 1, 1, 1] I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 65245), (5, 64957), (6, 64672), (7, 64390)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 65245), (5, 64957), (6, 64672), (7, 64390)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.2491693716), (5, 0.248342649), (6, 0.247522744), (7, 0.246709707)], [(4, 0.250276876), (5, 0.25055245), (6, 0.2508257518), (7, 0.251096764)], [(4, 0.250276876), (5, 0.25055245), (6, 0.2508257518), (7, 0.251096764)], [(4, 0.250276876), (5, 0.25055245), (6, 0.2508257518), (7, 0.251096764)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.248616903), (5, 0.2472437813), (6, 0.2458835603), (7, 0.2445360073)], [(4, 0.249721952), (5, 0.2494438041), (6, 0.2491646945), (7, 0.248884411)], [(4, 0.2508305723), (5, 0.251656207), (6, 0.2524758724), (7, 0.2532897906)], [(4, 0.2508305723), (5, 0.251656207), (6, 0.2524758724), (7, 0.2532897906)], [], [], [], []] - Dividends: [0.097904461, 0.198416279, 0.3015768253, 0.402102434, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0489522305, 0.0992081393, 0.1507884127, 0.201051217, 0, 0, 0, 0] - Validator Emission: [48952230, 99208139, 150788412, 201051217, 0, 0, 0, 0] - Normalized Combined Emission: [0.0489522305, 0.0992081393, 0.1507884127, 0.201051217, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [48952230, 99208139, 150788412, 201051217, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0489522305, 0.0992081393, 0.1507884127, 0.201051217, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + B: [[(4, 530), (5, 1060), (6, 1592), (7, 2122)], [(4, 1119), (5, 2240), (6, 3361), (7, 4481)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [], [], [], []] + B (outdatedmask): [[(4, 530), (5, 1060), (6, 1592), (7, 2122)], [(4, 1119), (5, 2240), (6, 3361), (7, 4481)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [], [], [], []] + B: [[(4, 0.0080872816), (5, 0.0161745632), (6, 0.0242923629), (7, 0.0323796445)], [(4, 0.0170748455), (5, 0.034180209), (6, 0.0512855726), (7, 0.068375677)], [(4, 0.0270695048), (5, 0.0541695277), (6, 0.0812848096), (7, 0.1083848325)], [(4, 0.0270695048), (5, 0.0541695277), (6, 0.0812848096), (7, 0.1083848325)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0072785532), (5, 0.0145571067), (6, 0.0218631264), (7, 0.0291416799)], [(4, 0.0153673608), (5, 0.030762188), (6, 0.0461570153), (7, 0.0615381093)], [(4, 0.03436231), (5, 0.0687526967), (6, 0.1031555962), (7, 0.1375472036)], [(4, 0.03436231), (5, 0.0687526967), (6, 0.1031555962), (7, 0.1375472036)], [], [], [], []] + emaB norm: [[(4, 0.0796597423), (5, 0.079623309), (6, 0.0796960597), (7, 0.0796712292)], [(4, 0.1681872709), (5, 0.168260579), (6, 0.1682528006), (7, 0.1682407067)], [(4, 0.3760764932), (5, 0.3760580558), (6, 0.3760255696), (7, 0.376044032)], [(4, 0.3760764932), (5, 0.3760580558), (6, 0.3760255696), (7, 0.376044032)], [], [], [], []] + total_bonds_per_validator: [0.079667945, 0.1682429651, 0.3760445435, 0.3760445435, 0, 0, 0, 0] + D: [0.0261337839, 0.1103787823, 0.3700660428, 0.493421391, 0, 0, 0, 0] + nE: [0.0130668918, 0.0551893911, 0.1850330213, 0.2467106953, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [13066891, 55189391, 185033021, 246710695, 49998779, 100000610, 149996337, 200004272] + P: [0.0130668918, 0.0551893911, 0.1850330213, 0.2467106953, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 63269); - assert_eq!(bonds[1][7], 64394); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); + assert_eq!(bonds[0][7], 1909); + assert_eq!(bonds[1][7], 4032); + assert_eq!(bonds[2][7], 9014); + assert_eq!(bonds[3][7], 9014); // === Set val3->srv4: 1 assert_ok!(SubtensorModule::set_weights( @@ -1269,37 +1263,42 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 5 - W: [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (mask+norm): [[], [], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.1600034179] - C: [0, 0, 0, 0, 0, 0, 0, 0] - Clipped Weights: [[], [], [], [], [], [], [], []] - Validator Trust: [0, 0, 0, 0, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0] - T: [0, 0, 0, 0, 0, 0, 0, 0] - I (=R): [0, 0, 0, 0, 0, 0, 0, 0] - B: [[(4, 64956), (5, 64385), (6, 63823), (7, 63270)], [(4, 65245), (5, 64958), (6, 64675), (7, 64395)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 64956), (5, 64385), (6, 63823), (7, 63270)], [(4, 65245), (5, 64958), (6, 64675), (7, 64395)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.2486154223), (5, 0.247241881), (6, 0.2458816185), (7, 0.244535915)], [(4, 0.2497215534), (5, 0.249442232), (6, 0.2491639955), (7, 0.2488839931)], [(4, 0.250831512), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [(4, 0.250831512), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.247241881), (6, 0.2458816185), (7, 0.244535915)], [(4, 0.2497215534), (5, 0.249442232), (6, 0.2491639955), (7, 0.248883993)], [(4, 0.2508315118), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [(4, 0.2508315118), (5, 0.2516579432), (6, 0.2524771928), (7, 0.2532900458)], [], [], [], []] - Dividends: [0, 0, 0, 0, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 0] - Normalized Validator Emission: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Validator Emission: [99999999, 199999999, 299999999, 399999999, 0, 0, 0, 0] - Normalized Combined Emission: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Combined Emission: [99999999, 199999999, 299999999, 399999999, 0, 0, 0, 0] - Pruning Scores: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + current_block: 6, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + I (=R): [0, 0, 0, 0, 0, 0, 0, 1] + B: [[(4, 476), (5, 953), (6, 1432), (7, 1909)], [(4, 1007), (5, 2015), (6, 3024), (7, 4032)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [], [], [], []] + B (outdatedmask): [[(4, 476), (5, 953), (6, 1432), (7, 1909)], [(4, 1007), (5, 2015), (6, 3024), (7, 4032)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [], [], [], []] + B: [[(4, 0.0072632944), (5, 0.0145418479), (6, 0.0218509194), (7, 0.0291294728)], [(4, 0.015365835), (5, 0.030746929), (6, 0.0461432822), (7, 0.0615243763)], [(4, 0.0343480583), (5, 0.0687418936), (6, 0.103150988), (7, 0.1375448233)], [(4, 0.0343480583), (5, 0.0687418936), (6, 0.103150988), (7, 0.1375448233)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0065369648), (5, 0.0130876629), (6, 0.0196658273), (7, 0.0262165254)], [(4, 0.0138292515), (5, 0.027672236), (6, 0.041528954), (7, 0.0553719385)], [(4, 0.0309132524), (5, 0.0618677041), (6, 0.092835889), (7, 0.1637911955)], [(4, 0.0309132524), (5, 0.0618677041), (6, 0.092835889), (7, 0.1637911955)], [], [], [], []] + emaB norm: [[(4, 0.0795321616), (5, 0.0795625302), (6, 0.0796617707), (7, 0.0640723184)], [(4, 0.1682539685), (5, 0.168225079), (6, 0.168224299), (7, 0.1353271813)], [(4, 0.3761069346), (5, 0.3761061952), (6, 0.3760569647), (7, 0.40030025)], [(4, 0.3761069346), (5, 0.3761061952), (6, 0.3760569647), (7, 0.40030025)], [], [], [], []] + total_bonds_per_validator: [0.0640723184, 0.1353271813, 0.40030025, 0.40030025, 0, 0, 0, 0] + D: [0.020425828, 0.0862828067, 0.3828391563, 0.5104522086, 0, 0, 0, 0] + nE: [0.0102129139, 0.0431414032, 0.1914195782, 0.2552261043, 0, 0, 0, 0.5] + E: [10212913, 43141403, 191419578, 255226104, 0, 0, 0, 500000000] + P: [0.0102129139, 0.0431414032, 0.1914195782, 0.2552261043, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 62177); - assert_eq!(bonds[1][7], 63283); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); + assert_eq!(bonds[0][7], 1718); + assert_eq!(bonds[1][7], 3628); + assert_eq!(bonds[2][7], 10734); + assert_eq!(bonds[3][7], 10734); next_block(); if sparse { @@ -1308,25 +1307,42 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 6 - B: [[(4, 64956), (5, 64384), (6, 63822), (7, 63269)], [(4, 65245), (5, 64958), (6, 64675), (7, 64394)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 64956), (5, 64384), (6, 63822), (7, 63269)], [(4, 65245), (5, 64958), (6, 64675), (7, 64394)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.2486154223), (5, 0.2472389904), (6, 0.2458787132), (7, 0.2445339402)], [(4, 0.2497215534), (5, 0.24944319), (6, 0.2491649555), (7, 0.248882052)], [(4, 0.250831512), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2532920036)], [(4, 0.250831512), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2532920036)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.2472389904), (6, 0.2458787132), (7, 0.2423794107)], [(4, 0.2497215534), (5, 0.2494431897), (6, 0.2491649555), (7, 0.2466892123)], [(4, 0.2508315118), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2554656884)], [(4, 0.2508315118), (5, 0.2516589097), (6, 0.2524781656), (7, 0.2554656884)], [], [], [], []] - Dividends: [0.0960292057, 0.195473444, 0.3036417211, 0.4048556287, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0.0480146029, 0.0977367219, 0.1518208606, 0.2024278142, 0, 0, 0, 0] - Validator Emission: [48014602, 97736721, 151820860, 202427814, 0, 0, 0, 0] - Normalized Combined Emission: [0.0480146029, 0.0977367219, 0.1518208606, 0.2024278142, 0, 0, 0, 0.5] - Combined Emission: [48014602, 97736721, 151820860, 202427814, 0, 0, 0, 500000000] - Pruning Scores: [0.0480146029, 0.0977367219, 0.1518208606, 0.2024278142, 0, 0, 0, 0.5] + current_block: 7, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + I (=R): [0, 0, 0, 0, 0, 0, 0, 1] + B: [[(4, 428), (5, 857), (6, 1288), (7, 1718)], [(4, 906), (5, 1813), (6, 2721), (7, 3628)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [], [], [], []] + B (outdatedmask): [[(4, 428), (5, 857), (6, 1288), (7, 1718)], [(4, 906), (5, 1813), (6, 2721), (7, 3628)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [], [], [], []] + B: [[(4, 0.0065308614), (5, 0.0130769818), (6, 0.0196536202), (7, 0.0262149996)], [(4, 0.0138246738), (5, 0.0276646067), (6, 0.0415197986), (7, 0.0553597314)], [(4, 0.0308995193), (5, 0.0618600748), (6, 0.0928206302), (7, 0.163790341)], [(4, 0.0308995193), (5, 0.0618600748), (6, 0.0928206302), (7, 0.163790341)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0058777751), (5, 0.0117692836), (6, 0.017688258), (7, 0.0235934996)], [(4, 0.0124422063), (5, 0.0248981458), (6, 0.0373678186), (7, 0.0498237582)], [(4, 0.0278095673), (5, 0.0556740672), (6, 0.083538567), (7, 0.1874121614)], [(4, 0.0278095673), (5, 0.0556740672), (6, 0.083538567), (7, 0.1874121614)], [], [], [], []] + emaB norm: [[(4, 0.0794947986), (5, 0.0795138243), (6, 0.0796290569), (7, 0.052635678)], [(4, 0.168276373), (5, 0.1682130254), (6, 0.1682225657), (7, 0.111153807)], [(4, 0.376114414), (5, 0.376136575), (6, 0.3760741884), (7, 0.4181052572)], [(4, 0.376114414), (5, 0.376136575), (6, 0.3760741884), (7, 0.4181052572)], [], [], [], []] + total_bonds_per_validator: [0.052635678, 0.111153807, 0.4181052572, 0.4181052572, 0, 0, 0, 0] + D: [0.0164400174, 0.069434674, 0.391767989, 0.5223573192, 0, 0, 0, 0] + nE: [0.0082200086, 0.034717337, 0.1958839945, 0.2611786595, 0, 0, 0, 0.5] + E: [8220008, 34717336, 195883994, 261178659, 0, 0, 0, 500000000] + P: [0.0082200086, 0.034717337, 0.1958839945, 0.2611786595, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 61113); - assert_eq!(bonds[1][7], 62200); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); + assert_eq!(bonds[0][7], 1546); + assert_eq!(bonds[1][7], 3265); + assert_eq!(bonds[2][7], 12282); + assert_eq!(bonds[3][7], 12282); next_block(); if sparse { @@ -1335,25 +1351,42 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 7 - B: [[(4, 64956), (5, 64383), (6, 63821), (7, 62177)], [(4, 65245), (5, 64957), (6, 64674), (7, 63283)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 64956), (5, 64383), (6, 63821), (7, 62177)], [(4, 65245), (5, 64957), (6, 64674), (7, 63283)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.2486154223), (5, 0.247237049), (6, 0.2458767553), (7, 0.2423771098)], [(4, 0.2497215534), (5, 0.2494412656), (6, 0.2491630227), (7, 0.2466884963)], [(4, 0.250831512), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2554671967)], [(4, 0.250831512), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2554671967)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.2472370488), (6, 0.2458767553), (7, 0.2402415834)], [(4, 0.2497215534), (5, 0.2494412656), (6, 0.2491630227), (7, 0.2445149834)], [(4, 0.2508315118), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2576217165)], [(4, 0.2508315118), (5, 0.2516608424), (6, 0.2524801109), (7, 0.2576217165)], [], [], [], []] - Dividends: [0.0948587805, 0.1930922437, 0.3051638464, 0.4068851292, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0.0474293903, 0.0965461219, 0.1525819232, 0.2034425645, 0, 0, 0, 0] - Validator Emission: [47429390, 96546121, 152581923, 203442564, 0, 0, 0, 0] - Normalized Combined Emission: [0.0474293903, 0.0965461219, 0.1525819232, 0.2034425645, 0, 0, 0, 0.5] - Combined Emission: [47429390, 96546121, 152581923, 203442564, 0, 0, 0, 500000000] - Pruning Scores: [0.0474293903, 0.0965461219, 0.1525819232, 0.2034425645, 0, 0, 0, 0.5] + current_block: 8, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + I (=R): [0, 0, 0, 0, 0, 0, 0, 1] + B: [[(4, 385), (5, 771), (6, 1159), (7, 1546)], [(4, 815), (5, 1631), (6, 2448), (7, 3265)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [], [], [], []] + B (outdatedmask): [[(4, 385), (5, 771), (6, 1159), (7, 1546)], [(4, 815), (5, 1631), (6, 2448), (7, 3265)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [], [], [], []] + B: [[(4, 0.0058747234), (5, 0.0117647059), (6, 0.0176852064), (7, 0.0235904478)], [(4, 0.0124361028), (5, 0.0248874647), (6, 0.0373540856), (7, 0.0498207065)], [(4, 0.027801938), (5, 0.0556649119), (6, 0.0835278858), (7, 0.187411307)], [(4, 0.027801938), (5, 0.0556649119), (6, 0.0835278858), (7, 0.187411307)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.005287251), (5, 0.0105882352), (6, 0.0159166856), (7, 0.0212314029)], [(4, 0.0111924924), (5, 0.0223987182), (6, 0.033618677), (7, 0.0448386357)], [(4, 0.025021744), (5, 0.0500984206), (6, 0.0751750972), (7, 0.2086710306)], [(4, 0.025021744), (5, 0.0500984206), (6, 0.0751750972), (7, 0.2086710306)], [], [], [], []] + emaB norm: [[(4, 0.0794797675), (5, 0.0795009276), (6, 0.0796289926), (7, 0.043919883)], [(4, 0.16824938), (5, 0.1681790059), (6, 0.1681896253), (7, 0.0927544753)], [(4, 0.3761354259), (5, 0.376160033), (6, 0.3760906907), (7, 0.4316628207)], [(4, 0.3761354259), (5, 0.376160033), (6, 0.3760906907), (7, 0.4316628207)], [], [], [], []] + total_bonds_per_validator: [0.043919883, 0.0927544753, 0.4316628207, 0.4316628207, 0, 0, 0, 0] + D: [0.0135093683, 0.0570609153, 0.398327021, 0.531102695, 0, 0, 0, 0] + nE: [0.006754684, 0.0285304575, 0.1991635105, 0.2655513475, 0, 0, 0, 0.5] + E: [6754684, 28530457, 199163510, 265551347, 0, 0, 0, 500000000] + P: [0.006754684, 0.0285304575, 0.1991635105, 0.2655513475, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 60076); - assert_eq!(bonds[1][7], 61145); - assert_eq!(bonds[2][7], 65535); - assert_eq!(bonds[3][7], 65535); + assert_eq!(bonds[0][7], 1391); + assert_eq!(bonds[1][7], 2938); + assert_eq!(bonds[2][7], 13675); + assert_eq!(bonds[3][7], 13675); next_block(); if sparse { @@ -1362,19 +1395,36 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* current_block: 8 - B: [[(4, 64956), (5, 64382), (6, 63821), (7, 61113)], [(4, 65245), (5, 64956), (6, 64674), (7, 62200)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 64956), (5, 64382), (6, 63821), (7, 61113)], [(4, 65245), (5, 64956), (6, 64674), (7, 62200)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.2486154223), (5, 0.247235108), (6, 0.2458767553), (7, 0.2402401103)], [(4, 0.2497215534), (5, 0.2494393412), (6, 0.2491630227), (7, 0.2445131945)], [(4, 0.250831512), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2576233475)], [(4, 0.250831512), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2576233475)], [], [], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - Exponential Moving Average Bonds: [[(4, 0.2486154223), (5, 0.247235108), (6, 0.2458767553), (7, 0.2381234125)], [(4, 0.2497215534), (5, 0.2494393412), (6, 0.2491630227), (7, 0.2423588475)], [(4, 0.2508315118), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2597588697)], [(4, 0.2508315118), (5, 0.2516627752), (6, 0.2524801109), (7, 0.2597588697)], [], [], [], []] - Dividends: [0.0937068302, 0.1907471363, 0.3066625856, 0.4088834478, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0.046853415, 0.0953735681, 0.1533312928, 0.2044417239, 0, 0, 0, 0] - Validator Emission: [46853414, 95373568, 153331292, 204441723, 0, 0, 0, 0] - Normalized Combined Emission: [0.046853415, 0.0953735681, 0.1533312928, 0.2044417239, 0, 0, 0, 0.5] - Combined Emission: [46853414, 95373568, 153331292, 204441723, 0, 0, 0, 500000000] - Pruning Scores: [0.046853415, 0.0953735681, 0.1533312928, 0.2044417239, 0, 0, 0, 0.5] + current_block: 9, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + I (=R): [0, 0, 0, 0, 0, 0, 0, 1] + B: [[(4, 346), (5, 693), (6, 1043), (7, 1391)], [(4, 733), (5, 1467), (6, 2203), (7, 2938)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [], [], [], []] + B (outdatedmask): [[(4, 346), (5, 693), (6, 1043), (7, 1391)], [(4, 733), (5, 1467), (6, 2203), (7, 2938)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [], [], [], []] + B: [[(4, 0.0052796216), (5, 0.0105745022), (6, 0.0159151598), (7, 0.0212252995)], [(4, 0.011184863), (5, 0.0223849851), (6, 0.0336156252), (7, 0.0448310063)], [(4, 0.0250095369), (5, 0.0500953689), (6, 0.0751659418), (7, 0.2086671244)], [(4, 0.0250095369), (5, 0.0500953689), (6, 0.0751659418), (7, 0.2086671244)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0047516592), (5, 0.0095170517), (6, 0.0143236436), (7, 0.0191027694)], [(4, 0.0100663765), (5, 0.0201464866), (6, 0.0302540625), (7, 0.0403479056)], [(4, 0.022508583), (5, 0.0450858318), (6, 0.0676493475), (7, 0.2278012664)], [(4, 0.022508583), (5, 0.0450858318), (6, 0.0676493475), (7, 0.2278012664)], [], [], [], []] + emaB norm: [[(4, 0.0794124375), (5, 0.0794178303), (6, 0.079630477), (7, 0.037088924)], [(4, 0.1682350226), (5, 0.1681182678), (6, 0.168193617), (7, 0.0783373541)], [(4, 0.3761762697), (5, 0.3762319507), (6, 0.3760879529), (7, 0.4422868607)], [(4, 0.3761762697), (5, 0.3762319507), (6, 0.3760879529), (7, 0.4422868607)], [], [], [], []] + total_bonds_per_validator: [0.037088924, 0.0783373541, 0.4422868607, 0.4422868607, 0, 0, 0, 0] + D: [0.011274011, 0.0476247966, 0.403329082, 0.5377721095, 0, 0, 0, 0] + nE: [0.0056370054, 0.0238123983, 0.201664541, 0.2688860546, 0, 0, 0, 0.5] + E: [5637005, 23812398, 201664540, 268886054, 0, 0, 0, 500000000] + P: [0.0056370054, 0.0238123983, 0.201664541, 0.2688860546, 0, 0, 0, 0.5] */ }); } @@ -1455,40 +1505,35 @@ fn test_bonds_with_liquid_alpha() { /* n: 8 current_block: 3 activity_cutoff: 5000 - Last update: [2, 2, 2, 2, 1, 1, 1, 1] Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 64 + max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, - Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 327 - Weights (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), - Weights (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + W: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] T: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] - alpha values: [0.7000076314, 0.7000076314, 0.7000076314, 0.7000076314, 0.8095842435, 0.8856769793, 0.9000076293, 0.9000076293] - Exponential Moving Average Bonds: [[(4, 0.1229952155), (5, 0.0488576517), (6, 0.0301549898), (7, 0.0233184719)], [(4, 0.292334928), (5, 0.3170474493), (6, 0.32328167), (7, 0.3255605092)], [(4, 0.292334928), (5, 0.3170474493), (6, 0.32328167), (7, 0.3255605092)], [(4, 0.292334928), (5, 0.3170474493), (6, 0.32328167), (7, 0.3255605092)], [], [], [], []] - Dividends: [0.0138551355, 0.2191433029, 0.3287149547, 0.4382866067, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0069275678, 0.1095716513, 0.1643574773, 0.2191433033, 0, 0, 0, 0] - Validator Emission: [6927567, 109571651, 164357477, 219143303, 0, 0, 0, 0] - Normalized Combined Emission: [0.0069275678, 0.1095716513, 0.1643574773, 0.2191433033, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [6927567, 109571651, 164357477, 219143303, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0069275678, 0.1095716513, 0.1643574773, 0.2191433033, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] + B (outdatedmask): [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] + B: [[(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0089951933), (5, 0.0179903866), (6, 0.0269993132), (7, 0.0359945067)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [], [], [], []] + emaB norm: [[(4, 0.1363320365), (5, 0.1363301442), (6, 0.136363573), (7, 0.1363528532)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [], [], [], []] + total_bonds_per_validator: [0.136349445, 0.2878835173, 0.2878835173, 0.2878835173, 0, 0, 0, 0] + D: [0.0499942757, 0.211112383, 0.3166685747, 0.422224766, 0, 0, 0, 0] + nE: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [24997137, 105556191, 158334287, 211112383, 49998779, 100000610, 149996337, 200004272] + P: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ // Expected bonds calculations @@ -1499,10 +1544,10 @@ fn test_bonds_with_liquid_alpha() { // Normalize ΔB: [0.25/7.5, 1.0/7.5, 2.25/7.5, 4.0/7.5] = [0.0333, 0.1333, 0.3, 0.5333] // Final bonds for netuid: [16383, 32767, 49151, 65535] - assert_eq!(bonds[0][4], 65535); // Note: Calculated as explained above - assert_eq!(bonds[1][4], 65535); // Note: Calculated as explained above - assert_eq!(bonds[2][4], 65535); // Note: Calculated as explained above - assert_eq!(bonds[3][4], 65535); // Note: Calculated as explained above + assert_eq!(bonds[0][4], 1247); // Note: Calculated as explained above + assert_eq!(bonds[1][4], 1247); // Note: Calculated as explained above + assert_eq!(bonds[2][4], 1247); // Note: Calculated as explained above + assert_eq!(bonds[3][4], 1247); // Note: Calculated as explained above // === Set self-weight only on val1 let uid = 0; @@ -1521,10 +1566,10 @@ fn test_bonds_with_liquid_alpha() { } let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 27572); - assert_eq!(bonds[1][4], 65535); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); + assert_eq!(bonds[0][4], 1009); + assert_eq!(bonds[1][4], 2257); + assert_eq!(bonds[2][4], 2257); + assert_eq!(bonds[3][4], 2257); // === Set self-weight only on val2 let uid = 1; @@ -1550,42 +1595,38 @@ fn test_bonds_with_liquid_alpha() { Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - Normalised Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 64 + max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - R (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] T: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 27572), (5, 10099), (6, 6112), (7, 4693)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (outdatedmask): [[(4, 27572), (5, 10099), (6, 6112), (7, 4693)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] - B (mask+norm): [[(4, 0.1229921), (5, 0.048857303), (6, 0.0301504065), (7, 0.023313694)], [(4, 0.2923359666), (5, 0.3170475655), (6, 0.3232831976), (7, 0.3255621018)], [(4, 0.2923359666), (5, 0.3170475655), (6, 0.3232831976), (7, 0.3255621018)], [(4, 0.2923359666), (5, 0.3170475655), (6, 0.3232831976), (7, 0.3255621018)], [], [], [], []] - alpha values: [0.7000076314, 0.7000076314, 0.7000076314, 0.7000076314, 0.8095842435, 0.8856769793, 0.9000076293, 0.9000076293] - Exponential Moving Average Bonds: [[(4, 0.0728453742), (5, 0.0130473885), (6, 0.0051448268), (7, 0.0031164943)], [(4, 0.1731438267), (5, 0.0846678526), (6, 0.0551646315), (7, 0.0435200238)], [(4, 0.3770053994), (5, 0.4511423793), (6, 0.4698452707), (7, 0.4766817407)], [(4, 0.3770053994), (5, 0.4511423793), (6, 0.4698452707), (7, 0.4766817407)], [], [], [], []] - Dividends: [0.0037682566, 0.0405260534, 0.4095881525, 0.546117537, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0018841282, 0.0202630267, 0.2047940763, 0.2730587684, 0, 0, 0, 0] - Validator Emission: [1884128, 20263026, 204794076, 273058768, 0, 0, 0, 0] - Normalized Combined Emission: [0.0018841282, 0.0202630267, 0.2047940763, 0.2730587684, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [1884128, 20263026, 204794076, 273058768, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0018841282, 0.0202630267, 0.2047940763, 0.2730587684, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] + B (outdatedmask): [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] + B: [[(4, 0.008987564), (5, 0.0179751278), (6, 0.0269932097), (7, 0.0359807736)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [], [], [], []] + alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] + emaB: [[(4, 0.0080888073), (5, 0.016177615), (6, 0.0242938886), (7, 0.0323826962)], [(4, 0.0170840009), (5, 0.0341817348), (6, 0.051293202), (7, 0.068390936)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [], [], [], []] + emaB norm: [[(4, 0.1019507758), (5, 0.10192353), (6, 0.102001434), (7, 0.101974368)], [(4, 0.2153255814), (5, 0.2153545555), (6, 0.2153619886), (7, 0.215365714)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [], [], [], []] + total_bonds_per_validator: [0.1019699604, 0.215358351, 0.3413358429, 0.3413358429, 0, 0, 0, 0] + D: [0.034896868, 0.1474028623, 0.3504429725, 0.4672572967, 0, 0, 0, 0] + nE: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [17448433, 73701431, 175221486, 233628648, 49998779, 100000610, 149996337, 200004272] + P: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ - assert_eq!(bonds[0][4], 12662); - assert_eq!(bonds[1][4], 30097); - assert_eq!(bonds[2][4], 65535); - assert_eq!(bonds[3][4], 65535); + assert_eq!(bonds[0][4], 816); + assert_eq!(bonds[1][4], 1827); + assert_eq!(bonds[2][4], 3075); + assert_eq!(bonds[3][4], 3075); }); } @@ -1717,7 +1758,7 @@ fn test_active_stake() { assert_eq!(*i, 0); } for i in bond.iter().take(n as usize).skip((n / 2) as usize) { - assert_eq!(*i, I32F32::from_num(65_535)); // floor(0.5*(2^16-1))/(2^16-1), then max-upscale to 65_535 + assert_eq!(*i, I32F32::from_num(3276)); // floor(0.5*(2^16-1))/(2^16-1), then max-upscale to 65_535 } } let activity_cutoff: u64 = SubtensorModule::get_activity_cutoff(netuid) as u64; @@ -1739,26 +1780,28 @@ fn test_active_stake() { /* current_block: 5002; activity_cutoff: 5000 Last update: [5002, 1, 0, 0]; Inactive: [false, true, true, true]; Block at registration: [0, 0, 0, 0] Normalised Stake: [0.25, 0.25, 0.25, 0.25] - validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] + validator_permits: [true, true, true, true] Active Stake: [1, 0, 0, 0] - W: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - R (before): [0, 0, 0.5, 0.5] - C: [0, 0, 0.5, 0.5] - Clipped W: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Ranks (before): [0, 0, 0.5, 0.5] + Consensus: [0, 0, 0.5, 0.5] + Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] Validator Trust: [1, 1, 0, 0] - R (after): [0, 0, 0.5, 0.5] - T: [0, 0, 1, 1] - I (=Rank): [0, 0, 0.5, 0.5] - B: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - B (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1] - emaB: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - D: [1, 0, 0, 0] + Ranks (after): [0, 0, 0.5, 0.5] + Trust: [0, 0, 1, 1] + Incentive (=Rank): [0, 0, 0.5, 0.5] + Bonds: [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] + Bonds (outdatedmask): [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] + Bonds: (mask+norm) [[(2, 0.0499885557), (3, 0.0499885557)], [(2, 0.0499885557), (3, 0.0499885557)], [], []] + Alphas: [0.1, 0.1, 0.1, 0.1] + weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + emaB: [[(2, 0.0949897), (3, 0.0949897)], [(2, 0.0949897), (3, 0.0949897)], [], []] + total_bonds_per_validator: [0.5, 0.5, 0, 0] + Dividends: [1, 0, 0, 0] Normalized Server Emission: [0, 0, 0.25, 0.25] Server Emission: [0, 0, 250000000, 250000000] Normalized Validator Emission: [0.5, 0, 0, 0] @@ -1768,16 +1811,16 @@ fn test_active_stake() { Pruning Scores: [0.5, 0, 0.25, 0.25] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 65535); // Note D = floor((0.5 * 0.9 + 0.1) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 500000000); // Note E = 0.5 * 0.55 * 1_000_000_000 = 275_000_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 65535); + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 500000000); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[0][server], I32F32::from_num(65_535)); // floor(0.55*(2^16-1))/(2^16-1), then max-upscale + assert_eq!(bonds[0][server], I32F32::from_num(6225)); } for validator in 1..(n / 2) { - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, validator), 0); // Note D = floor((0.5 * 0.9) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, validator), 0); // Note E = 0.5 * 0.45 * 1_000_000_000 = 225_000_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, validator), 0); + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, validator), 0); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[validator as usize][server], I32F32::from_num(65535)); + assert_eq!(bonds[validator as usize][server], I32F32::from_num(6225)); // floor(0.45*(2^16-1))/(2^16-1), then max-upscale } } @@ -1801,30 +1844,29 @@ fn test_active_stake() { Inactive: [false, false, true, true] Block at registration: [0, 0, 0, 0] hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3)] - ls: tao_weight: 0 Normalised Stake: [0.25, 0.25, 0.25, 0.25] validator_permits: [true, true, true, true] - max_allowed_validators: 4 - new_validator_permits: [true, true, true, true] Active Stake: [0.5, 0.5, 0, 0] - W: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - R (before): [0, 0, 0.5, 0.5] - C: [0, 0, 0.5, 0.5] - Clipped W: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Ranks (before): [0, 0, 0.5, 0.5] + Consensus: [0, 0, 0.5, 0.5] + Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] Validator Trust: [1, 1, 0, 0] - R (after): [0, 0, 0.5, 0.5] - T: [0, 0, 1, 1] - I (=Rank): [0, 0, 0.5, 0.5] - B: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - B (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - alpha values: [0.1, 0.1, 0.1, 0.1] - EmaB: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - D: [0.5, 0.5, 0, 0] + Ranks (after): [0, 0, 0.5, 0.5] + Trust: [0, 0, 1, 1] + Incentive (=Rank): [0, 0, 0.5, 0.5] + Bonds: [[(2, 6225), (3, 6225)], [(2, 6225), (3, 6225)], [], []] + Bonds (outdatedmask): [[(2, 6225), (3, 6225)], [(2, 6225), (3, 6225)], [], []] + Bonds: (mask+norm) [[(2, 0.0949874113), (3, 0.0949874113)], [(2, 0.0949874113), (3, 0.0949874113)], [], []] + Alphas: [0.1, 0.1, 0.1, 0.1] + weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + emaB: [[(2, 0.13548867), (3, 0.13548867)], [(2, 0.13548867), (3, 0.13548867)], [], []] + total_bonds_per_validator: [0.5, 0.5, 0, 0] + Dividends: [0.5, 0.5, 0, 0] Normalized Server Emission: [0, 0, 0.25, 0.25] Server Emission: [0, 0, 250000000, 250000000] Normalized Validator Emission: [0.25, 0.25, 0, 0] @@ -1834,15 +1876,15 @@ fn test_active_stake() { Pruning Scores: [0.25, 0.25, 0.25, 0.25] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); // Note D = floor((0.55 * 0.9 + 0.5 * 0.1) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); // Note E = 0.5 * (0.55 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 272_500_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[0][server], I32F32::from_num(65_535)); // floor((0.55 * 0.9 + 0.5 * 0.1)*(2^16-1))/(2^16-1), then max-upscale + assert_eq!(bonds[0][server], I32F32::from_num(8879)); } - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 32767); // Note D = floor((0.45 * 0.9 + 0.5 * 0.1) * 65_535) - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 250000000); // Note E = 0.5 * (0.45 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 227_500_000 (discrepancy) + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 32767); + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 250000000); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[1][server], I32F32::from_num(65_535)); // floor((0.45 * 0.9 + 0.5 * 0.1)/(0.55 * 0.9 + 0.5 * 0.1)*(2^16-1)) + assert_eq!(bonds[1][server], I32F32::from_num(8879)); } }); } @@ -2029,8 +2071,8 @@ fn test_outdated_weights() { let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); // Note D = floor(0.5 * 65_535) assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); // Note E = 0.5 * 0.5 * 1_000_000_000 = 249311245 - assert_eq!(bonds[0][2], I32F32::from_num(65_535)); // floor(0.5*(2^16-1))/(2^16-1), then max-upscale - assert_eq!(bonds[0][3], I32F32::from_num(65_535)); // only uid0 has updated weights for new reg + assert_eq!(bonds[0][2], I32F32::from_num(8300)); + assert_eq!(bonds[0][3], I32F32::from_num(1965)); }); } @@ -2814,15 +2856,21 @@ fn test_compute_ema_bonds_sparse() { ]; let alpha = vec![I32F32::from_num(0.9), I32F32::from_num(0.8)]; + // Expected values + // EMA calculation for each bond: + // EMA = alpha * bond_delta + (1 - alpha) * bond + // For bond (0, 0): + // EMA = 0.9 * 0.1 + (1 - 0.9) * 0.5 = 0.09 + 0.05 = 0.14 + // For bond (0, 1): + // EMA = 0.8 * 0.2 + (1 - 0.8) * 0.6 = 0.16 + 0.12 = 0.28 + // For bond (1, 0): + // EMA = 0.9 * 0.3 + (1 - 0.9) * 0.7 = 0.27 + 0.07 = 0.34 + // For bond (1, 1): + // EMA = 0.8 * 0.4 + (1 - 0.8) * 0.8 = 0.32 + 0.16 = 0.48 + let expected_ema_bonds = vec![ - vec![ - (0, I32F32::from_num(0.130999)), - (1, I32F32::from_num(0.247999)), - ], - vec![ - (0, I32F32::from_num(0.312999)), - (1, I32F32::from_num(0.415999)), - ], + vec![(0, I32F32::from_num(0.14)), (1, I32F32::from_num(0.28))], + vec![(0, I32F32::from_num(0.34)), (1, I32F32::from_num(0.48))], ]; // Call the function @@ -3354,25 +3402,53 @@ fn run_epoch(netuid: u16, sparse: bool) { } } -fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: &Vec>) { +fn run_epoch_and_check_bonds_dividends( + netuid: u16, + sparse: bool, + target_bonds: &[Vec], + target_dividends: &[f32], +) { run_epoch(netuid, sparse); let bonds = SubtensorModule::get_bonds(netuid); + let dividends = SubtensorModule::get_dividends(netuid); + // Check the bonds // server 1 assert_eq!(bonds[0][3], target_bonds[0][0]); assert_eq!(bonds[1][3], target_bonds[1][0]); assert_eq!(bonds[2][3], target_bonds[2][0]); - // server 2 assert_eq!(bonds[0][4], target_bonds[0][1]); assert_eq!(bonds[1][4], target_bonds[1][1]); assert_eq!(bonds[2][4], target_bonds[2][1]); + + // Check the dividends + let epsilon = I32F32::from_num(1e-3); + for (dividend, target_dividend) in dividends.iter().zip(target_dividends.iter()) { + assert_approx_eq( + u16_proportion_to_fixed(*dividend), + fixed(*target_dividend), + epsilon, + ); + } +} + +fn set_yuma_4_weights(netuid: u16, weights: Vec>) { + for (uid, weight) in weights.iter().enumerate() { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid as u64)), + netuid, + vec![3, 4], + weight.to_vec(), + 0 + )); + } } #[test] fn test_yuma_4_kappa_moves_first() { new_test_ext(1).execute_with(|| { - let sparse: bool = true; + let sparse: bool = false; let n: u16 = 5; // 3 validators, 2 servers let netuid: u16 = 1; let max_stake: u64 = 8; @@ -3383,7 +3459,7 @@ fn test_yuma_4_kappa_moves_first() { let stakes: Vec = vec![8, 1, 1, 0, 0]; setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); - let targets_bonds = vec![ + let targets_bonds = [ vec![ vec![656, 0], vec![656, 0], @@ -3421,69 +3497,50 @@ fn test_yuma_4_kappa_moves_first() { ], ]; - for epoch in 0..5 { + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], + vec![1.0000, 0.0000, 0.0000, 0.0000, 0.0000], + vec![0.9409, 0.0591, 0.0000, 0.0000, 0.0000], + vec![0.8882, 0.0744, 0.0374, 0.0000, 0.0000], + vec![0.8640, 0.0814, 0.0545, 0.0000, 0.0000], + vec![0.8502, 0.0854, 0.0644, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { match epoch { 0 => { // Initially, consensus is achieved by all Validators - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![u16::MAX, 0], - 0 - )); - } + set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { // Validator A -> Server 2 // Validator B -> Server 1 // Validator C -> Server 1 - for (uid, weights) in [vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } + set_yuma_4_weights( + netuid, + vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], + ); } 2 => { // Validator A -> Server 2 // Validator B -> Server 2 // Validator C -> Server 1 - for (uid, weights) in [vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } + set_yuma_4_weights( + netuid, + vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], + ); } 3 => { // Subsequent epochs All validators -> Server 2 - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![0, u16::MAX], - 0 - )); - } + set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); } _ => {} }; - run_epoch_check_bonds(netuid, sparse, &targets_bonds[epoch]); + run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); } }) } @@ -3502,7 +3559,7 @@ fn test_yuma_4_kappa_moves_second() { let stakes: Vec = vec![8, 1, 1, 0, 0]; setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); - let targets_bonds = vec![ + let targets_bonds = [ vec![ vec![656, 0], vec![656, 0], @@ -3539,70 +3596,50 @@ fn test_yuma_4_kappa_moves_second() { vec![0, 0], ], ]; + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000], + vec![0.8423, 0.0524, 0.1053], + vec![0.4233, 0.5767, 0.0000], + vec![0.5545, 0.4107, 0.0348], + vec![0.6184, 0.3298, 0.0518], + vec![0.6562, 0.2820, 0.0618], + ]; - for epoch in 0..5 { + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { match epoch { 0 => { // Initially, consensus is achieved by all Validators - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![u16::MAX, 0], - 0 - )); - } + set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 1 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } + set_yuma_4_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], + ); } 2 => { // Validator A -> Server 2 // Validator B -> Server 2 // Validator C -> Server 1 - for (uid, weights) in [vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } + set_yuma_4_weights( + netuid, + vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], + ); } 3 => { // Subsequent epochs All validators -> Server 2 - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![0, u16::MAX], - 0 - )); - } + set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); } _ => {} }; - run_epoch_check_bonds(netuid, sparse, &targets_bonds[epoch]); + run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); } }) } @@ -3621,77 +3658,110 @@ fn test_yuma_4_kappa_moves_last() { let stakes: Vec = vec![8, 1, 1, 0, 0]; setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); - let targets_bonds = vec![ + let targets_bonds = [ vec![vec![656, 0], vec![656, 0], vec![656, 0]], vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]], vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]], vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]], vec![vec![1576, 1305], vec![519, 13508], vec![1044, 7727]], ]; + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000], + vec![0.8423, 0.0524, 0.1053], + vec![0.8895, 0.0367, 0.0738], + vec![0.2067, 0.5117, 0.2816], + vec![0.3294, 0.4265, 0.2440], + vec![0.4108, 0.3701, 0.2191], + ]; - for epoch in 0..5 { + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { match epoch { 0 => { // Initially, consensus is achieved by all Validators - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![u16::MAX, 0], - 0 - )); - } + set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 1 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } + set_yuma_4_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], + ); } 2 => { // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 2 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } + set_yuma_4_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]], + ); } 3 => { // Subsequent epochs All validators -> Server 2 - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![0, u16::MAX], - 0 - )); - } + set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); } _ => {} }; - run_epoch_check_bonds(netuid, sparse, &targets_bonds[epoch]); + run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); + } + }) +} + +#[test] +fn test_yuma_4_one_epoch_switch() { + new_test_ext(1).execute_with(|| { + let sparse: bool = true; + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Equal stake validators + let stakes: Vec = vec![33, 33, 34, 0, 0]; + + setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + + let targets_bonds = [ + vec![vec![656, 0], vec![656, 0], vec![656, 0]], + vec![vec![1305, 0], vec![1305, 0], vec![1305, 0]], + vec![vec![1291, 6553], vec![1947, 0], vec![1947, 0]], + vec![vec![1934, 5897], vec![2583, 0], vec![2583, 0]], + vec![vec![2570, 5307], vec![3213, 0], vec![3213, 0]], + ]; + let targets_dividends = [ + vec![0.33, 0.33, 0.34, 0., 0.], + vec![0.33, 0.33, 0.34, 0., 0.], + vec![0.246_231_48, 0.371_259_12, 0.382_509_4, 0., 0.], + vec![0.269_393_1, 0.359_851_15, 0.370_755_73, 0., 0.], + vec![0.282_665_13, 0.353_314_2, 0.364_020_68, 0., 0.], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 2 => { + // Validator A -> Server 2 + // Validator B -> Server 1 + // Validator C -> Server 1 + set_yuma_4_weights( + netuid, + vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], + ); + } + _ => { + // All validators -> Server 1 + set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + } + }; + run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); } }) } diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index 1ab40869fe..b12e84852a 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -1256,6 +1256,26 @@ fn test_math_mat_vec_mul() { assert_mat_compare(&result, &target, I32F32::from_num(0)); } +#[test] +fn test_math_mat_vec_mul_sparse() { + let matrix: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; + let matrix = vec_to_sparse_mat_fixed(&matrix, 4, false); + let vector: Vec = vec_to_fixed(&[1., 2., 3.]); + let target: Vec = vec![1., 4., 9., 4., 10., 18., 7., 16., 27., 10., 22., 36.]; + let target = vec_to_sparse_mat_fixed(&target, 4, false); + let result = mat_vec_mul_sparse(&matrix, &vector); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0)); + let vector_one: Vec = vec_to_fixed(&[1., 0., 0.]); + let target: Vec = vec![1., 0., 0., 4., 0., 0., 7., 0., 0., 10., 0., 0.]; + let target = vec_to_sparse_mat_fixed(&target, 4, false); + let result = mat_vec_mul_sparse(&matrix, &vector_one); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0)); + let vector_empty: Vec = vec_to_fixed(&[]); + let result = mat_vec_mul_sparse(&matrix, &vector_empty); + let target = vec![vec![]; 4]; + assert_sparse_mat_compare(&result, &target, I32F32::from_num(0)); +} + #[test] fn test_math_row_hadamard() { let vector: Vec = vec_to_fixed(&[1., 2., 3., 4.]); @@ -2156,19 +2176,11 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); - let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; - let new: Vec = vec![ - 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., + let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(0); 3]); + assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); + let old: Vec = vec![ + 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, ]; - let target: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; - let old = vec_to_mat_fixed(&old, 4, false); - let new = vec_to_mat_fixed(&new, 4, false); - let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(0); old.len()]); - assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); - let old: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let new: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; @@ -2179,8 +2191,8 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &vec![I32F32::from_num(1); old.len()]); - assert_mat_compare(&result, &target, I32F32::from_num(0.000001)); + let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(1); 3]); + assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); } #[test] @@ -2190,7 +2202,7 @@ fn test_math_sparse_mat_ema() { ]; let new: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let target: Vec = vec![ - 0.1, 0.2, 1., 0.0759, 0.095, 0.11399, 0.133, 0.15199, 0.171, 0.19, 0.20899, 0.22799, + 0.19, 0.38, 1., 0.43599, 0.545, 0.65399, 0.763, 0.87199, 0.981, 1., 1., 1., ]; let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); @@ -2204,22 +2216,14 @@ fn test_math_sparse_mat_ema() { 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; let target: Vec = vec![ - 0.0019, 0.003799, 0.032699, 0.00399, 0.0455, 0.00599, 0.007, 0.008, 0.00899, 0.0099, - 0.01099, 0.01199, + 0.0109, 0.0218, 0.30270, 0.007599, 0.05, 0.01139, 0.0133, 0.01519, 0.017, 0.01899, 0.02089, + 0.0227, ]; let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); - let old: Vec = vec![0., 2., 3., 4., 0., 6., 7., 8., 0., 10., 11., 12.]; - let new: Vec = vec![10., 20., 0., 40., 0., 60., 0., 80., 90., 100., 110., 120.]; - let target: Vec = vec![1., 3.8, 2.7, 7.6, 0., 11.4, 6.3, 15.2, 9., 19., 20.9, 22.8]; - let old = vec_to_sparse_mat_fixed(&old, 4, false); - let new = vec_to_sparse_mat_fixed(&new, 4, false); - let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, @@ -2227,12 +2231,11 @@ fn test_math_sparse_mat_ema() { let target: Vec = vec![ 0.01, 0.02, 0.3, 0.00399, 0.005, 0.00599, 0.007, 0.00799, 0.009, 0.01, 0.011, 0.01199, ]; - let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let target: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; @@ -2240,7 +2243,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 2., 0., 0., 0., 0., 0., 0., 0.]; let target: Vec = vec![0.9, 0., 0., 0., 0.2, 0., 0., 0., 0., 0., 0., 0.]; @@ -2248,7 +2251,7 @@ fn test_math_sparse_mat_ema() { let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(0.000001)); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); } #[test] From 054f4729ddaeeb9000ec1431b353ec64f2ea8dd4 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 20 Feb 2025 06:19:10 +0000 Subject: [PATCH 025/226] rebase --- pallets/subtensor/src/epoch/math.rs | 5 --- scripts/map_consensus.py | 58 ++++++++++++++++++----------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 0b5c509512..abb0dc7737 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -90,11 +90,6 @@ pub fn vec_fixed_proportions_to_fixed(vec: Vec) -> Vec { vec.into_iter().map(fixed_proportion_to_fixed).collect() } -#[allow(dead_code)] -pub fn vec_u16_proportions_to_fixed(vec: Vec) -> Vec { - vec.into_iter().map(u16_proportion_to_fixed).collect() -} - #[allow(dead_code)] pub fn vec_fixed_proportions_to_u16(vec: Vec) -> Vec { vec.into_iter().map(fixed_proportion_to_u16).collect() diff --git a/scripts/map_consensus.py b/scripts/map_consensus.py index 8d022f8e11..1d09207bf3 100644 --- a/scripts/map_consensus.py +++ b/scripts/map_consensus.py @@ -16,7 +16,7 @@ def extract_data(filepath): A list of lists containing the numerical data, or None if an error occurs. """ try: - with open(filepath, 'r') as f: + with open(filepath, "r") as f: content = f.read() except FileNotFoundError: print(f"Error: File not found at {filepath}") @@ -31,8 +31,10 @@ def extract_data(filepath): # + Matches the previous group (number and comma) one or more times. # [0-9.]+ Matches the last number in the list. # \] Matches the closing square bracket. - - list_pattern = r'\[(?:[0-9.]+,\s*)+[0-9.]+\]' # Regular expression to match data rows + + list_pattern = ( + r"\[(?:[0-9.]+,\s*)+[0-9.]+\]" + ) # Regular expression to match data rows matches = re.findall(list_pattern, content) if not matches: @@ -45,10 +47,10 @@ def extract_data(filepath): # Extract numerical values from the matched string. # 1. match[1:-1]: Removes the square brackets from the beginning and end. # 2. .split(','): Splits the string into a list of strings at each comma. - # 3. [float(x.strip()) for x in ...]: Converts each string to a float + # 3. [float(x.strip()) for x in ...]: Converts each string to a float # after removing leading/trailing whitespace. - - row = [float(x.strip()) for x in match[1:-1].split(',')] + + row = [float(x.strip()) for x in match[1:-1].split(",")] data.append(row) except ValueError: print(f"Warning: Skipping invalid data row: {match}") @@ -68,8 +70,14 @@ def visualize_data(emission_data, output_filename="consensus_plot.svg"): avg_weight_devs = {} # Process the data to organize it by major stake - for major_stake, major_weight, minor_weight, avg_weight_dev, major_ratio in emission_data: - major_stake_str = f'{major_stake:.2f}' + for ( + major_stake, + major_weight, + minor_weight, + avg_weight_dev, + major_ratio, + ) in emission_data: + major_stake_str = f"{major_stake:.2f}" maj_idx, min_idx = int(round(50 * major_weight)), int(round(50 * minor_weight)) avg_weight_devs.setdefault(major_stake_str, np.zeros((51, 51))) @@ -78,46 +86,52 @@ def visualize_data(emission_data, output_filename="consensus_plot.svg"): major_ratios.setdefault(major_stake_str, np.zeros((51, 51))) major_ratios[major_stake_str][maj_idx][min_idx] = major_ratio - # Create the meshgrid for the contour plot x = np.linspace(0, 1, 51) y = np.linspace(0, 1, 51) - x, y = np.meshgrid(x, y, indexing='ij') + x, y = np.meshgrid(x, y, indexing="ij") # Set up the plot fig = plt.figure(figsize=(6, 6), dpi=70) ax = fig.gca() ax.set_xticks(np.arange(0, 1, 0.05)) - ax.set_yticks(np.arange(0, 1., 0.05)) - ax.set_xticklabels([f'{_:.2f}'[1:] for _ in np.arange(0, 1., 0.05)]) + ax.set_yticks(np.arange(0, 1.0, 0.05)) + ax.set_xticklabels([f"{_:.2f}"[1:] for _ in np.arange(0, 1.0, 0.05)]) plt.grid(linestyle="dotted", color=[0.85, 0.85, 0.85]) - # Define stakes and colors for contour lines - isolate = ['0.60'] # Stakes to highlight + isolate = ["0.60"] # Stakes to highlight stakes = [0.51, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99] colors = cm.viridis(np.linspace(0, 1, len(stakes) + 1)) # Create contour lines for each stake for i, stake in enumerate(stakes): - contours = plt.contour(x, y, major_ratios[f'{stake:.2f}'], levels=[0., stake], colors=[colors[i + 1]]) - if f'{stake:.2f}' in isolate: - contours.collections[1].set_linewidth(3) # Highlight isolated stake + contours = plt.contour( + x, + y, + major_ratios[f"{stake:.2f}"], + levels=[0.0, stake], + colors=[colors[i + 1]], + ) + if f"{stake:.2f}" in isolate: + contours.collections[1].set_linewidth(3) # Highlight isolated stake plt.clabel(contours, inline=True, fontsize=10) # Add title and labels - plt.title(f'Major emission [$stake_{{maj}}=emission_{{maj}}$ retention lines]') - plt.ylabel('Minor self-weight') - plt.xlabel('Major self-weight') + plt.title(f"Major emission [$stake_{{maj}}=emission_{{maj}}$ retention lines]") + plt.ylabel("Minor self-weight") + plt.xlabel("Major self-weight") # Save the plot - plt.savefig(output_filename, format='svg') + plt.savefig(output_filename, format="svg") print(f"Plot saved to {output_filename}") if __name__ == "__main__": if len(sys.argv) < 2: - print("Usage: python scripts/map_consensus.py [optional_output_filename]") + print( + "Usage: python scripts/map_consensus.py [optional_output_filename]" + ) sys.exit(1) filepath = sys.argv[1] From c5497bec1e3a720bda63e77a1c43210b787f0a62 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Mon, 17 Mar 2025 13:32:38 +0000 Subject: [PATCH 026/226] cargo fmt --- pallets/subtensor/src/tests/consensus.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pallets/subtensor/src/tests/consensus.rs b/pallets/subtensor/src/tests/consensus.rs index bb8175120b..2e576572cc 100644 --- a/pallets/subtensor/src/tests/consensus.rs +++ b/pallets/subtensor/src/tests/consensus.rs @@ -8,10 +8,10 @@ use super::mock::*; use crate::*; use frame_support::assert_ok; -use rand::{distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng, Rng, SeedableRng}; +use rand::{Rng, SeedableRng, distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng}; use sp_core::U256; use std::time::Instant; -use substrate_fixed::transcendental::{cos, ln, sqrt, PI}; +use substrate_fixed::transcendental::{PI, cos, ln, sqrt}; use substrate_fixed::types::{I32F32, I64F64}; pub fn fixed(val: f32) -> I32F32 { @@ -319,11 +319,7 @@ fn split_graph( .iter() .map(|x: &I32F32| { let v: I32F32 = (stddev * x) + one; - if v < zero { - zero - } else { - v - } + if v < zero { zero } else { v } }) .collect(); inplace_normalize(&mut sample); @@ -348,11 +344,7 @@ fn split_graph( .iter() .map(|x: &I32F32| { let v: I32F32 = (weight_stddev * x) + one; - if v < zero { - zero - } else { - v - } + if v < zero { zero } else { v } }) .collect(); inplace_normalize(&mut sample); From e18b9dce08b7a082d0a81d013bd353df29111a64 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 19 Mar 2025 17:16:22 +0000 Subject: [PATCH 027/226] liquid alpha 2 impl --- pallets/subtensor/src/epoch/math.rs | 216 +++++++++++++--- pallets/subtensor/src/epoch/run_epoch.rs | 299 ++++++++++++++++------- 2 files changed, 388 insertions(+), 127 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index abb0dc7737..e8c7919fa9 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -95,6 +95,18 @@ pub fn vec_fixed_proportions_to_u16(vec: Vec) -> Vec { vec.into_iter().map(fixed_proportion_to_u16).collect() } +#[allow(dead_code)] +pub fn mat_fixed_proportions_to_u16(mat: Vec>) -> Vec> { + mat.into_iter().map(vec_fixed_proportions_to_u16).collect() +} + +#[allow(dead_code)] +pub fn mat_fixed_proportions_to_fixed(mat: Vec>) -> Vec> { + mat.into_iter() + .map(vec_fixed_proportions_to_fixed) + .collect() +} + #[allow(dead_code)] // Max-upscale vector and convert to u16 so max_value = u16::MAX. Assumes non-negative normalized input. pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec { @@ -1317,73 +1329,197 @@ pub fn sparse_threshold(w: &[Vec<(u16, I32F32)>], threshold: I32F32) -> Vec], old: &[Vec], alpha: I32F32) -> Vec> { + let Some(first_row) = new.first() else { + return vec![vec![]]; + }; + if first_row.is_empty() { + return vec![vec![]; 1]; + } + let one_minus_alpha: I32F32 = I32F32::saturating_from_num(1.0).saturating_sub(alpha); + new.iter() + .zip(old) + .map(|(new_row, old_row)| { + new_row + .iter() + .zip(old_row) + .map(|(new_elem, old_elem)| { + alpha + .saturating_mul(*new_elem) + .saturating_add(one_minus_alpha.saturating_mul(*old_elem)) + }) + .collect() + }) + .collect() +} + +// Return sparse matrix exponential moving average: `alpha * a_ij + one_minus_alpha * b_ij`. +// `alpha` is the EMA coefficient, how much to add of the new observation, typically small, +// higher alpha discounts older observations faster. +#[allow(dead_code, clippy::indexing_slicing)] +pub fn mat_ema_sparse( new: &[Vec<(u16, I32F32)>], old: &[Vec<(u16, I32F32)>], - alpha: &[I32F32], + alpha: I32F32, ) -> Vec> { - // Ensure the new and old matrices have the same number of rows. assert!(new.len() == old.len()); - let n = new.len(); // Assume square matrix, rows=cols + let n = new.len(); // assume square matrix, rows=cols let zero: I32F32 = I32F32::saturating_from_num(0.0); + let one_minus_alpha: I32F32 = I32F32::saturating_from_num(1.0).saturating_sub(alpha); let mut result: Vec> = vec![vec![]; n]; - - // Iterate over each row of the matrices. - for (i, (new_row, old_row)) in new.iter().zip(old).enumerate() { - // Initialize a row of zeros for the result matrix. + for i in 0..new.len() { let mut row: Vec = vec![zero; n]; - - // Process the new matrix values. - for (j, new_val) in new_row.iter() { - // Retrieve the alpha value for the current column. - let alpha_val: I32F32 = alpha.get(*j as usize).copied().unwrap_or(zero); - // Compute the EMA component for the new value using saturating multiplication. - if let Some(row_val) = row.get_mut(*j as usize) { - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap - // Validators allocate their purchase across miners based on weights - *row_val = alpha_val.saturating_mul(*new_val); + for (j, value) in new[i].iter() { + row[*j as usize] = row[*j as usize].saturating_add(alpha.saturating_mul(*value)); + } + for (j, value) in old[i].iter() { + row[*j as usize] = + row[*j as usize].saturating_add(one_minus_alpha.saturating_mul(*value)); + } + for (j, value) in row.iter().enumerate() { + if *value > zero { + result[i].push((j as u16, *value)) } } + } + result +} - // Process the old matrix values. - for (j, old_val) in old_row.iter() { - // Retrieve the alpha value for the current column. - let alpha_val: I32F32 = alpha.get(*j as usize).copied().unwrap_or(zero); - // Calculate the complement of the alpha value using saturating subtraction. - let one_minus_alpha: I32F32 = - I32F32::saturating_from_num(1.0).saturating_sub(alpha_val); - // Compute the EMA component for the old value and add it to the row using saturating operations. - if let Some(purchase_increment) = row.get_mut(*j as usize) { - // *row_val = row_val.saturating_add(one_minus_alpha.saturating_mul(*value)); +/// Return matrix exponential moving average: `alpha_j * a_ij + one_minus_alpha_j * b_ij`. +/// `alpha_` is the EMA coefficient passed as a vector per column. +#[allow(dead_code)] +pub fn mat_ema_alpha( + new: &[Vec], // Weights + old: &[Vec], // Bonds + alpha: &[Vec], +) -> Vec> { + // Check if the new matrix is empty or its first row is empty. + if new.is_empty() || new.first().is_none_or(|row| row.is_empty()) { + return vec![vec![]; 1]; + } + + // Ensure the dimensions of the new, old and alpha matrices match. + assert!(new.len() == old.len()); + assert!(new.len() == alpha.len()); + + // Initialize the result matrix with zeros, having the same dimensions as the new matrix. + let mut result: Vec> = + vec![ + vec![I32F32::saturating_from_num(0.0); new.first().map_or(0, |row| row.len())]; + new.len() + ]; + + // Iterate over each row of the matrices. + for (i, ((new_row, old_row), alpha_row)) in new.iter().zip(old).zip(alpha).enumerate() { + assert!(new_row.len() == old_row.len()); + assert!(new_row.len() == alpha_row.len()); + + // Iterate over each column of the current row. + for j in 0..new_row.len() { + // Compute the EMA for the current element using saturating operations. + if let (Some(new_val), Some(old_val), Some(alpha_val), Some(result_val)) = ( + new_row.get(j), + old_row.get(j), + alpha_row.get(j), + result.get_mut(i).and_then(|row| row.get_mut(j)), + ) { + // Calculate the complement of the alpha value + let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(*alpha_val); + + // Bonds_decayed = Bonds * (1 - alpha) let decayed_val = one_minus_alpha.saturating_mul(*old_val); + + // Calculate remaining capacity to limit bonds purchase let remaining_capacity = I32F32::from_num(1.0) .saturating_sub(decayed_val) .max(I32F32::from_num(0.0)); + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + let purchase_increment = alpha_val.saturating_mul(*new_val); + // Ensure that purchase does not exceed remaining capacity - let purchase = (*purchase_increment).min(remaining_capacity); + let purchase = purchase_increment.min(remaining_capacity); - *purchase_increment = decayed_val + *result_val = decayed_val .saturating_add(purchase) .min(I32F32::from_num(1.0)); } } + } - // Collect the non-zero values into the result matrix. - for (j, value) in row.iter().enumerate() { - if *value > zero { - if let Some(result_row) = result.get_mut(i) { - result_row.push((j as u16, *value)); - log::trace!("result[{}][{}] = {}", i, j, value); - } + // Return the computed EMA matrix. + result +} + +/// Calculates the exponential moving average (EMA) for a sparse matrix using dynamic alpha values. +/// Return matrix exponential moving average: `alpha_j * a_ij + one_minus_alpha_j * b_ij`. +// `alpha` is the EMA coefficient, how much to add of the new observation, typically small, +// higher alpha discounts older observations faster. +// if liquid alpha off then the alpha vector will be constant +#[allow(dead_code)] +pub fn mat_ema_alpha_sparse( + new: &[Vec<(u16, I32F32)>], + old: &[Vec<(u16, I32F32)>], + alpha: &[Vec], +) -> Vec> { + // Ensure dimensions match. + assert!(new.len() == old.len()); + assert!(new.len() == alpha.len()); + + // The output vector of rows. + let mut result: Vec> = Vec::with_capacity(new.len()); + + let n = new.len(); // Assume square matrix, rows=cols + let zero: I32F32 = I32F32::saturating_from_num(0.0); + + // Iterate over each row of the matrices. + for (i, (new_row, old_row)) in new.iter().zip(old).enumerate() { + // Initialize a row of zeros for the result matrix. + let mut decayed_values: Vec = vec![zero; n]; + + let mut result_row: Vec<(u16, I32F32)> = Vec::new(); + + // Process the old matrix values. + for (j, old_val) in old_row.iter() { + let alpha_val = alpha[i][*j as usize]; + // Calculate the complement of the alpha value + let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(alpha_val); + + // Bonds_decayed = Bonds * (1 - alpha) + let decayed_val = one_minus_alpha.saturating_mul(*old_val); + decayed_values[*j as usize] = decayed_val; + } + + // Process the new matrix values. + for (j, new_val) in new_row.iter() { + let alpha_val = alpha[i][*j as usize]; + let decayed_val = decayed_values[*j as usize]; + + // Calculate remaining capacity to limit bonds purchase + let remaining_capacity = I32F32::from_num(1.0) + .saturating_sub(decayed_val) + .max(I32F32::from_num(0.0)); + + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + let purchase_increment = alpha_val.saturating_mul(*new_val); + + // Ensure that purchase does not exceed remaining capacity + let purchase = purchase_increment.min(remaining_capacity); + + let result_val = decayed_val + .saturating_add(purchase) + .min(I32F32::from_num(1.0)); + if result_val > zero { + result_row.push(({ *j }, result_val)); } } + result.push(result_row); } // Return the computed EMA sparse matrix. diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 5cb399039f..8c3392b952 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -200,18 +200,17 @@ impl Pallet { // Access network bonds. let mut bonds: Vec> = Self::get_bonds(netuid); inplace_mask_matrix(&outdated, &mut bonds); // mask outdated bonds - for bonds_row in &mut bonds { - *bonds_row = vec_fixed_proportions_to_fixed(bonds_row.clone()); - } - // inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 + bonds = mat_fixed_proportions_to_fixed(bonds.clone()); // TODO log::trace!("B: {:?}", &bonds); - // Get alpha values - let alphas = Self::compute_liquid_alpha(netuid, consensus.clone()); - log::trace!("alphas: {:?}", &alphas); - // Compute the Exponential Moving Average (EMA) of bonds. - let ema_bonds = Self::compute_ema_bonds(&weights_for_bonds.clone(), &bonds, alphas); + let ema_bonds = Self::compute_ema_bonds( + netuid, + &weights_for_bonds, + &bonds, + &consensus, + &active_stake, + ); log::trace!("emaB: {:?}", &ema_bonds); // Normalize EMA bonds. @@ -599,13 +598,15 @@ impl Pallet { let bonds = result; log::trace!("Bonds: (mask+norm) {:?}", &bonds); - // Get alpha values - let alphas = Self::compute_liquid_alpha(netuid, consensus.clone()); - log::trace!("Alphas: {:?}", &alphas); - // Compute the Exponential Moving Average (EMA) of bonds. log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); - let ema_bonds = Self::compute_ema_bonds_sparse(&weights_for_bonds.clone(), &bonds, alphas); + let ema_bonds = Self::compute_ema_bonds_sparse( + netuid, + &weights_for_bonds, + &bonds, + &consensus, + &active_stake, + ); log::trace!("emaB: {:?}", &ema_bonds); // Normalize EMA bonds. @@ -1013,115 +1014,239 @@ impl Pallet { log::trace!("alpha_clamped: {:?}", clamped_alpha); clamped_alpha } + /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting + /// + /// # Args: + /// * `netuid` - The network ID. + /// * `weights` - A vector of weights. + /// * `bonds` - A vector of bonds. + /// * `consensus` - A vector of consensus values. + /// * `active_stake` - A vector of active stake values. + /// + /// # Returns: + /// A vector of EMA bonds. + pub fn compute_ema_bonds( + netuid: u16, + weights: &[Vec], // weights_for_bonds + bonds: &[Vec], + consensus: &Vec, + active_stake: &Vec, + ) -> Vec> { + // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. + if LiquidAlphaOn::::get(netuid) + && !consensus.is_empty() + && consensus + .iter() + .any(|&c| c != I32F32::saturating_from_num(0)) + { + // Liquid Alpha is enabled, compute the liquid alphas matrix. + let alphas: Vec> = + Self::compute_liquid_alphas(netuid, weights, bonds, consensus); + log::trace!("alphas: {:?}", &alphas); + + // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. + mat_ema_alpha(weights, bonds, &alphas) + } else { + // Liquid Alpha is disabled, compute the liquid alpha value. + let alpha: I32F32 = Self::compute_disabled_liquid_alpha(netuid); + + // Compute bonds delta column normalized. + let mut bonds_delta: Vec> = row_hadamard(weights, active_stake); // ΔB = W◦S + inplace_col_normalize(&mut bonds_delta); // sum_i b_ij = 1 + log::trace!("ΔB:\n{:?}\n", &bonds_delta); + + // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. + + // Return the computed EMA bonds. + mat_ema(&bonds_delta, bonds, alpha) + } + } - /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values for a sparse matrix. + /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting /// /// # Args: + /// * `netuid` - The network ID. /// * `weights` - A vector of weights. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. + /// * `consensus` - A vector of consensus values. + /// * `active_stake` - A vector of active stake values. /// /// # Returns: /// A vector of EMA bonds. pub fn compute_ema_bonds_sparse( + netuid: u16, weights: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], - alpha: Vec, + consensus: &Vec, + active_stake: &Vec, ) -> Vec> { - // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec_sparse(weights, bonds, &alpha); + // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. + if LiquidAlphaOn::::get(netuid) + && !consensus.is_empty() + && consensus + .iter() + .any(|&c| c != I32F32::saturating_from_num(0)) + { + // Liquid Alpha is enabled, compute the liquid alphas matrix. + let alphas: Vec> = + Self::compute_liquid_alphas_sparse(netuid, weights, bonds, consensus); + log::trace!("alphas: {:?}", &alphas); + + // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. + mat_ema_alpha_sparse(weights, bonds, &alphas) + } else { + let n: u16 = Self::get_subnetwork_n(netuid); - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); + // Liquid Alpha is disabled, compute the liquid alpha value. + let alpha: I32F32 = Self::compute_disabled_liquid_alpha(netuid); - // Return the computed EMA bonds. - ema_bonds + // Compute bonds delta column normalized. + let mut bonds_delta: Vec> = + row_hadamard_sparse(weights, active_stake); // ΔB = W◦S + inplace_col_normalize_sparse(&mut bonds_delta, n); // sum_i b_ij = 1 + log::trace!("ΔB:\n{:?}\n", &bonds_delta); + + // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. + + // Return the computed EMA bonds. + mat_ema_sparse(&bonds_delta, bonds, alpha) + } } - /// Compute the Exponential Moving Average (EMA) of bonds using the alpha values. + /// Compute liquid alphas matrix + /// There is a separate alpha param for each validator-miner binding /// /// # Args: + /// * `netuid` - The network ID. /// * `weights` - A vector of weights. /// * `bonds` - A vector of bonds. - /// * `alpha` - A vector of clamped alpha values (for liquid alpha) or constant alpha values. + /// * `consensus` - A vector of consensus values. /// /// # Returns: - /// A vector of EMA bonds. - pub fn compute_ema_bonds( - weights: &[Vec], - bonds: &[Vec], - alpha: Vec, + /// A matrix of alphas + pub fn compute_liquid_alphas( + netuid: u16, + weights: &[Vec], // current epoch weights + bonds: &[Vec], // previous epoch bonds + consensus: &Vec, // previous epoch consensus weights ) -> Vec> { - // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. - let ema_bonds = mat_ema_alpha_vec(weights, bonds, &alpha); + assert!(weights.len() == bonds.len()); + let n = weights.len(); // Assume square matrix, rows=cols + + // Get the high and low alpha values for the network. + let alpha_sigmoid_steepness: I32F32 = I32F32::from_num(10.0); + let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); + + let mut alphas = Vec::new(); - // Log the computed EMA bonds for debugging purposes. - log::trace!("Exponential Moving Average Bonds: {:?}", ema_bonds); + for i in 0..n { + let mut row_alphas = Vec::new(); - // Return the computed EMA bonds. - ema_bonds + for j in 0..weights[i].len() { + let diff_buy = (weights[i][j] - consensus[j]) + .max(I32F32::from_num(0.0)) + .min(I32F32::from_num(1.0)); + let diff_sell = (bonds[i][j] - weights[i][j]) + .max(I32F32::from_num(0.0)) + .min(I32F32::from_num(1.0)); + + let combined_diff = if weights[i][j] >= bonds[i][j] { + diff_buy + } else { + diff_sell + }; + + // sigmoid = 1. / (1. + e^(-alpha_sigmoid_steepness * (combined_diff - 0.5))) + let sigmoid = I32F32::from_num(1.0).saturating_div( + I32F32::from_num(1.0) + + safe_exp( + -alpha_sigmoid_steepness + .saturating_mul(combined_diff - I32F32::from_num(0.5)), + ), + ); + let alpha = alpha_low + sigmoid * (alpha_high - alpha_low); + row_alphas.push(alpha.max(alpha_low).min(alpha_high)); + } + alphas.push(row_alphas); + } + alphas } - /// Compute liquid alphas based on the Liquid Alpha setting. + /// Compute liquid alphas sparse matrix + /// There is a separate alpha param for each validator-miner binding /// /// # Args: /// * `netuid` - The network ID. + /// * `weights` - A vector of weights. + /// * `bonds` - A vector of bonds. /// * `consensus` - A vector of consensus values. /// /// # Returns: - /// A vector of alphas - pub fn compute_liquid_alpha(netuid: u16, consensus: Vec) -> Vec { - // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. - if LiquidAlphaOn::::get(netuid) - && !consensus.is_empty() - && consensus - .iter() - .any(|&c| c != I32F32::saturating_from_num(0)) - { - // Calculate the 75th percentile (high) and 25th percentile (low) of the consensus values. - let mut consensus_high = quantile(&consensus, 0.75); - let consensus_low = quantile(&consensus, 0.25); + /// A matrix of alphas (not sparse as very few values will be zero) + pub fn compute_liquid_alphas_sparse( + netuid: u16, + weights: &[Vec<(u16, I32F32)>], // current epoch weights + bonds: &[Vec<(u16, I32F32)>], // previous epoch bonds + consensus: &Vec, // previous epoch consensus weights + ) -> Vec> { + assert!(weights.len() == bonds.len()); + let n = weights.len() as u16; // Assume square matrix, rows=cols + // + let alpha_sigmoid_steepness: I32F32 = I32F32::from_num(10.0); + let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); + + let mut alphas = Vec::with_capacity(n as usize); + + // iterate over rows + for (w_row, b_row) in weights.iter().zip(bonds.iter()) { + let mut row_alphas = Vec::with_capacity(w_row.len()); + let mut w_iter = 0; + let mut b_iter = 0; + for j in 0..n { + while w_iter < w_row.len() && w_row[w_iter].0 < j { + w_iter += 1; + } + let w_val = if w_iter < w_row.len() && w_row[w_iter].0 == j { + w_row[w_iter].1 + } else { + I32F32::from_num(0.0) + }; - if consensus_high == consensus_low { - consensus_high = quantile(&consensus, 0.99); - } - if consensus_high == consensus_low { - consensus_high = I32F32::saturating_from_num(1.0); + while b_iter < b_row.len() && b_row[b_iter].0 < j { + b_iter += 1; + } + let b_val = if b_iter < b_row.len() && b_row[b_iter].0 == j { + b_row[b_iter].1 + } else { + I32F32::from_num(0.0) + }; + + let diff_buy = (w_val - consensus[j as usize]) + .max(I32F32::from_num(0.0)) + .min(I32F32::from_num(1.0)); + let diff_sell = (b_val - w_val) + .max(I32F32::from_num(0.0)) + .min(I32F32::from_num(1.0)); + let combined_diff = if w_val >= b_val { diff_buy } else { diff_sell }; + + // sigmoid = 1. / (1. + e^(-alpha_sigmoid_steepness * (combined_diff - 0.5))) + let sigmoid = I32F32::from_num(1.0).saturating_div( + I32F32::from_num(1.0) + + safe_exp( + -alpha_sigmoid_steepness + .saturating_mul(combined_diff - I32F32::from_num(0.5)), + ), + ); + let mut alpha = alpha_low + sigmoid * (alpha_high - alpha_low); + alpha = alpha.max(alpha_low).min(alpha_high); + row_alphas.push(alpha); } - log::trace!( - "consensus_high: {:?}, consensus_low: {:?}", - consensus_high, - consensus_low - ); - - // Get the high and low alpha values for the network. - let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); - // log::warn!("alpha_high: {:?}, alpha_low: {:?} ", alpha_high, alpha_low); - - // Calculate the logistic function parameters 'a' and 'b' based on alpha and consensus values. - let (a, b) = Self::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Compute the alpha values using the logistic function parameters. - // alpha = 1 / (1 + math.e ** (-a * C + b)) # alpha to the old weight - let alpha = Self::compute_alpha_values(&consensus, a, b); - - // return 1 - alpha values clamped between alpha_high and alpha_low. - let clamped_alpha: Vec = Self::clamp_alpha_values(alpha, alpha_high, alpha_low); - return clamped_alpha - .iter() - .map(|a| I32F32::saturating_from_num(1.0).saturating_sub(*a)) - .collect(); + alphas.push(row_alphas); } + alphas + } - // Liquid Alpha is disabled - // or high and low consensus values do not meet the required conditions. - // return vector of constant alpha - + pub fn compute_disabled_liquid_alpha(netuid: u16) -> I32F32 { // Retrieve the bonds moving average for the given network ID and scale it down. let bonds_moving_average: I64F64 = I64F64::from_num(Self::get_bonds_moving_average(netuid)) .saturating_div(I64F64::from_num(1_000_000)); @@ -1131,7 +1256,7 @@ impl Pallet { let alpha: I32F32 = I32F32::from_num(1).saturating_sub(I32F32::from_num(bonds_moving_average)); - vec![alpha; consensus.len()] + alpha } pub fn do_set_alpha_values( From 875a0ff187383e58a55492ff655ad179bfb106aa Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 19 Mar 2025 17:41:57 +0000 Subject: [PATCH 028/226] fix yuma4 tests --- pallets/subtensor/src/epoch/math.rs | 13 + pallets/subtensor/src/epoch/run_epoch.rs | 147 +------ pallets/subtensor/src/tests/epoch.rs | 507 +++++++---------------- 3 files changed, 171 insertions(+), 496 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index e8c7919fa9..5737e31c97 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1329,6 +1329,19 @@ pub fn sparse_threshold(w: &[Vec<(u16, I32F32)>], threshold: I32F32) -> Vec I32F32 { + // First, clamp the value to ensure it does not exceed the upper bound (high). + // If the value is greater than 'high', it will be set to 'high'. + // otherwise it remains unchanged. + value + .min(I32F32::from_num(high)) + // Next, clamp the value to ensure it does not go below the lower bound (_low). + // If the value (after the first clamping) is less than 'low', it will be set to 'low'. + // otherwise it remains unchanged. + .max(I32F32::from_num(low)) +} + // Return matrix exponential moving average: `alpha * a_ij + one_minus_alpha * b_ij`. // `alpha` is the EMA coefficient, how much to add of the new observation, typically small, // higher alpha discounts older observations faster. diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 8c3392b952..2b3037ee94 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -893,127 +893,6 @@ impl Pallet { bonds } - /// Calculate the logistic function parameters 'a' and 'b' based on alpha and consensus values. - /// - /// # Args: - /// * `alpha_high` - The high alpha value. - /// * `alpha_low` - The low alpha value. - /// * `consensus_high` - The high consensus value. - /// * `consensus_low` - The low consensus value. - /// - /// # Returns: - /// A tuple containing the slope 'a' and intercept 'b' for the logistic function. - pub fn calculate_logistic_params( - alpha_high: I32F32, - alpha_low: I32F32, - consensus_high: I32F32, - consensus_low: I32F32, - ) -> (I32F32, I32F32) { - log::trace!("alpha_high: {:?}", alpha_high); - log::trace!("alpha_low: {:?}", alpha_low); - log::trace!("consensus_high: {:?}", consensus_high); - log::trace!("consensus_low: {:?}", consensus_low); - // Check for division by zero - // extra caution to ensure we never divide by zero - if consensus_high <= consensus_low || alpha_low == 0 || alpha_high == 0 { - // Return 0 for both 'a' and 'b' when consensus values are equal - return ( - I32F32::saturating_from_num(0.0), - I32F32::saturating_from_num(0.0), - ); - } - - // Calculate the slope 'a' of the logistic function. - // a = (ln((1 / alpha_high - 1)) - ln((1 / alpha_low - 1))) / (consensus_low - consensus_high) - let a = (safe_ln( - (I32F32::saturating_from_num(1.0).safe_div(alpha_high)) - .saturating_sub(I32F32::saturating_from_num(1.0)), - ) - .saturating_sub(safe_ln( - (I32F32::saturating_from_num(1.0).safe_div(alpha_low)) - .saturating_sub(I32F32::saturating_from_num(1.0)), - ))) - .safe_div(consensus_low.saturating_sub(consensus_high)); - log::trace!("a: {:?}", a); - - // Calculate the intercept 'b' of the logistic function. - // b = ln((1 / alpha_low - 1)) + a * consensus_low - let b = safe_ln( - (I32F32::saturating_from_num(1.0).safe_div(alpha_low)) - .saturating_sub(I32F32::saturating_from_num(1.0)), - ) - .saturating_add(a.saturating_mul(consensus_low)); - log::trace!("b: {:?}", b); - - // Return the calculated slope 'a' and intercept 'b'. - (a, b) - } - - /// Compute the alpha values using the logistic function parameters 'a' and 'b'. - /// - /// # Args: - /// * `consensus` - A vector of consensus values. - /// * `a` - The slope of the logistic function. - /// * `b` - The intercept of the logistic function. - /// - /// # Returns: - /// A vector of computed alpha values. - pub fn compute_alpha_values(consensus: &[I32F32], a: I32F32, b: I32F32) -> Vec { - // Compute the alpha values for each consensus value. - let alpha: Vec = consensus - .iter() - .map(|c| { - // Calculate the exponent value for the logistic function. - // exp_val = exp(b - a * c) - let exp_val = safe_exp(b.saturating_sub(a.saturating_mul(*c))); - - // Compute the alpha value using the logistic function formula. - // alpha = 1 / (1 + exp_val) - I32F32::saturating_from_num(1.0) - .safe_div(I32F32::saturating_from_num(1.0).saturating_add(exp_val)) - }) - .collect(); - - // Log the computed alpha values for debugging purposes. - log::trace!("alpha: {:?}", alpha); - - // Return the computed alpha values. - alpha - } - - /// Clamp the alpha values between alpha_high and alpha_low. - /// - /// # Args: - /// * `alpha` - A vector of alpha values. - /// * `alpha_high` - The high alpha value. - /// * `alpha_low` - The low alpha value. - /// - /// # Returns: - /// A vector of clamped alpha values. - pub fn clamp_alpha_values( - alpha: Vec, - alpha_high: I32F32, - alpha_low: I32F32, - ) -> Vec { - let clamped_alpha: Vec = alpha - .iter() - .map(|a| { - // First, clamp the value to ensure it does not exceed the upper bound (alpha_high). - // If 'a' is greater than 'alpha_high', it will be set to 'alpha_high'. - // If 'a' is less than or equal to 'alpha_high', it remains unchanged. - let clamped_a = a - .min(&alpha_high) - // Next, clamp the value to ensure it does not go below the lower bound (alpha_low). - // If the value (after the first clamping) is less than 'alpha_low', it will be set to 'alpha_low'. - // If the value is greater than or equal to 'alpha_low', it remains unchanged. - .max(&alpha_low); - // Return the clamped value. - *clamped_a - }) - .collect(); - log::trace!("alpha_clamped: {:?}", clamped_alpha); - clamped_alpha - } /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting /// /// # Args: @@ -1041,7 +920,7 @@ impl Pallet { { // Liquid Alpha is enabled, compute the liquid alphas matrix. let alphas: Vec> = - Self::compute_liquid_alphas(netuid, weights, bonds, consensus); + Self::compute_liquid_alpha_values(netuid, weights, bonds, consensus); log::trace!("alphas: {:?}", &alphas); // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. @@ -1089,7 +968,7 @@ impl Pallet { { // Liquid Alpha is enabled, compute the liquid alphas matrix. let alphas: Vec> = - Self::compute_liquid_alphas_sparse(netuid, weights, bonds, consensus); + Self::compute_liquid_alpha_values_sparse(netuid, weights, bonds, consensus); log::trace!("alphas: {:?}", &alphas); // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. @@ -1124,7 +1003,7 @@ impl Pallet { /// /// # Returns: /// A matrix of alphas - pub fn compute_liquid_alphas( + pub fn compute_liquid_alpha_values( netuid: u16, weights: &[Vec], // current epoch weights bonds: &[Vec], // previous epoch bonds @@ -1143,12 +1022,16 @@ impl Pallet { let mut row_alphas = Vec::new(); for j in 0..weights[i].len() { - let diff_buy = (weights[i][j] - consensus[j]) - .max(I32F32::from_num(0.0)) - .min(I32F32::from_num(1.0)); - let diff_sell = (bonds[i][j] - weights[i][j]) - .max(I32F32::from_num(0.0)) - .min(I32F32::from_num(1.0)); + let diff_buy = clamp_value( + weights[i][j] - consensus[j], + I32F32::from_num(0.0), + I32F32::from_num(1.0), + ); + let diff_sell = clamp_value( + bonds[i][j] - weights[i][j], + I32F32::from_num(0.0), + I32F32::from_num(1.0), + ); let combined_diff = if weights[i][j] >= bonds[i][j] { diff_buy @@ -1165,7 +1048,7 @@ impl Pallet { ), ); let alpha = alpha_low + sigmoid * (alpha_high - alpha_low); - row_alphas.push(alpha.max(alpha_low).min(alpha_high)); + row_alphas.push(clamp_value(alpha, alpha_low, alpha_high)); } alphas.push(row_alphas); } @@ -1183,7 +1066,7 @@ impl Pallet { /// /// # Returns: /// A matrix of alphas (not sparse as very few values will be zero) - pub fn compute_liquid_alphas_sparse( + pub fn compute_liquid_alpha_values_sparse( netuid: u16, weights: &[Vec<(u16, I32F32)>], // current epoch weights bonds: &[Vec<(u16, I32F32)>], // previous epoch bonds diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index d2a7645b86..e1bca93858 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -5,7 +5,9 @@ )] use super::mock::*; -use crate::epoch::math::{fixed, safe_exp, u16_proportion_to_fixed}; +use crate::epoch::math::{ + fixed, mat_fixed_proportions_to_fixed, safe_exp, u16_proportion_to_fixed, +}; use crate::*; use approx::assert_abs_diff_eq; @@ -2576,273 +2578,6 @@ fn test_validator_permits() { } } -#[test] -fn test_compute_alpha_values() { - // Define the consensus values. - let consensus = vec![ - I32F32::from_num(0.1), - I32F32::from_num(0.5), - I32F32::from_num(0.9), - ]; - // Define the logistic function parameters 'a' and 'b'. - let a = I32F32::from_num(1.0); - let b = I32F32::from_num(0.0); - - // Compute the alpha values using the function. - let alpha = SubtensorModule::compute_alpha_values(&consensus, a, b); - - // Ensure the length of the alpha vector matches the consensus vector. - assert_eq!(alpha.len(), consensus.len()); - - // Manually compute the expected alpha values for each consensus value. - // The logistic function is: 1 / (1 + exp(b - a * c)) - // where c is the consensus value. - - // For consensus[0] = 0.1: - // exp_val = exp(0.0 - 1.0 * 0.1) = exp(-0.1) - // alpha[0] = 1 / (1 + exp(-0.1)) ~ 0.9048374180359595 - let exp_val_0 = I32F32::from_num(0.9048374180359595); - let expected_alpha_0 = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val_0); - - // For consensus[1] = 0.5: - // exp_val = exp(0.0 - 1.0 * 0.5) = exp(-0.5) - // alpha[1] = 1 / (1 + exp(-0.5)) ~ 0.6065306597126334 - let exp_val_1 = I32F32::from_num(0.6065306597126334); - let expected_alpha_1 = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val_1); - - // For consensus[2] = 0.9: - // exp_val = exp(0.0 - 1.0 * 0.9) = exp(-0.9) - // alpha[2] = 1 / (1 + exp(-0.9)) ~ 0.4065696597405991 - let exp_val_2 = I32F32::from_num(0.4065696597405991); - let expected_alpha_2 = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val_2); - - // Define an epsilon for approximate equality checks. - let epsilon = I32F32::from_num(1e-6); - - // Assert that the computed alpha values match the expected values within the epsilon. - assert_approx_eq(alpha[0], expected_alpha_0, epsilon); - assert_approx_eq(alpha[1], expected_alpha_1, epsilon); - assert_approx_eq(alpha[2], expected_alpha_2, epsilon); -} - -#[test] -fn test_compute_alpha_values_256_miners() { - // Define the consensus values for 256 miners. - let consensus: Vec = (0..256) - .map(|i| I32F32::from_num(i as f32 / 255.0)) - .collect(); - // Define the logistic function parameters 'a' and 'b'. - let a = I32F32::from_num(1.0); - let b = I32F32::from_num(0.0); - - // Compute the alpha values using the function. - let alpha = SubtensorModule::compute_alpha_values(&consensus, a, b); - - // Ensure the length of the alpha vector matches the consensus vector. - assert_eq!(alpha.len(), consensus.len()); - - // Define an epsilon for approximate equality checks. - let epsilon = I32F32::from_num(1e-6); - - for (i, &c) in consensus.iter().enumerate() { - // Use saturating subtraction and multiplication - let exponent = b - (a * c); - - // Use safe_exp instead of exp - let exp_val = safe_exp(exponent); - - // Use saturating addition and division - let expected_alpha = I32F32::from_num(1.0) / (I32F32::from_num(1.0) + exp_val); - - // Assert that the computed alpha values match the expected values within the epsilon. - assert_approx_eq(alpha[i], expected_alpha, epsilon); - } -} - -#[test] -fn test_clamp_alpha_values() { - // Define the alpha values. - let alpha = vec![ - I32F32::from_num(0.1), - I32F32::from_num(0.5), - I32F32::from_num(0.9), - ]; - // Define the high and low clamping values. - let alpha_high = I32F32::from_num(0.8); - let alpha_low = I32F32::from_num(0.2); - - // Compute the clamped alpha values using the function. - let clamped_alpha = SubtensorModule::clamp_alpha_values(alpha.clone(), alpha_high, alpha_low); - - // Ensure the length of the clamped alpha vector matches the original alpha vector. - assert_eq!(clamped_alpha.len(), alpha.len()); - - // Manually compute the expected clamped alpha values for each alpha value. - // The clamping logic is: max(alpha_low, min(alpha_high, a)) - - // For alpha[0] = 0.1: - // clamped_a = max(0.2, min(0.8, 0.1)) = max(0.2, 0.1) = 0.2 - let expected_clamped_alpha_0 = I32F32::from_num(0.2); - - // For alpha[1] = 0.5: - // clamped_a = max(0.2, min(0.8, 0.5)) = max(0.2, 0.5) = 0.5 - let expected_clamped_alpha_1 = I32F32::from_num(0.5); - - // For alpha[2] = 0.9: - // clamped_a = max(0.2, min(0.8, 0.9)) = max(0.2, 0.8) = 0.8 - let expected_clamped_alpha_2 = I32F32::from_num(0.8); - - // Assert that the computed clamped alpha values match the expected values. - assert_eq!(clamped_alpha[0], expected_clamped_alpha_0); - assert_eq!(clamped_alpha[1], expected_clamped_alpha_1); - assert_eq!(clamped_alpha[2], expected_clamped_alpha_2); -} - -#[test] -fn test_calculate_logistic_params() { - // Define test inputs - let alpha_high = I32F32::from_num(0.9); - let alpha_low = I32F32::from_num(0.1); - let consensus_high = I32F32::from_num(0.8); - let consensus_low = I32F32::from_num(0.2); - - // Expected values - // a = (ln((1 / alpha_high - 1)) - ln((1 / alpha_low - 1))) / (consensus_low - consensus_high) - // = (ln((1 / 0.9 - 1)) - ln((1 / 0.1 - 1))) / (0.2 - 0.8) - // = (ln(0.1111) - ln(9)) / -0.6 - // = (-2.1972 - 2.1972) / -0.6 - // = -4.3944 / -0.6 - // = 7.324 - let expected_a = I32F32::from_num(7.324); - - // b = ln((1 / alpha_low - 1)) + a * consensus_low - // = ln((1 / 0.1 - 1)) + 7.324 * 0.2 - // = ln(9) + 1.4648 - // = 2.1972 + 1.4648 - // = 3.662 - let expected_b = I32F32::from_num(3.662); - - // Call the function - let (a, b) = SubtensorModule::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Assert the results - assert!( - (a - expected_a).abs() < I32F32::from_num(0.001), - "Expected a: {:?}, got: {:?}", - expected_a, - a - ); - assert!( - (b - expected_b).abs() < I32F32::from_num(0.001), - "Expected b: {:?}, got: {:?}", - expected_b, - b - ); -} - -#[test] -fn test_calculate_logistic_params_edge_cases() { - // Edge Case 1: Alpha values at their boundaries (0 and 1) - let alpha_high = I32F32::from_num(1.0); - let alpha_low = I32F32::from_num(0.0); - let consensus_high = I32F32::from_num(0.8); - let consensus_low = I32F32::from_num(0.2); - - // Call the function - let (a, b) = SubtensorModule::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Assert the results - assert_eq!(a, I32F32::from_num(0.0), "Expected a to be 0, got: {:?}", a); - assert_eq!(b, I32F32::from_num(0.0), "Expected b to be 0, got: {:?}", b); - - // Edge Case 2: Consensus values at their boundaries (0 and 1) - let alpha_high = I32F32::from_num(0.9); - let alpha_low = I32F32::from_num(0.1); - let consensus_high = I32F32::from_num(1.0); - let consensus_low = I32F32::from_num(0.0); - - // Call the function - let (a, b) = SubtensorModule::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Expected values - // a = (ln((1 / 0.9 - 1)) - ln((1 / 0.1 - 1))) / (0.0 - 1.0) - // = (ln(0.1111) - ln(9)) / -1.0 - // = (-2.1972 - 2.1972) / -1.0 - // = -4.3944 / -1.0 - // = 4.3944 - let expected_a = I32F32::from_num(4.3944); - - // b = ln((1 / 0.1 - 1)) + a * 0.0 - // = ln(9) + 0 - // = 2.1972 - let expected_b = I32F32::from_num(2.1972); - - // Assert the results - assert!( - (a - expected_a).abs() < I32F32::from_num(0.001), - "Expected a: {:?}, got: {:?}", - expected_a, - a - ); - assert!( - (b - expected_b).abs() < I32F32::from_num(0.001), - "Expected b: {:?}, got: {:?}", - expected_b, - b - ); - - // Edge Case 3: Alpha values being equal - let alpha_high = I32F32::from_num(0.5); - let alpha_low = I32F32::from_num(0.5); - let consensus_high = I32F32::from_num(0.8); - let consensus_low = I32F32::from_num(0.2); - - // Call the function - let (a, b) = SubtensorModule::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Assert the results - assert_eq!(a, I32F32::from_num(0.0), "Expected a to be 0, got: {:?}", a); - assert_eq!(b, I32F32::from_num(0.0), "Expected b to be 0, got: {:?}", b); - - // Edge Case 4: Consensus values being equal - let alpha_high = I32F32::from_num(0.9); - let alpha_low = I32F32::from_num(0.1); - let consensus_high = I32F32::from_num(0.5); - let consensus_low = I32F32::from_num(0.5); - - // Call the function - let (a, b) = SubtensorModule::calculate_logistic_params( - alpha_high, - alpha_low, - consensus_high, - consensus_low, - ); - - // Assert the results - assert_eq!(a, I32F32::from_num(0.0), "Expected a to be 0, got: {:?}", a); - assert_eq!(b, I32F32::from_num(0.0), "Expected b to be 0, got: {:?}", b); -} - #[test] fn test_compute_ema_bonds_sparse() { // Define test inputs @@ -3349,6 +3084,7 @@ fn setup_yuma_4_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak SubtensorModule::set_min_allowed_weights(netuid, 1); SubtensorModule::set_max_weight_limit(netuid, u16::MAX); SubtensorModule::set_bonds_penalty(netuid, 0); + // SubtensorModule::set_bonds_moving_average(netuid, 975_000); // === Register for key in 0..n as u64 { @@ -3381,8 +3117,9 @@ fn setup_yuma_4_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak // Enable Liquid Alpha SubtensorModule::set_kappa(netuid, u16::MAX / 2); SubtensorModule::set_liquid_alpha_enabled(netuid, true); + SubtensorModule::set_kappa(netuid, u16::MAX / 2); - SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.9), I32F32::from_num(0.99)); + SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.1), I32F32::from_num(0.3)); // === Issue validator permits SubtensorModule::set_max_allowed_validators(netuid, 3); @@ -3405,25 +3142,26 @@ fn run_epoch(netuid: u16, sparse: bool) { fn run_epoch_and_check_bonds_dividends( netuid: u16, sparse: bool, - target_bonds: &[Vec], + target_bonds: &[Vec], target_dividends: &[f32], ) { run_epoch(netuid, sparse); - let bonds = SubtensorModule::get_bonds(netuid); + let mut bonds = SubtensorModule::get_bonds(netuid); + bonds = mat_fixed_proportions_to_fixed(bonds.clone()); let dividends = SubtensorModule::get_dividends(netuid); + let epsilon = I32F32::from_num(1e-3); // Check the bonds // server 1 - assert_eq!(bonds[0][3], target_bonds[0][0]); - assert_eq!(bonds[1][3], target_bonds[1][0]); - assert_eq!(bonds[2][3], target_bonds[2][0]); + assert_approx_eq(bonds[0][3], fixed(target_bonds[0][0]), epsilon); + assert_approx_eq(bonds[1][3], fixed(target_bonds[1][0]), epsilon); + assert_approx_eq(bonds[2][3], fixed(target_bonds[2][0]), epsilon); // server 2 - assert_eq!(bonds[0][4], target_bonds[0][1]); - assert_eq!(bonds[1][4], target_bonds[1][1]); - assert_eq!(bonds[2][4], target_bonds[2][1]); + assert_approx_eq(bonds[0][4], fixed(target_bonds[0][1]), epsilon); + assert_approx_eq(bonds[1][4], fixed(target_bonds[1][1]), epsilon); + assert_approx_eq(bonds[2][4], fixed(target_bonds[2][1]), epsilon); // Check the dividends - let epsilon = I32F32::from_num(1e-3); for (dividend, target_dividend) in dividends.iter().zip(target_dividends.iter()) { assert_approx_eq( u16_proportion_to_fixed(*dividend), @@ -3448,7 +3186,7 @@ fn set_yuma_4_weights(netuid: u16, weights: Vec>) { #[test] fn test_yuma_4_kappa_moves_first() { new_test_ext(1).execute_with(|| { - let sparse: bool = false; + let sparse: bool = true; let n: u16 = 5; // 3 validators, 2 servers let netuid: u16 = 1; let max_stake: u64 = 8; @@ -3461,49 +3199,44 @@ fn test_yuma_4_kappa_moves_first() { setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ vec![ - vec![656, 0], - vec![656, 0], - vec![656, 0], - vec![0, 0], - vec![0, 0], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], ], vec![ - vec![590, 656], - vec![7144, 0], - vec![7144, 0], - vec![0, 0], - vec![0, 0], + vec![0.0908, 0.1013], + vec![0.3697, 0.0000], + vec![0.3697, 0.0000], ], vec![ - vec![530, 1305], - vec![6429, 656], - vec![12983, 0], - vec![0, 0], - vec![0, 0], + vec![0.0815, 0.1924], + vec![0.3170, 0.1013], + vec![0.5580, 0.0000], ], vec![ - vec![476, 1947], - vec![5786, 1305], - vec![11684, 656], - vec![0, 0], - vec![0, 0], + vec![0.0731, 0.2742], + vec![0.2765, 0.1924], + vec![0.4306, 0.1013], ], vec![ - vec![428, 2583], - vec![5207, 1947], - vec![10515, 1305], - vec![0, 0], - vec![0, 0], + vec![0.0656, 0.3478], + vec![0.2435, 0.2742], + vec![0.3589, 0.1924], + ], + vec![ + vec![0.0588, 0.4139], + vec![0.2157, 0.3478], + vec![0.3089, 0.2742], ], ]; let targets_dividends = [ vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], vec![1.0000, 0.0000, 0.0000, 0.0000, 0.0000], - vec![0.9409, 0.0591, 0.0000, 0.0000, 0.0000], - vec![0.8882, 0.0744, 0.0374, 0.0000, 0.0000], - vec![0.8640, 0.0814, 0.0545, 0.0000, 0.0000], - vec![0.8502, 0.0854, 0.0644, 0.0000, 0.0000], + vec![0.9382, 0.0618, 0.0000, 0.0000, 0.0000], + vec![0.8819, 0.0773, 0.0407, 0.0000, 0.0000], + vec![0.8564, 0.0844, 0.0592, 0.0000, 0.0000], + vec![0.8418, 0.0884, 0.0697, 0.0000, 0.0000], ]; for (epoch, (target_bonds, target_dividends)) in targets_bonds @@ -3548,7 +3281,7 @@ fn test_yuma_4_kappa_moves_first() { #[test] fn test_yuma_4_kappa_moves_second() { new_test_ext(1).execute_with(|| { - let sparse: bool = true; + let sparse: bool = false; let n: u16 = 5; // 3 validators, 2 servers let netuid: u16 = 1; let max_stake: u64 = 8; @@ -3561,48 +3294,43 @@ fn test_yuma_4_kappa_moves_second() { setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ vec![ - vec![656, 0], - vec![656, 0], - vec![656, 0], - vec![0, 0], - vec![0, 0], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.1924, 0.0000], + vec![0.0908, 0.2987], + vec![0.1924, 0.0000], ], vec![ - vec![1305, 0], - vec![649, 6553], - vec![1305, 0], - vec![0, 0], - vec![0, 0], + vec![0.1715, 0.1013], + vec![0.0815, 0.3697], + vec![0.4336, 0.0000], ], vec![ - vec![1174, 656], - vec![584, 7143], - vec![7728, 0], - vec![0, 0], - vec![0, 0], + vec![0.1531, 0.1924], + vec![0.0731, 0.4336], + vec![0.3608, 0.1013], ], vec![ - vec![1056, 1305], - vec![525, 7727], - vec![6955, 656], - vec![0, 0], - vec![0, 0], + vec![0.1369, 0.2742], + vec![0.0656, 0.4910], + vec![0.3103, 0.1924], ], vec![ - vec![950, 1947], - vec![472, 8305], - vec![6259, 1305], - vec![0, 0], - vec![0, 0], + vec![0.1225, 0.3478], + vec![0.0588, 0.5426], + vec![0.2712, 0.2742], ], ]; let targets_dividends = [ - vec![0.8000, 0.1000, 0.1000], - vec![0.8423, 0.0524, 0.1053], - vec![0.4233, 0.5767, 0.0000], - vec![0.5545, 0.4107, 0.0348], - vec![0.6184, 0.3298, 0.0518], - vec![0.6562, 0.2820, 0.0618], + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], + vec![0.8446, 0.0498, 0.1056, 0.0000, 0.0000], + vec![0.6868, 0.3132, 0.0000, 0.0000, 0.0000], + vec![0.7421, 0.2090, 0.0489, 0.0000, 0.0000], + vec![0.7625, 0.1706, 0.0669, 0.0000, 0.0000], + vec![0.7730, 0.1508, 0.0762, 0.0000, 0.0000], ]; for (epoch, (target_bonds, target_dividends)) in targets_bonds @@ -3659,19 +3387,44 @@ fn test_yuma_4_kappa_moves_last() { setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ - vec![vec![656, 0], vec![656, 0], vec![656, 0]], - vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]], - vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]], - vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]], - vec![vec![1576, 1305], vec![519, 13508], vec![1044, 7727]], + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.1924, 0.0000], + vec![0.0908, 0.2987], + vec![0.1924, 0.0000], + ], + vec![ + vec![0.2742, 0.0000], + vec![0.0815, 0.5081], + vec![0.1715, 0.2987], + ], + vec![ + vec![0.2416, 0.1013], + vec![0.0731, 0.5580], + vec![0.1531, 0.3697], + ], + vec![ + vec![0.2141, 0.1924], + vec![0.0656, 0.6028], + vec![0.1369, 0.4336], + ], + vec![ + vec![0.1903, 0.2742], + vec![0.0588, 0.6430], + vec![0.1225, 0.4910], + ], ]; let targets_dividends = [ - vec![0.8000, 0.1000, 0.1000], - vec![0.8423, 0.0524, 0.1053], - vec![0.8895, 0.0367, 0.0738], - vec![0.2067, 0.5117, 0.2816], - vec![0.3294, 0.4265, 0.2440], - vec![0.4108, 0.3701, 0.2191], + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], + vec![0.8446, 0.0498, 0.1056, 0.0000, 0.0000], + vec![0.8966, 0.0333, 0.0701, 0.0000, 0.0000], + vec![0.4663, 0.3210, 0.2127, 0.0000, 0.0000], + vec![0.5976, 0.2340, 0.1683, 0.0000, 0.0000], + vec![0.6592, 0.1932, 0.1475, 0.0000, 0.0000], ]; for (epoch, (target_bonds, target_dividends)) in targets_bonds @@ -3727,18 +3480,44 @@ fn test_yuma_4_one_epoch_switch() { setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ - vec![vec![656, 0], vec![656, 0], vec![656, 0]], - vec![vec![1305, 0], vec![1305, 0], vec![1305, 0]], - vec![vec![1291, 6553], vec![1947, 0], vec![1947, 0]], - vec![vec![1934, 5897], vec![2583, 0], vec![2583, 0]], - vec![vec![2570, 5307], vec![3213, 0], vec![3213, 0]], + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.1924, 0.0000], + vec![0.1924, 0.0000], + vec![0.1924, 0.0000], + ], + vec![ + vec![0.2742, 0.0000], + vec![0.2742, 0.0000], + vec![0.1715, 0.2987], + ], + vec![ + vec![0.3478, 0.0000], + vec![0.3478, 0.0000], + vec![0.2554, 0.2618], + ], + vec![ + vec![0.4139, 0.0000], + vec![0.4139, 0.0000], + vec![0.3309, 0.2312], + ], + vec![ + vec![0.4733, 0.0000], + vec![0.4733, 0.0000], + vec![0.3987, 0.2051], + ], ]; let targets_dividends = [ - vec![0.33, 0.33, 0.34, 0., 0.], - vec![0.33, 0.33, 0.34, 0., 0.], - vec![0.246_231_48, 0.371_259_12, 0.382_509_4, 0., 0.], - vec![0.269_393_1, 0.359_851_15, 0.370_755_73, 0., 0.], - vec![0.282_665_13, 0.353_314_2, 0.364_020_68, 0., 0.], + vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], + vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], + vec![0.3782, 0.3782, 0.2436, 0.0000, 0.0000], + vec![0.3628, 0.3628, 0.2745, 0.0000, 0.0000], + vec![0.3541, 0.3541, 0.2917, 0.0000, 0.0000], + vec![0.3487, 0.3487, 0.3026, 0.0000, 0.0000], ]; for (epoch, (target_bonds, target_dividends)) in targets_bonds @@ -3748,12 +3527,12 @@ fn test_yuma_4_one_epoch_switch() { { match epoch { 2 => { - // Validator A -> Server 2 + // Validator A -> Server 1 // Validator B -> Server 1 - // Validator C -> Server 1 + // Validator C -> Server 2 set_yuma_4_weights( netuid, - vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], + vec![vec![u16::MAX, 0], vec![u16::MAX, 0], vec![0, u16::MAX]], ); } _ => { From 197fd0b2afa88cdcd9ad1acd1b4d572e3c48bb2e Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 20 Mar 2025 10:09:36 +0000 Subject: [PATCH 029/226] fix math tests --- pallets/subtensor/src/epoch/math.rs | 63 ----------- pallets/subtensor/src/tests/epoch.rs | 64 +---------- pallets/subtensor/src/tests/math.rs | 155 +++++++++++++++++---------- 3 files changed, 101 insertions(+), 181 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 5737e31c97..9ae6be617f 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1539,69 +1539,6 @@ pub fn mat_ema_alpha_sparse( result } -/// Return matrix exponential moving average: `alpha_j * a_ij + one_minus_alpha_j * b_ij`. -/// `alpha_` is the EMA coefficient passed as a vector per column. -// if liquid alpha off then the alpha vector will be constant -#[allow(dead_code)] -pub fn mat_ema_alpha_vec( - new: &[Vec], - old: &[Vec], - alpha: &[I32F32], -) -> Vec> { - // Check if the new matrix is empty or its first row is empty. - if new.is_empty() || new.first().is_none_or(|row| row.is_empty()) { - return vec![vec![]; 1]; - } - - // Ensure the dimensions of the new and old matrices match. - assert!(new.len() == old.len()); - assert!(new.first().map_or(0, |row| row.len()) == alpha.len()); - - // Initialize the result matrix with zeros, having the same dimensions as the new matrix. - let mut result: Vec> = - vec![ - vec![I32F32::saturating_from_num(0.0); new.first().map_or(0, |row| row.len())]; - new.len() - ]; - - // Iterate over each row of the matrices. - for (i, (new_row, old_row)) in new.iter().zip(old).enumerate() { - assert!(new_row.len() == old_row.len()); - - // Iterate over each column of the current row. - for (j, &alpha_val) in alpha.iter().enumerate().take(new_row.len()) { - // Calculate the complement of the alpha value using saturating subtraction. - let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(alpha_val); - - // Compute the EMA for the current element using saturating operations. - if let (Some(new_val), Some(old_val), Some(result_val)) = ( - new_row.get(j), - old_row.get(j), - result.get_mut(i).and_then(|row| row.get_mut(j)), - ) { - let decayed_val = one_minus_alpha.saturating_mul(*old_val); - let remaining_capacity = I32F32::from_num(1.0) - .saturating_sub(decayed_val) - .max(I32F32::from_num(0.0)); - - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap - // Validators allocate their purchase across miners based on weights - let purchase_increment = alpha_val.saturating_mul(*new_val); - - // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.min(remaining_capacity); - - *result_val = decayed_val - .saturating_add(purchase) - .min(I32F32::from_num(1.0)); - } - } - } - - // Return the computed EMA matrix. - result -} - /// Return the quantile of a vector of I32F32 values. pub fn quantile(data: &[I32F32], quantile: f64) -> I32F32 { // Clone the input data to avoid modifying the original vector. diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index e1bca93858..89812bfb27 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -5,9 +5,7 @@ )] use super::mock::*; -use crate::epoch::math::{ - fixed, mat_fixed_proportions_to_fixed, safe_exp, u16_proportion_to_fixed, -}; +use crate::epoch::math::{fixed, mat_fixed_proportions_to_fixed, u16_proportion_to_fixed}; use crate::*; use approx::assert_abs_diff_eq; @@ -2578,66 +2576,6 @@ fn test_validator_permits() { } } -#[test] -fn test_compute_ema_bonds_sparse() { - // Define test inputs - let weights = vec![ - vec![(0, I32F32::from_num(0.1)), (1, I32F32::from_num(0.2))], - vec![(0, I32F32::from_num(0.3)), (1, I32F32::from_num(0.4))], - ]; - let bonds = vec![ - vec![(0, I32F32::from_num(0.5)), (1, I32F32::from_num(0.6))], - vec![(0, I32F32::from_num(0.7)), (1, I32F32::from_num(0.8))], - ]; - let alpha = vec![I32F32::from_num(0.9), I32F32::from_num(0.8)]; - - // Expected values - // EMA calculation for each bond: - // EMA = alpha * bond_delta + (1 - alpha) * bond - // For bond (0, 0): - // EMA = 0.9 * 0.1 + (1 - 0.9) * 0.5 = 0.09 + 0.05 = 0.14 - // For bond (0, 1): - // EMA = 0.8 * 0.2 + (1 - 0.8) * 0.6 = 0.16 + 0.12 = 0.28 - // For bond (1, 0): - // EMA = 0.9 * 0.3 + (1 - 0.9) * 0.7 = 0.27 + 0.07 = 0.34 - // For bond (1, 1): - // EMA = 0.8 * 0.4 + (1 - 0.8) * 0.8 = 0.32 + 0.16 = 0.48 - - let expected_ema_bonds = vec![ - vec![(0, I32F32::from_num(0.14)), (1, I32F32::from_num(0.28))], - vec![(0, I32F32::from_num(0.34)), (1, I32F32::from_num(0.48))], - ]; - - // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); - - // Assert the results with an epsilon for approximate equality - let epsilon = I32F32::from_num(1e-6); - - assert_approx_eq_vec_of_vec(&ema_bonds, &expected_ema_bonds, epsilon); -} - -#[test] -fn test_compute_ema_bonds_sparse_empty() { - // Test with empty inputs - let weights: Vec> = vec![]; - let bonds: Vec> = vec![]; - let alpha: Vec = vec![]; - - // Expected values: Empty Vec - let expected_ema_bonds: Vec> = vec![]; - - // Call the function - let ema_bonds = SubtensorModule::compute_ema_bonds_sparse(&weights, &bonds, alpha); - - // Assert the results - assert_eq!( - ema_bonds, expected_ema_bonds, - "Expected EMA bonds: {:?}, got: {:?}", - expected_ema_bonds, ema_bonds - ); -} - #[test] fn test_get_set_alpha() { new_test_ext(1).execute_with(|| { diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index b12e84852a..01e02742b7 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -2150,19 +2150,20 @@ fn test_math_hadamard_sparse() { } #[test] -fn test_math_mat_ema() { +fn test_math_mat_ema_alpha() { let old: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; let new: Vec = vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.]; let target: Vec = vec![ - 0.19, 0.38, 1., 0.4359, 0.545, 0.6539, 0.763, 0.8719, 0.981, 1., 1., 1., + 0.19, 0.38, 1., 0.436, 0.545, 0.6539, 0.763, 0.8719, 0.981, 1., 1., 1., ]; let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(0.1); 3]); + let alphas = vec_to_mat_fixed(&[0.1; 12], 4, false); + let result = mat_ema_alpha(&new, &old, &alphas); assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, @@ -2176,7 +2177,8 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(0); 3]); + let alphas = vec_to_mat_fixed(&[0.; 12], 4, false); + let result = mat_ema_alpha(&new, &old, &alphas); assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![ 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, @@ -2191,12 +2193,13 @@ fn test_math_mat_ema() { let old = vec_to_mat_fixed(&old, 4, false); let new = vec_to_mat_fixed(&new, 4, false); let target = vec_to_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec(&new, &old, &[I32F32::from_num(1); 3]); + let alphas = vec_to_mat_fixed(&[1.; 12], 4, false); + let result = mat_ema_alpha(&new, &old, &alphas); assert_mat_compare(&result, &target, I32F32::from_num(1e-4)); } #[test] -fn test_math_sparse_mat_ema() { +fn test_math_sparse_mat_ema_alpha() { let old: Vec = vec![ 0.1, 0.2, 3., 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, ]; @@ -2207,7 +2210,8 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); + let alphas = vec_to_mat_fixed(&[0.1; 12], 4, false); + let result = mat_ema_alpha_sparse(&new, &old, &alphas); assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![ 0.001, 0.002, 0.003, 0.004, 0.05, 0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, @@ -2222,7 +2226,8 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); + let alphas = vec_to_mat_fixed(&[0.1; 12], 4, false); + let result = mat_ema_alpha_sparse(&new, &old, &alphas); assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![ @@ -2234,7 +2239,8 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); + let alphas = vec_to_mat_fixed(&[0.1; 12], 4, false); + let result = mat_ema_alpha_sparse(&new, &old, &alphas); assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; @@ -2242,16 +2248,18 @@ fn test_math_sparse_mat_ema() { let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); + let alphas = vec_to_mat_fixed(&[0.1; 12], 4, false); + let result = mat_ema_alpha_sparse(&new, &old, &alphas); assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); let old: Vec = vec![1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]; let new: Vec = vec![0., 0., 0., 0., 2., 0., 0., 0., 0., 0., 0., 0.]; - let target: Vec = vec![0.9, 0., 0., 0., 0.2, 0., 0., 0., 0., 0., 0., 0.]; + let target: Vec = vec![0.0, 0., 0., 0., 0.2, 0., 0., 0., 0., 0., 0., 0.]; let old = vec_to_sparse_mat_fixed(&old, 4, false); let new = vec_to_sparse_mat_fixed(&new, 4, false); let target = vec_to_sparse_mat_fixed(&target, 4, false); - let result = mat_ema_alpha_vec_sparse(&new, &old, &vec![I32F32::from_num(0.1); old.len()]); - assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-4)); + let alphas = vec_to_mat_fixed(&[0.1; 12], 4, false); + let result = mat_ema_alpha_sparse(&new, &old, &alphas); + assert_sparse_mat_compare(&result, &target, I32F32::from_num(1e-1)); } #[test] @@ -2541,25 +2549,25 @@ fn test_checked_sum() { } #[test] -fn test_mat_ema_alpha_vec_sparse_empty() { +fn test_mat_ema_alpha_sparse_empty() { let new: Vec> = Vec::new(); let old: Vec> = Vec::new(); - let alpha: Vec = Vec::new(); - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha: Vec> = Vec::new(); + let result = mat_ema_alpha_sparse(&new, &old, &alpha); assert_eq!(result, Vec::>::new()); } #[test] -fn test_mat_ema_alpha_vec_sparse_single_element() { +fn test_mat_ema_alpha_sparse_single_element() { let new: Vec> = vec![vec![(0, I32F32::from_num(1.0))]]; let old: Vec> = vec![vec![(0, I32F32::from_num(2.0))]]; - let alpha: Vec = vec![I32F32::from_num(0.5)]; - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha = vec![vec![I32F32::from_num(0.5)]]; + let result = mat_ema_alpha_sparse(&new, &old, &alpha); assert_eq!(result, vec![vec![(0, I32F32::from_num(1.0))]]); } #[test] -fn test_mat_ema_alpha_vec_sparse_multiple_elements() { +fn test_mat_ema_alpha_sparse_multiple_elements() { let new: Vec> = vec![ vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(2.0))], vec![(0, I32F32::from_num(3.0)), (1, I32F32::from_num(4.0))], @@ -2568,8 +2576,8 @@ fn test_mat_ema_alpha_vec_sparse_multiple_elements() { vec![(0, I32F32::from_num(5.0)), (1, I32F32::from_num(6.0))], vec![(0, I32F32::from_num(7.0)), (1, I32F32::from_num(8.0))], ]; - let alpha: Vec = vec![I32F32::from_num(0.1), I32F32::from_num(0.2)]; - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha = vec![vec![I32F32::from_num(0.1), I32F32::from_num(0.2)]; 2]; + let result = mat_ema_alpha_sparse(&new, &old, &alpha); let expected = vec![ vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(1.0))], vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(1.0))], @@ -2578,25 +2586,25 @@ fn test_mat_ema_alpha_vec_sparse_multiple_elements() { } #[test] -fn test_mat_ema_alpha_vec_sparse_zero_alpha() { +fn test_mat_ema_alpha_sparse_zero_alpha() { let new: Vec> = vec![vec![(0, I32F32::from_num(1.0))]]; let old: Vec> = vec![vec![(0, I32F32::from_num(2.0))]]; - let alpha: Vec = vec![I32F32::from_num(0.0)]; - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha = vec![vec![I32F32::from_num(0.1), I32F32::from_num(0.0)]]; + let result = mat_ema_alpha_sparse(&new, &old, &alpha); assert_eq!(result, vec![vec![(0, I32F32::from_num(1.0))]]); } #[test] -fn test_mat_ema_alpha_vec_sparse_one_alpha() { +fn test_mat_ema_alpha_sparse_one_alpha() { let new: Vec> = vec![vec![(0, I32F32::from_num(1.0))]]; let old: Vec> = vec![vec![(0, I32F32::from_num(2.0))]]; - let alpha: Vec = vec![I32F32::from_num(1.0)]; - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha = vec![vec![I32F32::from_num(1.0), I32F32::from_num(0.0)]]; + let result = mat_ema_alpha_sparse(&new, &old, &alpha); assert_eq!(result, vec![vec![(0, I32F32::from_num(1.0))]]); } #[test] -fn test_mat_ema_alpha_vec_sparse_mixed_alpha() { +fn test_mat_ema_alpha_sparse_mixed_alpha() { let new: Vec> = vec![ vec![(0, I32F32::from_num(1.0)), (1, I32F32::from_num(2.0))], vec![(0, I32F32::from_num(3.0)), (1, I32F32::from_num(4.0))], @@ -2605,8 +2613,8 @@ fn test_mat_ema_alpha_vec_sparse_mixed_alpha() { vec![(0, I32F32::from_num(5.0)), (1, I32F32::from_num(6.0))], vec![(0, I32F32::from_num(7.0)), (1, I32F32::from_num(8.0))], ]; - let alpha: Vec = vec![I32F32::from_num(0.3), I32F32::from_num(0.7)]; - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha = vec![vec![I32F32::from_num(0.3), I32F32::from_num(0.7)]; 2]; + let result = mat_ema_alpha_sparse(&new, &old, &alpha); assert_sparse_mat_compare( &result, &[ @@ -2618,7 +2626,7 @@ fn test_mat_ema_alpha_vec_sparse_mixed_alpha() { } #[test] -fn test_mat_ema_alpha_vec_sparse_sparse_matrix() { +fn test_mat_ema_alpha_sparse_sparse_matrix() { let new: Vec> = vec![ vec![(0, I32F32::from_num(1.0))], vec![(1, I32F32::from_num(4.0))], @@ -2627,8 +2635,8 @@ fn test_mat_ema_alpha_vec_sparse_sparse_matrix() { vec![(0, I32F32::from_num(5.0))], vec![(1, I32F32::from_num(8.0))], ]; - let alpha: Vec = vec![I32F32::from_num(0.5), I32F32::from_num(0.5)]; - let result = mat_ema_alpha_vec_sparse(&new, &old, &alpha); + let alpha = vec![vec![I32F32::from_num(0.5), I32F32::from_num(0.5)]; 2]; + let result = mat_ema_alpha_sparse(&new, &old, &alpha); assert_eq!( result, vec![ @@ -2639,65 +2647,102 @@ fn test_mat_ema_alpha_vec_sparse_sparse_matrix() { } #[test] -fn test_mat_ema_alpha_vec_basic() { +fn test_mat_ema_alpha_basic() { let new = mat_to_fixed(&[vec![1.0, 2.0, 3.0], vec![4.0, 5.0, 6.0]]); let old = mat_to_fixed(&[vec![0.5, 1.5, 2.5], vec![3.5, 4.5, 5.5]]); let alpha = vec![ - I32F32::from_num(0.5), - I32F32::from_num(0.5), - I32F32::from_num(0.5), + vec![ + I32F32::from_num(0.5), + I32F32::from_num(0.5), + I32F32::from_num(0.5), + ]; + 2 ]; let expected = mat_to_fixed(&[vec![0.75, 1.0, 1.0], vec![1.0, 1.0, 1.0]]); - let result = mat_ema_alpha_vec(&new, &old, &alpha); + let result = mat_ema_alpha(&new, &old, &alpha); assert_eq!(result, expected); } #[test] -fn test_mat_ema_alpha_vec_varying_alpha() { +fn test_mat_ema_alpha_varying_alpha() { let new = mat_to_fixed(&[vec![1.0, 2.0, 3.0], vec![4.0, 5.0, 6.0]]); let old = mat_to_fixed(&[vec![0.5, 1.5, 2.5], vec![3.5, 4.5, 5.5]]); let alpha = vec![ - I32F32::from_num(0.2), - I32F32::from_num(0.5), - I32F32::from_num(0.8), + vec![ + I32F32::from_num(0.2), + I32F32::from_num(0.5), + I32F32::from_num(0.8), + ]; + 2 ]; let expected = mat_to_fixed(&[vec![0.6, 1.0, 1.0], vec![1.0, 1.0, 1.0]]); - let result = mat_ema_alpha_vec(&new, &old, &alpha); + let result = mat_ema_alpha(&new, &old, &alpha); assert_mat_approx_eq(&result, &expected, I32F32::from_num(1e-6)); } #[test] -fn test_mat_ema_alpha_vec_empty_matrices() { +fn test_mat_ema_alpha_sparse_varying_alpha() { + let weights = vec![ + vec![(0, I32F32::from_num(0.1)), (1, I32F32::from_num(0.2))], + vec![(0, I32F32::from_num(0.3)), (1, I32F32::from_num(0.4))], + ]; + let bonds = vec![ + vec![(0, I32F32::from_num(0.5)), (1, I32F32::from_num(0.6))], + vec![(0, I32F32::from_num(0.7)), (1, I32F32::from_num(0.8))], + ]; + let alpha = vec![ + vec![I32F32::from_num(0.9), I32F32::from_num(0.8)], + vec![I32F32::from_num(0.5), I32F32::from_num(0.7)], + ]; + + let expected = vec![ + vec![(0, I32F32::from_num(0.14)), (1, I32F32::from_num(0.28))], + vec![ + (0, I32F32::from_num(0.499999)), + (1, I32F32::from_num(0.519999)), + ], + ]; + + let result = mat_ema_alpha_sparse(&weights, &bonds, &alpha); + // Assert the results with an epsilon for approximate equality + assert_sparse_mat_compare(&result, &expected, I32F32::from_num(1e-6)); +} + +#[test] +fn test_mat_ema_alpha_empty_matrices() { let new: Vec> = vec![]; let old: Vec> = vec![]; - let alpha: Vec = vec![]; + let alpha = vec![]; let expected: Vec> = vec![vec![]; 1]; - let result = mat_ema_alpha_vec(&new, &old, &alpha); + let result = mat_ema_alpha(&new, &old, &alpha); assert_eq!(result, expected); } #[test] -fn test_mat_ema_alpha_vec_single_element() { +fn test_mat_ema_alpha_single_element() { let new = mat_to_fixed(&[vec![1.0]]); let old = mat_to_fixed(&[vec![0.5]]); - let alpha = vec![I32F32::from_num(0.5)]; + let alpha = vec![vec![I32F32::from_num(0.5)]]; let expected = mat_to_fixed(&[vec![0.75]]); - let result = mat_ema_alpha_vec(&new, &old, &alpha); + let result = mat_ema_alpha(&new, &old, &alpha); assert_eq!(result, expected); } // TODO: (@sd): Should these be non panicking? #[test] #[should_panic(expected = "assertion failed")] -fn test_mat_ema_alpha_vec_mismatched_dimensions() { +fn test_mat_ema_alpha_mismatched_dimensions() { let new = mat_to_fixed(&[vec![1.0, 2.0], vec![3.0, 4.0]]); let old = mat_to_fixed(&[vec![1.0, 2.0, 3.0], vec![4.0, 5.0, 6.0]]); let alpha = vec![ - I32F32::from_num(0.5), - I32F32::from_num(0.5), - I32F32::from_num(0.5), + vec![ + I32F32::from_num(0.5), + I32F32::from_num(0.5), + I32F32::from_num(0.5), + ]; + 2 ]; - let _result = mat_ema_alpha_vec(&new, &old, &alpha); + let _result = mat_ema_alpha(&new, &old, &alpha); } #[test] From 37057d3f70349f78cbd1a0ef5f2da772e563237a Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 20 Mar 2025 14:08:17 +0000 Subject: [PATCH 030/226] cleanup fixes --- pallets/subtensor/src/epoch/math.rs | 171 ++-- pallets/subtensor/src/epoch/run_epoch.rs | 28 +- pallets/subtensor/src/tests/epoch.rs | 954 ++++++++++++----------- 3 files changed, 559 insertions(+), 594 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 9ae6be617f..9d783acc11 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -55,11 +55,6 @@ pub fn u16_proportion_to_fixed(x: u16) -> I32F32 { I32F32::saturating_from_num(x).safe_div(I32F32::saturating_from_num(u16::MAX)) } -#[allow(dead_code)] -pub fn fixed_proportion_to_fixed(x: I32F32) -> I32F32 { - x.safe_div(I32F32::saturating_from_num(u16::MAX)) -} - #[allow(dead_code)] pub fn fixed_proportion_to_u16(x: I32F32) -> u16 { fixed_to_u16(x.saturating_mul(I32F32::saturating_from_num(u16::MAX))) @@ -85,28 +80,11 @@ pub fn vec_fixed64_to_u64(vec: Vec) -> Vec { vec.into_iter().map(fixed64_to_u64).collect() } -#[allow(dead_code)] -pub fn vec_fixed_proportions_to_fixed(vec: Vec) -> Vec { - vec.into_iter().map(fixed_proportion_to_fixed).collect() -} - #[allow(dead_code)] pub fn vec_fixed_proportions_to_u16(vec: Vec) -> Vec { vec.into_iter().map(fixed_proportion_to_u16).collect() } -#[allow(dead_code)] -pub fn mat_fixed_proportions_to_u16(mat: Vec>) -> Vec> { - mat.into_iter().map(vec_fixed_proportions_to_u16).collect() -} - -#[allow(dead_code)] -pub fn mat_fixed_proportions_to_fixed(mat: Vec>) -> Vec> { - mat.into_iter() - .map(vec_fixed_proportions_to_fixed) - .collect() -} - #[allow(dead_code)] // Max-upscale vector and convert to u16 so max_value = u16::MAX. Assumes non-negative normalized input. pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec { @@ -1316,19 +1294,6 @@ pub fn hadamard_sparse( result } -// Return sparse matrix only with elements >= threshold of an input sparse matrix. -#[allow(dead_code)] -pub fn sparse_threshold(w: &[Vec<(u16, I32F32)>], threshold: I32F32) -> Vec> { - w.iter() - .map(|row| { - row.iter() - .filter(|(_, weight)| *weight >= threshold) - .copied() - .collect() - }) - .collect() -} - /// Clamp the input value between high and low. pub fn clamp_value(value: I32F32, low: I32F32, high: I32F32) -> I32F32 { // First, clamp the value to ensure it does not exceed the upper bound (high). @@ -1402,78 +1367,7 @@ pub fn mat_ema_sparse( result } -/// Return matrix exponential moving average: `alpha_j * a_ij + one_minus_alpha_j * b_ij`. -/// `alpha_` is the EMA coefficient passed as a vector per column. -#[allow(dead_code)] -pub fn mat_ema_alpha( - new: &[Vec], // Weights - old: &[Vec], // Bonds - alpha: &[Vec], -) -> Vec> { - // Check if the new matrix is empty or its first row is empty. - if new.is_empty() || new.first().is_none_or(|row| row.is_empty()) { - return vec![vec![]; 1]; - } - - // Ensure the dimensions of the new, old and alpha matrices match. - assert!(new.len() == old.len()); - assert!(new.len() == alpha.len()); - - // Initialize the result matrix with zeros, having the same dimensions as the new matrix. - let mut result: Vec> = - vec![ - vec![I32F32::saturating_from_num(0.0); new.first().map_or(0, |row| row.len())]; - new.len() - ]; - - // Iterate over each row of the matrices. - for (i, ((new_row, old_row), alpha_row)) in new.iter().zip(old).zip(alpha).enumerate() { - assert!(new_row.len() == old_row.len()); - assert!(new_row.len() == alpha_row.len()); - - // Iterate over each column of the current row. - for j in 0..new_row.len() { - // Compute the EMA for the current element using saturating operations. - if let (Some(new_val), Some(old_val), Some(alpha_val), Some(result_val)) = ( - new_row.get(j), - old_row.get(j), - alpha_row.get(j), - result.get_mut(i).and_then(|row| row.get_mut(j)), - ) { - // Calculate the complement of the alpha value - let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(*alpha_val); - - // Bonds_decayed = Bonds * (1 - alpha) - let decayed_val = one_minus_alpha.saturating_mul(*old_val); - - // Calculate remaining capacity to limit bonds purchase - let remaining_capacity = I32F32::from_num(1.0) - .saturating_sub(decayed_val) - .max(I32F32::from_num(0.0)); - - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap - // Validators allocate their purchase across miners based on weights - let purchase_increment = alpha_val.saturating_mul(*new_val); - - // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.min(remaining_capacity); - - *result_val = decayed_val - .saturating_add(purchase) - .min(I32F32::from_num(1.0)); - } - } - } - - // Return the computed EMA matrix. - result -} - /// Calculates the exponential moving average (EMA) for a sparse matrix using dynamic alpha values. -/// Return matrix exponential moving average: `alpha_j * a_ij + one_minus_alpha_j * b_ij`. -// `alpha` is the EMA coefficient, how much to add of the new observation, typically small, -// higher alpha discounts older observations faster. -// if liquid alpha off then the alpha vector will be constant #[allow(dead_code)] pub fn mat_ema_alpha_sparse( new: &[Vec<(u16, I32F32)>], @@ -1539,6 +1433,71 @@ pub fn mat_ema_alpha_sparse( result } +/// Calculates the exponential moving average (EMA) for a dense matrix using dynamic alpha values. +#[allow(dead_code)] +pub fn mat_ema_alpha( + new: &[Vec], // Weights + old: &[Vec], // Bonds + alpha: &[Vec], +) -> Vec> { + // Check if the new matrix is empty or its first row is empty. + if new.is_empty() || new.first().is_none_or(|row| row.is_empty()) { + return vec![vec![]; 1]; + } + + // Ensure the dimensions of the new, old and alpha matrices match. + assert!(new.len() == old.len()); + assert!(new.len() == alpha.len()); + + // Initialize the result matrix with zeros, having the same dimensions as the new matrix. + let mut result: Vec> = + vec![ + vec![I32F32::saturating_from_num(0.0); new.first().map_or(0, |row| row.len())]; + new.len() + ]; + + // Iterate over each row of the matrices. + for (i, ((new_row, old_row), alpha_row)) in new.iter().zip(old).zip(alpha).enumerate() { + assert!(new_row.len() == old_row.len()); + assert!(new_row.len() == alpha_row.len()); + + // Iterate over each column of the current row. + for j in 0..new_row.len() { + // Compute the EMA for the current element using saturating operations. + if let (Some(new_val), Some(old_val), Some(alpha_val), Some(result_val)) = ( + new_row.get(j), + old_row.get(j), + alpha_row.get(j), + result.get_mut(i).and_then(|row| row.get_mut(j)), + ) { + // Calculate the complement of the alpha value + let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(*alpha_val); + + // Bonds_decayed = Bonds * (1 - alpha) + let decayed_val = one_minus_alpha.saturating_mul(*old_val); + + // Calculate remaining capacity to limit bonds purchase + let remaining_capacity = I32F32::from_num(1.0) + .saturating_sub(decayed_val) + .max(I32F32::from_num(0.0)); + + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + let purchase_increment = alpha_val.saturating_mul(*new_val); + + // Ensure that purchase does not exceed remaining capacity + let purchase = purchase_increment.min(remaining_capacity); + + *result_val = decayed_val + .saturating_add(purchase) + .min(I32F32::from_num(1.0)); + } + } + } + + // Return the computed EMA matrix. + result +} /// Return the quantile of a vector of I32F32 values. pub fn quantile(data: &[I32F32], quantile: f64) -> I32F32 { // Clone the input data to avoid modifying the original vector. diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 2b3037ee94..347828b6f3 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -200,7 +200,6 @@ impl Pallet { // Access network bonds. let mut bonds: Vec> = Self::get_bonds(netuid); inplace_mask_matrix(&outdated, &mut bonds); // mask outdated bonds - bonds = mat_fixed_proportions_to_fixed(bonds.clone()); // TODO log::trace!("B: {:?}", &bonds); // Compute the Exponential Moving Average (EMA) of bonds. @@ -587,16 +586,7 @@ impl Pallet { &block_at_registration, &|last_tempo, registered| last_tempo <= registered, ); - log::trace!("Bonds (outdatedmask): {:?}", &bonds); - - let mut result: Vec> = vec![vec![]; bonds.len()]; - for (i, sparse_row) in bonds.iter().enumerate() { - for (j, value) in sparse_row { - result[i].push((*j, fixed_proportion_to_fixed(*value))); - } - } - let bonds = result; - log::trace!("Bonds: (mask+norm) {:?}", &bonds); + log::trace!("Bonds: (mask) {:?}", &bonds); // Compute the Exponential Moving Average (EMA) of bonds. log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); @@ -867,7 +857,7 @@ impl Pallet { bonds .get_mut(uid_i as usize) .expect("uid_i is filtered to be less than n; qed") - .push((uid_j, I32F32::saturating_from_num(bonds_ij))); + .push((uid_j, u16_proportion_to_fixed(bonds_ij))); } } bonds @@ -887,7 +877,7 @@ impl Pallet { .expect("uid_i has been filtered to be less than n; qed") .get_mut(uid_j as usize) .expect("uid_j has been filtered to be less than n; qed") = - I32F32::saturating_from_num(bonds_ij); + u16_proportion_to_fixed(bonds_ij); } } bonds @@ -932,16 +922,14 @@ impl Pallet { // Compute bonds delta column normalized. let mut bonds_delta: Vec> = row_hadamard(weights, active_stake); // ΔB = W◦S inplace_col_normalize(&mut bonds_delta); // sum_i b_ij = 1 - log::trace!("ΔB:\n{:?}\n", &bonds_delta); + log::trace!("ΔB: {:?}", &bonds_delta); // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - - // Return the computed EMA bonds. mat_ema(&bonds_delta, bonds, alpha) } } - /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting + /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting for a sparse matrix. /// /// # Args: /// * `netuid` - The network ID. @@ -983,11 +971,9 @@ impl Pallet { let mut bonds_delta: Vec> = row_hadamard_sparse(weights, active_stake); // ΔB = W◦S inplace_col_normalize_sparse(&mut bonds_delta, n); // sum_i b_ij = 1 - log::trace!("ΔB:\n{:?}\n", &bonds_delta); + log::trace!("ΔB: {:?}", &bonds_delta); // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - - // Return the computed EMA bonds. mat_ema_sparse(&bonds_delta, bonds, alpha) } } @@ -1065,7 +1051,7 @@ impl Pallet { /// * `consensus` - A vector of consensus values. /// /// # Returns: - /// A matrix of alphas (not sparse as very few values will be zero) + /// A dense matrix of alphas pub fn compute_liquid_alpha_values_sparse( netuid: u16, weights: &[Vec<(u16, I32F32)>], // current epoch weights diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 89812bfb27..733372c728 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -5,7 +5,7 @@ )] use super::mock::*; -use crate::epoch::math::{fixed, mat_fixed_proportions_to_fixed, u16_proportion_to_fixed}; +use crate::epoch::math::{fixed, u16_proportion_to_fixed}; use crate::*; use approx::assert_abs_diff_eq; @@ -714,7 +714,7 @@ fn test_512_graph() { assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, uid), 1023); // Note D = floor(1 / 64 * 65_535) = 1023 assert_eq!(SubtensorModule::get_emission_for_uid(netuid, uid), 7812500); // Note E = 0.5 / 200 * 1_000_000_000 = 7_812_500 assert_eq!(bonds[uid as usize][validator], 0.0); - assert_eq!(bonds[uid as usize][server], I32F32::from_num(38)); + assert_eq!(bonds[uid as usize][server], I32F32::from_num(276)); } for uid in servers { assert_eq!( @@ -1053,42 +1053,50 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* n: 8 - current_block: 2, activity_cutoff: 5000, Last update: [2, 2, 2, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] + current_block: 2 + activity_cutoff: 5000 + Last update: [2, 2, 2, 2, 1, 1, 1, 1] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] - B: [[], [], [], [], [], [], [], []] - B (outdatedmask): [[], [], [], [], [], [], [], []] - B: [[], [], [], [], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992675), (7, 0.0400008545)], [], [], [], []] - emaB norm: [[(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [(4, 0.25), (5, 0.25), (6, 0.25), (7, 0.25)], [], [], [], []] - total_bonds_per_validator: [0.2499999995, 0.2499999995, 0.2499999995, 0.2499999995, 0, 0, 0, 0] - D: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - nE: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - E: [49999999, 99999999, 149999999, 199999999, 49998779, 100000610, 149996337, 200004272] - P: [0.0499999998, 0.0999999999, 0.15, 0.2, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] + Bonds: [[], [], [], [], [], [], [], []] + Bonds: (mask+norm) [[], [], [], [], [], [], [], []] + weights_for_bonds: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + ΔB: + , 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] + + emaB: [[(4, 0.0099999998), (5, 0.0099999998), (6, 0.0099999998), (7, 0.0099999998)], [(4, 0.0199999998), (5, 0.0199999998), (6, 0.0199999998), (7, 0.0199999998)], [(4, 0.0299999998), (5, 0.0299999998), (6, 0.03), (7, 0.03)], [(4, 0.04), (5, 0.0399999998), (6, 0.04), (7, 0.04)], [], [], [], []] + emaB norm: [[(4, 0.0999999982), (5, 0.0999999985), (6, 0.099999998), (7, 0.099999998)], [(4, 0.199999999), (5, 0.1999999995), (6, 0.1999999986), (7, 0.1999999986)], [(4, 0.2999999996), (5, 0.3000000003), (6, 0.3000000012), (7, 0.3000000012)], [(4, 0.4000000027), (5, 0.4000000013), (6, 0.4000000018), (7, 0.4000000018)], [], [], [], []] + total_bonds_per_validator: [0.0999999975, 0.1999999979, 0.3000000003, 0.4000000008, 0, 0, 0, 0] + Dividends: [0.0333333318, 0.1333333314, 0.3000000005, 0.5333333358, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0, 0, 0, 0] + Validator Emission: [16666665, 66666665, 150000000, 266666668, 0, 0, 0, 0] + Normalized Combined Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Combined Emission: [16666665, 66666665, 150000000, 266666668, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] */ + let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(bonds[0][4], 655); - assert_eq!(bonds[1][4], 655); - assert_eq!(bonds[2][4], 655); - assert_eq!(bonds[3][4], 655); + assert_eq!(bonds[1][4], 1310); + assert_eq!(bonds[2][4], 1966); + assert_eq!(bonds[3][4], 2621); // === Set self-weight only on val1 let uid = 0; @@ -1106,41 +1114,46 @@ fn test_bonds() { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } /* n: 8 - current_block: 3, activity_cutoff: 5000, Last update: [2, 2, 2, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] + current_block: 3 + activity_cutoff: 5000 + Last update: [2, 2, 2, 2, 1, 1, 1, 1] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] - B (outdatedmask): [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] - B: [[(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0089951933), (5, 0.0179903866), (6, 0.0269993132), (7, 0.0359945067)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [], [], [], []] - emaB norm: [[(4, 0.1363320365), (5, 0.1363301442), (6, 0.136363573), (7, 0.1363528532)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [], [], [], []] - total_bonds_per_validator: [0.136349445, 0.2878835173, 0.2878835173, 0.2878835173, 0, 0, 0, 0] - D: [0.0499942757, 0.211112383, 0.3166685747, 0.422224766, 0, 0, 0, 0] - nE: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [24997137, 105556191, 158334287, 211112383, 49998779, 100000610, 149996337, 200004272] - P: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0 + .400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + Bonds: [[(4, 655), (5, 655), (6, 655), (7, 655)], [(4, 1310), (5, 1310), (6, 1310), (7, 1310)], [(4, 1966), (5, 1966), (6, 1966), (7, 1966)], [(4, 2621), (5, 2621), (6, 2621), (7, 2621)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.0099946593), (5, 0.0099946593), (6, 0.0099946593), (7, 0.0099946593)], [(4, 0.0199893187), (5, 0.0199893187), (6, 0.0199893187), (7, 0.0199893187)], [(4, 0.029999237), (5, 0.029999237), (6, 0.029999237), (7, 0.029999237)], [(4, 0.0399938964), (5, 0.0399938964), (6, 0.0399938964), (7, 0.0399938964)], [], [], [], []] + weights_for_bonds: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + emaB: [[(4, 0.0089951933), (5, 0.0089951933), (6, 0.0089951933), (7, 0.0089951933)], [(4, 0.0402126086), (5, 0.0402126086), (6, 0.0402126086), (7, 0.0402126086)], [(4, 0.0603326464), (5, 0.0603326464), (6, 0.0603326464), (7, 0.0603326464)], [(4, 0.0804389513), (5, 0.080438951), (6, 0.080438951), (7, 0.080438951)], [], [], [], []] + emaB norm: [[(4, 0.0473482562), (5, 0.0473482562), (6, 0.0473482562), (7, 0.0473482562)], [(4, 0.2116682583), (5, 0.2116682585), (6, 0.2116682585), (7, 0.2116682585)], [(4, 0.3175746764), (5, 0.3175746768), (6, 0.3175746768), (7, 0.3175746768)], [(4, 0.4234088087), (5, 0.423408808), (6, 0.423408808), (7, 0.423408808)], [], [], [], []] + total_bonds_per_validator: [0.0473482558, 0.2116682578, 0.3175746764, 0.4234088075, 0, 0, 0, 0] + Dividends: [0.0151901136, 0.1358134532, 0.3056498466, 0.5433465862, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0075950567, 0.0679067266, 0.1528249232, 0.271673293, 0, 0, 0, 0] + Validator Emission: [7595056, 67906726, 152824923, 271673293, 0, 0, 0, 0] + Normalized Combined Emission: [0.0075950567, 0.0679067266, 0.1528249232, 0.271673293, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [7595056, 67906726, 152824923, 271673293, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0075950567, 0.0679067266, 0.1528249232, 0.271673293, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ assert_eq!(bonds[0][4], 655); - assert_eq!(bonds[1][4], 655); - assert_eq!(bonds[2][4], 655); - assert_eq!(bonds[3][4], 655); + assert_eq!(bonds[1][4], 1310); + assert_eq!(bonds[2][4], 1966); + assert_eq!(bonds[3][4], 2621); // === Set self-weight only on val2 let uid = 1; @@ -1157,43 +1170,47 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 3 - current_block: 4, activity_cutoff: 5000, Last update: [2, 3, 2, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] + /* n: 8 + current_block: 4 + activity_cutoff: 5000 + Last update: [2, 3, 2, 2, 1, 1, 1, 1] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] - B (outdatedmask): [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] - B: [[(4, 0.008987564), (5, 0.0179751278), (6, 0.0269932097), (7, 0.0359807736)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0080888073), (5, 0.016177615), (6, 0.0242938886), (7, 0.0323826962)], [(4, 0.0170840009), (5, 0.0341817348), (6, 0.051293202), (7, 0.068390936)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [], [], [], []] - emaB norm: [[(4, 0.1019507758), (5, 0.10192353), (6, 0.102001434), (7, 0.101974368)], [(4, 0.2153255814), (5, 0.2153545555), (6, 0.2153619886), (7, 0.215365714)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [], [], [], []] - total_bonds_per_validator: [0.1019699604, 0.215358351, 0.3413358429, 0.3413358429, 0, 0, 0, 0] - D: [0.034896868, 0.1474028623, 0.3504429725, 0.4672572967, 0, 0, 0, 0] - nE: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [17448433, 73701431, 175221486, 233628648, 49998779, 100000610, 149996337, 200004272] - P: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + Bonds: [[(4, 589), (5, 589), (6, 589), (7, 589)], [(4, 2635), (5, 2635), (6, 2635), (7, 2635)], [(4, 3953), (5, 3953), (6, 3953), (7, 3953)], [(4, 5271), (5, 5271), (6, 5271), (7, 5271)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.008987564), (5, 0.008987564), (6, 0.008987564), (7, 0.008987564)], [(4, 0.0402075227), (5, 0.0402075227), (6, 0.0402075227), (7, 0.0402075227)], [(4, 0.0603189135), (5, 0.0603189135), (6, 0.0603189135), (7, 0.0603189135)], [(4, 0.0804303044), (5, 0.0804303044), (6, 0.0804303044), (7, 0.0804303044)], [], [], [], []] + weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + emaB: [[(4, 0.0080888073), (5, 0.0080888073), (6, 0.0080888073), (7, 0.0080888073)], [(4, 0.0361867703), (5, 0.0361867703), (6, 0.0361867703), (7, 0.0361867703)], [(4, 0.0971441646), (5, 0.0971441648), (6, 0.0971441648), (7, 0.0971441648)], [(4, 0.1295301311), (5, 0.129530131), (6, 0.129530131), (7, 0.129530131)], [], [], [], []] + emaB norm: [[(4, 0.0298535195), (5, 0.0298535195), (6, 0.0298535195), (7, 0.0298535195)], [(4, 0.1335552211), (5, 0.1335552211), (6, 0.1335552211), (7, 0.1335552211)], [(4, 0.3585318692), (5, 0.3585318702), (6, 0.3585318702), (7, 0.3585318702)], [(4, 0.4780593896), (5, 0.4780593887), (6, 0.4780593887), (7, 0.4780593887)], [], [], [], []] + total_bonds_per_validator: [0.0298535188, 0.1335552207, 0.3585318697, 0.4780593882, 0, 0, 0, 0] + Dividends: [0.0090883898, 0.08131718, 0.3274465878, 0.5821478418, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0045441948, 0.04065859, 0.163723294, 0.291073921, 0, 0, 0, 0] + Validator Emission: [4544194, 40658589, 163723293, 291073920, 0, 0, 0, 0] + Normalized Combined Emission: [0.0045441948, 0.04065859, 0.163723294, 0.291073921, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [4544194, 40658589, 163723293, 291073920, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0045441948, 0.04065859, 0.163723294, 0.291073921, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(bonds[0][4], 530); - assert_eq!(bonds[1][4], 1119); - assert_eq!(bonds[2][4], 1774); - assert_eq!(bonds[3][4], 1774); + assert_eq!(bonds[1][4], 2371); + assert_eq!(bonds[2][4], 6366); + assert_eq!(bonds[3][4], 8488); // === Set self-weight only on val2 let uid = 1; @@ -1210,43 +1227,47 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 4 - current_block: 5, activity_cutoff: 5000, Last update: [2, 4, 2, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] + /* n: 8 + current_block: 5 + activity_cutoff: 5000 + Last update: [2, 4, 2, 2, 1, 1, 1, 1] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 530), (5, 1060), (6, 1592), (7, 2122)], [(4, 1119), (5, 2240), (6, 3361), (7, 4481)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [], [], [], []] - B (outdatedmask): [[(4, 530), (5, 1060), (6, 1592), (7, 2122)], [(4, 1119), (5, 2240), (6, 3361), (7, 4481)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [(4, 1774), (5, 3550), (6, 5327), (7, 7103)], [], [], [], []] - B: [[(4, 0.0080872816), (5, 0.0161745632), (6, 0.0242923629), (7, 0.0323796445)], [(4, 0.0170748455), (5, 0.034180209), (6, 0.0512855726), (7, 0.068375677)], [(4, 0.0270695048), (5, 0.0541695277), (6, 0.0812848096), (7, 0.1083848325)], [(4, 0.0270695048), (5, 0.0541695277), (6, 0.0812848096), (7, 0.1083848325)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0072785532), (5, 0.0145571067), (6, 0.0218631264), (7, 0.0291416799)], [(4, 0.0153673608), (5, 0.030762188), (6, 0.0461570153), (7, 0.0615381093)], [(4, 0.03436231), (5, 0.0687526967), (6, 0.1031555962), (7, 0.1375472036)], [(4, 0.03436231), (5, 0.0687526967), (6, 0.1031555962), (7, 0.1375472036)], [], [], [], []] - emaB norm: [[(4, 0.0796597423), (5, 0.079623309), (6, 0.0796960597), (7, 0.0796712292)], [(4, 0.1681872709), (5, 0.168260579), (6, 0.1682528006), (7, 0.1682407067)], [(4, 0.3760764932), (5, 0.3760580558), (6, 0.3760255696), (7, 0.376044032)], [(4, 0.3760764932), (5, 0.3760580558), (6, 0.3760255696), (7, 0.376044032)], [], [], [], []] - total_bonds_per_validator: [0.079667945, 0.1682429651, 0.3760445435, 0.3760445435, 0, 0, 0, 0] - D: [0.0261337839, 0.1103787823, 0.3700660428, 0.493421391, 0, 0, 0, 0] - nE: [0.0130668918, 0.0551893911, 0.1850330213, 0.2467106953, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [13066891, 55189391, 185033021, 246710695, 49998779, 100000610, 149996337, 200004272] - P: [0.0130668918, 0.0551893911, 0.1850330213, 0.2467106953, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + Bonds: [[(4, 530), (5, 530), (6, 530), (7, 530)], [(4, 2371), (5, 2371), (6, 2371), (7, 2371)], [(4, 6366), (5, 6366), (6, 6366), (7, 6366)], [(4, 8488), (5, 8488), (6, 8488), (7, 8488)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.0080872816), (5, 0.0080872816), (6, 0.0080872816), (7, 0.0080872816)], [(4, 0.036179141), (5, 0.036179141), (6, 0.036179141), (7, 0.036179141)], [(4, 0.0971389334), (5, 0.0971389334), (6, 0.0971389334), (7, 0.0971389334)], [(4, 0.1295185778), (5, 0.1295185778), (6, 0.1295185778), (7, 0.1295185778)], [], [], [], []] + weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + emaB: [[(4, 0.0072785532), (5, 0.0072785532), (6, 0.0072785532), (7, 0.0072785532)], [(4, 0.0325612267), (5, 0.0325612267), (6, 0.0325612267), (7, 0.0325612267)], [(4, 0.1302821825), (5, 0.1302821827), (6, 0.1302821827), (7, 0.1302821827)], [(4, 0.1737095772), (5, 0.173709577), (6, 0.173709577), (7, 0.173709577)], [], [], [], []] + emaB norm: [[(4, 0.0211689514), (5, 0.0211689514), (6, 0.0211689514), (7, 0.0211689514)], [(4, 0.094701105), (5, 0.094701105), (6, 0.094701105), (7, 0.094701105)], [(4, 0.3789128321), (5, 0.3789128328), (6, 0.3789128328), (7, 0.3789128328)], [(4, 0.505217111), (5, 0.5052171105), (6, 0.5052171105), (7, 0.5052171105)], [], [], [], []] + total_bonds_per_validator: [0.021168951, 0.0947011046, 0.3789128324, 0.50521711, 0, 0, 0, 0] + Dividends: [0.0062849855, 0.0562328366, 0.3374935838, 0.599988594, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.0031424926, 0.0281164183, 0.1687467918, 0.2999942969, 0, 0, 0, 0] + Validator Emission: [3142492, 28116418, 168746791, 299994296, 0, 0, 0, 0] + Normalized Combined Emission: [0.0031424926, 0.0281164183, 0.1687467918, 0.2999942969, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [3142492, 28116418, 168746791, 299994296, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.0031424926, 0.0281164183, 0.1687467918, 0.2999942969, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 1909); - assert_eq!(bonds[1][7], 4032); - assert_eq!(bonds[2][7], 9014); - assert_eq!(bonds[3][7], 9014); + assert_eq!(bonds[0][7], 476); + assert_eq!(bonds[1][7], 2133); + assert_eq!(bonds[2][7], 8538); + assert_eq!(bonds[3][7], 11384); // === Set val3->srv4: 1 assert_ok!(SubtensorModule::set_weights( @@ -1262,43 +1283,48 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 5 - current_block: 6, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] + /* n: 8 + current_block: 6 + activity_cutoff: 5000 + Last update: [2, 4, 5, 2, 1, 1, 1, 1] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] max_allowed_validators: 8 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - I (=R): [0, 0, 0, 0, 0, 0, 0, 1] - B: [[(4, 476), (5, 953), (6, 1432), (7, 1909)], [(4, 1007), (5, 2015), (6, 3024), (7, 4032)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [], [], [], []] - B (outdatedmask): [[(4, 476), (5, 953), (6, 1432), (7, 1909)], [(4, 1007), (5, 2015), (6, 3024), (7, 4032)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [(4, 2251), (5, 4505), (6, 6760), (7, 9014)], [], [], [], []] - B: [[(4, 0.0072632944), (5, 0.0145418479), (6, 0.0218509194), (7, 0.0291294728)], [(4, 0.015365835), (5, 0.030746929), (6, 0.0461432822), (7, 0.0615243763)], [(4, 0.0343480583), (5, 0.0687418936), (6, 0.103150988), (7, 0.1375448233)], [(4, 0.0343480583), (5, 0.0687418936), (6, 0.103150988), (7, 0.1375448233)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0065369648), (5, 0.0130876629), (6, 0.0196658273), (7, 0.0262165254)], [(4, 0.0138292515), (5, 0.027672236), (6, 0.041528954), (7, 0.0553719385)], [(4, 0.0309132524), (5, 0.0618677041), (6, 0.092835889), (7, 0.1637911955)], [(4, 0.0309132524), (5, 0.0618677041), (6, 0.092835889), (7, 0.1637911955)], [], [], [], []] - emaB norm: [[(4, 0.0795321616), (5, 0.0795625302), (6, 0.0796617707), (7, 0.0640723184)], [(4, 0.1682539685), (5, 0.168225079), (6, 0.168224299), (7, 0.1353271813)], [(4, 0.3761069346), (5, 0.3761061952), (6, 0.3760569647), (7, 0.40030025)], [(4, 0.3761069346), (5, 0.3761061952), (6, 0.3760569647), (7, 0.40030025)], [], [], [], []] - total_bonds_per_validator: [0.0640723184, 0.1353271813, 0.40030025, 0.40030025, 0, 0, 0, 0] - D: [0.020425828, 0.0862828067, 0.3828391563, 0.5104522086, 0, 0, 0, 0] - nE: [0.0102129139, 0.0431414032, 0.1914195782, 0.2552261043, 0, 0, 0, 0.5] - E: [10212913, 43141403, 191419578, 255226104, 0, 0, 0, 500000000] - P: [0.0102129139, 0.0431414032, 0.1914195782, 0.2552261043, 0, 0, 0, 0.5] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] + Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + Clipped Weights: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] + Bonds: [[(4, 476), (5, 476), (6, 476), (7, 476)], [(4, 2133), (5, 2133), (6, 2133), (7, 2133)], [(4, 8538), (5, 8538), (6, 8538), (7, 8538)], [(4, 11384), (5, 11384), (6, 11384), (7, 11384)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.0072632944), (5, 0.0072632944), (6, 0.0072632944), (7, 0.0072632944)], [(4, 0.0325474937), (5, 0.0325474937), (6, 0.0325474937), (7, 0.0325474937)], [(4, 0.130281529), (5, 0.130281529), (6, 0.130281529), (7, 0.130281529)], [(4, 0.1737087052), (5, 0.1737087052), (6, 0.1737087052), (7, 0.1737087052)], [], [], [], []] + weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + emaB: [[(4, 0.0065369648), (5, 0.0065369648), (6, 0.0065369648), (7, 0.0065369648)], [(4, 0.0292927441), (5, 0.0292927441), (6, 0.0292927441), (7, 0.0292927441)], [(4, 0.117253376), (5, 0.117253376), (6, 0.117253376), (7, 0.1601105188)], [(4, 0.1563378347), (5, 0.1563378347), (6, 0.1563378347), (7, 0.2134806917)], [], [], [], []] + emaB norm: [[(4, 0.0211264472), (5, 0.0211264472), (6, 0.0211264472), (7, 0.0159663672)], [(4, 0.0946695658), (5, 0.0946695658), (6, 0.0946695658), (7, 0.0715467692)], [(4, 0.3789445655), (5, 0.3789445655), (6, 0.3789445655), (7, 0.3910657985)], [(4, 0.505259421), (5, 0.505259421), (6, 0.505259421), (7, 0.5214210646)], [], [], [], []] + total_bonds_per_validator: [0.0159663672, 0.0715467692, 0.3910657985, 0.5214210646, 0, 0, 0, 0] + Dividends: [0.0046713396, 0.0418654135, 0.3432467687, 0.610216478, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] + Normalized Validator Emission: [0.0023356697, 0.0209327068, 0.1716233843, 0.305108239, 0, 0, 0, 0] + Validator Emission: [2335669, 20932706, 171623384, 305108238, 0, 0, 0, 0] + Normalized Combined Emission: [0.0023356697, 0.0209327068, 0.1716233843, 0.305108239, 0, 0, 0, 0.5] + Combined Emission: [2335669, 20932706, 171623384, 305108238, 0, 0, 0, 500000000] + Pruning Scores: [0.0023356697, 0.0209327068, 0.1716233843, 0.305108239, 0, 0, 0, 0.5] + */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 1718); - assert_eq!(bonds[1][7], 3628); - assert_eq!(bonds[2][7], 10734); - assert_eq!(bonds[3][7], 10734); + assert_eq!(bonds[0][7], 428); + assert_eq!(bonds[1][7], 1919); + assert_eq!(bonds[2][7], 10492); + assert_eq!(bonds[3][7], 13990); next_block(); if sparse { @@ -1306,43 +1332,47 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 6 - current_block: 7, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - I (=R): [0, 0, 0, 0, 0, 0, 0, 1] - B: [[(4, 428), (5, 857), (6, 1288), (7, 1718)], [(4, 906), (5, 1813), (6, 2721), (7, 3628)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [], [], [], []] - B (outdatedmask): [[(4, 428), (5, 857), (6, 1288), (7, 1718)], [(4, 906), (5, 1813), (6, 2721), (7, 3628)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [(4, 2025), (5, 4054), (6, 6083), (7, 10734)], [], [], [], []] - B: [[(4, 0.0065308614), (5, 0.0130769818), (6, 0.0196536202), (7, 0.0262149996)], [(4, 0.0138246738), (5, 0.0276646067), (6, 0.0415197986), (7, 0.0553597314)], [(4, 0.0308995193), (5, 0.0618600748), (6, 0.0928206302), (7, 0.163790341)], [(4, 0.0308995193), (5, 0.0618600748), (6, 0.0928206302), (7, 0.163790341)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0058777751), (5, 0.0117692836), (6, 0.017688258), (7, 0.0235934996)], [(4, 0.0124422063), (5, 0.0248981458), (6, 0.0373678186), (7, 0.0498237582)], [(4, 0.0278095673), (5, 0.0556740672), (6, 0.083538567), (7, 0.1874121614)], [(4, 0.0278095673), (5, 0.0556740672), (6, 0.083538567), (7, 0.1874121614)], [], [], [], []] - emaB norm: [[(4, 0.0794947986), (5, 0.0795138243), (6, 0.0796290569), (7, 0.052635678)], [(4, 0.168276373), (5, 0.1682130254), (6, 0.1682225657), (7, 0.111153807)], [(4, 0.376114414), (5, 0.376136575), (6, 0.3760741884), (7, 0.4181052572)], [(4, 0.376114414), (5, 0.376136575), (6, 0.3760741884), (7, 0.4181052572)], [], [], [], []] - total_bonds_per_validator: [0.052635678, 0.111153807, 0.4181052572, 0.4181052572, 0, 0, 0, 0] - D: [0.0164400174, 0.069434674, 0.391767989, 0.5223573192, 0, 0, 0, 0] - nE: [0.0082200086, 0.034717337, 0.1958839945, 0.2611786595, 0, 0, 0, 0.5] - E: [8220008, 34717336, 195883994, 261178659, 0, 0, 0, 500000000] - P: [0.0082200086, 0.034717337, 0.1958839945, 0.2611786595, 0, 0, 0, 0.5] + /* n: 8 + current_block: 7 + activity_cutoff: 5000 + Last update: [2, 4, 5, 2, 1, 1, 1, 1] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] + Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + Clipped Weights: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] + Bonds: [[(4, 428), (5, 428), (6, 428), (7, 428)], [(4, 1919), (5, 1919), (6, 1919), (7, 1919)], [(4, 7684), (5, 7684), (6, 7684), (7, 10492)], [(4, 10245), (5, 10245), (6, 10245), (7, 13990)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.0065308614), (5, 0.0065308614), (6, 0.0065308614), (7, 0.0065308614)], [(4, 0.029282063), (5, 0.029282063), (6, 0.029282063), (7, 0.029282063)], [(4, 0.1172503242), (5, 0.1172503242), (6, 0.1172503242), (7, 0.1600976577)], [(4, 0.1563286793), (5, 0.1563286793), (6, 0.1563286793), (7, 0.2134737163)], [], [], [], []] + weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + emaB: [[(4, 0.0058777751), (5, 0.0058777751), (6, 0.0058777751), (7, 0.0058777751)], [(4, 0.0263538565), (5, 0.0263538565), (6, 0.0263538565), (7, 0.0263538565)], [(4, 0.1055252918), (5, 0.1055252918), (6, 0.1055252918), (7, 0.1869450347)], [(4, 0.1406958112), (5, 0.1406958112), (6, 0.1406958112), (7, 0.2492692014)], [], [], [], []] + emaB norm: [[(4, 0.0211086995), (5, 0.0211086995), (6, 0.0211086995), (7, 0.0125473945)], [(4, 0.0946439134), (5, 0.0946439134), (6, 0.0946439134), (7, 0.0562580617)], [(4, 0.3789702114), (5, 0.3789702114), (6, 0.3789702114), (7, 0.3990749998)], [(4, 0.5052771752), (5, 0.5052771752), (6, 0.5052771752), (7, 0.5321195435)], [], [], [], []] + total_bonds_per_validator: [0.0125473945, 0.0562580617, 0.3990749998, 0.5321195435, 0, 0, 0, 0] + Dividends: [0.003636117, 0.0326061223, 0.3469446378, 0.6168131223, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] + Normalized Validator Emission: [0.0018180585, 0.016303061, 0.1734723188, 0.3084065611, 0, 0, 0, 0] + Validator Emission: [1818058, 16303061, 173472318, 308406561, 0, 0, 0, 0] + Normalized Combined Emission: [0.0018180585, 0.016303061, 0.1734723188, 0.3084065611, 0, 0, 0, 0.5] + Combined Emission: [1818058, 16303061, 173472318, 308406561, 0, 0, 0, 500000000] + Pruning Scores: [0.0018180585, 0.016303061, 0.1734723188, 0.3084065611, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 1546); - assert_eq!(bonds[1][7], 3265); - assert_eq!(bonds[2][7], 12282); - assert_eq!(bonds[3][7], 12282); + assert_eq!(bonds[0][7], 385); + assert_eq!(bonds[1][7], 1727); + assert_eq!(bonds[2][7], 12251); + assert_eq!(bonds[3][7], 16335); next_block(); if sparse { @@ -1350,43 +1380,47 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 7 - current_block: 8, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - I (=R): [0, 0, 0, 0, 0, 0, 0, 1] - B: [[(4, 385), (5, 771), (6, 1159), (7, 1546)], [(4, 815), (5, 1631), (6, 2448), (7, 3265)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [], [], [], []] - B (outdatedmask): [[(4, 385), (5, 771), (6, 1159), (7, 1546)], [(4, 815), (5, 1631), (6, 2448), (7, 3265)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [(4, 1822), (5, 3648), (6, 5474), (7, 12282)], [], [], [], []] - B: [[(4, 0.0058747234), (5, 0.0117647059), (6, 0.0176852064), (7, 0.0235904478)], [(4, 0.0124361028), (5, 0.0248874647), (6, 0.0373540856), (7, 0.0498207065)], [(4, 0.027801938), (5, 0.0556649119), (6, 0.0835278858), (7, 0.187411307)], [(4, 0.027801938), (5, 0.0556649119), (6, 0.0835278858), (7, 0.187411307)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.005287251), (5, 0.0105882352), (6, 0.0159166856), (7, 0.0212314029)], [(4, 0.0111924924), (5, 0.0223987182), (6, 0.033618677), (7, 0.0448386357)], [(4, 0.025021744), (5, 0.0500984206), (6, 0.0751750972), (7, 0.2086710306)], [(4, 0.025021744), (5, 0.0500984206), (6, 0.0751750972), (7, 0.2086710306)], [], [], [], []] - emaB norm: [[(4, 0.0794797675), (5, 0.0795009276), (6, 0.0796289926), (7, 0.043919883)], [(4, 0.16824938), (5, 0.1681790059), (6, 0.1681896253), (7, 0.0927544753)], [(4, 0.3761354259), (5, 0.376160033), (6, 0.3760906907), (7, 0.4316628207)], [(4, 0.3761354259), (5, 0.376160033), (6, 0.3760906907), (7, 0.4316628207)], [], [], [], []] - total_bonds_per_validator: [0.043919883, 0.0927544753, 0.4316628207, 0.4316628207, 0, 0, 0, 0] - D: [0.0135093683, 0.0570609153, 0.398327021, 0.531102695, 0, 0, 0, 0] - nE: [0.006754684, 0.0285304575, 0.1991635105, 0.2655513475, 0, 0, 0, 0.5] - E: [6754684, 28530457, 199163510, 265551347, 0, 0, 0, 500000000] - P: [0.006754684, 0.0285304575, 0.1991635105, 0.2655513475, 0, 0, 0, 0.5] + /* n: 8 + current_block: 8 + activity_cutoff: 5000 + Last update: [2, 4, 5, 2, 1, 1, 1, 1] + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] + Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + Clipped Weights: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] + Bonds: [[(4, 385), (5, 385), (6, 385), (7, 385)], [(4, 1727), (5, 1727), (6, 1727), (7, 1727)], [(4, 6915), (5, 6915), (6, 6915), (7, 12251)], [(4, 9220), (5, 9220), (6, 9220), (7, 16335)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.0058747234), (5, 0.0058747234), (6, 0.0058747234), (7, 0.0058747234)], [(4, 0.0263523308), (5, 0.0263523308), (6, 0.0263523308), (7, 0.0263523308)], [(4, 0.1055161364), (5, 0.1055161364), (6, 0.1055161364), (7, 0.1869382772)], [(4, 0.1406881819), (5, 0.1406881819), (6, 0.1406881819), (7, 0.2492561226)], [], [], [], []] + weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + emaB: [[(4, 0.005287251), (5, 0.005287251), (6, 0.005287251), (7, 0.005287251)], [(4, 0.0237170977), (5, 0.0237170977), (6, 0.0237170977), (7, 0.0237170977)], [(4, 0.0949645226), (5, 0.0949645226), (6, 0.0949645226), (7, 0.2111015923)], [(4, 0.1266193634), (5, 0.1266193634), (6, 0.1266193634), (7, 0.2814733672)], [], [], [], []] + emaB norm: [[(4, 0.0210993583), (5, 0.0210993583), (6, 0.0210993583), (7, 0.010137003)], [(4, 0.094645695), (5, 0.094645695), (6, 0.094645695), (7, 0.0454716997)], [(4, 0.3789664055), (5, 0.3789664055), (6, 0.3789664055), (7, 0.404735366)], [(4, 0.5052885406), (5, 0.5052885406), (6, 0.5052885406), (7, 0.539655931)], [], [], [], []] + total_bonds_per_validator: [0.010137003, 0.0454716997, 0.404735366, 0.539655931, 0, 0, 0, 0] + Dividends: [0.0029180378, 0.0261789719, 0.3495214381, 0.621381552, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] + Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] + Normalized Validator Emission: [0.0014590188, 0.013089486, 0.174760719, 0.310690776, 0, 0, 0, 0] + Validator Emission: [1459018, 13089485, 174760719, 310690775, 0, 0, 0, 0] + Normalized Combined Emission: [0.0014590188, 0.013089486, 0.174760719, 0.310690776, 0, 0, 0, 0.5] + Combined Emission: [1459018, 13089485, 174760719, 310690775, 0, 0, 0, 500000000] + Pruning Scores: [0.0014590188, 0.013089486, 0.174760719, 0.310690776, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 1391); - assert_eq!(bonds[1][7], 2938); - assert_eq!(bonds[2][7], 13675); - assert_eq!(bonds[3][7], 13675); + assert_eq!(bonds[0][7], 346); + assert_eq!(bonds[1][7], 1554); + assert_eq!(bonds[2][7], 13834); + assert_eq!(bonds[3][7], 18446); next_block(); if sparse { @@ -1394,38 +1428,6 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 8 - current_block: 9, activity_cutoff: 5000, Last update: [2, 4, 5, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - I (=R): [0, 0, 0, 0, 0, 0, 0, 1] - B: [[(4, 346), (5, 693), (6, 1043), (7, 1391)], [(4, 733), (5, 1467), (6, 2203), (7, 2938)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [], [], [], []] - B (outdatedmask): [[(4, 346), (5, 693), (6, 1043), (7, 1391)], [(4, 733), (5, 1467), (6, 2203), (7, 2938)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [(4, 1639), (5, 3283), (6, 4926), (7, 13675)], [], [], [], []] - B: [[(4, 0.0052796216), (5, 0.0105745022), (6, 0.0159151598), (7, 0.0212252995)], [(4, 0.011184863), (5, 0.0223849851), (6, 0.0336156252), (7, 0.0448310063)], [(4, 0.0250095369), (5, 0.0500953689), (6, 0.0751659418), (7, 0.2086671244)], [(4, 0.0250095369), (5, 0.0500953689), (6, 0.0751659418), (7, 0.2086671244)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0047516592), (5, 0.0095170517), (6, 0.0143236436), (7, 0.0191027694)], [(4, 0.0100663765), (5, 0.0201464866), (6, 0.0302540625), (7, 0.0403479056)], [(4, 0.022508583), (5, 0.0450858318), (6, 0.0676493475), (7, 0.2278012664)], [(4, 0.022508583), (5, 0.0450858318), (6, 0.0676493475), (7, 0.2278012664)], [], [], [], []] - emaB norm: [[(4, 0.0794124375), (5, 0.0794178303), (6, 0.079630477), (7, 0.037088924)], [(4, 0.1682350226), (5, 0.1681182678), (6, 0.168193617), (7, 0.0783373541)], [(4, 0.3761762697), (5, 0.3762319507), (6, 0.3760879529), (7, 0.4422868607)], [(4, 0.3761762697), (5, 0.3762319507), (6, 0.3760879529), (7, 0.4422868607)], [], [], [], []] - total_bonds_per_validator: [0.037088924, 0.0783373541, 0.4422868607, 0.4422868607, 0, 0, 0, 0] - D: [0.011274011, 0.0476247966, 0.403329082, 0.5377721095, 0, 0, 0, 0] - nE: [0.0056370054, 0.0238123983, 0.201664541, 0.2688860546, 0, 0, 0, 0.5] - E: [5637005, 23812398, 201664540, 268886054, 0, 0, 0, 500000000] - P: [0.0056370054, 0.0238123983, 0.201664541, 0.2688860546, 0, 0, 0, 0.5] - */ }); } @@ -1505,49 +1507,46 @@ fn test_bonds_with_liquid_alpha() { /* n: 8 current_block: 3 activity_cutoff: 5000 - Inactive: [false, false, false, false, false, false, false, false] + Last update: [2, 2, 2, 2, 1, 1, 1, 1] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 + max_allowed_validators: 64 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] - B (outdatedmask): [[(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [(4, 655), (5, 1310), (6, 1966), (7, 2621)], [], [], [], []] - B: [[(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [(4, 0.0099946593), (5, 0.0199893187), (6, 0.029999237), (7, 0.0399938964)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0089951933), (5, 0.0179903866), (6, 0.0269993132), (7, 0.0359945067)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [(4, 0.018994949), (5, 0.0379905086), (6, 0.0569985807), (7, 0.0759953612)], [], [], [], []] - emaB norm: [[(4, 0.1363320365), (5, 0.1363301442), (6, 0.136363573), (7, 0.1363528532)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [(4, 0.287889321), (5, 0.2878899518), (6, 0.2878788088), (7, 0.287882382)], [], [], [], []] - total_bonds_per_validator: [0.136349445, 0.2878835173, 0.2878835173, 0.2878835173, 0, 0, 0, 0] - D: [0.0499942757, 0.211112383, 0.3166685747, 0.422224766, 0, 0, 0, 0] - nE: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [24997137, 105556191, 158334287, 211112383, 49998779, 100000610, 149996337, 200004272] - P: [0.0249971377, 0.1055561914, 0.1583342873, 0.211112383, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - */ + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + Bonds: [[(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [], [], [], []] + Bonds: (mask+norm) [[(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [], [], [], []] + weights_for_bonds: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + alphas: [[0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7026884612, 0.7053405554, 0.7104771058, 0.7200544013], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993]] + emaB: [[], [(4, 0.0910776372), (5, 0.1821595554), (6, 0.273232912), (7, 0.364327949)], [(4, 0.0910776372), (5, 0.1821595554), (6, 0.273232912), (7, 0.364327949)], [(4, 0.0910776372), (5, 0.1821595554), (6, 0.273232912), (7, 0.364327949)], [], [], [], []] + emaB norm: [[], [(4, 0.3333333333), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.3333333333), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.3333333333), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [], [], [], []] + total_bonds_per_validator: [0, 0.3333333328, 0.3333333328, 0.3333333328, 0, 0, 0, 0] + Dividends: [0, 0.222222222, 0.333333333, 0.4444444447, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0, 0.111111111, 0.1666666665, 0.2222222222, 0, 0, 0, 0] + Validator Emission: [0, 111111111, 166666666, 222222222, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0.111111111, 0.1666666665, 0.2222222222, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [0, 111111111, 166666666, 222222222, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0, 0.111111111, 0.1666666665, 0.2222222222, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - // Expected bonds calculations - // For uid 0: - // Initial weights: [0.25, 0.5, 0.75, 1.0] - // Active stake: [1, 2, 3, 4] - // ΔB = W◦S = [0.25*1, 0.5*2, 0.75*3, 1.0*4] = [0.25, 1.0, 2.25, 4.0] - // Normalize ΔB: [0.25/7.5, 1.0/7.5, 2.25/7.5, 4.0/7.5] = [0.0333, 0.1333, 0.3, 0.5333] - // Final bonds for netuid: [16383, 32767, 49151, 65535] + */ - assert_eq!(bonds[0][4], 1247); // Note: Calculated as explained above - assert_eq!(bonds[1][4], 1247); // Note: Calculated as explained above - assert_eq!(bonds[2][4], 1247); // Note: Calculated as explained above - assert_eq!(bonds[3][4], 1247); // Note: Calculated as explained above + assert_eq!(bonds[0][4], 4596); // Note: Calculated as explained above + assert_eq!(bonds[1][4], 4596); // Note: Calculated as explained above + assert_eq!(bonds[2][4], 4596); // Note: Calculated as explained above + assert_eq!(bonds[3][4], 4596); // Note: Calculated as explained above // === Set self-weight only on val1 let uid = 0; @@ -1566,10 +1565,10 @@ fn test_bonds_with_liquid_alpha() { } let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 1009); - assert_eq!(bonds[1][4], 2257); - assert_eq!(bonds[2][4], 2257); - assert_eq!(bonds[3][4], 2257); + assert_eq!(bonds[0][4], 0); + assert_eq!(bonds[1][4], 5968); + assert_eq!(bonds[2][4], 5968); + assert_eq!(bonds[3][4], 5968); // === Set self-weight only on val2 let uid = 1; @@ -1592,41 +1591,44 @@ fn test_bonds_with_liquid_alpha() { current_block: 4 activity_cutoff: 5000 Last update: [2, 3, 2, 2, 1, 1, 1, 1] - Inactive: [false, false, false, false, false, false, false, false] Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 + max_allowed_validators: 64 new_validator_permits: [true, true, true, true, true, true, true, true] - S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - T: [0, 0, 0, 0, 1, 1, 1, 1] - I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - B: [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] - B (outdatedmask): [[(4, 589), (5, 1178), (6, 1769), (7, 2358)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [(4, 1244), (5, 2489), (6, 3735), (7, 4980)], [], [], [], []] - B: [[(4, 0.008987564), (5, 0.0179751278), (6, 0.0269932097), (7, 0.0359807736)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [(4, 0.0189822232), (5, 0.0379797055), (6, 0.0569924468), (7, 0.075989929)], [], [], [], []] - alphas: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] - emaB: [[(4, 0.0080888073), (5, 0.016177615), (6, 0.0242938886), (7, 0.0323826962)], [(4, 0.0170840009), (5, 0.0341817348), (6, 0.051293202), (7, 0.068390936)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [(4, 0.0270837566), (5, 0.0541818568), (6, 0.0812924695), (7, 0.1083917904)], [], [], [], []] - emaB norm: [[(4, 0.1019507758), (5, 0.10192353), (6, 0.102001434), (7, 0.101974368)], [(4, 0.2153255814), (5, 0.2153545555), (6, 0.2153619886), (7, 0.215365714)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [(4, 0.3413618212), (5, 0.341360957), (6, 0.3413182884), (7, 0.3413299588)], [], [], [], []] - total_bonds_per_validator: [0.1019699604, 0.215358351, 0.3413358429, 0.3413358429, 0, 0, 0, 0] - D: [0.034896868, 0.1474028623, 0.3504429725, 0.4672572967, 0, 0, 0, 0] - nE: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - E: [17448433, 73701431, 175221486, 233628648, 49998779, 100000610, 149996337, 200004272] - P: [0.017448434, 0.073701431, 0.1752214862, 0.2336286483, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + Bonds: [[], [(4, 5968), (5, 11937), (6, 17906), (7, 23876)], [(4, 5968), (5, 11937), (6, 17906), (7, 23876)], [(4, 5968), (5, 11937), (6, 17906), (7, 23876)], [], [], [], []] + Bonds: (mask+norm) [[], [(4, 0.0910658427), (5, 0.1821469443), (6, 0.273228046), (7, 0.3643244067)], [(4, 0.0910658427), (5, 0.1821469443), (6, 0.273228046), (7, 0.3643244067)], [(4, 0.0910658427), (5, 0.1821469443), (6, 0.273228046), (7, 0.3643244067)], [], [], [], []] + weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + alphas: [[0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7033024912, 0.7080039687, 0.718774016, 0.74096124], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993]] + emaB: [[], [], [(4, 0.0973300673), (5, 0.1946689729), (6, 0.291999317), (7, 0.3893513412)], [(4, 0.0973300673), (5, 0.1946689729), (6, 0.291999317), (7, 0.3893513412)], [], [], [], []] + emaB norm: [[], [], [(4, 0.5), (5, 0.5), (6, 0.5), (7, 0.5)], [(4, 0.5), (5, 0.5), (6, 0.5), (7, 0.5)], [], [], [], []] + total_bonds_per_validator: [0, 0, 0.4999999998, 0.4999999998, 0, 0, 0, 0] + Dividends: [0, 0, 0.4285714282, 0.5714285716, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0, 0, 0.214285714, 0.2857142857, 0, 0, 0, 0] + Validator Emission: [0, 0, 214285714, 285714285, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0, 0.214285714, 0.2857142857, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [0, 0, 214285714, 285714285, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0, 0, 0.214285714, 0.2857142857, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726]/ */ - assert_eq!(bonds[0][4], 816); - assert_eq!(bonds[1][4], 1827); - assert_eq!(bonds[2][4], 3075); - assert_eq!(bonds[3][4], 3075); + assert_eq!(bonds[0][4], 0); + assert_eq!(bonds[1][4], 0); + assert_eq!(bonds[2][4], 6378); + assert_eq!(bonds[3][4], 6378); }); } @@ -1777,51 +1779,53 @@ fn test_active_stake() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 5002; activity_cutoff: 5000 - Last update: [5002, 1, 0, 0]; Inactive: [false, true, true, true]; Block at registration: [0, 0, 0, 0] - Normalised Stake: [0.25, 0.25, 0.25, 0.25] - validator_permits: [true, true, true, true] - Active Stake: [1, 0, 0, 0] - Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Ranks (before): [0, 0, 0.5, 0.5] - Consensus: [0, 0, 0.5, 0.5] - Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Validator Trust: [1, 1, 0, 0] - Ranks (after): [0, 0, 0.5, 0.5] - Trust: [0, 0, 1, 1] - Incentive (=Rank): [0, 0, 0.5, 0.5] - Bonds: [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] - Bonds (outdatedmask): [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] - Bonds: (mask+norm) [[(2, 0.0499885557), (3, 0.0499885557)], [(2, 0.0499885557), (3, 0.0499885557)], [], []] - Alphas: [0.1, 0.1, 0.1, 0.1] - weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - emaB: [[(2, 0.0949897), (3, 0.0949897)], [(2, 0.0949897), (3, 0.0949897)], [], []] - total_bonds_per_validator: [0.5, 0.5, 0, 0] - Dividends: [1, 0, 0, 0] - Normalized Server Emission: [0, 0, 0.25, 0.25] - Server Emission: [0, 0, 250000000, 250000000] - Normalized Validator Emission: [0.5, 0, 0, 0] - Validator Emission: [500000000, 0, 0, 0] - Normalized Combined Emission: [0.5, 0, 0.25, 0.25] - Combined Emission: [500000000, 0, 250000000, 250000000] - Pruning Scores: [0.5, 0, 0.25, 0.25] + /* + current_block: 5002 + activity_cutoff: 5000 + Last update: [5002, 1, 0, 0] + Block at registration: [0, 0, 0, 0] + validator_permits: [true, true, true, true] + max_allowed_validators: 4 + new_validator_permits: [true, true, true, true] + Active Stake: [1, 0, 0, 0] + Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Ranks (before): [0, 0, 0.5, 0.5] + Consensus: [0, 0, 0.5, 0.5] + Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Validator Trust: [1, 1, 0, 0] + Ranks (after): [0, 0, 0.5, 0.5] + Trust: [0, 0, 1, 1] + Incentive (=Rank): [0, 0, 0.5, 0.5] + Bonds: [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] + Bonds: (mask+norm) [[(2, 0.0499885557), (3, 0.0499885557)], [(2, 0.0499885557), (3, 0.0499885557)], [], []] + weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + emaB: [[(2, 0.1449897), (3, 0.1449897)], [(2, 0.0449897), (3, 0.0449897)], [], []] + emaB norm: [[(2, 0.7631864299), (3, 0.7631864299)], [(2, 0.23681357), (3, 0.23681357)], [], []] + total_bonds_per_validator: [0.7631864296, 0.23681357, 0, 0] + Dividends: [1, 0, 0, 0] + Normalized Server Emission: [0, 0, 0.25, 0.25] + Server Emission: [0, 0, 250000000, 250000000] + Normalized Validator Emission: [0.5, 0, 0, 0] + Validator Emission: [500000000, 0, 0, 0] + Normalized Combined Emission: [0.5, 0, 0.25, 0.25] + Combined Emission: [500000000, 0, 250000000, 250000000] + Pruning Scores: [0.5, 0, 0.25, 0.25] */ let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 65535); assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 500000000); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[0][server], I32F32::from_num(6225)); + assert_eq!(bonds[0][server], I32F32::from_num(9501)); } for validator in 1..(n / 2) { assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, validator), 0); assert_eq!(SubtensorModule::get_emission_for_uid(netuid, validator), 0); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[validator as usize][server], I32F32::from_num(6225)); - // floor(0.45*(2^16-1))/(2^16-1), then max-upscale + assert_eq!(bonds[validator as usize][server], I32F32::from_num(2948)); } } @@ -1839,52 +1843,52 @@ fn test_active_stake() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 5003; activity_cutoff: 5000 - Last update: [5002, 5002, 0, 0]; Inactive: [false, false, true, true]; Block at registration: [0, 0, 0, 0] - Inactive: [false, false, true, true] - Block at registration: [0, 0, 0, 0] - hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3)] - Normalised Stake: [0.25, 0.25, 0.25, 0.25] - validator_permits: [true, true, true, true] - Active Stake: [0.5, 0.5, 0, 0] - Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Ranks (before): [0, 0, 0.5, 0.5] - Consensus: [0, 0, 0.5, 0.5] - Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Validator Trust: [1, 1, 0, 0] - Ranks (after): [0, 0, 0.5, 0.5] - Trust: [0, 0, 1, 1] - Incentive (=Rank): [0, 0, 0.5, 0.5] - Bonds: [[(2, 6225), (3, 6225)], [(2, 6225), (3, 6225)], [], []] - Bonds (outdatedmask): [[(2, 6225), (3, 6225)], [(2, 6225), (3, 6225)], [], []] - Bonds: (mask+norm) [[(2, 0.0949874113), (3, 0.0949874113)], [(2, 0.0949874113), (3, 0.0949874113)], [], []] - Alphas: [0.1, 0.1, 0.1, 0.1] - weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - emaB: [[(2, 0.13548867), (3, 0.13548867)], [(2, 0.13548867), (3, 0.13548867)], [], []] - total_bonds_per_validator: [0.5, 0.5, 0, 0] - Dividends: [0.5, 0.5, 0, 0] - Normalized Server Emission: [0, 0, 0.25, 0.25] - Server Emission: [0, 0, 250000000, 250000000] - Normalized Validator Emission: [0.25, 0.25, 0, 0] - Validator Emission: [250000000, 250000000, 0, 0] - Normalized Combined Emission: [0.25, 0.25, 0.25, 0.25] - Combined Emission: [250000000, 250000000, 250000000, 250000000] - Pruning Scores: [0.25, 0.25, 0.25, 0.25] + /* + current_block: 5003 + activity_cutoff: 5000 + Last update: [5002, 5002, 0, 0] + Block at registration: [0, 0, 0, 0] + validator_permits: [true, true, true, true] + max_allowed_validators: 4 + new_validator_permits: [true, true, true, true] + Active Stake: [0.5, 0.5, 0, 0] + Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Ranks (before): [0, 0, 0.5, 0.5] + Consensus: [0, 0, 0.5, 0.5] + Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + Validator Trust: [1, 1, 0, 0] + Ranks (after): [0, 0, 0.5, 0.5] + Trust: [0, 0, 1, 1] + Incentive (=Rank): [0, 0, 0.5, 0.5] + Bonds: [[(2, 9501), (3, 9501)], [(2, 2948), (3, 2948)], [], []] + Bonds: (mask+norm) [[(2, 0.144975967), (3, 0.144975967)], [(2, 0.0449835965), (3, 0.0449835965)], [], []] + weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + emaB: [[(2, 0.1804783703), (3, 0.1804783703)], [(2, 0.0904852368), (3, 0.0904852368)], [], []] + emaB norm: [[(2, 0.666061292), (3, 0.666061292)], [(2, 0.3339387078), (3, 0.3339387078)], [], []] + total_bonds_per_validator: [0.666061292, 0.3339387076, 0, 0] + Dividends: [0.6660612922, 0.3339387076, 0, 0] + Normalized Server Emission: [0, 0, 0.25, 0.25] + Server Emission: [0, 0, 250000000, 250000000] + Normalized Validator Emission: [0.333030646, 0.1669693538, 0, 0] + Validator Emission: [333030645, 166969353, 0, 0] + Normalized Combined Emission: [0.333030646, 0.1669693538, 0.25, 0.25] + Combined Emission: [333030645, 166969353, 250000000, 250000000] + Pruning Scores: [0.333030646, 0.1669693538, 0.25, 0.25] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 43650); + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 333030645); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[0][server], I32F32::from_num(8879)); + assert_eq!(bonds[0][server], I32F32::from_num(11827)); } - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 32767); - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 250000000); + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 21884); + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 166969353); for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[1][server], I32F32::from_num(8879)); + assert_eq!(bonds[1][server], I32F32::from_num(5929)); } }); } @@ -1969,33 +1973,43 @@ fn test_outdated_weights() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 1; activity_cutoff: 5000 - Last update: [1, 1, 1, 1]; Inactive: [false, false, false, false]; Block at registration: [0, 0, 0, 0] - S: [0.25, 0.25, 0.25, 0.25]; S (mask): [0.25, 0.25, 0.25, 0.25]; S (mask+norm): [0.25, 0.25, 0.25, 0.25] - validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] - W: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - W (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - W (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] - W (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] - W (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] - R (before): [0, 0, 0.3333316376, 0.166668362] - C: [0, 0, 0.6666632756, 0.3333367242] - W: [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] - Tv: [0.9999999998, 0.9999999998, 0, 0] - R (after): [0, 0, 0.3333316376, 0.166668362] - T: [0, 0, 1, 1] - I (=R): [0, 0, 0.6666632756, 0.3333367242] - B: [[], [], [], []] - B (outdatedmask): [[], [], [], []] - B (mask+norm): [[], [], [], []] - ΔB: [[(2, 0.1666658188), (3, 0.083334181)], [(2, 0.1666658188), (3, 0.083334181)], [], []] - ΔB (norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - emaB: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - D: [0.5, 0.5, 0, 0] - nE: [0.25, 0.25, 0.3333316378, 0.166668362] - E: [250000000, 250000000, 333331637, 166668361] - P: [0.25, 0.25, 0.3333316378, 0.166668362] - P (u16): [49151, 49151, 65535, 32767] */ + /* + Number of Neurons in Network: 4 + current_block: 2 + activity_cutoff: 5000 + Last update: [2, 2, 2, 2] + Block at registration: [1, 1, 1, 1] + validator_permits: [true, true, true, true] + max_allowed_validators: 4 + new_validator_permits: [true, true, true, true] + Active Stake: [0.25, 0.25, 0.25, 0.25] + Weights: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + Weights (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + Weights (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] + Weights (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] + Weights (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] + Ranks (before): [0, 0, 0.3333316376, 0.166668362] + Consensus: [0, 0, 0.6666632756, 0.3333367242] + Clipped Weights: [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] + Validator Trust: [0.9999999998, 0.9999999998, 0, 0] + Ranks (after): [0, 0, 0.3333316376, 0.166668362] + Trust: [0, 0, 1, 1] + Incentive (=Rank): [0, 0, 0.6666632756, 0.3333367242] + Bonds: [[], [], [], []] + Bonds: (mask+norm) [[], [], [], []] + weights_for_bonds: [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] + emaB: [[(2, 0.05), (3, 0.05)], [(2, 0.05), (3, 0.05)], [], []] + emaB norm: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + total_bonds_per_validator: [0.4999999998, 0.4999999998, 0, 0] + Dividends: [0.5, 0.5, 0, 0] + Normalized Server Emission: [0, 0, 0.3333316378, 0.166668362] + Server Emission: [0, 0, 333331637, 166668361] + Normalized Validator Emission: [0.25, 0.25, 0, 0] + Validator Emission: [250000000, 250000000, 0, 0] + Normalized Combined Emission: [0.25, 0.25, 0.3333316378, 0.166668362] + Combined Emission: [250000000, 250000000, 333331637, 166668361] + Pruning Scores: [0.25, 0.25, 0.3333316378, 0.166668362] + */ // === Dereg server2 at uid3 (least emission) + register new key over uid3 let new_key: u64 = n as u64; // register a new key while at max capacity, which means the least incentive uid will be deregistered @@ -2038,41 +2052,48 @@ fn test_outdated_weights() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* current_block: 2; activity_cutoff: 5000 - Last update: [2, 1, 1, 1]; Inactive: [false, false, false, false]; Block at registration: [0, 0, 0, 1] - S: [0.3333333333, 0.3333333333, 0.3333333333, 0] - S (mask): [0.3333333333, 0.3333333333, 0.3333333333, 0] - S (mask+norm): [0.3333333333, 0.3333333333, 0.3333333333, 0] - validator_permits: [true, true, true, false]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] - W: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - W (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - W (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] - W (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535)], [], []] - W (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 1)], [], []] - R (before): [0, 0, 0.5555544249, 0.1111122412] - C: [0, 0, 0.6666632756, 0] - W: [[(2, 0.6666632756)], [(2, 0.6666632756)], [], []] - Tv: [0.6666632756, 0.6666632756, 0, 0] - R (after): [0, 0, 0.4444421832, 0] - T: [0, 0, 0.799997558, 0] - I (=R): [0, 0, 1, 0] - B: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 65535)], [], []] - B (mask+norm): [[(2, 0.5), (3, 1)], [(2, 0.5)], [], []] - ΔB: [[(2, 0.2222210916)], [(2, 0.2222210916)], [], []] - ΔB (norm): [[(2, 0.5)], [(2, 0.5)], [], []] - emaB: [[(2, 0.5), (3, 1)], [(2, 0.5)], [], []] - emaB (max-upscale): [[(2, 1), (3, 1)], [(2, 1)], [], []] - D: [0.5, 0.5, 0, 0] - nE: [0.25, 0.25, 0.5, 0] - E: [250000000, 250000000, 500000000, 0] - P: [0.25, 0.25, 0.5, 0] - P (u16): [32767, 32767, 65535, 0] */ + /* + Number of Neurons in Network: 4 + current_block: 3 + activity_cutoff: 5000 + Last update: [3, 2, 2, 2] + Block at registration: [1, 1, 1, 2] + validator_permits: [true, true, true, true] + max_allowed_validators: 4 + new_validator_permits: [true, true, true, true] + Active Stake: [0.3333333333, 0.3333333333, 0.3333333333, 0] + Weights: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + Weights (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + Weights (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] + Weights (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535)], [], []] + Weights (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 1)], [], []] + Ranks (before): [0, 0, 0.5555544249, 0.1111122412] + Consensus: [0, 0, 0.6666632756, 0] + Clipped Weights: [[(2, 0.6666632756)], [(2, 0.6666632756)], [], []] + Validator Trust: [0.6666632756, 0.6666632756, 0, 0] + Ranks (after): [0, 0, 0.4444421832, 0] + Trust: [0, 0, 0.799997558, 0] + Incentive (=Rank): [0, 0, 1, 0] + Bonds: [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] + Bonds: (mask+norm) [[(2, 0.0499885557), (3, 0.0499885557)], [(2, 0.0499885557)], [], []] + weights_for_bonds: [[(2, 0.6666632756)], [(2, 0.6666632756)], [], []] + emaB: [[(2, 0.0949897), (3, 0.0449897)], [(2, 0.0949897)], [], []] + emaB norm: [[(2, 0.5), (3, 1)], [(2, 0.5)], [], []] + total_bonds_per_validator: [0.5, 0.5, 0, 0] + Dividends: [0.5, 0.5, 0, 0] + Normalized Server Emission: [0, 0, 0.5, 0] + Server Emission: [0, 0, 500000000, 0] + Normalized Validator Emission: [0.25, 0.25, 0, 0] + Validator Emission: [250000000, 250000000, 0, 0] + Normalized Combined Emission: [0.25, 0.25, 0.5, 0] + Combined Emission: [250000000, 250000000, 500000000, 0] + Pruning Scores: [0.25, 0.25, 0.5, 0] + */ let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); // Note D = floor(0.5 * 65_535) assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); // Note E = 0.5 * 0.5 * 1_000_000_000 = 249311245 - assert_eq!(bonds[0][2], I32F32::from_num(8300)); - assert_eq!(bonds[0][3], I32F32::from_num(1965)); + assert_eq!(bonds[0][2], I32F32::from_num(6225)); + assert_eq!(bonds[0][3], I32F32::from_num(2948)); }); } @@ -2133,7 +2154,7 @@ fn test_zero_weights() { S: [1, 0]; S (mask): [1, 0]; S (mask+norm): [1, 0]; Block at registration: [0, 0] W: [[], []]; W (diagmask): [[], []]; W (diag+outdatemask): [[], []]; W (mask+norm): [[], []] R: [0, 0]; W (threshold): [[], []]; T: [0, 0]; C: [0.006693358, 0.006693358]; I: [0, 0] - B: [[], []]; B (outdatedmask): [[], []]; B (mask+norm): [[], []]; + B: [[], []]; B (mask+norm): [[], []]; ΔB: [[], []]; ΔB (norm): [[], []]; emaB: [[], []]; D: [0, 0] E: [1000000000, 0]; P: [1, 0] */ for validator in 0..(n / 2) { @@ -2169,7 +2190,7 @@ fn test_zero_weights() { W: [[], [(1, 1)]] W (diagmask): [[], []]; W (diag+outdatemask): [[], []]; W (mask+norm): [[], []] R: [0, 0]; W (threshold): [[], []]; T: [0, 0]; C: [0.006693358, 0.006693358]; I: [0, 0] - B: [[], []]: B (outdatedmask): [[], []]; B (mask+norm): [[], []] + B: [[], []]: B (mask+norm): [[], []] ΔB: [[], []]; ΔB (norm): [[], []]; emaB: [[], []]; D: [0, 0] E: [1000000000, 0]; P: [1, 0] */ for validator in 0..(n / 2) { @@ -2224,7 +2245,7 @@ fn test_zero_weights() { S: [1, 0]; S (mask): [1, 0]; S (mask+norm): [1, 0]; Block at registration: [0, 2]; W: [[(1, 1)], []]; W (diagmask): [[(1, 1)], []]; W (diag+outdatemask): [[], []]; W (mask+norm): [[], []]; R: [0, 0]; W (threshold): [[], []]; T: [0, 0]; C: [0.006693358, 0.006693358]; I: [0, 0]; - B: [[], []]; B (outdatedmask): [[], []]; B (mask+norm): [[], []]; + B: [[], []]; B (mask+norm): [[], []]; ΔB: [[], []]; ΔB (norm): [[], []]; emaB: [[], []]; D: [0, 0]; E: [1000000000, 0]; P: [1, 0] */ for validator in 0..(n / 2) { @@ -2258,7 +2279,7 @@ fn test_zero_weights() { S: [1, 0]; S (mask): [1, 0]; S (mask+norm): [1, 0]; Block at registration: [0, 2]; W: [[(1, 1)], []]; W (diagmask): [[(1, 1)], []]; W (diag+outdatemask): [[(1, 1)], []]; W (mask+norm): [[(1, 1)], []]; R: [0, 1]; W (threshold): [[(1, 1)], []]; T: [0, 1]; C: [0.006693358, 0.9933076561]; I: [0, 1]; - B: [[], []]; B (outdatedmask): [[], []]; B (mask+norm): [[], []]; + B: [[], []]; B (mask+norm): [[], []]; ΔB: [[(1, 1)], []]; ΔB (norm): [[(1, 1)], []]; emaB: [[(1, 1)], []]; D: [1, 0]; emaB (max-upscale): [[(1, 1)], []] E: [500000000, 500000000]; P: [0.5, 0.5] */ for validator in 0..n { @@ -3084,8 +3105,7 @@ fn run_epoch_and_check_bonds_dividends( target_dividends: &[f32], ) { run_epoch(netuid, sparse); - let mut bonds = SubtensorModule::get_bonds(netuid); - bonds = mat_fixed_proportions_to_fixed(bonds.clone()); + let bonds = SubtensorModule::get_bonds(netuid); let dividends = SubtensorModule::get_dividends(netuid); let epsilon = I32F32::from_num(1e-3); From f57481f315e9b7eda8e68f343eebfe8df836f648 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 20 Mar 2025 15:26:13 +0000 Subject: [PATCH 031/226] clippy refactor --- pallets/subtensor/src/epoch/math.rs | 80 ++++++------ pallets/subtensor/src/epoch/run_epoch.rs | 156 ++++++++++++----------- pallets/subtensor/src/tests/epoch.rs | 27 ---- 3 files changed, 120 insertions(+), 143 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 9d783acc11..e80c03e99a 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1380,50 +1380,48 @@ pub fn mat_ema_alpha_sparse( // The output vector of rows. let mut result: Vec> = Vec::with_capacity(new.len()); - - let n = new.len(); // Assume square matrix, rows=cols let zero: I32F32 = I32F32::saturating_from_num(0.0); + let one = I32F32::saturating_from_num(1.0); // Iterate over each row of the matrices. - for (i, (new_row, old_row)) in new.iter().zip(old).enumerate() { + for ((new_row, old_row), alpha_row) in new.iter().zip(old).zip(alpha) { // Initialize a row of zeros for the result matrix. - let mut decayed_values: Vec = vec![zero; n]; + let mut decayed_values: Vec = vec![zero; alpha_row.len()]; let mut result_row: Vec<(u16, I32F32)> = Vec::new(); // Process the old matrix values. for (j, old_val) in old_row.iter() { - let alpha_val = alpha[i][*j as usize]; - // Calculate the complement of the alpha value - let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(alpha_val); - - // Bonds_decayed = Bonds * (1 - alpha) - let decayed_val = one_minus_alpha.saturating_mul(*old_val); - decayed_values[*j as usize] = decayed_val; + if let (Some(alpha_val), Some(decayed_val)) = ( + alpha_row.get(*j as usize), + decayed_values.get_mut(*j as usize), + ) { + // Calculate the complement of the alpha value + let one_minus_alpha = one.saturating_sub(*alpha_val); + // Bonds_decayed = Bonds * (1 - alpha) + *decayed_val = one_minus_alpha.saturating_mul(*old_val); + } } // Process the new matrix values. for (j, new_val) in new_row.iter() { - let alpha_val = alpha[i][*j as usize]; - let decayed_val = decayed_values[*j as usize]; - - // Calculate remaining capacity to limit bonds purchase - let remaining_capacity = I32F32::from_num(1.0) - .saturating_sub(decayed_val) - .max(I32F32::from_num(0.0)); - - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap - // Validators allocate their purchase across miners based on weights - let purchase_increment = alpha_val.saturating_mul(*new_val); - - // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.min(remaining_capacity); - - let result_val = decayed_val - .saturating_add(purchase) - .min(I32F32::from_num(1.0)); - if result_val > zero { - result_row.push(({ *j }, result_val)); + if let (Some(alpha_val), Some(decayed_val)) = + (alpha_row.get(*j as usize), decayed_values.get(*j as usize)) + { + // Calculate remaining capacity to limit bonds purchase + let remaining_capacity = one.saturating_sub(*decayed_val).max(zero); + + // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap + // Validators allocate their purchase across miners based on weights + let purchase_increment = alpha_val.saturating_mul(*new_val); + + // Ensure that purchase does not exceed remaining capacity + let purchase = purchase_increment.min(remaining_capacity); + + let result_val = decayed_val.saturating_add(purchase).min(one); + if result_val > zero { + result_row.push((*j, result_val)); + } } } result.push(result_row); @@ -1450,11 +1448,11 @@ pub fn mat_ema_alpha( assert!(new.len() == alpha.len()); // Initialize the result matrix with zeros, having the same dimensions as the new matrix. - let mut result: Vec> = - vec![ - vec![I32F32::saturating_from_num(0.0); new.first().map_or(0, |row| row.len())]; - new.len() - ]; + let zero: I32F32 = I32F32::saturating_from_num(0.0); + let one = I32F32::saturating_from_num(1.0); + let n = new.len(); // assume square matrix + + let mut result: Vec> = vec![vec![zero; n]; n]; // Iterate over each row of the matrices. for (i, ((new_row, old_row), alpha_row)) in new.iter().zip(old).zip(alpha).enumerate() { @@ -1471,15 +1469,13 @@ pub fn mat_ema_alpha( result.get_mut(i).and_then(|row| row.get_mut(j)), ) { // Calculate the complement of the alpha value - let one_minus_alpha = I32F32::saturating_from_num(1.0).saturating_sub(*alpha_val); + let one_minus_alpha = one.saturating_sub(*alpha_val); // Bonds_decayed = Bonds * (1 - alpha) let decayed_val = one_minus_alpha.saturating_mul(*old_val); // Calculate remaining capacity to limit bonds purchase - let remaining_capacity = I32F32::from_num(1.0) - .saturating_sub(decayed_val) - .max(I32F32::from_num(0.0)); + let remaining_capacity = one.saturating_sub(decayed_val).max(zero); // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap // Validators allocate their purchase across miners based on weights @@ -1488,9 +1484,7 @@ pub fn mat_ema_alpha( // Ensure that purchase does not exceed remaining capacity let purchase = purchase_increment.min(remaining_capacity); - *result_val = decayed_val - .saturating_add(purchase) - .min(I32F32::from_num(1.0)); + *result_val = decayed_val.saturating_add(purchase).min(one); } } } diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 347828b6f3..25fd599ccd 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -898,8 +898,8 @@ impl Pallet { netuid: u16, weights: &[Vec], // weights_for_bonds bonds: &[Vec], - consensus: &Vec, - active_stake: &Vec, + consensus: &[I32F32], + active_stake: &[I32F32], ) -> Vec> { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) @@ -944,8 +944,8 @@ impl Pallet { netuid: u16, weights: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], - consensus: &Vec, - active_stake: &Vec, + consensus: &[I32F32], + active_stake: &[I32F32], ) -> Vec> { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) @@ -993,10 +993,9 @@ impl Pallet { netuid: u16, weights: &[Vec], // current epoch weights bonds: &[Vec], // previous epoch bonds - consensus: &Vec, // previous epoch consensus weights + consensus: &[I32F32], // previous epoch consensus weights ) -> Vec> { assert!(weights.len() == bonds.len()); - let n = weights.len(); // Assume square matrix, rows=cols // Get the high and low alpha values for the network. let alpha_sigmoid_steepness: I32F32 = I32F32::from_num(10.0); @@ -1004,37 +1003,19 @@ impl Pallet { let mut alphas = Vec::new(); - for i in 0..n { + for (w_row, b_row) in weights.iter().zip(bonds.iter()) { let mut row_alphas = Vec::new(); - for j in 0..weights[i].len() { - let diff_buy = clamp_value( - weights[i][j] - consensus[j], - I32F32::from_num(0.0), - I32F32::from_num(1.0), - ); - let diff_sell = clamp_value( - bonds[i][j] - weights[i][j], - I32F32::from_num(0.0), - I32F32::from_num(1.0), + for ((weight, bond), cons) in w_row.iter().zip(b_row.iter()).zip(consensus.iter()) { + let alpha = Self::alpha_sigmoid( + *cons, + *weight, + *bond, + alpha_low, + alpha_high, + alpha_sigmoid_steepness, ); - - let combined_diff = if weights[i][j] >= bonds[i][j] { - diff_buy - } else { - diff_sell - }; - - // sigmoid = 1. / (1. + e^(-alpha_sigmoid_steepness * (combined_diff - 0.5))) - let sigmoid = I32F32::from_num(1.0).saturating_div( - I32F32::from_num(1.0) - + safe_exp( - -alpha_sigmoid_steepness - .saturating_mul(combined_diff - I32F32::from_num(0.5)), - ), - ); - let alpha = alpha_low + sigmoid * (alpha_high - alpha_low); - row_alphas.push(clamp_value(alpha, alpha_low, alpha_high)); + row_alphas.push(alpha); } alphas.push(row_alphas); } @@ -1056,58 +1037,56 @@ impl Pallet { netuid: u16, weights: &[Vec<(u16, I32F32)>], // current epoch weights bonds: &[Vec<(u16, I32F32)>], // previous epoch bonds - consensus: &Vec, // previous epoch consensus weights + consensus: &[I32F32], // previous epoch consensus weights ) -> Vec> { assert!(weights.len() == bonds.len()); - let n = weights.len() as u16; // Assume square matrix, rows=cols - // + let alpha_sigmoid_steepness: I32F32 = I32F32::from_num(10.0); let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); - let mut alphas = Vec::with_capacity(n as usize); + let mut alphas = Vec::with_capacity(consensus.len()); + let zero = I32F32::from_num(0.0); // iterate over rows for (w_row, b_row) in weights.iter().zip(bonds.iter()) { let mut row_alphas = Vec::with_capacity(w_row.len()); - let mut w_iter = 0; - let mut b_iter = 0; - for j in 0..n { - while w_iter < w_row.len() && w_row[w_iter].0 < j { - w_iter += 1; + let mut w_iter = w_row.iter().peekable(); + let mut b_iter = b_row.iter().peekable(); + for (j_pos, consensus_val) in consensus.iter().enumerate() { + let j = j_pos as u16; + + let mut weight = zero; + while let Some(&&(i, val)) = w_iter.peek() { + if i < j { + w_iter.next(); + } else { + if i == j { + weight = val; + } + break; + } } - let w_val = if w_iter < w_row.len() && w_row[w_iter].0 == j { - w_row[w_iter].1 - } else { - I32F32::from_num(0.0) - }; - while b_iter < b_row.len() && b_row[b_iter].0 < j { - b_iter += 1; + let mut bond = zero; + while let Some(&&(i, val)) = b_iter.peek() { + if i < j { + b_iter.next(); + } else { + if i == j { + bond = val; + } + break; + } } - let b_val = if b_iter < b_row.len() && b_row[b_iter].0 == j { - b_row[b_iter].1 - } else { - I32F32::from_num(0.0) - }; - - let diff_buy = (w_val - consensus[j as usize]) - .max(I32F32::from_num(0.0)) - .min(I32F32::from_num(1.0)); - let diff_sell = (b_val - w_val) - .max(I32F32::from_num(0.0)) - .min(I32F32::from_num(1.0)); - let combined_diff = if w_val >= b_val { diff_buy } else { diff_sell }; - - // sigmoid = 1. / (1. + e^(-alpha_sigmoid_steepness * (combined_diff - 0.5))) - let sigmoid = I32F32::from_num(1.0).saturating_div( - I32F32::from_num(1.0) - + safe_exp( - -alpha_sigmoid_steepness - .saturating_mul(combined_diff - I32F32::from_num(0.5)), - ), + + let alpha = Self::alpha_sigmoid( + *consensus_val, + weight, + bond, + alpha_low, + alpha_high, + alpha_sigmoid_steepness, ); - let mut alpha = alpha_low + sigmoid * (alpha_high - alpha_low); - alpha = alpha.max(alpha_low).min(alpha_high); row_alphas.push(alpha); } alphas.push(row_alphas); @@ -1115,6 +1094,37 @@ impl Pallet { alphas } + /// Helper function to compute the alpha value using a sigmoid function. + pub fn alpha_sigmoid( + consensus: I32F32, + weight: I32F32, + bond: I32F32, + alpha_low: I32F32, + alpha_high: I32F32, + alpha_sigmoid_steepness: I32F32, + ) -> I32F32 { + let zero = I32F32::from_num(0.0); + let one = I32F32::from_num(1.0); + + let diff_buy = clamp_value(weight.saturating_sub(consensus), zero, one); + let diff_sell = clamp_value(bond.saturating_sub(weight), zero, one); + let combined_diff = if weight >= bond { diff_buy } else { diff_sell }; + + // sigmoid = 1. / (1. + e^(-steepness * (combined_diff - 0.5))) + let sigmoid = one.saturating_div( + one.saturating_add(safe_exp( + I32F32::from_num(-1).saturating_mul( + alpha_sigmoid_steepness + .saturating_mul(combined_diff.saturating_sub(I32F32::from_num(0.5))), + ), + )), + ); + let alpha = + alpha_low.saturating_add(sigmoid.saturating_mul(alpha_high.saturating_sub(alpha_low))); + + clamp_value(alpha, alpha_low, alpha_high) + } + pub fn compute_disabled_liquid_alpha(netuid: u16) -> I32F32 { // Retrieve the bonds moving average for the given network ID and scale it down. let bonds_moving_average: I64F64 = I64F64::from_num(Self::get_bonds_moving_average(netuid)) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 733372c728..4422f4faf5 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3002,33 +3002,6 @@ pub fn assert_approx_eq(left: I32F32, right: I32F32, epsilon: I32F32) { } } -/// Helper function to assert approximate equality of two vectors of vectors of tuples. -fn assert_approx_eq_vec_of_vec( - left: &[Vec<(u16, I32F32)>], - right: &[Vec<(u16, I32F32)>], - epsilon: I32F32, -) { - assert_eq!(left.len(), right.len(), "Vectors have different lengths"); - for (left_row, right_row) in left.iter().zip(right.iter()) { - assert_eq!( - left_row.len(), - right_row.len(), - "Rows have different lengths" - ); - for ((left_idx, left_val), (right_idx, right_val)) in left_row.iter().zip(right_row.iter()) - { - assert_eq!(left_idx, right_idx, "Indices are different"); - assert!( - (left_val - right_val).abs() < epsilon, - "Values are different: left = {:?}, right = {:?}, epsilon = {:?}", - left_val, - right_val, - epsilon - ); - } - } -} - // test Yuma 4 scenarios over a sequence of epochs. fn setup_yuma_4_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stakes: Vec) { let block_number = System::block_number(); From 9cdef41d68679972995b451becd0961740a6273c Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 20 Mar 2025 16:38:17 +0000 Subject: [PATCH 032/226] add alpha sigmoid steepness param --- hyperparameters.md | 2 ++ pallets/admin-utils/src/lib.rs | 29 ++++++++++++++++++++++++++ pallets/admin-utils/src/tests/mock.rs | 2 ++ pallets/subtensor/src/lib.rs | 9 ++++++++ pallets/subtensor/src/macros/config.rs | 3 +++ pallets/subtensor/src/macros/events.rs | 2 ++ pallets/subtensor/src/tests/mock.rs | 2 ++ pallets/subtensor/src/utils/misc.rs | 8 +++++++ precompiles/src/subnet.rs | 22 +++++++++++++++++++ runtime/src/lib.rs | 4 +++- 10 files changed, 82 insertions(+), 1 deletion(-) diff --git a/hyperparameters.md b/hyperparameters.md index c8d2ce1106..049ace84d2 100644 --- a/hyperparameters.md +++ b/hyperparameters.md @@ -7,6 +7,7 @@ TxRateLimit: u64 = 1; // [1 @ 64,888] ### netuid 1 (text_prompting) ```rust Rho: u16 = 10; +AlphaSigmoidSteepness: u16 = 10.0 Kappa: u16 = 32_767; // 0.5 = 65535/2 MaxAllowedUids: u16 = 1024; Issuance: u64 = 0; @@ -46,6 +47,7 @@ WeightsSetRateLimit: u64 = 100; ### netuid 3 (causallmnext) ```rust Rho: u16 = 10; +AlphaSigmoidSteepness: u16 = 10.0 Kappa: u16 = 32_767; // 0.5 = 65535/2 MaxAllowedUids: u16 = 4096; Issuance: u64 = 0; diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 19bbbee73b..0175401b7f 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1476,6 +1476,35 @@ pub mod pallet { ); Ok(()) } + + /// + /// + /// # Arguments + /// * `origin` - The origin of the call, which must be the root account. + /// * `netuid` - The unique identifier for the subnet. + /// * `steepness` - The new steepness for the alpha sigmoid function. + /// + /// # Errors + /// * `BadOrigin` - If the caller is not the root account. + /// # Weight + /// Weight is handled by the `#[pallet::weight]` attribute. + #[pallet::call_index(66)] + #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + pub fn sudo_set_alpha_sigmoid_steepness( + origin: OriginFor, + netuid: u16, + steepness: u16, + ) -> DispatchResult { + ensure_root(origin)?; + pallet_subtensor::Pallet::::set_alpha_sigmoid_steepness(netuid, steepness); + + log::debug!( + "AlphaSigmoidSteepnessSet( netuid: {:?}, steepness: {:?} )", + netuid, + steepness + ); + Ok(()) + } } } diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 99c11b7165..6932632f4b 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -80,6 +80,7 @@ parameter_types! { pub const TransactionByteFee: Balance = 100; pub const SDebug:u64 = 1; pub const InitialRho: u16 = 30; + pub const InitialAlphaSigmoidSteepness: u16 = u16::MAX/10; // 10% steepness pub const InitialKappa: u16 = 32_767; pub const InitialTempo: u16 = 0; pub const SelfOwnership: u64 = 2; @@ -157,6 +158,7 @@ impl pallet_subtensor::Config for Test { type InitialAdjustmentAlpha = InitialAdjustmentAlpha; type InitialTargetRegistrationsPerInterval = InitialTargetRegistrationsPerInterval; type InitialRho = InitialRho; + type InitialAlphaSigmoidSteepness = InitialAlphaSigmoidSteepness; type InitialKappa = InitialKappa; type InitialMaxAllowedUids = InitialMaxAllowedUids; type InitialValidatorPruneLen = InitialValidatorPruneLen; diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index e360c307e1..a78001e66b 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -566,6 +566,11 @@ pub mod pallet { T::InitialRho::get() } #[pallet::type_value] + /// Default value for alpha sigmoid steepness. + pub fn DefaultAlphaSigmoidSteepness() -> u16 { + T::InitialAlphaSigmoidSteepness::get() + } + #[pallet::type_value] /// Default value for kappa parameter. pub fn DefaultKappa() -> u16 { T::InitialKappa::get() @@ -1215,6 +1220,10 @@ pub mod pallet { /// --- MAP ( netuid ) --> Rho pub type Rho = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultRho>; #[pallet::storage] + /// --- MAP ( netuid ) --> AlphaSigmoidSteepness + pub type AlphaSigmoidSteepness = + StorageMap<_, Identity, u16, u16, ValueQuery, DefaultAlphaSigmoidSteepness>; + #[pallet::storage] /// --- MAP ( netuid ) --> Kappa pub type Kappa = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultKappa>; #[pallet::storage] diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index cf4d97b65b..76e7840e74 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -102,6 +102,9 @@ mod config { /// Rho constant. #[pallet::constant] type InitialRho: Get; + /// AlphaSigmoidSteepness constant. + #[pallet::constant] + type InitialAlphaSigmoidSteepness: Get; /// Kappa constant. #[pallet::constant] type InitialKappa: Get; diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index 8c2e863d0e..771e3f545a 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -43,6 +43,8 @@ mod events { ActivityCutoffSet(u16, u16), /// Rho value is set. RhoSet(u16, u16), + /// steepness of the sigmoid used to compute alpha values. + AlphaSigmoidSteepnessSet(u16, u16), /// Kappa is set for a subnet. KappaSet(u16, u16), /// minimum allowed weight is set for a subnet. diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 9729d55d1a..eb86dc8935 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -132,6 +132,7 @@ parameter_types! { pub const TransactionByteFee: Balance = 100; pub const SDebug:u64 = 1; pub const InitialRho: u16 = 30; + pub const InitialAlphaSigmoidSteepness: u16 = u16::MAX/10; pub const InitialKappa: u16 = 32_767; pub const InitialTempo: u16 = 360; pub const SelfOwnership: u64 = 2; @@ -366,6 +367,7 @@ impl crate::Config for Test { type InitialAdjustmentAlpha = InitialAdjustmentAlpha; type InitialTargetRegistrationsPerInterval = InitialTargetRegistrationsPerInterval; type InitialRho = InitialRho; + type InitialAlphaSigmoidSteepness = InitialAlphaSigmoidSteepness; type InitialKappa = InitialKappa; type InitialMaxAllowedUids = InitialMaxAllowedUids; type InitialValidatorPruneLen = InitialValidatorPruneLen; diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index 6f2ea1ffa3..72eeb5bc5e 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -687,6 +687,14 @@ impl Pallet { (converted_low, converted_high) } + pub fn set_alpha_sigmoid_steepness(netuid: u16, steepness: u16) { + AlphaSigmoidSteepness::::insert(netuid, steepness); + } + pub fn get_alpha_sigmoid_steepness(netuid: u16) -> I32F32 { + let alpha = AlphaSigmoidSteepness::::get(netuid); + I32F32::saturating_from_num(alpha).safe_div(I32F32::saturating_from_num(u16::MAX)) + } + pub fn set_liquid_alpha_enabled(netuid: u16, enabled: bool) { LiquidAlphaOn::::set(netuid, enabled); } diff --git a/precompiles/src/subnet.rs b/precompiles/src/subnet.rs index e9bfc0c5f9..ae57584eb5 100644 --- a/precompiles/src/subnet.rs +++ b/precompiles/src/subnet.rs @@ -327,6 +327,12 @@ where Ok(pallet_subtensor::Rho::::get(netuid)) } + #[precompile::public("getAlphaSigmoidSteepness(uint16)")] + #[precompile::view] + fn get_alpha_sigmoid_steepness(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::AlphaSigmoidSteepness::::get(netuid)) + } + #[precompile::public("setRho(uint16,uint16)")] #[precompile::payable] fn set_rho(handle: &mut impl PrecompileHandle, netuid: u16, rho: u16) -> EvmResult<()> { @@ -338,6 +344,22 @@ where ) } + #[precompile::public("setAlphaSigmoidSteepness(uint16,uint16)")] + #[precompile::payable] + fn set_alpha_sigmoid_steepness( + handle: &mut impl PrecompileHandle, + netuid: u16, + steepness: u16, + ) -> EvmResult<()> { + let call = + pallet_admin_utils::Call::::sudo_set_alpha_sigmoid_steepness { netuid, steepness }; + + handle.try_dispatch_runtime_call::( + call, + RawOrigin::Signed(handle.caller_account_id::()), + ) + } + #[precompile::public("getActivityCutoff(uint16)")] #[precompile::view] fn get_activity_cutoff(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 41117a6c5d..e7d0732cfa 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -990,7 +990,8 @@ pub const INITIAL_CHILDKEY_TAKE_RATELIMIT: u64 = 5; // Configure the pallet subtensor. parameter_types! { - pub const SubtensorInitialRho: u16 = 10; + pub const SubtensorInitialRho: u16 = u16::MAX/10; // 10% + pub const SubtensorInitialAlphaSigmoidSteepness: u16 = 1000; pub const SubtensorInitialKappa: u16 = 32_767; // 0.5 = 65535/2 pub const SubtensorInitialMaxAllowedUids: u16 = 4096; pub const SubtensorInitialIssuance: u64 = 0; @@ -1061,6 +1062,7 @@ impl pallet_subtensor::Config for Runtime { type TriumvirateInterface = TriumvirateVotes; type Scheduler = Scheduler; type InitialRho = SubtensorInitialRho; + type InitialAlphaSigmoidSteepness = SubtensorInitialAlphaSigmoidSteepness; type InitialKappa = SubtensorInitialKappa; type InitialMaxAllowedUids = SubtensorInitialMaxAllowedUids; type InitialBondsMovingAverage = SubtensorInitialBondsMovingAverage; From ae6d281b9fd0dc0ec9e1e74d58fca8c0a34c8137 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Fri, 21 Mar 2025 10:47:52 +0000 Subject: [PATCH 033/226] refactor bonds fetching --- pallets/subtensor/src/epoch/math.rs | 24 ++++++++++------- pallets/subtensor/src/epoch/run_epoch.rs | 34 +++++++++++++++++++----- pallets/subtensor/src/tests/epoch.rs | 2 +- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index e80c03e99a..365276ca9f 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -55,6 +55,11 @@ pub fn u16_proportion_to_fixed(x: u16) -> I32F32 { I32F32::saturating_from_num(x).safe_div(I32F32::saturating_from_num(u16::MAX)) } +#[allow(dead_code)] +pub fn fixed_to_fixed_proportion(x: I32F32) -> I32F32 { + x.safe_div(I32F32::saturating_from_num(u16::MAX)) +} + #[allow(dead_code)] pub fn fixed_proportion_to_u16(x: I32F32) -> u16 { fixed_to_u16(x.saturating_mul(I32F32::saturating_from_num(u16::MAX))) @@ -1450,24 +1455,21 @@ pub fn mat_ema_alpha( // Initialize the result matrix with zeros, having the same dimensions as the new matrix. let zero: I32F32 = I32F32::saturating_from_num(0.0); let one = I32F32::saturating_from_num(1.0); - let n = new.len(); // assume square matrix - let mut result: Vec> = vec![vec![zero; n]; n]; + let mut result: Vec> = Vec::with_capacity(new.len()); // Iterate over each row of the matrices. - for (i, ((new_row, old_row), alpha_row)) in new.iter().zip(old).zip(alpha).enumerate() { + for ((new_row, old_row), alpha_row) in new.iter().zip(old).zip(alpha) { assert!(new_row.len() == old_row.len()); assert!(new_row.len() == alpha_row.len()); + let mut result_row: Vec = Vec::new(); // Iterate over each column of the current row. for j in 0..new_row.len() { // Compute the EMA for the current element using saturating operations. - if let (Some(new_val), Some(old_val), Some(alpha_val), Some(result_val)) = ( - new_row.get(j), - old_row.get(j), - alpha_row.get(j), - result.get_mut(i).and_then(|row| row.get_mut(j)), - ) { + if let (Some(new_val), Some(old_val), Some(alpha_val)) = + (new_row.get(j), old_row.get(j), alpha_row.get(j)) + { // Calculate the complement of the alpha value let one_minus_alpha = one.saturating_sub(*alpha_val); @@ -1484,9 +1486,11 @@ pub fn mat_ema_alpha( // Ensure that purchase does not exceed remaining capacity let purchase = purchase_increment.min(remaining_capacity); - *result_val = decayed_val.saturating_add(purchase).min(one); + let result_val = decayed_val.saturating_add(purchase).min(one); + result_row.push(result_val); } } + result.push(result_row); } // Return the computed EMA matrix. diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 25fd599ccd..c65e239867 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -198,7 +198,7 @@ impl Pallet { interpolate(&weights, &clipped_weights, bonds_penalty); // Access network bonds. - let mut bonds: Vec> = Self::get_bonds(netuid); + let mut bonds: Vec> = Self::get_bonds_fixed_proportion(netuid); inplace_mask_matrix(&outdated, &mut bonds); // mask outdated bonds log::trace!("B: {:?}", &bonds); @@ -573,7 +573,7 @@ impl Pallet { interpolate_sparse(&weights, &clipped_weights, n, bonds_penalty); // Access network bonds. - let mut bonds: Vec> = Self::get_bonds_sparse(netuid); + let mut bonds: Vec> = Self::get_bonds_sparse_fixed_proportion(netuid); log::trace!("Bonds: {:?}", &bonds); // Remove bonds referring to neurons that have registered since last tempo. @@ -857,7 +857,7 @@ impl Pallet { bonds .get_mut(uid_i as usize) .expect("uid_i is filtered to be less than n; qed") - .push((uid_j, u16_proportion_to_fixed(bonds_ij))); + .push((uid_j, u16_to_fixed(bonds_ij))); } } bonds @@ -877,12 +877,32 @@ impl Pallet { .expect("uid_i has been filtered to be less than n; qed") .get_mut(uid_j as usize) .expect("uid_j has been filtered to be less than n; qed") = - u16_proportion_to_fixed(bonds_ij); + u16_to_fixed(bonds_ij); } } bonds } + pub fn get_bonds_fixed_proportion(netuid: u16) -> Vec> { + let mut bonds = Self::get_bonds(netuid); + bonds.iter_mut().for_each(|bonds_row| { + bonds_row + .iter_mut() + .for_each(|bond| *bond = fixed_to_fixed_proportion(*bond)); + }); + bonds + } + + pub fn get_bonds_sparse_fixed_proportion(netuid: u16) -> Vec> { + let mut bonds = Self::get_bonds_sparse(netuid); + bonds.iter_mut().for_each(|bonds_row| { + bonds_row + .iter_mut() + .for_each(|(_, bond)| *bond = fixed_to_fixed_proportion(*bond)); + }); + bonds + } + /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting /// /// # Args: @@ -1006,9 +1026,11 @@ impl Pallet { for (w_row, b_row) in weights.iter().zip(bonds.iter()) { let mut row_alphas = Vec::new(); - for ((weight, bond), cons) in w_row.iter().zip(b_row.iter()).zip(consensus.iter()) { + for ((weight, bond), consensus_val) in + w_row.iter().zip(b_row.iter()).zip(consensus.iter()) + { let alpha = Self::alpha_sigmoid( - *cons, + *consensus_val, *weight, *bond, alpha_low, diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 4422f4faf5..62b94e8331 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3078,7 +3078,7 @@ fn run_epoch_and_check_bonds_dividends( target_dividends: &[f32], ) { run_epoch(netuid, sparse); - let bonds = SubtensorModule::get_bonds(netuid); + let bonds = SubtensorModule::get_bonds_fixed_proportion(netuid); let dividends = SubtensorModule::get_dividends(netuid); let epsilon = I32F32::from_num(1e-3); From fc06c55e447be089dd50a1b82bad34abaa69043a Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Fri, 21 Mar 2025 11:56:05 +0000 Subject: [PATCH 034/226] use sigmoid steepness param --- pallets/admin-utils/src/tests/mock.rs | 2 +- pallets/subtensor/src/epoch/run_epoch.rs | 4 ++-- pallets/subtensor/src/tests/epoch.rs | 2 +- pallets/subtensor/src/tests/mock.rs | 2 +- pallets/subtensor/src/utils/misc.rs | 2 +- runtime/src/lib.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 6932632f4b..5f0d6bdcfa 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -80,7 +80,7 @@ parameter_types! { pub const TransactionByteFee: Balance = 100; pub const SDebug:u64 = 1; pub const InitialRho: u16 = 30; - pub const InitialAlphaSigmoidSteepness: u16 = u16::MAX/10; // 10% steepness + pub const InitialAlphaSigmoidSteepness: u16 = 10; pub const InitialKappa: u16 = 32_767; pub const InitialTempo: u16 = 0; pub const SelfOwnership: u64 = 2; diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index c65e239867..0d8d123c9e 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -1018,7 +1018,7 @@ impl Pallet { assert!(weights.len() == bonds.len()); // Get the high and low alpha values for the network. - let alpha_sigmoid_steepness: I32F32 = I32F32::from_num(10.0); + let alpha_sigmoid_steepness: I32F32 = Self::get_alpha_sigmoid_steepness(netuid); let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); let mut alphas = Vec::new(); @@ -1063,7 +1063,7 @@ impl Pallet { ) -> Vec> { assert!(weights.len() == bonds.len()); - let alpha_sigmoid_steepness: I32F32 = I32F32::from_num(10.0); + let alpha_sigmoid_steepness: I32F32 = Self::get_alpha_sigmoid_steepness(netuid); let (alpha_low, alpha_high): (I32F32, I32F32) = Self::get_alpha_values_32(netuid); let mut alphas = Vec::with_capacity(consensus.len()); diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 62b94e8331..bb54392480 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3016,7 +3016,7 @@ fn setup_yuma_4_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak SubtensorModule::set_min_allowed_weights(netuid, 1); SubtensorModule::set_max_weight_limit(netuid, u16::MAX); SubtensorModule::set_bonds_penalty(netuid, 0); - // SubtensorModule::set_bonds_moving_average(netuid, 975_000); + SubtensorModule::set_alpha_sigmoid_steepness(netuid, 10); // === Register for key in 0..n as u64 { diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index eb86dc8935..dff78b7a28 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -132,7 +132,7 @@ parameter_types! { pub const TransactionByteFee: Balance = 100; pub const SDebug:u64 = 1; pub const InitialRho: u16 = 30; - pub const InitialAlphaSigmoidSteepness: u16 = u16::MAX/10; + pub const InitialAlphaSigmoidSteepness: u16 = 10; pub const InitialKappa: u16 = 32_767; pub const InitialTempo: u16 = 360; pub const SelfOwnership: u64 = 2; diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index 72eeb5bc5e..e36f033a74 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -692,7 +692,7 @@ impl Pallet { } pub fn get_alpha_sigmoid_steepness(netuid: u16) -> I32F32 { let alpha = AlphaSigmoidSteepness::::get(netuid); - I32F32::saturating_from_num(alpha).safe_div(I32F32::saturating_from_num(u16::MAX)) + I32F32::saturating_from_num(alpha) } pub fn set_liquid_alpha_enabled(netuid: u16, enabled: bool) { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index e7d0732cfa..a6e3350b5e 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -990,7 +990,7 @@ pub const INITIAL_CHILDKEY_TAKE_RATELIMIT: u64 = 5; // Configure the pallet subtensor. parameter_types! { - pub const SubtensorInitialRho: u16 = u16::MAX/10; // 10% + pub const SubtensorInitialRho: u16 = 10; pub const SubtensorInitialAlphaSigmoidSteepness: u16 = 1000; pub const SubtensorInitialKappa: u16 = 32_767; // 0.5 = 65535/2 pub const SubtensorInitialMaxAllowedUids: u16 = 4096; From bf6f6d7da83ac5fb877cdfaffedfe6389d33052e Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 25 Mar 2025 10:05:01 +0000 Subject: [PATCH 035/226] yuma3 rename --- pallets/subtensor/src/tests/epoch.rs | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index bb54392480..d3c95bde4d 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3003,7 +3003,7 @@ pub fn assert_approx_eq(left: I32F32, right: I32F32, epsilon: I32F32) { } // test Yuma 4 scenarios over a sequence of epochs. -fn setup_yuma_4_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stakes: Vec) { +fn setup_yuma_3_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stakes: Vec) { let block_number = System::block_number(); let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead add_network(netuid, tempo, 0); @@ -3102,7 +3102,7 @@ fn run_epoch_and_check_bonds_dividends( } } -fn set_yuma_4_weights(netuid: u16, weights: Vec>) { +fn set_yuma_3_weights(netuid: u16, weights: Vec>) { for (uid, weight) in weights.iter().enumerate() { assert_ok!(SubtensorModule::set_weights( RuntimeOrigin::signed(U256::from(uid as u64)), @@ -3115,7 +3115,7 @@ fn set_yuma_4_weights(netuid: u16, weights: Vec>) { } #[test] -fn test_yuma_4_kappa_moves_first() { +fn test_yuma_3_kappa_moves_first() { new_test_ext(1).execute_with(|| { let sparse: bool = true; let n: u16 = 5; // 3 validators, 2 servers @@ -3127,7 +3127,7 @@ fn test_yuma_4_kappa_moves_first() { // Validator C: Small lazy validator (0.1) - moves last let stakes: Vec = vec![8, 1, 1, 0, 0]; - setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ vec![ vec![0.1013, 0.0000], @@ -3178,13 +3178,13 @@ fn test_yuma_4_kappa_moves_first() { match epoch { 0 => { // Initially, consensus is achieved by all Validators - set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { // Validator A -> Server 2 // Validator B -> Server 1 // Validator C -> Server 1 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], ); @@ -3193,14 +3193,14 @@ fn test_yuma_4_kappa_moves_first() { // Validator A -> Server 2 // Validator B -> Server 2 // Validator C -> Server 1 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], ); } 3 => { // Subsequent epochs All validators -> Server 2 - set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3]); } _ => {} }; @@ -3210,7 +3210,7 @@ fn test_yuma_4_kappa_moves_first() { } #[test] -fn test_yuma_4_kappa_moves_second() { +fn test_yuma_3_kappa_moves_second() { new_test_ext(1).execute_with(|| { let sparse: bool = false; let n: u16 = 5; // 3 validators, 2 servers @@ -3222,7 +3222,7 @@ fn test_yuma_4_kappa_moves_second() { // Validator C: Small lazy validator (0.1) - moves last let stakes: Vec = vec![8, 1, 1, 0, 0]; - setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ vec![ vec![0.1013, 0.0000], @@ -3272,13 +3272,13 @@ fn test_yuma_4_kappa_moves_second() { match epoch { 0 => { // Initially, consensus is achieved by all Validators - set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 1 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], ); @@ -3287,14 +3287,14 @@ fn test_yuma_4_kappa_moves_second() { // Validator A -> Server 2 // Validator B -> Server 2 // Validator C -> Server 1 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], ); } 3 => { // Subsequent epochs All validators -> Server 2 - set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3]); } _ => {} }; @@ -3304,7 +3304,7 @@ fn test_yuma_4_kappa_moves_second() { } #[test] -fn test_yuma_4_kappa_moves_last() { +fn test_yuma_3_kappa_moves_last() { new_test_ext(1).execute_with(|| { let sparse: bool = true; let n: u16 = 5; // 3 validators, 2 servers @@ -3316,7 +3316,7 @@ fn test_yuma_4_kappa_moves_last() { // Validator C: Small lazy validator (0.1) - moves second let stakes: Vec = vec![8, 1, 1, 0, 0]; - setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ vec![ vec![0.1013, 0.0000], @@ -3366,13 +3366,13 @@ fn test_yuma_4_kappa_moves_last() { match epoch { 0 => { // Initially, consensus is achieved by all Validators - set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 1 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], ); @@ -3381,14 +3381,14 @@ fn test_yuma_4_kappa_moves_last() { // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 2 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]], ); } 3 => { // Subsequent epochs All validators -> Server 2 - set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3]); } _ => {} }; @@ -3398,7 +3398,7 @@ fn test_yuma_4_kappa_moves_last() { } #[test] -fn test_yuma_4_one_epoch_switch() { +fn test_yuma_3_one_epoch_switch() { new_test_ext(1).execute_with(|| { let sparse: bool = true; let n: u16 = 5; // 3 validators, 2 servers @@ -3408,7 +3408,7 @@ fn test_yuma_4_one_epoch_switch() { // Equal stake validators let stakes: Vec = vec![33, 33, 34, 0, 0]; - setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); let targets_bonds = [ vec![ @@ -3461,14 +3461,14 @@ fn test_yuma_4_one_epoch_switch() { // Validator A -> Server 1 // Validator B -> Server 1 // Validator C -> Server 2 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![u16::MAX, 0], vec![u16::MAX, 0], vec![0, u16::MAX]], ); } _ => { // All validators -> Server 1 - set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } }; run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); From d6c51f005216873b509f3425d2456943d5c45fa4 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 25 Mar 2025 11:12:11 +0000 Subject: [PATCH 036/226] more improved tests --- pallets/subtensor/src/tests/epoch.rs | 839 +++++++++++++++------------ 1 file changed, 479 insertions(+), 360 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index d3c95bde4d..97d4fdf400 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3049,13 +3049,10 @@ fn setup_yuma_3_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak // Enable Liquid Alpha SubtensorModule::set_kappa(netuid, u16::MAX / 2); SubtensorModule::set_liquid_alpha_enabled(netuid, true); - SubtensorModule::set_kappa(netuid, u16::MAX / 2); - SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.1), I32F32::from_num(0.3)); // === Issue validator permits SubtensorModule::set_max_allowed_validators(netuid, 3); - assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), 3); // run first epoch to set allowed validators // run to next block to ensure weights are set on nodes after their registration block @@ -3083,15 +3080,12 @@ fn run_epoch_and_check_bonds_dividends( let epsilon = I32F32::from_num(1e-3); // Check the bonds - // server 1 - assert_approx_eq(bonds[0][3], fixed(target_bonds[0][0]), epsilon); - assert_approx_eq(bonds[1][3], fixed(target_bonds[1][0]), epsilon); - assert_approx_eq(bonds[2][3], fixed(target_bonds[2][0]), epsilon); - // server 2 - assert_approx_eq(bonds[0][4], fixed(target_bonds[0][1]), epsilon); - assert_approx_eq(bonds[1][4], fixed(target_bonds[1][1]), epsilon); - assert_approx_eq(bonds[2][4], fixed(target_bonds[2][1]), epsilon); - + for (bond, target_bond) in bonds.iter().zip(target_bonds.iter()) { + // skip the 3 validators + for (b, t) in bond.iter().zip(target_bond.iter().skip(3)) { + assert_approx_eq(*b, fixed(*t), epsilon); + } + } // Check the dividends for (dividend, target_dividend) in dividends.iter().zip(target_dividends.iter()) { assert_approx_eq( @@ -3102,12 +3096,12 @@ fn run_epoch_and_check_bonds_dividends( } } -fn set_yuma_3_weights(netuid: u16, weights: Vec>) { +fn set_yuma_3_weights(netuid: u16, weights: Vec>, indices: Vec) { for (uid, weight) in weights.iter().enumerate() { assert_ok!(SubtensorModule::set_weights( RuntimeOrigin::signed(U256::from(uid as u64)), netuid, - vec![3, 4], + indices.clone(), weight.to_vec(), 0 )); @@ -3116,362 +3110,487 @@ fn set_yuma_3_weights(netuid: u16, weights: Vec>) { #[test] fn test_yuma_3_kappa_moves_first() { - new_test_ext(1).execute_with(|| { - let sparse: bool = true; - let n: u16 = 5; // 3 validators, 2 servers - let netuid: u16 = 1; - let max_stake: u64 = 8; - - // Validator A: kappa / Big validator (0.8) - moves first - // Validator B: Small eager validator (0.1) - moves second - // Validator C: Small lazy validator (0.1) - moves last - let stakes: Vec = vec![8, 1, 1, 0, 0]; - - setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); - let targets_bonds = [ - vec![ - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - ], - vec![ - vec![0.0908, 0.1013], - vec![0.3697, 0.0000], - vec![0.3697, 0.0000], - ], - vec![ - vec![0.0815, 0.1924], - vec![0.3170, 0.1013], - vec![0.5580, 0.0000], - ], - vec![ - vec![0.0731, 0.2742], - vec![0.2765, 0.1924], - vec![0.4306, 0.1013], - ], - vec![ - vec![0.0656, 0.3478], - vec![0.2435, 0.2742], - vec![0.3589, 0.1924], - ], - vec![ - vec![0.0588, 0.4139], - vec![0.2157, 0.3478], - vec![0.3089, 0.2742], - ], - ]; - - let targets_dividends = [ - vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], - vec![1.0000, 0.0000, 0.0000, 0.0000, 0.0000], - vec![0.9382, 0.0618, 0.0000, 0.0000, 0.0000], - vec![0.8819, 0.0773, 0.0407, 0.0000, 0.0000], - vec![0.8564, 0.0844, 0.0592, 0.0000, 0.0000], - vec![0.8418, 0.0884, 0.0697, 0.0000, 0.0000], - ]; - - for (epoch, (target_bonds, target_dividends)) in targets_bonds - .iter() - .zip(targets_dividends.iter()) - .enumerate() - { - match epoch { - 0 => { - // Initially, consensus is achieved by all Validators - set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); - } - 1 => { - // Validator A -> Server 2 - // Validator B -> Server 1 - // Validator C -> Server 1 - set_yuma_3_weights( - netuid, - vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], - ); - } - 2 => { - // Validator A -> Server 2 - // Validator B -> Server 2 - // Validator C -> Server 1 - set_yuma_3_weights( - netuid, - vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], - ); - } - 3 => { - // Subsequent epochs All validators -> Server 2 - set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3]); - } - _ => {} - }; - run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); - } - }) + for sparse in [true, false].iter() { + new_test_ext(1).execute_with(|| { + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) - moves first + // Validator B: Small eager validator (0.1) - moves second + // Validator C: Small lazy validator (0.1) - moves last + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_3_scenario(netuid, n, *sparse, max_stake, stakes); + let targets_bonds = [ + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.0908, 0.1013], + vec![0.3697, 0.0000], + vec![0.3697, 0.0000], + ], + vec![ + vec![0.0815, 0.1924], + vec![0.3170, 0.1013], + vec![0.5580, 0.0000], + ], + vec![ + vec![0.0731, 0.2742], + vec![0.2765, 0.1924], + vec![0.4306, 0.1013], + ], + vec![ + vec![0.0656, 0.3478], + vec![0.2435, 0.2742], + vec![0.3589, 0.1924], + ], + vec![ + vec![0.0588, 0.4139], + vec![0.2157, 0.3478], + vec![0.3089, 0.2742], + ], + ]; + + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], + vec![1.0000, 0.0000, 0.0000, 0.0000, 0.0000], + vec![0.9382, 0.0618, 0.0000, 0.0000, 0.0000], + vec![0.8819, 0.0773, 0.0407, 0.0000, 0.0000], + vec![0.8564, 0.0844, 0.0592, 0.0000, 0.0000], + vec![0.8418, 0.0884, 0.0697, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 0 => { + // Initially, consensus is achieved by all Validators + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); + } + 1 => { + // Validator A -> Server 2 + // Validator B -> Server 1 + // Validator C -> Server 1 + set_yuma_3_weights( + netuid, + vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], + vec![3, 4], + ); + } + 2 => { + // Validator A -> Server 2 + // Validator B -> Server 2 + // Validator C -> Server 1 + set_yuma_3_weights( + netuid, + vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], + vec![3, 4], + ); + } + 3 => { + // Subsequent epochs All validators -> Server 2 + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3], vec![3, 4]); + } + _ => {} + }; + run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + } + }) + } } #[test] fn test_yuma_3_kappa_moves_second() { - new_test_ext(1).execute_with(|| { - let sparse: bool = false; - let n: u16 = 5; // 3 validators, 2 servers - let netuid: u16 = 1; - let max_stake: u64 = 8; - - // Validator A: kappa / Big validator (0.8) - moves second - // Validator B: Small eager validator (0.1) - moves first - // Validator C: Small lazy validator (0.1) - moves last - let stakes: Vec = vec![8, 1, 1, 0, 0]; - - setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); - let targets_bonds = [ - vec![ - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - ], - vec![ - vec![0.1924, 0.0000], - vec![0.0908, 0.2987], - vec![0.1924, 0.0000], - ], - vec![ - vec![0.1715, 0.1013], - vec![0.0815, 0.3697], - vec![0.4336, 0.0000], - ], - vec![ - vec![0.1531, 0.1924], - vec![0.0731, 0.4336], - vec![0.3608, 0.1013], - ], - vec![ - vec![0.1369, 0.2742], - vec![0.0656, 0.4910], - vec![0.3103, 0.1924], - ], - vec![ - vec![0.1225, 0.3478], - vec![0.0588, 0.5426], - vec![0.2712, 0.2742], - ], - ]; - let targets_dividends = [ - vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], - vec![0.8446, 0.0498, 0.1056, 0.0000, 0.0000], - vec![0.6868, 0.3132, 0.0000, 0.0000, 0.0000], - vec![0.7421, 0.2090, 0.0489, 0.0000, 0.0000], - vec![0.7625, 0.1706, 0.0669, 0.0000, 0.0000], - vec![0.7730, 0.1508, 0.0762, 0.0000, 0.0000], - ]; - - for (epoch, (target_bonds, target_dividends)) in targets_bonds - .iter() - .zip(targets_dividends.iter()) - .enumerate() - { - match epoch { - 0 => { - // Initially, consensus is achieved by all Validators - set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); - } - 1 => { - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 1 - set_yuma_3_weights( - netuid, - vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], - ); - } - 2 => { - // Validator A -> Server 2 - // Validator B -> Server 2 - // Validator C -> Server 1 - set_yuma_3_weights( - netuid, - vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], - ); - } - 3 => { - // Subsequent epochs All validators -> Server 2 - set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3]); - } - _ => {} - }; - run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); - } - }) + for sparse in [true, false].iter() { + new_test_ext(1).execute_with(|| { + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) - moves second + // Validator B: Small eager validator (0.1) - moves first + // Validator C: Small lazy validator (0.1) - moves last + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_3_scenario(netuid, n, *sparse, max_stake, stakes); + let targets_bonds = [ + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.1924, 0.0000], + vec![0.0908, 0.2987], + vec![0.1924, 0.0000], + ], + vec![ + vec![0.1715, 0.1013], + vec![0.0815, 0.3697], + vec![0.4336, 0.0000], + ], + vec![ + vec![0.1531, 0.1924], + vec![0.0731, 0.4336], + vec![0.3608, 0.1013], + ], + vec![ + vec![0.1369, 0.2742], + vec![0.0656, 0.4910], + vec![0.3103, 0.1924], + ], + vec![ + vec![0.1225, 0.3478], + vec![0.0588, 0.5426], + vec![0.2712, 0.2742], + ], + ]; + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], + vec![0.8446, 0.0498, 0.1056, 0.0000, 0.0000], + vec![0.6868, 0.3132, 0.0000, 0.0000, 0.0000], + vec![0.7421, 0.2090, 0.0489, 0.0000, 0.0000], + vec![0.7625, 0.1706, 0.0669, 0.0000, 0.0000], + vec![0.7730, 0.1508, 0.0762, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 0 => { + // Initially, consensus is achieved by all Validators + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); + } + 1 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 1 + set_yuma_3_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], + vec![3, 4], + ); + } + 2 => { + // Validator A -> Server 2 + // Validator B -> Server 2 + // Validator C -> Server 1 + set_yuma_3_weights( + netuid, + vec![vec![0, u16::MAX], vec![0, u16::MAX], vec![u16::MAX, 0]], + vec![3, 4], + ); + } + 3 => { + // Subsequent epochs All validators -> Server 2 + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3], vec![3, 4]); + } + _ => {} + }; + run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + } + }) + } } #[test] fn test_yuma_3_kappa_moves_last() { - new_test_ext(1).execute_with(|| { - let sparse: bool = true; - let n: u16 = 5; // 3 validators, 2 servers - let netuid: u16 = 1; - let max_stake: u64 = 8; - - // Validator A: kappa / Big validator (0.8) - moves last - // Validator B: Small eager validator (0.1) - moves first - // Validator C: Small lazy validator (0.1) - moves second - let stakes: Vec = vec![8, 1, 1, 0, 0]; - - setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); - let targets_bonds = [ - vec![ - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - ], - vec![ - vec![0.1924, 0.0000], - vec![0.0908, 0.2987], - vec![0.1924, 0.0000], - ], - vec![ - vec![0.2742, 0.0000], - vec![0.0815, 0.5081], - vec![0.1715, 0.2987], - ], - vec![ - vec![0.2416, 0.1013], - vec![0.0731, 0.5580], - vec![0.1531, 0.3697], - ], - vec![ - vec![0.2141, 0.1924], - vec![0.0656, 0.6028], - vec![0.1369, 0.4336], - ], - vec![ - vec![0.1903, 0.2742], - vec![0.0588, 0.6430], - vec![0.1225, 0.4910], - ], - ]; - let targets_dividends = [ - vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], - vec![0.8446, 0.0498, 0.1056, 0.0000, 0.0000], - vec![0.8966, 0.0333, 0.0701, 0.0000, 0.0000], - vec![0.4663, 0.3210, 0.2127, 0.0000, 0.0000], - vec![0.5976, 0.2340, 0.1683, 0.0000, 0.0000], - vec![0.6592, 0.1932, 0.1475, 0.0000, 0.0000], - ]; - - for (epoch, (target_bonds, target_dividends)) in targets_bonds - .iter() - .zip(targets_dividends.iter()) - .enumerate() - { - match epoch { - 0 => { - // Initially, consensus is achieved by all Validators - set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); - } - 1 => { - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 1 - set_yuma_3_weights( - netuid, - vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], - ); - } - 2 => { - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 2 - set_yuma_3_weights( - netuid, - vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]], - ); - } - 3 => { - // Subsequent epochs All validators -> Server 2 - set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3]); - } - _ => {} - }; - run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); - } - }) + for sparse in [true, false].iter() { + new_test_ext(1).execute_with(|| { + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) - moves last + // Validator B: Small eager validator (0.1) - moves first + // Validator C: Small lazy validator (0.1) - moves second + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_3_scenario(netuid, n, *sparse, max_stake, stakes); + let targets_bonds = [ + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.1924, 0.0000], + vec![0.0908, 0.2987], + vec![0.1924, 0.0000], + ], + vec![ + vec![0.2742, 0.0000], + vec![0.0815, 0.5081], + vec![0.1715, 0.2987], + ], + vec![ + vec![0.2416, 0.1013], + vec![0.0731, 0.5580], + vec![0.1531, 0.3697], + ], + vec![ + vec![0.2141, 0.1924], + vec![0.0656, 0.6028], + vec![0.1369, 0.4336], + ], + vec![ + vec![0.1903, 0.2742], + vec![0.0588, 0.6430], + vec![0.1225, 0.4910], + ], + ]; + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000], + vec![0.8446, 0.0498, 0.1056, 0.0000, 0.0000], + vec![0.8966, 0.0333, 0.0701, 0.0000, 0.0000], + vec![0.4663, 0.3210, 0.2127, 0.0000, 0.0000], + vec![0.5976, 0.2340, 0.1683, 0.0000, 0.0000], + vec![0.6592, 0.1932, 0.1475, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 0 => { + // Initially, consensus is achieved by all Validators + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); + } + 1 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 1 + set_yuma_3_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], + vec![3, 4], + ); + } + 2 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 2 + set_yuma_3_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]], + vec![3, 4], + ); + } + 3 => { + // Subsequent epochs All validators -> Server 2 + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3], vec![3, 4]); + } + _ => {} + }; + run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + } + }) + } } #[test] fn test_yuma_3_one_epoch_switch() { - new_test_ext(1).execute_with(|| { - let sparse: bool = true; - let n: u16 = 5; // 3 validators, 2 servers - let netuid: u16 = 1; - let max_stake: u64 = 8; - - // Equal stake validators - let stakes: Vec = vec![33, 33, 34, 0, 0]; - - setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); - - let targets_bonds = [ - vec![ - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - vec![0.1013, 0.0000], - ], - vec![ - vec![0.1924, 0.0000], - vec![0.1924, 0.0000], - vec![0.1924, 0.0000], - ], - vec![ - vec![0.2742, 0.0000], - vec![0.2742, 0.0000], - vec![0.1715, 0.2987], - ], - vec![ - vec![0.3478, 0.0000], - vec![0.3478, 0.0000], - vec![0.2554, 0.2618], - ], - vec![ - vec![0.4139, 0.0000], - vec![0.4139, 0.0000], - vec![0.3309, 0.2312], - ], - vec![ - vec![0.4733, 0.0000], - vec![0.4733, 0.0000], - vec![0.3987, 0.2051], - ], - ]; - let targets_dividends = [ - vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], - vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], - vec![0.3782, 0.3782, 0.2436, 0.0000, 0.0000], - vec![0.3628, 0.3628, 0.2745, 0.0000, 0.0000], - vec![0.3541, 0.3541, 0.2917, 0.0000, 0.0000], - vec![0.3487, 0.3487, 0.3026, 0.0000, 0.0000], - ]; - - for (epoch, (target_bonds, target_dividends)) in targets_bonds - .iter() - .zip(targets_dividends.iter()) - .enumerate() - { - match epoch { - 2 => { - // Validator A -> Server 1 - // Validator B -> Server 1 - // Validator C -> Server 2 - set_yuma_3_weights( - netuid, - vec![vec![u16::MAX, 0], vec![u16::MAX, 0], vec![0, u16::MAX]], - ); - } - _ => { - // All validators -> Server 1 - set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3]); - } - }; - run_epoch_and_check_bonds_dividends(netuid, sparse, target_bonds, target_dividends); - } - }) + for sparse in [true, false].iter() { + new_test_ext(1).execute_with(|| { + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Equal stake validators + let stakes: Vec = vec![33, 33, 34, 0, 0]; + + setup_yuma_3_scenario(netuid, n, *sparse, max_stake, stakes); + + let targets_bonds = [ + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + vec![ + vec![0.1924, 0.0000], + vec![0.1924, 0.0000], + vec![0.1924, 0.0000], + ], + vec![ + vec![0.2742, 0.0000], + vec![0.2742, 0.0000], + vec![0.1715, 0.2987], + ], + vec![ + vec![0.3478, 0.0000], + vec![0.3478, 0.0000], + vec![0.2554, 0.2618], + ], + vec![ + vec![0.4139, 0.0000], + vec![0.4139, 0.0000], + vec![0.3309, 0.2312], + ], + vec![ + vec![0.4733, 0.0000], + vec![0.4733, 0.0000], + vec![0.3987, 0.2051], + ], + ]; + let targets_dividends = [ + vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], + vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], + vec![0.3782, 0.3782, 0.2436, 0.0000, 0.0000], + vec![0.3628, 0.3628, 0.2745, 0.0000, 0.0000], + vec![0.3541, 0.3541, 0.2917, 0.0000, 0.0000], + vec![0.3487, 0.3487, 0.3026, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 2 => { + // Validator A -> Server 1 + // Validator B -> Server 1 + // Validator C -> Server 2 + set_yuma_3_weights( + netuid, + vec![vec![u16::MAX, 0], vec![u16::MAX, 0], vec![0, u16::MAX]], + vec![3, 4], + ); + } + _ => { + // All validators -> Server 1 + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); + } + }; + run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + } + }) + } +} + +#[test] +fn test_yuma_3_stable_miner() { + for sparse in [true, false].iter() { + new_test_ext(1).execute_with(|| { + let netuid: u16 = 1; + let n: u16 = 6; // 3 validators, 3 servers + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) + // Validator B: Small eager validator (0.1) + // Validator C: Small lazy validator (0.1) + let stakes: Vec = vec![8, 1, 1, 0, 0, 0]; + + setup_yuma_3_scenario(netuid, n, *sparse, max_stake, stakes); + let targets_bonds = [ + vec![ + vec![0.0507, 0.0000, 0.0507], + vec![0.0507, 0.0000, 0.0507], + vec![0.0507, 0.0000, 0.0507], + ], + vec![ + vec![0.0962, 0.0000, 0.0962], + vec![0.0455, 0.1000, 0.0962], + vec![0.0962, 0.0000, 0.0962], + ], + vec![ + vec![0.0863, 0.0507, 0.1371], + vec![0.0408, 0.1405, 0.1371], + vec![0.1770, 0.0000, 0.1371], + ], + vec![ + vec![0.0774, 0.0962, 0.1739], + vec![0.0367, 0.1770, 0.1739], + vec![0.1579, 0.0507, 0.1739], + ], + vec![ + vec![0.0694, 0.1371, 0.2069], + vec![0.0329, 0.2097, 0.2069], + vec![0.1411, 0.0962, 0.2069], + ], + vec![ + vec![0.0623, 0.1739, 0.2366], + vec![0.0296, 0.2391, 0.2366], + vec![0.1263, 0.1371, 0.2366], + ], + ]; + let targets_dividends = [ + vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000], + vec![0.8226, 0.0745, 0.1028, 0.0000, 0.0000, 0.0000], + vec![0.7750, 0.1685, 0.0565, 0.0000, 0.0000, 0.0000], + vec![0.7864, 0.1372, 0.0764, 0.0000, 0.0000, 0.0000], + vec![0.7912, 0.1241, 0.0847, 0.0000, 0.0000, 0.0000], + vec![0.7937, 0.1173, 0.0890, 0.0000, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 0 => { + // all validators 0.5 for first and third server + set_yuma_3_weights( + netuid, + vec![vec![u16::MAX / 2, 0, u16::MAX / 2]; 3], + vec![3, 4, 5], + ); + } + 1 => { + // one of small validators moves 0.5 to seconds server + set_yuma_3_weights( + netuid, + vec![ + vec![u16::MAX / 2, 0, u16::MAX / 2], + vec![0, u16::MAX / 2, u16::MAX / 2], + vec![u16::MAX / 2, 0, u16::MAX / 2], + ], + vec![3, 4, 5], + ); + } + 2 => { + // big validator follows + set_yuma_3_weights( + netuid, + vec![ + vec![0, u16::MAX / 2, u16::MAX / 2], + vec![0, u16::MAX / 2, u16::MAX / 2], + vec![u16::MAX / 2, 0, u16::MAX / 2], + ], + vec![3, 4, 5], + ); + } + 3 => { + // Subsequent epochs all validators have moves + set_yuma_3_weights( + netuid, + vec![vec![0, u16::MAX / 2, u16::MAX / 2]; 3], + vec![3, 4, 5], + ); + } + _ => {} + }; + run_epoch_and_check_bonds_dividends( + netuid, + *sparse, + target_bonds, + target_dividends, + ); + } + }) + } } From b5d766b1f8eb51969ba844ec7cf567caa5880ec8 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 25 Mar 2025 12:23:56 +0000 Subject: [PATCH 037/226] fix rebase --- pallets/subtensor/src/epoch/run_epoch.rs | 4 +-- pallets/subtensor/src/tests/epoch.rs | 34 +++++++++++++++++++----- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 0d8d123c9e..07df343997 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -68,7 +68,7 @@ impl Pallet { .iter() .map(|registered| last_tempo <= *registered) .collect(); - log::trace!("Recently registered:\n{:?}\n", &recently_registered); + log::trace!("Recently registered: {:?}", &recently_registered); // =========== // == Stake == @@ -199,7 +199,7 @@ impl Pallet { // Access network bonds. let mut bonds: Vec> = Self::get_bonds_fixed_proportion(netuid); - inplace_mask_matrix(&outdated, &mut bonds); // mask outdated bonds + inplace_mask_cols(&recently_registered, &mut bonds); // mask outdated bonds log::trace!("B: {:?}", &bonds); // Compute the Exponential Moving Average (EMA) of bonds. diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 97d4fdf400..3eb7f441d8 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3002,10 +3002,10 @@ pub fn assert_approx_eq(left: I32F32, right: I32F32, epsilon: I32F32) { } } -// test Yuma 4 scenarios over a sequence of epochs. +// test Yuma 3 scenarios over a sequence of epochs. fn setup_yuma_3_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stakes: Vec) { let block_number = System::block_number(); - let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead + let tempo: u16 = 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead add_network(netuid, tempo, 0); SubtensorModule::set_max_allowed_uids(netuid, n); @@ -3060,7 +3060,7 @@ fn setup_yuma_3_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak } fn run_epoch(netuid: u16, sparse: bool) { - next_block(); + next_block_no_epoch(netuid); if sparse { SubtensorModule::epoch(netuid, 1_000_000_000); } else { @@ -3200,7 +3200,12 @@ fn test_yuma_3_kappa_moves_first() { } _ => {} }; - run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + run_epoch_and_check_bonds_dividends( + netuid, + *sparse, + target_bonds, + target_dividends, + ); } }) } @@ -3297,7 +3302,12 @@ fn test_yuma_3_kappa_moves_second() { } _ => {} }; - run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + run_epoch_and_check_bonds_dividends( + netuid, + *sparse, + target_bonds, + target_dividends, + ); } }) } @@ -3394,7 +3404,12 @@ fn test_yuma_3_kappa_moves_last() { } _ => {} }; - run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + run_epoch_and_check_bonds_dividends( + netuid, + *sparse, + target_bonds, + target_dividends, + ); } }) } @@ -3475,7 +3490,12 @@ fn test_yuma_3_one_epoch_switch() { set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); } }; - run_epoch_and_check_bonds_dividends(netuid, *sparse, target_bonds, target_dividends); + run_epoch_and_check_bonds_dividends( + netuid, + *sparse, + target_bonds, + target_dividends, + ); } }) } From 4cda7e27960533126145cb641ee056ba0e26ff4c Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 25 Mar 2025 15:04:46 +0000 Subject: [PATCH 038/226] fix rebase tests --- pallets/subtensor/src/tests/epoch.rs | 350 +++++++++++---------------- 1 file changed, 146 insertions(+), 204 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 3eb7f441d8..9bb9f5a6e7 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -714,7 +714,7 @@ fn test_512_graph() { assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, uid), 1023); // Note D = floor(1 / 64 * 65_535) = 1023 assert_eq!(SubtensorModule::get_emission_for_uid(netuid, uid), 7812500); // Note E = 0.5 / 200 * 1_000_000_000 = 7_812_500 assert_eq!(bonds[uid as usize][validator], 0.0); - assert_eq!(bonds[uid as usize][server], I32F32::from_num(276)); + assert_eq!(bonds[uid as usize][server], I32F32::from_num(102)); } for uid in servers { assert_eq!( @@ -1052,51 +1052,47 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 2 - activity_cutoff: 5000 - Last update: [2, 2, 2, 2, 1, 1, 1, 1] - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] - Bonds: [[], [], [], [], [], [], [], []] - Bonds: (mask+norm) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - ΔB: - , 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] - - emaB: [[(4, 0.0099999998), (5, 0.0099999998), (6, 0.0099999998), (7, 0.0099999998)], [(4, 0.0199999998), (5, 0.0199999998), (6, 0.0199999998), (7, 0.0199999998)], [(4, 0.0299999998), (5, 0.0299999998), (6, 0.03), (7, 0.03)], [(4, 0.04), (5, 0.0399999998), (6, 0.04), (7, 0.04)], [], [], [], []] - emaB norm: [[(4, 0.0999999982), (5, 0.0999999985), (6, 0.099999998), (7, 0.099999998)], [(4, 0.199999999), (5, 0.1999999995), (6, 0.1999999986), (7, 0.1999999986)], [(4, 0.2999999996), (5, 0.3000000003), (6, 0.3000000012), (7, 0.3000000012)], [(4, 0.4000000027), (5, 0.4000000013), (6, 0.4000000018), (7, 0.4000000018)], [], [], [], []] - total_bonds_per_validator: [0.0999999975, 0.1999999979, 0.3000000003, 0.4000000008, 0, 0, 0, 0] - Dividends: [0.0333333318, 0.1333333314, 0.3000000005, 0.5333333358, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0, 0, 0, 0] - Validator Emission: [16666665, 66666665, 150000000, 266666668, 0, 0, 0, 0] - Normalized Combined Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Combined Emission: [16666665, 66666665, 150000000, 266666668, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - */ + /* current_block: 2 + Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] + Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + Weights: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149 + ), (7, 65535)], [], [], [], []] + Weights (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), + (6, 49149), (7, 65535)], [], [], [], []] + Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584) + , (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Ranks (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + Clipped Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5 + , 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + Ranks (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + Trust: [0, 0, 0, 0, 1, 1, 1, 1] + Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] + Bonds: [[], [], [], [], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] + weights_for_bonds: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), + (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + ΔB: [[(4, 0.0999999996), (5, 0.0999999999), (6, 0.0999999994), (7, 0.0999999996)], [(4, 0.1999999995), (5, 0.2), (6, 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, + 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] + emaB: [[(4, 0.0099999998), (5, 0.0099999998), (6, 0.0099999998), (7, 0.0099999998)], [(4, 0.0199999998), (5, 0.0199999998), (6, 0.0199999998), (7, 0.0199999998)], [(4, 0.0299999998), (5, 0.0299999998), (6, 0.03), (7, 0.03)], [(4, 0.04), (5, 0.0399999998), (6, 0.04), (7, 0.04)], [], [], [], []] + emaB norm: [[(4, 0.0999999982), (5, 0.0999999985), (6, 0.099999998), (7, 0.099999998)], [(4, 0.199999999), (5, 0.1999999995), (6, 0.1999999986), (7, 0.1999999986)], [(4, 0.2999999996), (5, 0.3000000003), (6, 0.3000000012), (7, 0.3000000012)], [(4, 0.4000000027), (5, 0.4000000013), (6, 0.4000000018), (7, 0.4000000018)], [], [], [], []] + total_bonds_per_validator: [0.0999999975, 0.1999999979, 0.3000000003, 0.4000000008, 0, 0, 0, 0] + Dividends: [0.0333333318, 0.1333333314, 0.3000000005, 0.5333333358, 0, 0, 0, 0] + Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] + Normalized Validator Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0, 0, 0, 0] + Validator Emission: [16666665, 66666665, 150000000, 266666668, 0, 0, 0, 0] + Normalized Combined Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + Combined Emission: [16666665, 66666665, 150000000, 266666668, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + s: [[0, 0, 0, 0, 655, 655, 655, 655], [0, 0, 0, 0, 1310, 1310, 1310, 1310], [0, 0, 0, 0, 1966, 1966, 1966, 1966], [0, 0, 0, 0, 2621, 2621, 2621, 2621], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] + */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 655); - assert_eq!(bonds[1][4], 1310); - assert_eq!(bonds[2][4], 1966); - assert_eq!(bonds[3][4], 2621); + for (i, target_bond) in [655, 1310, 1966, 2621].iter().enumerate() { + assert_eq!(bonds[i][4], *target_bond); + } // === Set self-weight only on val1 let uid = 0; @@ -1113,21 +1109,12 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 3 - activity_cutoff: 5000 - Last update: [2, 2, 2, 2, 1, 1, 1, 1] + /* current_block: 3 Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0 - .400008545)], [], [], [], []] + Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Ranks (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] @@ -1135,25 +1122,25 @@ fn test_bonds() { Ranks (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] Trust: [0, 0, 0, 0, 1, 1, 1, 1] Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[(4, 655), (5, 655), (6, 655), (7, 655)], [(4, 1310), (5, 1310), (6, 1310), (7, 1310)], [(4, 1966), (5, 1966), (6, 1966), (7, 1966)], [(4, 2621), (5, 2621), (6, 2621), (7, 2621)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.0099946593), (5, 0.0099946593), (6, 0.0099946593), (7, 0.0099946593)], [(4, 0.0199893187), (5, 0.0199893187), (6, 0.0199893187), (7, 0.0199893187)], [(4, 0.029999237), (5, 0.029999237), (6, 0.029999237), (7, 0.029999237)], [(4, 0.0399938964), (5, 0.0399938964), (6, 0.0399938964), (7, 0.0399938964)], [], [], [], []] + Bonds: [[(4, 0.0099946593), (5, 0.0099946593), (6, 0.0099946593), (7, 0.0099946593)], [(4, 0.0199893187), (5, 0.0199893187), (6, 0.0199893187), (7, 0.0199893187)], [(4, 0.029999237), (5, 0.029999237), (6, 0.029999237), (7, 0.029999237)], [(4, 0.0399938964), (5, 0.0399938964), (6, 0.0399938964), (7, 0.0399938964)], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] weights_for_bonds: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - emaB: [[(4, 0.0089951933), (5, 0.0089951933), (6, 0.0089951933), (7, 0.0089951933)], [(4, 0.0402126086), (5, 0.0402126086), (6, 0.0402126086), (7, 0.0402126086)], [(4, 0.0603326464), (5, 0.0603326464), (6, 0.0603326464), (7, 0.0603326464)], [(4, 0.0804389513), (5, 0.080438951), (6, 0.080438951), (7, 0.080438951)], [], [], [], []] - emaB norm: [[(4, 0.0473482562), (5, 0.0473482562), (6, 0.0473482562), (7, 0.0473482562)], [(4, 0.2116682583), (5, 0.2116682585), (6, 0.2116682585), (7, 0.2116682585)], [(4, 0.3175746764), (5, 0.3175746768), (6, 0.3175746768), (7, 0.3175746768)], [(4, 0.4234088087), (5, 0.423408808), (6, 0.423408808), (7, 0.423408808)], [], [], [], []] - total_bonds_per_validator: [0.0473482558, 0.2116682578, 0.3175746764, 0.4234088075, 0, 0, 0, 0] - Dividends: [0.0151901136, 0.1358134532, 0.3056498466, 0.5433465862, 0, 0, 0, 0] + ΔB: [[], [(4, 0.2222222215), (5, 0.222222222), (6, 0.2222222218), (7, 0.2222222218)], [(4, 0.3333333323), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.4444444457), (5, 0.4444444443), (6, 0.4444444447), (7, 0.4444444445)], [], [], [], []] + emaB: [[], [(4, 0.022222222), (5, 0.022222222), (6, 0.022222222), (7, 0.022222222)], [(4, 0.0333333332), (5, 0.0333333332), (6, 0.0333333332), (7, 0.0333333332)], [(4, 0.0444444446), (5, 0.0444444444), (6, 0.0444444444), (7, 0.0444444444)], [], [], [], []] + emaB norm: [[], [(4, 0.2222222209), (5, 0.2222222213), (6, 0.2222222213), (7, 0.2222222213)], [(4, 0.3333333323), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.4444444464), (5, 0.4444444452), (6, 0.4444444452), (7, 0.4444444452)], [], [], [], []] + total_bonds_per_validator: [0, 0.2222222209, 0.3333333328, 0.444444445, 0, 0, 0, 0] + Dividends: [0, 0.1379310335, 0.310344827, 0.5517241391, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0075950567, 0.0679067266, 0.1528249232, 0.271673293, 0, 0, 0, 0] - Validator Emission: [7595056, 67906726, 152824923, 271673293, 0, 0, 0, 0] - Normalized Combined Emission: [0.0075950567, 0.0679067266, 0.1528249232, 0.271673293, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [7595056, 67906726, 152824923, 271673293, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0075950567, 0.0679067266, 0.1528249232, 0.271673293, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Normalized Validator Emission: [0, 0.0689655168, 0.1551724134, 0.2758620696, 0, 0, 0, 0] + Validator Emission: [0, 68965516, 155172413, 275862069, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0.0689655168, 0.1551724134, 0.2758620696, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [0, 68965516, 155172413, 275862069, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0, 0.0689655168, 0.1551724134, 0.2758620696, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ - assert_eq!(bonds[0][4], 655); - assert_eq!(bonds[1][4], 1310); - assert_eq!(bonds[2][4], 1966); - assert_eq!(bonds[3][4], 2621); + for (i, target_bond) in [655, 1310, 1966, 2621].iter().enumerate() { + assert_eq!(bonds[i][4], *target_bond); + } // === Set self-weight only on val2 let uid = 1; @@ -1170,19 +1157,11 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 4 - activity_cutoff: 5000 - Last update: [2, 3, 2, 2, 1, 1, 1, 1] + /* current_block: 4 Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] @@ -1191,26 +1170,26 @@ fn test_bonds() { Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] Trust: [0, 0, 0, 0, 1, 1, 1, 1] Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[(4, 589), (5, 589), (6, 589), (7, 589)], [(4, 2635), (5, 2635), (6, 2635), (7, 2635)], [(4, 3953), (5, 3953), (6, 3953), (7, 3953)], [(4, 5271), (5, 5271), (6, 5271), (7, 5271)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.008987564), (5, 0.008987564), (6, 0.008987564), (7, 0.008987564)], [(4, 0.0402075227), (5, 0.0402075227), (6, 0.0402075227), (7, 0.0402075227)], [(4, 0.0603189135), (5, 0.0603189135), (6, 0.0603189135), (7, 0.0603189135)], [(4, 0.0804303044), (5, 0.0804303044), (6, 0.0804303044), (7, 0.0804303044)], [], [], [], []] + Bonds: [[], [(4, 0.0222171359), (5, 0.0222171359), (6, 0.0222171359), (7, 0.0222171359)], [(4, 0.0333257038), (5, 0.0333257038), (6, 0.0333257038), (7, 0.0333257038)], [(4, 0.0444342718), (5, 0.0444342718), (6, 0.0444342718), (7, 0.0444342718)], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - emaB: [[(4, 0.0080888073), (5, 0.0080888073), (6, 0.0080888073), (7, 0.0080888073)], [(4, 0.0361867703), (5, 0.0361867703), (6, 0.0361867703), (7, 0.0361867703)], [(4, 0.0971441646), (5, 0.0971441648), (6, 0.0971441648), (7, 0.0971441648)], [(4, 0.1295301311), (5, 0.129530131), (6, 0.129530131), (7, 0.129530131)], [], [], [], []] - emaB norm: [[(4, 0.0298535195), (5, 0.0298535195), (6, 0.0298535195), (7, 0.0298535195)], [(4, 0.1335552211), (5, 0.1335552211), (6, 0.1335552211), (7, 0.1335552211)], [(4, 0.3585318692), (5, 0.3585318702), (6, 0.3585318702), (7, 0.3585318702)], [(4, 0.4780593896), (5, 0.4780593887), (6, 0.4780593887), (7, 0.4780593887)], [], [], [], []] - total_bonds_per_validator: [0.0298535188, 0.1335552207, 0.3585318697, 0.4780593882, 0, 0, 0, 0] - Dividends: [0.0090883898, 0.08131718, 0.3274465878, 0.5821478418, 0, 0, 0, 0] + ΔB: [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] + emaB: [[], [], [(4, 0.0428571426), (5, 0.0428571429), (6, 0.0428571429), (7, 0.0428571429)], [(4, 0.0571428572), (5, 0.057142857), (6, 0.057142857), (7, 0.057142857)], [], [], [], []] + emaB norm: [[], [], [(4, 0.4285714268), (5, 0.428571429), (6, 0.428571429), (7, 0.428571429)], [(4, 0.571428573), (5, 0.5714285707), (6, 0.5714285707), (7, 0.5714285707)], [], [], [], []] + total_bonds_per_validator: [0, 0, 0.4285714284, 0.5714285704, 0, 0, 0, 0] + Dividends: [0, 0, 0.36, 0.6399999997, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0045441948, 0.04065859, 0.163723294, 0.291073921, 0, 0, 0, 0] - Validator Emission: [4544194, 40658589, 163723293, 291073920, 0, 0, 0, 0] - Normalized Combined Emission: [0.0045441948, 0.04065859, 0.163723294, 0.291073921, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [4544194, 40658589, 163723293, 291073920, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0045441948, 0.04065859, 0.163723294, 0.291073921, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Normalized Validator Emission: [0, 0, 0.18, 0.3199999998, 0, 0, 0, 0] + Validator Emission: [0, 0, 179999999, 319999999, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [0, 0, 179999999, 319999999, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 530); - assert_eq!(bonds[1][4], 2371); - assert_eq!(bonds[2][4], 6366); - assert_eq!(bonds[3][4], 8488); + for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { + assert_eq!(bonds[i][4], *target_bond); + } // === Set self-weight only on val2 let uid = 1; @@ -1227,19 +1206,11 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 5 - activity_cutoff: 5000 - Last update: [2, 4, 2, 2, 1, 1, 1, 1] + /* current_block: 5 Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] @@ -1248,26 +1219,26 @@ fn test_bonds() { Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] Trust: [0, 0, 0, 0, 1, 1, 1, 1] Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[(4, 530), (5, 530), (6, 530), (7, 530)], [(4, 2371), (5, 2371), (6, 2371), (7, 2371)], [(4, 6366), (5, 6366), (6, 6366), (7, 6366)], [(4, 8488), (5, 8488), (6, 8488), (7, 8488)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.0080872816), (5, 0.0080872816), (6, 0.0080872816), (7, 0.0080872816)], [(4, 0.036179141), (5, 0.036179141), (6, 0.036179141), (7, 0.036179141)], [(4, 0.0971389334), (5, 0.0971389334), (6, 0.0971389334), (7, 0.0971389334)], [(4, 0.1295185778), (5, 0.1295185778), (6, 0.1295185778), (7, 0.1295185778)], [], [], [], []] + Bonds: [[], [], [(4, 0.0428473335), (5, 0.0428473335), (6, 0.0428473335), (7, 0.0428473335)], [(4, 0.057129778), (5, 0.057129778), (6, 0.057129778), (7, 0.057129778)], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - emaB: [[(4, 0.0072785532), (5, 0.0072785532), (6, 0.0072785532), (7, 0.0072785532)], [(4, 0.0325612267), (5, 0.0325612267), (6, 0.0325612267), (7, 0.0325612267)], [(4, 0.1302821825), (5, 0.1302821827), (6, 0.1302821827), (7, 0.1302821827)], [(4, 0.1737095772), (5, 0.173709577), (6, 0.173709577), (7, 0.173709577)], [], [], [], []] - emaB norm: [[(4, 0.0211689514), (5, 0.0211689514), (6, 0.0211689514), (7, 0.0211689514)], [(4, 0.094701105), (5, 0.094701105), (6, 0.094701105), (7, 0.094701105)], [(4, 0.3789128321), (5, 0.3789128328), (6, 0.3789128328), (7, 0.3789128328)], [(4, 0.505217111), (5, 0.5052171105), (6, 0.5052171105), (7, 0.5052171105)], [], [], [], []] - total_bonds_per_validator: [0.021168951, 0.0947011046, 0.3789128324, 0.50521711, 0, 0, 0, 0] - Dividends: [0.0062849855, 0.0562328366, 0.3374935838, 0.599988594, 0, 0, 0, 0] + ΔB: [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] + emaB: [[], [], [(4, 0.0428571426), (5, 0.0428571429), (6, 0.0428571429), (7, 0.0428571429)], [(4, 0.0571428572), (5, 0.057142857), (6, 0.057142857), (7, 0.057142857)], [], [], [], []] + emaB norm: [[], [], [(4, 0.4285714268), (5, 0.428571429), (6, 0.428571429), (7, 0.428571429)], [(4, 0.571428573), (5, 0.5714285707), (6, 0.5714285707), (7, 0.5714285707)], [], [], [], []] + total_bonds_per_validator: [0, 0, 0.4285714284, 0.5714285704, 0, 0, 0, 0] + Dividends: [0, 0, 0.36, 0.6399999997, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.0031424926, 0.0281164183, 0.1687467918, 0.2999942969, 0, 0, 0, 0] - Validator Emission: [3142492, 28116418, 168746791, 299994296, 0, 0, 0, 0] - Normalized Combined Emission: [0.0031424926, 0.0281164183, 0.1687467918, 0.2999942969, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [3142492, 28116418, 168746791, 299994296, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.0031424926, 0.0281164183, 0.1687467918, 0.2999942969, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Normalized Validator Emission: [0, 0, 0.18, 0.3199999998, 0, 0, 0, 0] + Validator Emission: [0, 0, 179999999, 319999999, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + Combined Emission: [0, 0, 179999999, 319999999, 49998779, 100000610, 149996337, 200004272] + Pruning Scores: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 476); - assert_eq!(bonds[1][7], 2133); - assert_eq!(bonds[2][7], 8538); - assert_eq!(bonds[3][7], 11384); + for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { + assert_eq!(bonds[i][7], *target_bond); + } // === Set val3->srv4: 1 assert_ok!(SubtensorModule::set_weights( @@ -1283,19 +1254,11 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 6 - activity_cutoff: 5000 - Last update: [2, 4, 5, 2, 1, 1, 1, 1] + /* current_block: 6 Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] @@ -1304,47 +1267,38 @@ fn test_bonds() { Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] - Bonds: [[(4, 476), (5, 476), (6, 476), (7, 476)], [(4, 2133), (5, 2133), (6, 2133), (7, 2133)], [(4, 8538), (5, 8538), (6, 8538), (7, 8538)], [(4, 11384), (5, 11384), (6, 11384), (7, 11384)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.0072632944), (5, 0.0072632944), (6, 0.0072632944), (7, 0.0072632944)], [(4, 0.0325474937), (5, 0.0325474937), (6, 0.0325474937), (7, 0.0325474937)], [(4, 0.130281529), (5, 0.130281529), (6, 0.130281529), (7, 0.130281529)], [(4, 0.1737087052), (5, 0.1737087052), (6, 0.1737087052), (7, 0.1737087052)], [], [], [], []] + Bonds: [[], [], [(4, 0.0428473335), (5, 0.0428473335), (6, 0.0428473335), (7, 0.0428473335)], [(4, 0.057129778), (5, 0.057129778), (6, 0.057129778), (7, 0.057129778)], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - emaB: [[(4, 0.0065369648), (5, 0.0065369648), (6, 0.0065369648), (7, 0.0065369648)], [(4, 0.0292927441), (5, 0.0292927441), (6, 0.0292927441), (7, 0.0292927441)], [(4, 0.117253376), (5, 0.117253376), (6, 0.117253376), (7, 0.1601105188)], [(4, 0.1563378347), (5, 0.1563378347), (6, 0.1563378347), (7, 0.2134806917)], [], [], [], []] - emaB norm: [[(4, 0.0211264472), (5, 0.0211264472), (6, 0.0211264472), (7, 0.0159663672)], [(4, 0.0946695658), (5, 0.0946695658), (6, 0.0946695658), (7, 0.0715467692)], [(4, 0.3789445655), (5, 0.3789445655), (6, 0.3789445655), (7, 0.3910657985)], [(4, 0.505259421), (5, 0.505259421), (6, 0.505259421), (7, 0.5214210646)], [], [], [], []] - total_bonds_per_validator: [0.0159663672, 0.0715467692, 0.3910657985, 0.5214210646, 0, 0, 0, 0] - Dividends: [0.0046713396, 0.0418654135, 0.3432467687, 0.610216478, 0, 0, 0, 0] + ΔB: [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[], [], [(7, 0.0428571429)], [(7, 0.057142857)], [], [], [], []] + emaB norm: [[], [], [(7, 0.428571429)], [(7, 0.5714285707)], [], [], [], []] + total_bonds_per_validator: [0, 0, 0.428571429, 0.5714285707, 0, 0, 0, 0] + Dividends: [0, 0, 0.3600000006, 0.6399999992, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0.0023356697, 0.0209327068, 0.1716233843, 0.305108239, 0, 0, 0, 0] - Validator Emission: [2335669, 20932706, 171623384, 305108238, 0, 0, 0, 0] - Normalized Combined Emission: [0.0023356697, 0.0209327068, 0.1716233843, 0.305108239, 0, 0, 0, 0.5] - Combined Emission: [2335669, 20932706, 171623384, 305108238, 0, 0, 0, 500000000] - Pruning Scores: [0.0023356697, 0.0209327068, 0.1716233843, 0.305108239, 0, 0, 0, 0.5] - + Normalized Validator Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0] + Validator Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] + Combined Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 500000000] + Pruning Scores: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 428); - assert_eq!(bonds[1][7], 1919); - assert_eq!(bonds[2][7], 10492); - assert_eq!(bonds[3][7], 13990); + for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { + assert_eq!(bonds[i][7], *target_bond); + } next_block(); if sparse { SubtensorModule::epoch(netuid, 1_000_000_000); } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 7 - activity_cutoff: 5000 - Last update: [2, 4, 5, 2, 1, 1, 1, 1] + /* current_block: 7 Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] @@ -1353,26 +1307,26 @@ fn test_bonds() { Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] - Bonds: [[(4, 428), (5, 428), (6, 428), (7, 428)], [(4, 1919), (5, 1919), (6, 1919), (7, 1919)], [(4, 7684), (5, 7684), (6, 7684), (7, 10492)], [(4, 10245), (5, 10245), (6, 10245), (7, 13990)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.0065308614), (5, 0.0065308614), (6, 0.0065308614), (7, 0.0065308614)], [(4, 0.029282063), (5, 0.029282063), (6, 0.029282063), (7, 0.029282063)], [(4, 0.1172503242), (5, 0.1172503242), (6, 0.1172503242), (7, 0.1600976577)], [(4, 0.1563286793), (5, 0.1563286793), (6, 0.1563286793), (7, 0.2134737163)], [], [], [], []] + Bonds: [[], [], [(7, 0.0428473335)], [(7, 0.057129778)], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - emaB: [[(4, 0.0058777751), (5, 0.0058777751), (6, 0.0058777751), (7, 0.0058777751)], [(4, 0.0263538565), (5, 0.0263538565), (6, 0.0263538565), (7, 0.0263538565)], [(4, 0.1055252918), (5, 0.1055252918), (6, 0.1055252918), (7, 0.1869450347)], [(4, 0.1406958112), (5, 0.1406958112), (6, 0.1406958112), (7, 0.2492692014)], [], [], [], []] - emaB norm: [[(4, 0.0211086995), (5, 0.0211086995), (6, 0.0211086995), (7, 0.0125473945)], [(4, 0.0946439134), (5, 0.0946439134), (6, 0.0946439134), (7, 0.0562580617)], [(4, 0.3789702114), (5, 0.3789702114), (6, 0.3789702114), (7, 0.3990749998)], [(4, 0.5052771752), (5, 0.5052771752), (6, 0.5052771752), (7, 0.5321195435)], [], [], [], []] - total_bonds_per_validator: [0.0125473945, 0.0562580617, 0.3990749998, 0.5321195435, 0, 0, 0, 0] - Dividends: [0.003636117, 0.0326061223, 0.3469446378, 0.6168131223, 0, 0, 0, 0] + ΔB: [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[], [], [(7, 0.0428571429)], [(7, 0.057142857)], [], [], [], []] + emaB norm: [[], [], [(7, 0.428571429)], [(7, 0.5714285707)], [], [], [], []] + total_bonds_per_validator: [0, 0, 0.428571429, 0.5714285707, 0, 0, 0, 0] + Dividends: [0, 0, 0.3600000006, 0.6399999992, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0.0018180585, 0.016303061, 0.1734723188, 0.3084065611, 0, 0, 0, 0] - Validator Emission: [1818058, 16303061, 173472318, 308406561, 0, 0, 0, 0] - Normalized Combined Emission: [0.0018180585, 0.016303061, 0.1734723188, 0.3084065611, 0, 0, 0, 0.5] - Combined Emission: [1818058, 16303061, 173472318, 308406561, 0, 0, 0, 500000000] - Pruning Scores: [0.0018180585, 0.016303061, 0.1734723188, 0.3084065611, 0, 0, 0, 0.5] + Normalized Validator Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0] + Validator Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] + Combined Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 500000000] + Pruning Scores: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 385); - assert_eq!(bonds[1][7], 1727); - assert_eq!(bonds[2][7], 12251); - assert_eq!(bonds[3][7], 16335); + for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { + assert_eq!(bonds[i][7], *target_bond); + } next_block(); if sparse { @@ -1380,19 +1334,11 @@ fn test_bonds() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* n: 8 - current_block: 8 - activity_cutoff: 5000 - Last update: [2, 4, 5, 2, 1, 1, 1, 1] + /* current_block: 8 Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 8 - new_validator_permits: [true, true, true, true, true, true, true, true] Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] @@ -1401,26 +1347,26 @@ fn test_bonds() { Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] - Bonds: [[(4, 385), (5, 385), (6, 385), (7, 385)], [(4, 1727), (5, 1727), (6, 1727), (7, 1727)], [(4, 6915), (5, 6915), (6, 6915), (7, 12251)], [(4, 9220), (5, 9220), (6, 9220), (7, 16335)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.0058747234), (5, 0.0058747234), (6, 0.0058747234), (7, 0.0058747234)], [(4, 0.0263523308), (5, 0.0263523308), (6, 0.0263523308), (7, 0.0263523308)], [(4, 0.1055161364), (5, 0.1055161364), (6, 0.1055161364), (7, 0.1869382772)], [(4, 0.1406881819), (5, 0.1406881819), (6, 0.1406881819), (7, 0.2492561226)], [], [], [], []] + Bonds: [[], [], [(7, 0.0428473335)], [(7, 0.057129778)], [], [], [], []] + Bonds: (mask) [[], [], [], [], [], [], [], []] weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - emaB: [[(4, 0.005287251), (5, 0.005287251), (6, 0.005287251), (7, 0.005287251)], [(4, 0.0237170977), (5, 0.0237170977), (6, 0.0237170977), (7, 0.0237170977)], [(4, 0.0949645226), (5, 0.0949645226), (6, 0.0949645226), (7, 0.2111015923)], [(4, 0.1266193634), (5, 0.1266193634), (6, 0.1266193634), (7, 0.2814733672)], [], [], [], []] - emaB norm: [[(4, 0.0210993583), (5, 0.0210993583), (6, 0.0210993583), (7, 0.010137003)], [(4, 0.094645695), (5, 0.094645695), (6, 0.094645695), (7, 0.0454716997)], [(4, 0.3789664055), (5, 0.3789664055), (6, 0.3789664055), (7, 0.404735366)], [(4, 0.5052885406), (5, 0.5052885406), (6, 0.5052885406), (7, 0.539655931)], [], [], [], []] - total_bonds_per_validator: [0.010137003, 0.0454716997, 0.404735366, 0.539655931, 0, 0, 0, 0] - Dividends: [0.0029180378, 0.0261789719, 0.3495214381, 0.621381552, 0, 0, 0, 0] + ΔB: [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[], [], [(7, 0.0428571429)], [(7, 0.057142857)], [], [], [], []] + emaB norm: [[], [], [(7, 0.428571429)], [(7, 0.5714285707)], [], [], [], []] + total_bonds_per_validator: [0, 0, 0.428571429, 0.5714285707, 0, 0, 0, 0] + Dividends: [0, 0, 0.3600000006, 0.6399999992, 0, 0, 0, 0] Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0.0014590188, 0.013089486, 0.174760719, 0.310690776, 0, 0, 0, 0] - Validator Emission: [1459018, 13089485, 174760719, 310690775, 0, 0, 0, 0] - Normalized Combined Emission: [0.0014590188, 0.013089486, 0.174760719, 0.310690776, 0, 0, 0, 0.5] - Combined Emission: [1459018, 13089485, 174760719, 310690775, 0, 0, 0, 500000000] - Pruning Scores: [0.0014590188, 0.013089486, 0.174760719, 0.310690776, 0, 0, 0, 0.5] + Normalized Validator Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0] + Validator Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 0] + Normalized Combined Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] + Combined Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 500000000] + Pruning Scores: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][7], 346); - assert_eq!(bonds[1][7], 1554); - assert_eq!(bonds[2][7], 13834); - assert_eq!(bonds[3][7], 18446); + for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { + assert_eq!(bonds[i][7], *target_bond); + } next_block(); if sparse { @@ -1542,11 +1488,9 @@ fn test_bonds_with_liquid_alpha() { Pruning Scores: [0, 0.111111111, 0.1666666665, 0.2222222222, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] */ - - assert_eq!(bonds[0][4], 4596); // Note: Calculated as explained above - assert_eq!(bonds[1][4], 4596); // Note: Calculated as explained above - assert_eq!(bonds[2][4], 4596); // Note: Calculated as explained above - assert_eq!(bonds[3][4], 4596); // Note: Calculated as explained above + for (i, target_bond) in [4596, 4596, 4596, 4596].iter().enumerate() { + assert_eq!(bonds[i][4], *target_bond); + } // === Set self-weight only on val1 let uid = 0; @@ -1565,10 +1509,9 @@ fn test_bonds_with_liquid_alpha() { } let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(bonds[0][4], 0); - assert_eq!(bonds[1][4], 5968); - assert_eq!(bonds[2][4], 5968); - assert_eq!(bonds[3][4], 5968); + for (i, target_bond) in [0, 5968, 5968, 5968].iter().enumerate() { + assert_eq!(bonds[i][4], *target_bond); + } // === Set self-weight only on val2 let uid = 1; @@ -1625,10 +1568,9 @@ fn test_bonds_with_liquid_alpha() { Pruning Scores: [0, 0, 0.214285714, 0.2857142857, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726]/ */ - assert_eq!(bonds[0][4], 0); - assert_eq!(bonds[1][4], 0); - assert_eq!(bonds[2][4], 6378); - assert_eq!(bonds[3][4], 6378); + for (i, target_bond) in [0, 0, 6378, 6378].iter().enumerate() { + assert_eq!(bonds[i][4], *target_bond); + } }); } From fddbf005fcc273ec9d61d1da7c81a08ea5b7f63c Mon Sep 17 00:00:00 2001 From: andreea-popescu-reef <160024917+andreea-popescu-reef@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:35:00 -0400 Subject: [PATCH 039/226] Update pallets/subtensor/src/epoch/math.rs Co-authored-by: Cameron Fairchild --- pallets/subtensor/src/epoch/math.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 365276ca9f..8b64b09c95 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1300,6 +1300,7 @@ pub fn hadamard_sparse( } /// Clamp the input value between high and low. +/// Note: assumes high > low pub fn clamp_value(value: I32F32, low: I32F32, high: I32F32) -> I32F32 { // First, clamp the value to ensure it does not exceed the upper bound (high). // If the value is greater than 'high', it will be set to 'high'. From eb53de38962da9edbdfdfb9745d1040bf94b4e0e Mon Sep 17 00:00:00 2001 From: andreea-popescu-reef <160024917+andreea-popescu-reef@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:35:28 -0400 Subject: [PATCH 040/226] Update pallets/subtensor/src/epoch/math.rs Co-authored-by: Cameron Fairchild --- pallets/subtensor/src/epoch/math.rs | 2 +- pallets/subtensor/src/epoch/run_epoch.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 8b64b09c95..a2108bd197 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -56,7 +56,7 @@ pub fn u16_proportion_to_fixed(x: u16) -> I32F32 { } #[allow(dead_code)] -pub fn fixed_to_fixed_proportion(x: I32F32) -> I32F32 { +pub fn fixed_to_fixed_u16_proportion(x: I32F32) -> I32F32 { x.safe_div(I32F32::saturating_from_num(u16::MAX)) } diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 07df343997..356a7ad785 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -888,7 +888,7 @@ impl Pallet { bonds.iter_mut().for_each(|bonds_row| { bonds_row .iter_mut() - .for_each(|bond| *bond = fixed_to_fixed_proportion(*bond)); + .for_each(|bond| *bond = fixed_to_fixed_u16_proportion(*bond)); }); bonds } @@ -898,7 +898,7 @@ impl Pallet { bonds.iter_mut().for_each(|bonds_row| { bonds_row .iter_mut() - .for_each(|(_, bond)| *bond = fixed_to_fixed_proportion(*bond)); + .for_each(|(_, bond)| *bond = fixed_to_fixed_u16_proportion(*bond)); }); bonds } From d480c6c5c81cc9b35b95d42487ab681f8a78a2f7 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 1 Apr 2025 02:01:16 +0100 Subject: [PATCH 041/226] simplify alphas matrix computation --- pallets/subtensor/src/epoch/math.rs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index a2108bd197..5898ced70c 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1414,17 +1414,11 @@ pub fn mat_ema_alpha_sparse( if let (Some(alpha_val), Some(decayed_val)) = (alpha_row.get(*j as usize), decayed_values.get(*j as usize)) { - // Calculate remaining capacity to limit bonds purchase - let remaining_capacity = one.saturating_sub(*decayed_val).max(zero); - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap // Validators allocate their purchase across miners based on weights - let purchase_increment = alpha_val.saturating_mul(*new_val); - - // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.min(remaining_capacity); + let purchase_increment = alpha_val.saturating_mul(*new_val).max(zero); + let result_val = decayed_val.saturating_add(purchase_increment).min(one); - let result_val = decayed_val.saturating_add(purchase).min(one); if result_val > zero { result_row.push((*j, result_val)); } @@ -1477,17 +1471,10 @@ pub fn mat_ema_alpha( // Bonds_decayed = Bonds * (1 - alpha) let decayed_val = one_minus_alpha.saturating_mul(*old_val); - // Calculate remaining capacity to limit bonds purchase - let remaining_capacity = one.saturating_sub(decayed_val).max(zero); - // Each validator can increase bonds by at most clamped_alpha per epoch towards the cap // Validators allocate their purchase across miners based on weights - let purchase_increment = alpha_val.saturating_mul(*new_val); - - // Ensure that purchase does not exceed remaining capacity - let purchase = purchase_increment.min(remaining_capacity); - - let result_val = decayed_val.saturating_add(purchase).min(one); + let purchase_increment = alpha_val.saturating_mul(*new_val).max(zero); + let result_val = decayed_val.saturating_add(purchase_increment).min(one); result_row.push(result_val); } } From 7fb65556dbe271c34aee39ed1f34266231f9a49b Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 8 Apr 2025 23:30:46 +0100 Subject: [PATCH 042/226] add Yuma3 toggle --- evm-tests/src/contracts/subnet.ts | 21 ++++++++++- .../subnet.precompile.hyperparameter.test.ts | 19 +++++++++- pallets/admin-utils/src/lib.rs | 26 +++++++++++++ pallets/admin-utils/src/tests/mock.rs | 2 + pallets/subtensor/src/lib.rs | 8 ++++ pallets/subtensor/src/macros/config.rs | 2 + pallets/subtensor/src/tests/mock.rs | 2 + pallets/subtensor/src/utils/misc.rs | 8 ++++ precompiles/src/solidity/subnet.abi | 37 +++++++++++++++++++ precompiles/src/solidity/subnet.sol | 7 ++++ precompiles/src/subnet.rs | 21 +++++++++++ runtime/src/lib.rs | 2 + 12 files changed, 152 insertions(+), 3 deletions(-) diff --git a/evm-tests/src/contracts/subnet.ts b/evm-tests/src/contracts/subnet.ts index 9b6fe00596..9ddc2da873 100644 --- a/evm-tests/src/contracts/subnet.ts +++ b/evm-tests/src/contracts/subnet.ts @@ -572,6 +572,25 @@ export const ISubnetABI = [ stateMutability: "view", type: "function", }, + { + inputs: [ + { + internalType: "uint16", + name: "netuid", + type: "uint16", + }, + ], + name: "getYuma3Enabled", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [ { @@ -886,4 +905,4 @@ export const ISubnetABI = [ stateMutability: "payable", type: "function" }, -]; \ No newline at end of file +]; diff --git a/evm-tests/test/subnet.precompile.hyperparameter.test.ts b/evm-tests/test/subnet.precompile.hyperparameter.test.ts index 1805b85ce9..6ddc29e7bc 100644 --- a/evm-tests/test/subnet.precompile.hyperparameter.test.ts +++ b/evm-tests/test/subnet.precompile.hyperparameter.test.ts @@ -80,7 +80,7 @@ describe("Test the Subnet precompile contract", () => { assert.equal(valueFromContract, onchainValue); } - // minDifficulty hyperparameter + // minDifficulty hyperparameter // // disabled: only by sudo // @@ -406,6 +406,21 @@ describe("Test the Subnet precompile contract", () => { assert.equal(valueFromContract, onchainValue); } + // yuma3Enabled hyperparameter + { + const newValue = true; + const tx = await contract.setYuma3Enabled(netuid, newValue); + await tx.wait(); + + let onchainValue = await api.query.SubtensorModule.Yuma3Enabled.getValue(netuid) + + let valueFromContract = Boolean( + await contract.getYuma3Enabled(netuid) + ); + assert.equal(valueFromContract, newValue) + assert.equal(valueFromContract, onchainValue); + } + // alphaValues hyperparameter { const newValue = [118, 52429]; @@ -439,4 +454,4 @@ describe("Test the Subnet precompile contract", () => { assert.equal(valueFromContract, onchainValue); } }) -}); \ No newline at end of file +}); diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 0175401b7f..6b3bfb8e82 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1505,6 +1505,32 @@ pub mod pallet { ); Ok(()) } + + /// Enables or disables Yuma3 for a given subnet. + /// + /// # Parameters + /// - `origin`: The origin of the call, which must be the root account or subnet owner. + /// - `netuid`: The unique identifier for the subnet. + /// - `enabled`: A boolean flag to enable or disable Yuma3. + /// + /// # Weight + /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. + #[pallet::call_index(67)] + #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + pub fn sudo_set_yuma3_enabled( + origin: OriginFor, + netuid: u16, + enabled: bool, + ) -> DispatchResult { + pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin, netuid)?; + pallet_subtensor::Pallet::::set_yuma3_enabled(netuid, enabled); + log::debug!( + "Yuma3EnableToggled( netuid: {:?}, Enabled: {:?} ) ", + netuid, + enabled + ); + Ok(()) + } } } diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 5f0d6bdcfa..1fade2a6d5 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -130,6 +130,7 @@ parameter_types! { pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn + pub const InitialYuma3On: bool = false; // Default value for Yuma3On // pub const InitialHotkeyEmissionTempo: u64 = 1; // (DEPRECATED) // pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days @@ -197,6 +198,7 @@ impl pallet_subtensor::Config for Test { type AlphaHigh = InitialAlphaHigh; type AlphaLow = InitialAlphaLow; type LiquidAlphaOn = InitialLiquidAlphaOn; + type Yuma3On = InitialYuma3On; type Preimages = (); type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration; type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration; diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index a78001e66b..049173bdce 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -730,6 +730,11 @@ pub mod pallet { false } #[pallet::type_value] + /// -- ITEM (switches liquid alpha on) + pub fn DefaultYuma3() -> bool { + false + } + #[pallet::type_value] /// (alpha_low: 0.7, alpha_high: 0.9) pub fn DefaultAlphaValues() -> (u16, u16) { (45875, 58982) @@ -1356,6 +1361,9 @@ pub mod pallet { pub type LiquidAlphaOn = StorageMap<_, Blake2_128Concat, u16, bool, ValueQuery, DefaultLiquidAlpha>; #[pallet::storage] + /// --- MAP ( netuid ) --> Whether or not Yuma3 is enabled + pub type Yuma3On = StorageMap<_, Blake2_128Concat, u16, bool, ValueQuery, DefaultYuma3>; + #[pallet::storage] /// MAP ( netuid ) --> (alpha_low, alpha_high) pub type AlphaValues = StorageMap<_, Identity, u16, (u16, u16), ValueQuery, DefaultAlphaValues>; diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index 76e7840e74..628e3609af 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -198,6 +198,8 @@ mod config { /// A flag to indicate if Liquid Alpha is enabled. #[pallet::constant] type LiquidAlphaOn: Get; + /// A flag to indicate if Yuma3 is enabled. + type Yuma3On: Get; // /// Initial hotkey emission tempo. // #[pallet::constant] // type InitialHotkeyEmissionTempo: Get; diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index dff78b7a28..c9f6697237 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -181,6 +181,7 @@ parameter_types! { pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn + pub const InitialYuma3On: bool = false; // Default value for Yuma3On // pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days @@ -406,6 +407,7 @@ impl crate::Config for Test { type AlphaHigh = InitialAlphaHigh; type AlphaLow = InitialAlphaLow; type LiquidAlphaOn = InitialLiquidAlphaOn; + type Yuma3On = InitialYuma3On; type Preimages = Preimage; type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration; type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration; diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index e36f033a74..caea51d285 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -703,6 +703,14 @@ impl Pallet { LiquidAlphaOn::::get(netuid) } + pub fn set_yuma3_enabled(netuid: u16, enabled: bool) { + Yuma3On::::set(netuid, enabled); + } + + pub fn get_yuma3_enabled(netuid: u16) -> bool { + Yuma3On::::get(netuid) + } + /// Set the duration for coldkey swap /// /// # Arguments diff --git a/precompiles/src/solidity/subnet.abi b/precompiles/src/solidity/subnet.abi index e2a3e569da..a2849a0cbe 100644 --- a/precompiles/src/solidity/subnet.abi +++ b/precompiles/src/solidity/subnet.abi @@ -194,6 +194,25 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "netuid", + "type": "uint16" + } + ], + "name": "getYuma3Enabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -668,6 +687,24 @@ "stateMutability": "payable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "netuid", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "yuma3Enabled", + "type": "bool" + } + ], + "name": "setYuma3Enabled", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, { "inputs": [ { diff --git a/precompiles/src/solidity/subnet.sol b/precompiles/src/solidity/subnet.sol index d5ef0916d9..2fa9d3f550 100644 --- a/precompiles/src/solidity/subnet.sol +++ b/precompiles/src/solidity/subnet.sol @@ -152,6 +152,13 @@ interface ISubnet { bool liquidAlphaEnabled ) external payable; + function getYuma3Enabled(uint16 netuid) external view returns (bool); + + function setYuma3Enabled( + uint16 netuid, + bool yuma3Enabled + ) external payable; + function getAlphaValues( uint16 netuid ) external view returns (uint16, uint16); diff --git a/precompiles/src/subnet.rs b/precompiles/src/subnet.rs index ae57584eb5..ad1ce61ff7 100644 --- a/precompiles/src/subnet.rs +++ b/precompiles/src/subnet.rs @@ -575,6 +575,27 @@ where ) } + #[precompile::public("getYuma3Enabled(uint16)")] + #[precompile::view] + fn get_yuma3_enabled(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::Yuma3On::::get(netuid)) + } + + #[precompile::public("setYuma3Enabled(uint16,bool)")] + #[precompile::payable] + fn set_yuma3_enabled( + handle: &mut impl PrecompileHandle, + netuid: u16, + enabled: bool, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_yuma3_enabled { netuid, enabled }; + + handle.try_dispatch_runtime_call::( + call, + RawOrigin::Signed(handle.caller_account_id::()), + ) + } + #[precompile::public("getAlphaValues(uint16)")] #[precompile::view] fn get_alpha_values(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult<(u16, u16)> { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a6e3350b5e..d058cd3bfc 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1040,6 +1040,7 @@ parameter_types! { pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn + pub const InitialYuma3On: bool = false; // Default value for Yuma3On // pub const SubtensorInitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days pub const InitialDissolveNetworkScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days @@ -1110,6 +1111,7 @@ impl pallet_subtensor::Config for Runtime { type AlphaHigh = InitialAlphaHigh; type AlphaLow = InitialAlphaLow; type LiquidAlphaOn = InitialLiquidAlphaOn; + type Yuma3On = InitialYuma3On; type InitialTaoWeight = SubtensorInitialTaoWeight; type Preimages = Preimage; type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration; From be623f009e8830b29e4dbe9e7f80637648943748 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 8 Apr 2025 23:36:14 +0100 Subject: [PATCH 043/226] revert original yuma --- pallets/subtensor/src/epoch/run_epoch.rs | 287 +++++++++++++++++------ 1 file changed, 217 insertions(+), 70 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 356a7ad785..28bbb89d07 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -197,37 +197,67 @@ impl Pallet { let weights_for_bonds: Vec> = interpolate(&weights, &clipped_weights, bonds_penalty); - // Access network bonds. - let mut bonds: Vec> = Self::get_bonds_fixed_proportion(netuid); - inplace_mask_cols(&recently_registered, &mut bonds); // mask outdated bonds - log::trace!("B: {:?}", &bonds); + let mut dividends: Vec; + let mut ema_bonds: Vec>; + if Yuma3On::::get(netuid) { + // Access network bonds. + let mut bonds: Vec> = Self::get_bonds_fixed_proportion(netuid); + inplace_mask_cols(&recently_registered, &mut bonds); // mask outdated bonds + log::trace!("B: {:?}", &bonds); + + // Compute the Exponential Moving Average (EMA) of bonds. + ema_bonds = Self::compute_bonds( + netuid, + &weights_for_bonds, + &bonds, + &consensus, + &active_stake, + ); + log::trace!("emaB: {:?}", &ema_bonds); + + // Normalize EMA bonds. + let mut ema_bonds_norm = ema_bonds.clone(); + inplace_col_normalize(&mut ema_bonds_norm); + log::trace!("emaB norm: {:?}", &ema_bonds_norm); + + // # === Dividend Calculation=== + let total_bonds_per_validator: Vec = + row_sum(&mat_vec_mul(&ema_bonds_norm, &incentive)); + log::trace!( + "total_bonds_per_validator: {:?}", + &total_bonds_per_validator + ); + + dividends = vec_mul(&total_bonds_per_validator, &active_stake); + inplace_normalize(&mut dividends); + log::trace!("D: {:?}", ÷nds); + } else { + // original Yuma - liquid alpha disabled + // Access network bonds. + let mut bonds: Vec> = Self::get_bonds(netuid); + // Remove bonds referring to neurons that have registered since last tempo. + inplace_mask_cols(&recently_registered, &mut bonds); // mask recently registered bonds + inplace_col_normalize(&mut bonds); // sum_i b_ij = 1 + log::trace!("B: {:?}", &bonds); - // Compute the Exponential Moving Average (EMA) of bonds. - let ema_bonds = Self::compute_ema_bonds( - netuid, - &weights_for_bonds, - &bonds, - &consensus, - &active_stake, - ); - log::trace!("emaB: {:?}", &ema_bonds); + // Compute bonds delta column normalized. + let mut bonds_delta: Vec> = row_hadamard(&weights_for_bonds, &active_stake); // ΔB = W◦S + inplace_col_normalize(&mut bonds_delta); // sum_i b_ij = 1 + log::trace!("ΔB: {:?}", &bonds_delta); - // Normalize EMA bonds. - let mut ema_bonds_norm = ema_bonds.clone(); - inplace_col_normalize(&mut ema_bonds_norm); - log::trace!("emaB norm: {:?}", &ema_bonds_norm); + // Compute the Exponential Moving Average (EMA) of bonds. + ema_bonds = Self::compute_ema_bonds_normal(&bonds_delta, &bonds, netuid); + inplace_col_normalize(&mut ema_bonds); // sum_i b_ij = 1 + log::trace!("emaB: {:?}", &ema_bonds); - // # === Dividend Calculation=== - let total_bonds_per_validator: Vec = - row_sum(&mat_vec_mul(&ema_bonds_norm, &incentive)); - log::trace!( - "total_bonds_per_validator: {:?}", - &total_bonds_per_validator - ); + // Compute dividends: d_i = SUM(j) b_ij * inc_j + dividends = matmul_transpose(&ema_bonds, &incentive); + inplace_normalize(&mut dividends); + log::trace!("Dividends: {:?}", ÷nds); - let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); - inplace_normalize(&mut dividends); - log::trace!("D: {:?}", ÷nds); + // Column max-upscale EMA bonds for storage: max_i w_ij = 1. + inplace_col_max_upscale(&mut ema_bonds); + } // ================================= // == Emission and Pruning scores == @@ -572,49 +602,98 @@ impl Pallet { let weights_for_bonds: Vec> = interpolate_sparse(&weights, &clipped_weights, n, bonds_penalty); - // Access network bonds. - let mut bonds: Vec> = Self::get_bonds_sparse_fixed_proportion(netuid); - log::trace!("Bonds: {:?}", &bonds); - - // Remove bonds referring to neurons that have registered since last tempo. - // Mask if: the last tempo block happened *before* the registration block - // ==> last_tempo <= registered - let last_tempo: u64 = current_block.saturating_sub(tempo); - bonds = scalar_vec_mask_sparse_matrix( - &bonds, - last_tempo, - &block_at_registration, - &|last_tempo, registered| last_tempo <= registered, - ); - log::trace!("Bonds: (mask) {:?}", &bonds); - - // Compute the Exponential Moving Average (EMA) of bonds. - log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); - let ema_bonds = Self::compute_ema_bonds_sparse( - netuid, - &weights_for_bonds, - &bonds, - &consensus, - &active_stake, - ); - log::trace!("emaB: {:?}", &ema_bonds); - - // Normalize EMA bonds. - let mut ema_bonds_norm = ema_bonds.clone(); - inplace_col_normalize_sparse(&mut ema_bonds_norm, n); // sum_i b_ij = 1 - log::trace!("emaB norm: {:?}", &ema_bonds_norm); + let mut dividends: Vec; + let mut ema_bonds: Vec>; + if Yuma3On::::get(netuid) { + // Access network bonds. + let mut bonds = Self::get_bonds_sparse_fixed_proportion(netuid); + log::trace!("Bonds: {:?}", &bonds); + + // Remove bonds referring to neurons that have registered since last tempo. + // Mask if: the last tempo block happened *before* the registration block + // ==> last_tempo <= registered + let last_tempo: u64 = current_block.saturating_sub(tempo); + bonds = scalar_vec_mask_sparse_matrix( + &bonds, + last_tempo, + &block_at_registration, + &|last_tempo, registered| last_tempo <= registered, + ); + log::trace!("Bonds: (mask) {:?}", &bonds); + + // Compute the Exponential Moving Average (EMA) of bonds. + log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); + ema_bonds = Self::compute_bonds_sparse( + netuid, + &weights_for_bonds, + &bonds, + &consensus, + &active_stake, + ); + log::trace!("emaB: {:?}", &ema_bonds); + + // Normalize EMA bonds. + let mut ema_bonds_norm = ema_bonds.clone(); + inplace_col_normalize_sparse(&mut ema_bonds_norm, n); // sum_i b_ij = 1 + log::trace!("emaB norm: {:?}", &ema_bonds_norm); + + // # === Dividend Calculation=== + let total_bonds_per_validator: Vec = + row_sum_sparse(&mat_vec_mul_sparse(&ema_bonds_norm, &incentive)); + log::trace!( + "total_bonds_per_validator: {:?}", + &total_bonds_per_validator + ); + + dividends = vec_mul(&total_bonds_per_validator, &active_stake); + inplace_normalize(&mut dividends); + log::trace!("Dividends: {:?}", ÷nds); + } else { + // original Yuma - liquid alpha disabled + // Access network bonds. + let mut bonds: Vec> = Self::get_bonds_sparse(netuid); + log::trace!("B: {:?}", &bonds); + + // Remove bonds referring to neurons that have registered since last tempo. + // Mask if: the last tempo block happened *before* the registration block + // ==> last_tempo <= registered + let last_tempo: u64 = current_block.saturating_sub(tempo); + bonds = scalar_vec_mask_sparse_matrix( + &bonds, + last_tempo, + &block_at_registration, + &|last_tempo, registered| last_tempo <= registered, + ); + log::trace!("B (outdatedmask): {:?}", &bonds); + + // Normalize remaining bonds: sum_i b_ij = 1. + inplace_col_normalize_sparse(&mut bonds, n); + log::trace!("B (mask+norm): {:?}", &bonds); - // # === Dividend Calculation=== - let total_bonds_per_validator: Vec = - row_sum_sparse(&mat_vec_mul_sparse(&ema_bonds_norm, &incentive)); - log::trace!( - "total_bonds_per_validator: {:?}", - &total_bonds_per_validator - ); + // Compute bonds delta column normalized. + let mut bonds_delta: Vec> = + row_hadamard_sparse(&weights_for_bonds, &active_stake); // ΔB = W◦S (outdated W masked) + log::trace!("ΔB: {:?}", &bonds_delta); - let mut dividends: Vec = vec_mul(&total_bonds_per_validator, &active_stake); - inplace_normalize(&mut dividends); - log::trace!("Dividends: {:?}", ÷nds); + // Normalize bonds delta. + inplace_col_normalize_sparse(&mut bonds_delta, n); // sum_i b_ij = 1 + log::trace!("ΔB (norm): {:?}", &bonds_delta); + + // Compute the Exponential Moving Average (EMA) of bonds. + ema_bonds = Self::compute_ema_bonds_normal_sparse(&bonds_delta, &bonds, netuid); + // Normalize EMA bonds. + inplace_col_normalize_sparse(&mut ema_bonds, n); // sum_i b_ij = 1 + log::trace!("Exponential Moving Average Bonds: {:?}", &ema_bonds); + + // Compute dividends: d_i = SUM(j) b_ij * inc_j. + // range: I32F32(0, 1) + dividends = matmul_transpose_sparse(&ema_bonds, &incentive); + inplace_normalize(&mut dividends); + log::trace!("Dividends: {:?}", ÷nds); + + // Column max-upscale EMA bonds for storage: max_i w_ij = 1. + inplace_col_max_upscale_sparse(&mut ema_bonds, n); + } // ================================= // == Emission and Pruning scores == @@ -903,6 +982,74 @@ impl Pallet { bonds } + /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value for a sparse matrix. + /// + /// # Args: + /// * `bonds_delta` - A vector of bond deltas. + /// * `bonds` - A vector of bonds. + /// * `netuid` - The network ID. + /// + /// # Returns: + /// A vector of EMA bonds. + pub fn compute_ema_bonds_normal_sparse( + bonds_delta: &[Vec<(u16, I32F32)>], + bonds: &[Vec<(u16, I32F32)>], + netuid: u16, + ) -> Vec> { + // Retrieve the bonds moving average for the given network ID and scale it down. + let bonds_moving_average: I64F64 = + I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) + .safe_div(I64F64::saturating_from_num(1_000_000)); + + // Calculate the alpha value for the EMA calculation. + // Alpha is derived by subtracting the scaled bonds moving average from 1. + let alpha: I32F32 = I32F32::saturating_from_num(1) + .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); + + // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. + let ema_bonds = mat_ema_sparse(bonds_delta, bonds, alpha); + + // Log the computed EMA bonds for debugging purposes. + log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); + + // Return the computed EMA bonds. + ema_bonds + } + + /// Compute the Exponential Moving Average (EMA) of bonds using a normal alpha value. + /// + /// # Args: + /// * `bonds_delta` - A vector of bond deltas. + /// * `bonds` - A vector of bonds. + /// * `netuid` - The network ID. + /// + /// # Returns: + /// A vector of EMA bonds. + pub fn compute_ema_bonds_normal( + bonds_delta: &[Vec], + bonds: &[Vec], + netuid: u16, + ) -> Vec> { + // Retrieve the bonds moving average for the given network ID and scale it down. + let bonds_moving_average: I64F64 = + I64F64::saturating_from_num(Self::get_bonds_moving_average(netuid)) + .safe_div(I64F64::saturating_from_num(1_000_000)); + + // Calculate the alpha value for the EMA calculation. + // Alpha is derived by subtracting the scaled bonds moving average from 1. + let alpha: I32F32 = I32F32::saturating_from_num(1) + .saturating_sub(I32F32::saturating_from_num(bonds_moving_average)); + + // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. + let ema_bonds = mat_ema(bonds_delta, bonds, alpha); + + // Log the computed EMA bonds for debugging purposes. + log::trace!("Exponential Moving Average Bonds Normal: {:?}", ema_bonds); + + // Return the computed EMA bonds. + ema_bonds + } + /// Compute the Exponential Moving Average (EMA) of bonds based on the Liquid Alpha setting /// /// # Args: @@ -914,7 +1061,7 @@ impl Pallet { /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds( + pub fn compute_bonds( netuid: u16, weights: &[Vec], // weights_for_bonds bonds: &[Vec], @@ -960,7 +1107,7 @@ impl Pallet { /// /// # Returns: /// A vector of EMA bonds. - pub fn compute_ema_bonds_sparse( + pub fn compute_bonds_sparse( netuid: u16, weights: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], From 564745ae21fe77c26089d7b938cf7b182279971e Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 9 Apr 2025 00:17:08 +0100 Subject: [PATCH 044/226] revert no liquid alpha tests --- pallets/subtensor/src/epoch/run_epoch.rs | 2 +- pallets/subtensor/src/tests/epoch.rs | 1159 ++++++++-------------- 2 files changed, 423 insertions(+), 738 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 28bbb89d07..a8885047b9 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -252,7 +252,7 @@ impl Pallet { // Compute dividends: d_i = SUM(j) b_ij * inc_j dividends = matmul_transpose(&ema_bonds, &incentive); - inplace_normalize(&mut dividends); + inplace_normalize(&mut dividends); log::trace!("Dividends: {:?}", ÷nds); // Column max-upscale EMA bonds for storage: max_i w_ij = 1. diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 9bb9f5a6e7..9b9e3e8727 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -714,7 +714,8 @@ fn test_512_graph() { assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, uid), 1023); // Note D = floor(1 / 64 * 65_535) = 1023 assert_eq!(SubtensorModule::get_emission_for_uid(netuid, uid), 7812500); // Note E = 0.5 / 200 * 1_000_000_000 = 7_812_500 assert_eq!(bonds[uid as usize][validator], 0.0); - assert_eq!(bonds[uid as usize][server], I32F32::from_num(102)); + assert_eq!(bonds[uid as usize][server], I32F32::from_num(65_535)); + // Note B_ij = floor(1 / 64 * 65_535) / 65_535 = 1023 / 65_535, then max-upscaled to 65_535 } for uid in servers { assert_eq!( @@ -982,599 +983,310 @@ fn test_512_graph_random_weights() { // }); // } -// Test bonds exponential moving average over a sequence of epochs. +// Test bonds exponential moving average over a sequence of epochs - no liquid alpha #[test] fn test_bonds() { new_test_ext(1).execute_with(|| { - let sparse: bool = true; - let n: u16 = 8; - let netuid: u16 = 1; - let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead - let max_stake: u64 = 4; - let stakes: Vec = vec![1, 2, 3, 4, 0, 0, 0, 0]; + let sparse: bool = true; + let n: u16 = 8; + let netuid: u16 = 1; + let tempo: u16 = 1; + let max_stake: u64 = 4; + let stakes: Vec = vec![1, 2, 3, 4, 0, 0, 0, 0]; let block_number = System::block_number(); - add_network(netuid, tempo, 0); - SubtensorModule::set_max_allowed_uids(netuid, n); - assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); - SubtensorModule::set_max_registrations_per_block(netuid, n); - SubtensorModule::set_target_registrations_per_interval(netuid, n); - SubtensorModule::set_weights_set_rate_limit(netuid, 0); - SubtensorModule::set_min_allowed_weights(netuid, 1); - SubtensorModule::set_max_weight_limit(netuid, u16::MAX); - SubtensorModule::set_bonds_penalty(netuid, u16::MAX); - - // === Register [validator1, validator2, validator3, validator4, server1, server2, server3, server4] - for key in 0..n as u64 { - SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), max_stake); - let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( - netuid, - block_number, - key * 1_000_000, - &U256::from(key), - ); - assert_ok!(SubtensorModule::register( - <::RuntimeOrigin>::signed(U256::from(key)), - netuid, - block_number, - nonce, - work, - U256::from(key), - U256::from(key) - )); - SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( - &U256::from(key), - &U256::from(key), - netuid, - stakes[key as usize], - ); - } - assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); - assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); - - // === Issue validator permits - SubtensorModule::set_max_allowed_validators(netuid, n); - assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), n); - SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators - next_block(); // run to next block to ensure weights are set on nodes after their registration block - - // === Set weights [val->srv1: 0.1, val->srv2: 0.2, val->srv3: 0.3, val->srv4: 0.4] - for uid in 0..(n / 2) as u64 { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - ((n / 2)..n).collect(), - vec![u16::MAX / 4, u16::MAX / 2, (u16::MAX / 4) * 3, u16::MAX], - 0 - )); - } - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 2 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149 - ), (7, 65535)], [], [], [], []] - Weights (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), - (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584) - , (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5 - , 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] - Bonds: [[], [], [], [], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), - (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - ΔB: [[(4, 0.0999999996), (5, 0.0999999999), (6, 0.0999999994), (7, 0.0999999996)], [(4, 0.1999999995), (5, 0.2), (6, 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, - 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] - emaB: [[(4, 0.0099999998), (5, 0.0099999998), (6, 0.0099999998), (7, 0.0099999998)], [(4, 0.0199999998), (5, 0.0199999998), (6, 0.0199999998), (7, 0.0199999998)], [(4, 0.0299999998), (5, 0.0299999998), (6, 0.03), (7, 0.03)], [(4, 0.04), (5, 0.0399999998), (6, 0.04), (7, 0.04)], [], [], [], []] - emaB norm: [[(4, 0.0999999982), (5, 0.0999999985), (6, 0.099999998), (7, 0.099999998)], [(4, 0.199999999), (5, 0.1999999995), (6, 0.1999999986), (7, 0.1999999986)], [(4, 0.2999999996), (5, 0.3000000003), (6, 0.3000000012), (7, 0.3000000012)], [(4, 0.4000000027), (5, 0.4000000013), (6, 0.4000000018), (7, 0.4000000018)], [], [], [], []] - total_bonds_per_validator: [0.0999999975, 0.1999999979, 0.3000000003, 0.4000000008, 0, 0, 0, 0] - Dividends: [0.0333333318, 0.1333333314, 0.3000000005, 0.5333333358, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0, 0, 0, 0] - Validator Emission: [16666665, 66666665, 150000000, 266666668, 0, 0, 0, 0] - Normalized Combined Emission: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - Combined Emission: [16666665, 66666665, 150000000, 266666668, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0.016666666, 0.0666666657, 0.1500000001, 0.266666668, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] - s: [[0, 0, 0, 0, 655, 655, 655, 655], [0, 0, 0, 0, 1310, 1310, 1310, 1310], [0, 0, 0, 0, 1966, 1966, 1966, 1966], [0, 0, 0, 0, 2621, 2621, 2621, 2621], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] - */ - - let bonds = SubtensorModule::get_bonds(netuid); - for (i, target_bond) in [655, 1310, 1966, 2621].iter().enumerate() { - assert_eq!(bonds[i][4], *target_bond); - } - - // === Set self-weight only on val1 - let uid = 0; - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![uid], - vec![u16::MAX], - 0 - )); - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 3 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[(4, 0.0099946593), (5, 0.0099946593), (6, 0.0099946593), (7, 0.0099946593)], [(4, 0.0199893187), (5, 0.0199893187), (6, 0.0199893187), (7, 0.0199893187)], [(4, 0.029999237), (5, 0.029999237), (6, 0.029999237), (7, 0.029999237)], [(4, 0.0399938964), (5, 0.0399938964), (6, 0.0399938964), (7, 0.0399938964)], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - ΔB: [[], [(4, 0.2222222215), (5, 0.222222222), (6, 0.2222222218), (7, 0.2222222218)], [(4, 0.3333333323), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.4444444457), (5, 0.4444444443), (6, 0.4444444447), (7, 0.4444444445)], [], [], [], []] - emaB: [[], [(4, 0.022222222), (5, 0.022222222), (6, 0.022222222), (7, 0.022222222)], [(4, 0.0333333332), (5, 0.0333333332), (6, 0.0333333332), (7, 0.0333333332)], [(4, 0.0444444446), (5, 0.0444444444), (6, 0.0444444444), (7, 0.0444444444)], [], [], [], []] - emaB norm: [[], [(4, 0.2222222209), (5, 0.2222222213), (6, 0.2222222213), (7, 0.2222222213)], [(4, 0.3333333323), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.4444444464), (5, 0.4444444452), (6, 0.4444444452), (7, 0.4444444452)], [], [], [], []] - total_bonds_per_validator: [0, 0.2222222209, 0.3333333328, 0.444444445, 0, 0, 0, 0] - Dividends: [0, 0.1379310335, 0.310344827, 0.5517241391, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0, 0.0689655168, 0.1551724134, 0.2758620696, 0, 0, 0, 0] - Validator Emission: [0, 68965516, 155172413, 275862069, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0.0689655168, 0.1551724134, 0.2758620696, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [0, 68965516, 155172413, 275862069, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0, 0.0689655168, 0.1551724134, 0.2758620696, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - */ - for (i, target_bond) in [655, 1310, 1966, 2621].iter().enumerate() { - assert_eq!(bonds[i][4], *target_bond); - } - - // === Set self-weight only on val2 - let uid = 1; - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![uid], - vec![u16::MAX], - 0 - )); - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 4 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[], [(4, 0.0222171359), (5, 0.0222171359), (6, 0.0222171359), (7, 0.0222171359)], [(4, 0.0333257038), (5, 0.0333257038), (6, 0.0333257038), (7, 0.0333257038)], [(4, 0.0444342718), (5, 0.0444342718), (6, 0.0444342718), (7, 0.0444342718)], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - ΔB: [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] - emaB: [[], [], [(4, 0.0428571426), (5, 0.0428571429), (6, 0.0428571429), (7, 0.0428571429)], [(4, 0.0571428572), (5, 0.057142857), (6, 0.057142857), (7, 0.057142857)], [], [], [], []] - emaB norm: [[], [], [(4, 0.4285714268), (5, 0.428571429), (6, 0.428571429), (7, 0.428571429)], [(4, 0.571428573), (5, 0.5714285707), (6, 0.5714285707), (7, 0.5714285707)], [], [], [], []] - total_bonds_per_validator: [0, 0, 0.4285714284, 0.5714285704, 0, 0, 0, 0] - Dividends: [0, 0, 0.36, 0.6399999997, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0, 0, 0.18, 0.3199999998, 0, 0, 0, 0] - Validator Emission: [0, 0, 179999999, 319999999, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [0, 0, 179999999, 319999999, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - */ - let bonds = SubtensorModule::get_bonds(netuid); - for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { - assert_eq!(bonds[i][4], *target_bond); - } - - // === Set self-weight only on val2 - let uid = 1; - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![uid], - vec![u16::MAX], - 0 - )); - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 5 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[], [], [(4, 0.0428473335), (5, 0.0428473335), (6, 0.0428473335), (7, 0.0428473335)], [(4, 0.057129778), (5, 0.057129778), (6, 0.057129778), (7, 0.057129778)], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - ΔB: [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] - emaB: [[], [], [(4, 0.0428571426), (5, 0.0428571429), (6, 0.0428571429), (7, 0.0428571429)], [(4, 0.0571428572), (5, 0.057142857), (6, 0.057142857), (7, 0.057142857)], [], [], [], []] - emaB norm: [[], [], [(4, 0.4285714268), (5, 0.428571429), (6, 0.428571429), (7, 0.428571429)], [(4, 0.571428573), (5, 0.5714285707), (6, 0.5714285707), (7, 0.5714285707)], [], [], [], []] - total_bonds_per_validator: [0, 0, 0.4285714284, 0.5714285704, 0, 0, 0, 0] - Dividends: [0, 0, 0.36, 0.6399999997, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0, 0, 0.18, 0.3199999998, 0, 0, 0, 0] - Validator Emission: [0, 0, 179999999, 319999999, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [0, 0, 179999999, 319999999, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0, 0, 0.18, 0.3199999998, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - */ - let bonds = SubtensorModule::get_bonds(netuid); - for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { - assert_eq!(bonds[i][7], *target_bond); - } - - // === Set val3->srv4: 1 - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(2)), - netuid, - vec![7], - vec![u16::MAX], - 0 - )); - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 6 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] - Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - Clipped Weights: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] - Bonds: [[], [], [(4, 0.0428473335), (5, 0.0428473335), (6, 0.0428473335), (7, 0.0428473335)], [(4, 0.057129778), (5, 0.057129778), (6, 0.057129778), (7, 0.057129778)], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - ΔB: [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[], [], [(7, 0.0428571429)], [(7, 0.057142857)], [], [], [], []] - emaB norm: [[], [], [(7, 0.428571429)], [(7, 0.5714285707)], [], [], [], []] - total_bonds_per_validator: [0, 0, 0.428571429, 0.5714285707, 0, 0, 0, 0] - Dividends: [0, 0, 0.3600000006, 0.6399999992, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0] - Validator Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] - Combined Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 500000000] - Pruning Scores: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] - */ - let bonds = SubtensorModule::get_bonds(netuid); - - for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { - assert_eq!(bonds[i][7], *target_bond); - } - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 7 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] - Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - Clipped Weights: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] - Bonds: [[], [], [(7, 0.0428473335)], [(7, 0.057129778)], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - ΔB: [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[], [], [(7, 0.0428571429)], [(7, 0.057142857)], [], [], [], []] - emaB norm: [[], [], [(7, 0.428571429)], [(7, 0.5714285707)], [], [], [], []] - total_bonds_per_validator: [0, 0, 0.428571429, 0.5714285707, 0, 0, 0, 0] - Dividends: [0, 0, 0.3600000006, 0.6399999992, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0] - Validator Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] - Combined Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 500000000] - Pruning Scores: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] - */ - let bonds = SubtensorModule::get_bonds(netuid); - for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { - assert_eq!(bonds[i][7], *target_bond); - } - - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - /* current_block: 8 - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] - Consensus: [0, 0, 0, 0, 0, 0, 0, 0.400008545] - Clipped Weights: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] - Trust: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] - Incentive (=Rank): [0, 0, 0, 0, 0, 0, 0, 1] - Bonds: [[], [], [(7, 0.0428473335)], [(7, 0.057129778)], [], [], [], []] - Bonds: (mask) [[], [], [], [], [], [], [], []] - weights_for_bonds: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] - ΔB: [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] - emaB: [[], [], [(7, 0.0428571429)], [(7, 0.057142857)], [], [], [], []] - emaB norm: [[], [], [(7, 0.428571429)], [(7, 0.5714285707)], [], [], [], []] - total_bonds_per_validator: [0, 0, 0.428571429, 0.5714285707, 0, 0, 0, 0] - Dividends: [0, 0, 0.3600000006, 0.6399999992, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0, 0, 0, 0.5] - Server Emission: [0, 0, 0, 0, 0, 0, 0, 500000000] - Normalized Validator Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0] - Validator Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] - Combined Emission: [0, 0, 180000000, 319999999, 0, 0, 0, 500000000] - Pruning Scores: [0, 0, 0.1800000002, 0.3199999996, 0, 0, 0, 0.5] - */ - let bonds = SubtensorModule::get_bonds(netuid); - for (i, target_bond) in [0, 0, 2808, 3744].iter().enumerate() { - assert_eq!(bonds[i][7], *target_bond); - } - - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - }); -} - -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::epoch::test_512_graph_random_weights --exact --show-output --nocapture -#[test] -fn test_bonds_with_liquid_alpha() { - new_test_ext(1).execute_with(|| { - let sparse: bool = true; - let n: u16 = 8; - let netuid: u16 = 1; - let tempo: u16 = 1; - let max_stake: u64 = 4; - let stakes: Vec = vec![1, 2, 3, 4, 0, 0, 0, 0]; - let block_number = System::block_number(); - add_network(netuid, tempo, 0); - SubtensorModule::set_max_allowed_uids(netuid, n); - SubtensorModule::set_max_registrations_per_block(netuid, n); - SubtensorModule::set_target_registrations_per_interval(netuid, n); - SubtensorModule::set_weights_set_rate_limit(netuid, 0); - SubtensorModule::set_min_allowed_weights(netuid, 1); - SubtensorModule::set_max_weight_limit(netuid, u16::MAX); - - // Register validators and servers - for key in 0..n as u64 { - SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), max_stake); - let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( - netuid, - block_number, - key * 1_000_000, - &U256::from(key), - ); - assert_ok!(SubtensorModule::register( - RuntimeOrigin::signed(U256::from(key)), - netuid, - block_number, - nonce, - work, - U256::from(key), - U256::from(key) - )); - SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( - &U256::from(key), - &U256::from(key), - netuid, - stakes[key as usize], - ); - } + add_network(netuid, tempo, 0); + SubtensorModule::set_max_allowed_uids( netuid, n ); + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + SubtensorModule::set_max_registrations_per_block( netuid, n ); + SubtensorModule::set_target_registrations_per_interval(netuid, n); + SubtensorModule::set_weights_set_rate_limit( netuid, 0 ); + SubtensorModule::set_min_allowed_weights( netuid, 1 ); + SubtensorModule::set_max_weight_limit( netuid, u16::MAX ); + SubtensorModule::set_bonds_penalty(netuid, u16::MAX); + + + // === Register [validator1, validator2, validator3, validator4, server1, server2, server3, server4] + for key in 0..n as u64 { + SubtensorModule::add_balance_to_coldkey_account( &U256::from(key), max_stake ); + let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( netuid, block_number, key * 1_000_000, &U256::from(key)); + assert_ok!(SubtensorModule::register(<::RuntimeOrigin>::signed(U256::from(key)), netuid, block_number, nonce, work, U256::from(key), U256::from(key))); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( &U256::from(key), &U256::from(key), netuid, stakes[key as usize] ); + } + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); + + // === Issue validator permits + SubtensorModule::set_max_allowed_validators(netuid, n); + assert_eq!( SubtensorModule::get_max_allowed_validators(netuid), n); + SubtensorModule::epoch( netuid, 1_000_000_000 ); // run first epoch to set allowed validators + next_block_no_epoch(netuid); // run to next block to ensure weights are set on nodes after their registration block - // Initilize with first epoch - SubtensorModule::epoch(netuid, 1_000_000_000); + // === Set weights [val->srv1: 0.1, val->srv2: 0.2, val->srv3: 0.3, val->srv4: 0.4] + for uid in 0..(n/2) as u64 { + assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, ((n/2)..n).collect(), vec![ u16::MAX/4, u16::MAX/2, (u16::MAX/4)*3, u16::MAX], 0)); + } + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* n: 8 + current_block: 1; activity_cutoff: 5000; Last update: [1, 1, 1, 1, 0, 0, 0, 0] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [0, 0, 0, 0, 0, 0, 0, 0] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + W: [[(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0.9999999995, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.099997558, 0.2000012202, 0.2999926745, 0.4000085443] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926752, 0.4000085455] + B: [[], [], [], [], [], [], [], []] + B (outdatedmask): [[], [], [], [], [], [], [], []] + B (mask+norm): [[], [], [], [], [], [], [], []] + ΔB: [[(4, 0.0099997558), (5, 0.020000122), (6, 0.0299992673), (7, 0.0400008543)], [(4, 0.0199995115), (5, 0.040000244), (6, 0.0599985349), (7, 0.0800017088)], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[(4, 0.0999999996), (5, 0.0999999999), (6, 0.0999999994), (7, 0.0999999996)], [(4, 0.1999999995), (5, 0.2), (6, 0.1999999997), (7, 0.1999999997)], [(4, 0.299999999), (5, 0.2999999998), (6, 0.3), (7, 0.3)], [(4, 0.4000000013), (5, 0.4), (6, 0.4000000004), (7, 0.4000000001)], [], [], [], []] + emaB: [[(4, 0.0999999982), (5, 0.0999999985), (6, 0.099999998), (7, 0.099999998)], [(4, 0.199999999), (5, 0.1999999995), (6, 0.1999999986), (7, 0.1999999986)], [(4, 0.2999999996), (5, 0.3000000003), (6, 0.3000000012), (7, 0.3000000012)], [(4, 0.4000000027), (5, 0.4000000013), (6, 0.4000000018), (7, 0.4000000018)], [], [], [], []] + D: [0.0999999978, 0.1999999983, 0.3000000012, 0.4000000022, 0, 0, 0, 0] + nE: [0.0499999989, 0.0999999992, 0.1500000006, 0.2000000011, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + E: [49999998, 99999999, 150000000, 200000001, 49998779, 100000610, 149996337, 200004272] + P: [0.0499999989, 0.0999999992, 0.1500000006, 0.2000000011, 0.049998779, 0.1000006103, 0.1499963375, 0.2000042726] + emaB: [[(4, 0.2499999937), (5, 0.2499999953), (6, 0.2499999937), (7, 0.2499999937)], [(4, 0.4999999942), (5, 0.499999997), (6, 0.4999999942), (7, 0.4999999942)], [(4, 0.7499999937), (5, 0.7499999981), (6, 0.7499999995), (7, 0.7499999995)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][4], 16383); + assert_eq!(bonds[1][4], 32767); + assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[3][4], 65535); + + // === Set self-weight only on val1 + let uid = 0; + assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, vec![uid], vec![u16::MAX], 0)); next_block_no_epoch(netuid); - // Set weights - for uid in 0..(n / 2) { - SubtensorModule::set_validator_permit_for_uid(netuid, uid, true); - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - ((n / 2)..n).collect(), - vec![u16::MAX / 4, u16::MAX / 2, (u16::MAX / 4) * 3, u16::MAX], - 0 - )); - } + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* n: 8 + current_block: 2 + activity_cutoff: 5000 + Last update: [1, 1, 1, 1, 0, 0, 0, 0] + Inactive: [false, false, false, false, false, false, false, false] + Block at registration: [0, 0, 0, 0, 0, 0, 0, 0] + hotkeys: [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + validator_permits: [true, true, true, true, true, true, true, true] + max_allowed_validators: 8 + new_validator_permits: [true, true, true, true, true, true, true, true] + S: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + W: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + W: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 16383), (5, 16383), (6, 16383), (7, 16383)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 16383), (5, 16383), (6, 16383), (7, 16383)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0999963377), (5, 0.0999963377), (6, 0.0999963377), (7, 0.0999963377)], [(4, 0.1999987792), (5, 0.1999987792), (6, 0.1999987792), (7, 0.1999987792)], [(4, 0.3000012205), (5, 0.3000012205), (6, 0.3000012205), (7, 0.3000012205)], [(4, 0.400003662), (5, 0.400003662), (6, 0.400003662), (7, 0.400003662)], [], [], [], []] + ΔB: [[], [(4, 0.0199995115), (5, 0.040000244), (6, 0.0599985349), (7, 0.0800017088)], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[], [(4, 0.2222222215), (5, 0.222222222), (6, 0.2222222218), (7, 0.2222222218)], [(4, 0.3333333323), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.4444444457), (5, 0.4444444443), (6, 0.4444444447), (7, 0.4444444445)], [], [], [], []] + emaB: [[(4, 0.0899967037), (5, 0.0899967037), (6, 0.0899967037), (7, 0.0899967037)], [(4, 0.2022211235), (5, 0.2022211235), (6, 0.2022211235), (7, 0.2022211235)], [(4, 0.3033344317), (5, 0.3033344317), (6, 0.3033344317), (7, 0.3033344317)], [(4, 0.4044477409), (5, 0.4044477406), (6, 0.4044477406), (7, 0.4044477406)], [], [], [], []] + D: [0.0899967032, 0.2022211233, 0.303334432, 0.404447741, 0, 0, 0, 0] + nE: [0.0449983515, 0.1011105615, 0.1516672159, 0.2022238704, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [44998351, 101110561, 151667215, 202223870, 49998779, 100000610, 149996337, 200004272] + P: [0.0449983515, 0.1011105615, 0.1516672159, 0.2022238704, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + emaB: [[(4, 0.2225175085), (5, 0.2225175085), (6, 0.2225175085), (7, 0.2225175085)], [(4, 0.499993208), (5, 0.4999932083), (6, 0.4999932083), (7, 0.4999932083)], [(4, 0.7499966028), (5, 0.7499966032), (6, 0.7499966032), (7, 0.7499966032)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][4], 14582); + assert_eq!(bonds[1][4], 32767); + assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[3][4], 65535); + + // === Set self-weight only on val2 + let uid = 1; + assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, vec![uid], vec![u16::MAX], 0)); + next_block_no_epoch(netuid); - // Enable Liquid Alpha - SubtensorModule::set_liquid_alpha_enabled(netuid, true); - // Run epoch with Liquid Alpha - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* current_block: 3 + W: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + C: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] + W: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] + T: [0, 0, 0, 0, 1, 1, 1, 1] + I (=R): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] + B: [[(4, 14582), (5, 14582), (6, 14582), (7, 14582)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 14582), (5, 14582), (6, 14582), (7, 14582)], [(4, 32767), (5, 32767), (6, 32767), (7, 32767)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0899929027), (5, 0.0899929027), (6, 0.0899929027), (7, 0.0899929027)], [(4, 0.2022217421), (5, 0.2022217421), (6, 0.2022217421), (7, 0.2022217421)], [(4, 0.303335699), (5, 0.303335699), (6, 0.303335699), (7, 0.303335699)], [(4, 0.404449656), (5, 0.404449656), (6, 0.404449656), (7, 0.404449656)], [], [], [], []] + ΔB: [[], [], [(4, 0.0299992673), (5, 0.060000366), (6, 0.0899978024), (7, 0.1200025633)], [(4, 0.0399990233), (5, 0.080000488), (6, 0.11999707), (7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[], [], [(4, 0.428571427), (5, 0.4285714284), (6, 0.4285714284), (7, 0.4285714284)], [(4, 0.5714285728), (5, 0.5714285714), (6, 0.5714285714), (7, 0.5714285714)], [], [], [], []] + emaB: [[(4, 0.0809936123), (5, 0.0809936123), (6, 0.0809936123), (7, 0.0809936123)], [(4, 0.181999568), (5, 0.181999568), (6, 0.181999568), (7, 0.181999568)], [(4, 0.3158592717), (5, 0.315859272), (6, 0.315859272), (7, 0.315859272)], [(4, 0.4211475477), (5, 0.4211475474), (6, 0.4211475474), (7, 0.4211475474)], [], [], [], []] + D: [0.0809936118, 0.1819995677, 0.3158592721, 0.421147548, 0, 0, 0, 0] + nE: [0.040496806, 0.0909997837, 0.157929636, 0.2105737738, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + E: [40496805, 90999783, 157929636, 210573773, 49998779, 100000610, 149996337, 200004272] + P: [0.040496806, 0.0909997837, 0.157929636, 0.2105737738, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] + emaB: [[(4, 0.192316476), (5, 0.192316476), (6, 0.192316476), (7, 0.192316476)], [(4, 0.4321515555), (5, 0.4321515558), (6, 0.4321515558), (7, 0.4321515558)], [(4, 0.7499967015), (5, 0.7499967027), (6, 0.7499967027), (7, 0.7499967027)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][4], 12603); + assert_eq!(bonds[1][4], 28321); + assert_eq!(bonds[2][4], 49151); + assert_eq!(bonds[3][4], 65535); + + // === Set self-weight only on val3 + let uid = 2; + assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(uid)), netuid, vec![uid], vec![u16::MAX], 0)); + next_block_no_epoch(netuid); - // Check bonds and emissions - let bonds = SubtensorModule::get_bonds(netuid); + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* current_block: 4 + W: [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(2, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.1600034179] + C: [0, 0, 0, 0, 0, 0, 0, 0] + W: [[], [], [], [], [], [], [], []] + Tv: [0, 0, 0, 0, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0] + T: [0, 0, 0, 0, 0, 0, 0, 0] + I (=R): [0, 0, 0, 0, 0, 0, 0, 0] + B: [[(4, 12603), (5, 12603), (6, 12603), (7, 12603)], [(4, 28321), (5, 28321), (6, 28321), (7, 28321)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 12603), (5, 12603), (6, 12603), (7, 12603)], [(4, 28321), (5, 28321), (6, 28321), (7, 28321)], [(4, 49151), (5, 49151), (6, 49151), (7, 49151)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0809909387), (5, 0.0809909387), (6, 0.0809909387), (7, 0.0809909387)], [(4, 0.1819998713), (5, 0.1819998713), (6, 0.1819998713), (7, 0.1819998713)], [(4, 0.3158601632), (5, 0.3158601632), (6, 0.3158601632), (7, 0.3158601632)], [(4, 0.4211490264), (5, 0.4211490264), (6, 0.4211490264), (7, 0.4211490264)], [], [], [], []] + ΔB: [[], [], [], [], [], [], [], []] + ΔB (norm): [[], [], [], [], [], [], [], []] + emaB: [[(4, 0.0809909385), (5, 0.0809909385), (6, 0.0809909385), (7, 0.0809909385)], [(4, 0.1819998713), (5, 0.1819998713), (6, 0.1819998713), (7, 0.1819998713)], [(4, 0.3158601632), (5, 0.3158601632), (6, 0.3158601632), (7, 0.3158601632)], [(4, 0.4211490266), (5, 0.4211490266), (6, 0.4211490266), (7, 0.4211490266)], [], [], [], []] + D: [0, 0, 0, 0, 0, 0, 0, 0] + nE: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + E: [99999999, 199999999, 299999999, 399999999, 0, 0, 0, 0] + P: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] + emaB: [[(4, 0.1923094518), (5, 0.1923094518), (6, 0.1923094518), (7, 0.1923094518)], [(4, 0.4321507583), (5, 0.4321507583), (6, 0.4321507583), (7, 0.4321507583)], [(4, 0.7499961846), (5, 0.7499961846), (6, 0.7499961846), (7, 0.7499961846)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][7], 12602); + assert_eq!(bonds[1][7], 28320); + assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[3][7], 65535); + + // === Set val3->srv4: 1 + assert_ok!(SubtensorModule::set_weights(RuntimeOrigin::signed(U256::from(2)), netuid, vec![7], vec![u16::MAX], 0)); + next_block_no_epoch(netuid); - /* n: 8 - current_block: 3 - activity_cutoff: 5000 - Last update: [2, 2, 2, 2, 1, 1, 1, 1] - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 64 - new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0.9999999995, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.0899978022, 0.1800010982, 0.2699934072, 0.36000769] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [(4, 4596), (5, 9192), (6, 13788), (7, 18385)], [], [], [], []] - Bonds: (mask+norm) [[(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [(4, 0.0701304646), (5, 0.1402609292), (6, 0.2103913939), (7, 0.2805371175)], [], [], [], []] - weights_for_bonds: [[], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - alphas: [[0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7026884612, 0.7053405554, 0.7104771058, 0.7200544013], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993]] - emaB: [[], [(4, 0.0910776372), (5, 0.1821595554), (6, 0.273232912), (7, 0.364327949)], [(4, 0.0910776372), (5, 0.1821595554), (6, 0.273232912), (7, 0.364327949)], [(4, 0.0910776372), (5, 0.1821595554), (6, 0.273232912), (7, 0.364327949)], [], [], [], []] - emaB norm: [[], [(4, 0.3333333333), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.3333333333), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [(4, 0.3333333333), (5, 0.3333333333), (6, 0.3333333333), (7, 0.3333333333)], [], [], [], []] - total_bonds_per_validator: [0, 0.3333333328, 0.3333333328, 0.3333333328, 0, 0, 0, 0] - Dividends: [0, 0.222222222, 0.333333333, 0.4444444447, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0, 0.111111111, 0.1666666665, 0.2222222222, 0, 0, 0, 0] - Validator Emission: [0, 111111111, 166666666, 222222222, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0.111111111, 0.1666666665, 0.2222222222, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [0, 111111111, 166666666, 222222222, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0, 0.111111111, 0.1666666665, 0.2222222222, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - - */ - for (i, target_bond) in [4596, 4596, 4596, 4596].iter().enumerate() { - assert_eq!(bonds[i][4], *target_bond); - } + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* current_block: 5 + W: [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit): [[(0, 65535)], [(1, 65535)], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (permit+diag+outdate): [[], [], [(7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] + W (mask+norm): [[], [], [(7, 1)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] + R (before): [0, 0, 0, 0, 0.0399990233, 0.080000488, 0.11999707, 0.4600034177] + C: [0, 0, 0, 0, 0, 0, 0, 0.400008545] + W: [[], [], [(7, 0.400008545)], [(7, 0.400008545)], [], [], [], []] + Tv: [0, 0, 0.400008545, 0.400008545, 0, 0, 0, 0] + R (after): [0, 0, 0, 0, 0, 0, 0, 0.2800059812] + T: [0, 0, 0, 0, 0, 0, 0, 0.6087041323] + I (=R): [0, 0, 0, 0, 0, 0, 0, 1] + B: [[(4, 12602), (5, 12602), (6, 12602), (7, 12602)], [(4, 28320), (5, 28320), (6, 28320), (7, 28320)], [(4, 49150), (5, 49150), (6, 49150), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 12602), (5, 12602), (6, 12602), (7, 12602)], [(4, 28320), (5, 28320), (6, 28320), (7, 28320)], [(4, 49150), (5, 49150), (6, 49150), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0809860737), (5, 0.0809860737), (6, 0.0809860737), (7, 0.0809860737)], [(4, 0.1819969537), (5, 0.1819969537), (6, 0.1819969537), (7, 0.1819969537)], [(4, 0.3158598263), (5, 0.3158598263), (6, 0.3158598263), (7, 0.3158598263)], [(4, 0.4211571459), (5, 0.4211571459), (6, 0.4211571459), (7, 0.4211571459)], [], [], [], []] + ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[(4, 0.0809860737), (5, 0.0809860737), (6, 0.0809860737), (7, 0.0728874663)], [(4, 0.1819969537), (5, 0.1819969537), (6, 0.1819969537), (7, 0.1637972582)], [(4, 0.3158598263), (5, 0.3158598263), (6, 0.3158598263), (7, 0.3271309866)], [(4, 0.421157146), (5, 0.421157146), (6, 0.421157146), (7, 0.4361842885)], [], [], [], []] + D: [0.0728874663, 0.1637972582, 0.3271309866, 0.4361842885, 0, 0, 0, 0] + nE: [0.0364437331, 0.081898629, 0.1635654932, 0.2180921442, 0, 0, 0, 0.5] + E: [36443733, 81898628, 163565493, 218092144, 0, 0, 0, 500000000] + P: [0.0364437331, 0.081898629, 0.1635654932, 0.2180921442, 0, 0, 0, 0.5] + emaB: [[(4, 0.1922941932), (5, 0.1922941932), (6, 0.1922941932), (7, 0.1671024568)], [(4, 0.4321354993), (5, 0.4321354993), (6, 0.4321354993), (7, 0.3755230587)], [(4, 0.7499809256), (5, 0.7499809256), (6, 0.7499809256), (7, 0.749983425)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][7], 10951); + assert_eq!(bonds[1][7], 24609); + assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[3][7], 65535); - // === Set self-weight only on val1 - let uid = 0; - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![uid], - vec![u16::MAX], - 0 - )); next_block_no_epoch(netuid); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - let bonds = SubtensorModule::get_bonds(netuid); - for (i, target_bond) in [0, 5968, 5968, 5968].iter().enumerate() { - assert_eq!(bonds[i][4], *target_bond); - } + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* current_block: 6 + B: [[(4, 12601), (5, 12601), (6, 12601), (7, 10951)], [(4, 28319), (5, 28319), (6, 28319), (7, 24609)], [(4, 49149), (5, 49149), (6, 49149), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 12601), (5, 12601), (6, 12601), (7, 10951)], [(4, 28319), (5, 28319), (6, 28319), (7, 24609)], [(4, 49149), (5, 49149), (6, 49149), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0809812085), (5, 0.0809812085), (6, 0.0809812085), (7, 0.0728876167)], [(4, 0.181994036), (5, 0.181994036), (6, 0.181994036), (7, 0.163792472)], [(4, 0.3158594894), (5, 0.3158594894), (6, 0.3158594894), (7, 0.3271323503)], [(4, 0.4211652656), (5, 0.4211652656), (6, 0.4211652656), (7, 0.4361875602)], [], [], [], []] + ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[(4, 0.0809812082), (5, 0.0809812082), (6, 0.0809812082), (7, 0.0655988548)], [(4, 0.181994036), (5, 0.181994036), (6, 0.181994036), (7, 0.1474132247)], [(4, 0.3158594896), (5, 0.3158594896), (6, 0.3158594896), (7, 0.3372762585)], [(4, 0.4211652658), (5, 0.4211652658), (6, 0.4211652658), (7, 0.4497116616)], [], [], [], []] + D: [0.0655988548, 0.1474132247, 0.3372762585, 0.4497116616, 0, 0, 0, 0] + nE: [0.0327994274, 0.0737066122, 0.1686381293, 0.2248558307, 0, 0, 0, 0.5] + E: [32799427, 73706612, 168638129, 224855830, 0, 0, 0, 500000000] + P: [0.0327994274, 0.0737066122, 0.1686381293, 0.2248558307, 0, 0, 0, 0.5] + emaB: [[(4, 0.1922789337), (5, 0.1922789337), (6, 0.1922789337), (7, 0.1458686984)], [(4, 0.4321202405), (5, 0.4321202405), (6, 0.4321202405), (7, 0.3277949789)], [(4, 0.749965667), (5, 0.749965667), (6, 0.749965667), (7, 0.74998335)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][7], 9559); + assert_eq!(bonds[1][7], 21482); + assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[3][7], 65535); - // === Set self-weight only on val2 - let uid = 1; - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![uid], - vec![u16::MAX], - 0 - )); next_block_no_epoch(netuid); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - let bonds = SubtensorModule::get_bonds(netuid); - /* n: 8 - current_block: 4 - activity_cutoff: 5000 - Last update: [2, 3, 2, 2, 1, 1, 1, 1] - Block at registration: [1, 1, 1, 1, 1, 1, 1, 1] - validator_permits: [true, true, true, true, true, true, true, true] - max_allowed_validators: 64 - new_validator_permits: [true, true, true, true, true, true, true, true] - Active Stake: [0.0999999999, 0.2, 0.2999999998, 0.4, 0, 0, 0, 0] - Weights: [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit): [[(0, 65535)], [(1, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (permit+diag+outdate): [[], [], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [(4, 16383), (5, 32767), (6, 49149), (7, 65535)], [], [], [], []] - Weights (mask+norm): [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Ranks (before): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Consensus: [0, 0, 0, 0, 0.0999975584, 0.2000012207, 0.2999926754, 0.400008545] - Clipped Weights: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - Validator Trust: [0, 0, 0.9999999995, 0.9999999995, 0, 0, 0, 0] - Ranks (after): [0, 0, 0, 0, 0.0699982906, 0.1400008542, 0.2099948723, 0.2800059812] - Trust: [0, 0, 0, 0, 1, 1, 1, 1] - Incentive (=Rank): [0, 0, 0, 0, 0.0999975582, 0.2000012207, 0.2999926754, 0.4000085455] - Bonds: [[], [(4, 5968), (5, 11937), (6, 17906), (7, 23876)], [(4, 5968), (5, 11937), (6, 17906), (7, 23876)], [(4, 5968), (5, 11937), (6, 17906), (7, 23876)], [], [], [], []] - Bonds: (mask+norm) [[], [(4, 0.0910658427), (5, 0.1821469443), (6, 0.273228046), (7, 0.3643244067)], [(4, 0.0910658427), (5, 0.1821469443), (6, 0.273228046), (7, 0.3643244067)], [(4, 0.0910658427), (5, 0.1821469443), (6, 0.273228046), (7, 0.3643244067)], [], [], [], []] - weights_for_bonds: [[], [], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [(4, 0.0999975584), (5, 0.2000012207), (6, 0.2999926754), (7, 0.400008545)], [], [], [], []] - alphas: [[0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7033024912, 0.7080039687, 0.718774016, 0.74096124], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993], [0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993, 0.7013461993]] - emaB: [[], [], [(4, 0.0973300673), (5, 0.1946689729), (6, 0.291999317), (7, 0.3893513412)], [(4, 0.0973300673), (5, 0.1946689729), (6, 0.291999317), (7, 0.3893513412)], [], [], [], []] - emaB norm: [[], [], [(4, 0.5), (5, 0.5), (6, 0.5), (7, 0.5)], [(4, 0.5), (5, 0.5), (6, 0.5), (7, 0.5)], [], [], [], []] - total_bonds_per_validator: [0, 0, 0.4999999998, 0.4999999998, 0, 0, 0, 0] - Dividends: [0, 0, 0.4285714282, 0.5714285716, 0, 0, 0, 0] - Normalized Server Emission: [0, 0, 0, 0, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Server Emission: [0, 0, 0, 0, 49998779, 100000610, 149996337, 200004272] - Normalized Validator Emission: [0, 0, 0.214285714, 0.2857142857, 0, 0, 0, 0] - Validator Emission: [0, 0, 214285714, 285714285, 0, 0, 0, 0] - Normalized Combined Emission: [0, 0, 0.214285714, 0.2857142857, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726] - Combined Emission: [0, 0, 214285714, 285714285, 49998779, 100000610, 149996337, 200004272] - Pruning Scores: [0, 0, 0.214285714, 0.2857142857, 0.049998779, 0.1000006103, 0.1499963377, 0.2000042726]/ - */ - - for (i, target_bond) in [0, 0, 6378, 6378].iter().enumerate() { - assert_eq!(bonds[i][4], *target_bond); - } - }); + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* current_block: 7 + B: [[(4, 12600), (5, 12600), (6, 12600), (7, 9559)], [(4, 28318), (5, 28318), (6, 28318), (7, 21482)], [(4, 49148), (5, 49148), (6, 49148), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 12600), (5, 12600), (6, 12600), (7, 9559)], [(4, 28318), (5, 28318), (6, 28318), (7, 21482)], [(4, 49148), (5, 49148), (6, 49148), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0809763432), (5, 0.0809763432), (6, 0.0809763432), (7, 0.065595707)], [(4, 0.1819911182), (5, 0.1819911182), (6, 0.1819911182), (7, 0.1474136391)], [(4, 0.3158591525), (5, 0.3158591525), (6, 0.3158591525), (7, 0.337276807)], [(4, 0.4211733856), (5, 0.4211733856), (6, 0.4211733856), (7, 0.4497138464)], [], [], [], []] + ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[(4, 0.080976343), (5, 0.080976343), (6, 0.080976343), (7, 0.0590361361)], [(4, 0.181991118), (5, 0.181991118), (6, 0.181991118), (7, 0.1326722752)], [(4, 0.3158591525), (5, 0.3158591525), (6, 0.3158591525), (7, 0.3464062694)], [(4, 0.4211733858), (5, 0.4211733858), (6, 0.4211733858), (7, 0.4618853189)], [], [], [], []] + D: [0.0590361361, 0.1326722752, 0.3464062694, 0.4618853189, 0, 0, 0, 0] + nE: [0.029518068, 0.0663361375, 0.1732031347, 0.2309426593, 0, 0, 0, 0.5] + E: [29518068, 66336137, 173203134, 230942659, 0, 0, 0, 500000000] + P: [0.029518068, 0.0663361375, 0.1732031347, 0.2309426593, 0, 0, 0, 0.5] + emaB: [[(4, 0.192263675), (5, 0.192263675), (6, 0.192263675), (7, 0.1278155716)], [(4, 0.4321049813), (5, 0.4321049813), (6, 0.4321049813), (7, 0.2872407278)], [(4, 0.7499504078), (5, 0.7499504078), (6, 0.7499504078), (7, 0.7499832863)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + let bonds = SubtensorModule::get_bonds( netuid ); + assert_eq!(bonds[0][7], 8376); + assert_eq!(bonds[1][7], 18824); + assert_eq!(bonds[2][7], 49150); + assert_eq!(bonds[3][7], 65535); + + next_block_no_epoch(netuid); + + if sparse { SubtensorModule::epoch( netuid, 1_000_000_000 ); } + else { SubtensorModule::epoch_dense( netuid, 1_000_000_000 ); } + /* current_block: 8 + B: [[(4, 12599), (5, 12599), (6, 12599), (7, 8376)], [(4, 28317), (5, 28317), (6, 28317), (7, 18824)], [(4, 49147), (5, 49147), (6, 49147), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (outdatedmask): [[(4, 12599), (5, 12599), (6, 12599), (7, 8376)], [(4, 28317), (5, 28317), (6, 28317), (7, 18824)], [(4, 49147), (5, 49147), (6, 49147), (7, 49150)], [(4, 65535), (5, 65535), (6, 65535), (7, 65535)], [], [], [], []] + B (mask+norm): [[(4, 0.0809714776), (5, 0.0809714776), (6, 0.0809714776), (7, 0.0590337245)], [(4, 0.1819882002), (5, 0.1819882002), (6, 0.1819882002), (7, 0.1326708249)], [(4, 0.3158588156), (5, 0.3158588156), (6, 0.3158588156), (7, 0.3464073015)], [(4, 0.421181506), (5, 0.421181506), (6, 0.421181506), (7, 0.4618881487)], [], [], [], []] + ΔB: [[], [], [(7, 0.1200025633)], [(7, 0.1600034179)], [], [], [], []] + ΔB (norm): [[], [], [(7, 0.4285714284)], [(7, 0.5714285714)], [], [], [], []] + emaB: [[(4, 0.0809714776), (5, 0.0809714776), (6, 0.0809714776), (7, 0.053130352)], [(4, 0.1819882002), (5, 0.1819882002), (6, 0.1819882002), (7, 0.1194037423)], [(4, 0.3158588156), (5, 0.3158588156), (6, 0.3158588156), (7, 0.3546237142)], [(4, 0.4211815062), (5, 0.4211815062), (6, 0.4211815062), (7, 0.472842191)], [], [], [], []] + D: [0.053130352, 0.1194037423, 0.3546237142, 0.472842191, 0, 0, 0, 0] + nE: [0.026565176, 0.0597018711, 0.177311857, 0.2364210954, 0, 0, 0, 0.5] + E: [26565175, 59701871, 177311856, 236421095, 0, 0, 0, 500000000] + P: [0.026565176, 0.0597018711, 0.177311857, 0.2364210954, 0, 0, 0, 0.5] + emaB: [[(4, 0.1922484161), (5, 0.1922484161), (6, 0.1922484161), (7, 0.1123638137)], [(4, 0.4320897225), (5, 0.4320897225), (6, 0.4320897225), (7, 0.2525234516)], [(4, 0.7499351487), (5, 0.7499351487), (6, 0.7499351487), (7, 0.7499832308)], [(4, 1), (5, 1), (6, 1), (7, 1)], [], [], [], []] */ + }); } -// #[test] fn test_set_alpha_disabled() { new_test_ext(1).execute_with(|| { @@ -1702,7 +1414,7 @@ fn test_active_stake() { assert_eq!(*i, 0); } for i in bond.iter().take(n as usize).skip((n / 2) as usize) { - assert_eq!(*i, I32F32::from_num(3276)); // floor(0.5*(2^16-1))/(2^16-1), then max-upscale to 65_535 + assert_eq!(*i, I32F32::from_num(65_535)); // floor(0.5*(2^16-1))/(2^16-1), then max-upscale to 65_535 } } let activity_cutoff: u64 = SubtensorModule::get_activity_cutoff(netuid) as u64; @@ -1721,53 +1433,50 @@ fn test_active_stake() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* - current_block: 5002 - activity_cutoff: 5000 - Last update: [5002, 1, 0, 0] - Block at registration: [0, 0, 0, 0] - validator_permits: [true, true, true, true] - max_allowed_validators: 4 - new_validator_permits: [true, true, true, true] - Active Stake: [1, 0, 0, 0] - Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Ranks (before): [0, 0, 0.5, 0.5] - Consensus: [0, 0, 0.5, 0.5] - Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Validator Trust: [1, 1, 0, 0] - Ranks (after): [0, 0, 0.5, 0.5] - Trust: [0, 0, 1, 1] - Incentive (=Rank): [0, 0, 0.5, 0.5] - Bonds: [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] - Bonds: (mask+norm) [[(2, 0.0499885557), (3, 0.0499885557)], [(2, 0.0499885557), (3, 0.0499885557)], [], []] - weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - emaB: [[(2, 0.1449897), (3, 0.1449897)], [(2, 0.0449897), (3, 0.0449897)], [], []] - emaB norm: [[(2, 0.7631864299), (3, 0.7631864299)], [(2, 0.23681357), (3, 0.23681357)], [], []] - total_bonds_per_validator: [0.7631864296, 0.23681357, 0, 0] - Dividends: [1, 0, 0, 0] - Normalized Server Emission: [0, 0, 0.25, 0.25] - Server Emission: [0, 0, 250000000, 250000000] - Normalized Validator Emission: [0.5, 0, 0, 0] - Validator Emission: [500000000, 0, 0, 0] - Normalized Combined Emission: [0.5, 0, 0.25, 0.25] - Combined Emission: [500000000, 0, 250000000, 250000000] - Pruning Scores: [0.5, 0, 0.25, 0.25] - */ + /* current_block: 5002; activity_cutoff: 5000 + Last update: [5002, 1, 0, 0]; Inactive: [false, true, true, true]; Block at registration: [0, 0, 0, 0] + S: [0.25, 0.25, 0.25, 0.25]; S (mask): [0.25, 0, 0, 0]; S (mask+norm): [1, 0, 0, 0] + validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] + W: [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (permit): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (permit+diag): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (permit+diag+outdate): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + R: [0, 0, 0.5, 0.5] + W (threshold): [[(2, 1), (3, 1)], [(2, 1), (3, 1)], [], []] + T: [0, 0, 1, 1] + C: [0.006693358, 0.006693358, 0.9933076561, 0.9933076561] + I: [0, 0, 0.5, 0.5] + B: [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + B (outdatedmask): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + B (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + ΔB: [[(2, 0.5), (3, 0.5)], [(2, 0), (3, 0)], [], []] + ΔB (norm): [[(2, 1), (3, 1)], [(2, 0), (3, 0)], [], []] + emaB: [[(2, 0.55), (3, 0.55)], [(2, 0.45), (3, 0.45)], [], []] + emaB (max-upscale): [[(2, 1), (3, 1)], [(2, 1), (3, 1)], [], []] + D: [0.55, 0.4499999997, 0, 0] + nE: [0.275, 0.2249999999, 0.25, 0.25] + E: [274999999, 224999999, 250000000, 250000000] + P: [0.275, 0.2249999999, 0.25, 0.25] + P (u16): [65535, 53619, 59577, 59577] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 65535); - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 500000000); + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 36044); // Note D = floor((0.5 * 0.9 + 0.1) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 274999999); // Note E = 0.5 * 0.55 * 1_000_000_000 = 275_000_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[0][server], I32F32::from_num(9501)); + assert_eq!(bonds[0][server], I32F32::from_num(65_535)); // floor(0.55*(2^16-1))/(2^16-1), then max-upscale } for validator in 1..(n / 2) { - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, validator), 0); - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, validator), 0); + assert_eq!( + SubtensorModule::get_dividends_for_uid(netuid, validator), + 29490 + ); // Note D = floor((0.5 * 0.9) * 65_535) + assert_eq!( + SubtensorModule::get_emission_for_uid(netuid, validator), + 224999999 + ); // Note E = 0.5 * 0.45 * 1_000_000_000 = 225_000_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[validator as usize][server], I32F32::from_num(2948)); + assert_eq!(bonds[validator as usize][server], I32F32::from_num(53619)); + // floor(0.45*(2^16-1))/(2^16-1), then max-upscale } } @@ -1785,52 +1494,42 @@ fn test_active_stake() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* - current_block: 5003 - activity_cutoff: 5000 - Last update: [5002, 5002, 0, 0] - Block at registration: [0, 0, 0, 0] - validator_permits: [true, true, true, true] - max_allowed_validators: 4 - new_validator_permits: [true, true, true, true] - Active Stake: [0.5, 0.5, 0, 0] - Weights: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (permit+diag+outdate): [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] - Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Ranks (before): [0, 0, 0.5, 0.5] - Consensus: [0, 0, 0.5, 0.5] - Clipped Weights: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - Validator Trust: [1, 1, 0, 0] - Ranks (after): [0, 0, 0.5, 0.5] - Trust: [0, 0, 1, 1] - Incentive (=Rank): [0, 0, 0.5, 0.5] - Bonds: [[(2, 9501), (3, 9501)], [(2, 2948), (3, 2948)], [], []] - Bonds: (mask+norm) [[(2, 0.144975967), (3, 0.144975967)], [(2, 0.0449835965), (3, 0.0449835965)], [], []] - weights_for_bonds: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - emaB: [[(2, 0.1804783703), (3, 0.1804783703)], [(2, 0.0904852368), (3, 0.0904852368)], [], []] - emaB norm: [[(2, 0.666061292), (3, 0.666061292)], [(2, 0.3339387078), (3, 0.3339387078)], [], []] - total_bonds_per_validator: [0.666061292, 0.3339387076, 0, 0] - Dividends: [0.6660612922, 0.3339387076, 0, 0] - Normalized Server Emission: [0, 0, 0.25, 0.25] - Server Emission: [0, 0, 250000000, 250000000] - Normalized Validator Emission: [0.333030646, 0.1669693538, 0, 0] - Validator Emission: [333030645, 166969353, 0, 0] - Normalized Combined Emission: [0.333030646, 0.1669693538, 0.25, 0.25] - Combined Emission: [333030645, 166969353, 250000000, 250000000] - Pruning Scores: [0.333030646, 0.1669693538, 0.25, 0.25] - */ + /* current_block: 5003; activity_cutoff: 5000 + Last update: [5002, 5002, 0, 0]; Inactive: [false, false, true, true]; Block at registration: [0, 0, 0, 0] + S: [0.25, 0.25, 0.25, 0.25]; S (mask): [0.25, 0.25, 0, 0]; S (mask+norm): [0.5, 0.5, 0, 0] + validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] + W: [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (permit): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (permit+diag): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (permit+diag+outdate): [[(2, 0.4999923704), (3, 0.4999923704)], [(2, 0.4999923704), (3, 0.4999923704)], [], []] + W (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + R: [0, 0, 0.5, 0.5] + W (threshold): [[(2, 1), (3, 1)], [(2, 1), (3, 1)], [], []] + T: [0, 0, 1, 1] + C: [0.006693358, 0.006693358, 0.9933076561, 0.9933076561] + I: [0, 0, 0.5, 0.5] + B: [[(2, 65535), (3, 65535)], [(2, 53619), (3, 53619)], [], []] + B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 53619), (3, 53619)], [], []] + B (mask+norm): [[(2, 0.5500025176), (3, 0.5500025176)], [(2, 0.4499974821), (3, 0.4499974821)], [], []] + ΔB: [[(2, 0.25), (3, 0.25)], [(2, 0.25), (3, 0.25)], [], []] + ΔB (norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + emaB: [[(2, 0.545002266), (3, 0.545002266)], [(2, 0.4549977337), (3, 0.4549977337)], [], []] + emaB (max-upscale): [[(2, 1), (3, 1)], [(2, 0.8348547556), (3, 0.8348547556)], [], []] + D: [0.545002266, 0.4549977337, 0, 0] + nE: [0.272501133, 0.2274988669, 0.25, 0.25] + E: [272501132, 227498866, 250000000, 250000000] + P: [0.272501133, 0.2274988669, 0.25, 0.25] + P (u16): [65535, 54711, 60123, 60123] */ let bonds = SubtensorModule::get_bonds(netuid); - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 43650); - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 333030645); + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 35716); // Note D = floor((0.55 * 0.9 + 0.5 * 0.1) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 272501132); // Note E = 0.5 * (0.55 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 272_500_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[0][server], I32F32::from_num(11827)); + assert_eq!(bonds[0][server], I32F32::from_num(65_535)); // floor((0.55 * 0.9 + 0.5 * 0.1)*(2^16-1))/(2^16-1), then max-upscale } - assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 21884); - assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 166969353); + assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 1), 29818); // Note D = floor((0.45 * 0.9 + 0.5 * 0.1) * 65_535) + assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 1), 227498866); // Note E = 0.5 * (0.45 * 0.9 + 0.5 * 0.1) * 1_000_000_000 = 227_500_000 (discrepancy) for server in ((n / 2) as usize)..n as usize { - assert_eq!(bonds[1][server], I32F32::from_num(5929)); + assert_eq!(bonds[1][server], I32F32::from_num(54712)); // floor((0.45 * 0.9 + 0.5 * 0.1)/(0.55 * 0.9 + 0.5 * 0.1)*(2^16-1)) } }); } @@ -1915,43 +1614,33 @@ fn test_outdated_weights() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* - Number of Neurons in Network: 4 - current_block: 2 - activity_cutoff: 5000 - Last update: [2, 2, 2, 2] - Block at registration: [1, 1, 1, 1] - validator_permits: [true, true, true, true] - max_allowed_validators: 4 - new_validator_permits: [true, true, true, true] - Active Stake: [0.25, 0.25, 0.25, 0.25] - Weights: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - Weights (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - Weights (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] - Weights (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] - Weights (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] - Ranks (before): [0, 0, 0.3333316376, 0.166668362] - Consensus: [0, 0, 0.6666632756, 0.3333367242] - Clipped Weights: [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] - Validator Trust: [0.9999999998, 0.9999999998, 0, 0] - Ranks (after): [0, 0, 0.3333316376, 0.166668362] - Trust: [0, 0, 1, 1] - Incentive (=Rank): [0, 0, 0.6666632756, 0.3333367242] - Bonds: [[], [], [], []] - Bonds: (mask+norm) [[], [], [], []] - weights_for_bonds: [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] - emaB: [[(2, 0.05), (3, 0.05)], [(2, 0.05), (3, 0.05)], [], []] - emaB norm: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] - total_bonds_per_validator: [0.4999999998, 0.4999999998, 0, 0] - Dividends: [0.5, 0.5, 0, 0] - Normalized Server Emission: [0, 0, 0.3333316378, 0.166668362] - Server Emission: [0, 0, 333331637, 166668361] - Normalized Validator Emission: [0.25, 0.25, 0, 0] - Validator Emission: [250000000, 250000000, 0, 0] - Normalized Combined Emission: [0.25, 0.25, 0.3333316378, 0.166668362] - Combined Emission: [250000000, 250000000, 333331637, 166668361] - Pruning Scores: [0.25, 0.25, 0.3333316378, 0.166668362] - */ + /* current_block: 1; activity_cutoff: 5000 + Last update: [1, 1, 1, 1]; Inactive: [false, false, false, false]; Block at registration: [0, 0, 0, 0] + S: [0.25, 0.25, 0.25, 0.25]; S (mask): [0.25, 0.25, 0.25, 0.25]; S (mask+norm): [0.25, 0.25, 0.25, 0.25] + validator_permits: [true, true, true, true]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] + W: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + W (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + W (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] + W (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] + W (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] + R (before): [0, 0, 0.3333316376, 0.166668362] + C: [0, 0, 0.6666632756, 0.3333367242] + W: [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 0.6666632756), (3, 0.3333367242)], [], []] + Tv: [0.9999999998, 0.9999999998, 0, 0] + R (after): [0, 0, 0.3333316376, 0.166668362] + T: [0, 0, 1, 1] + I (=R): [0, 0, 0.6666632756, 0.3333367242] + B: [[], [], [], []] + B (outdatedmask): [[], [], [], []] + B (mask+norm): [[], [], [], []] + ΔB: [[(2, 0.1666658188), (3, 0.083334181)], [(2, 0.1666658188), (3, 0.083334181)], [], []] + ΔB (norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + emaB: [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []] + D: [0.5, 0.5, 0, 0] + nE: [0.25, 0.25, 0.3333316378, 0.166668362] + E: [250000000, 250000000, 333331637, 166668361] + P: [0.25, 0.25, 0.3333316378, 0.166668362] + P (u16): [49151, 49151, 65535, 32767] */ // === Dereg server2 at uid3 (least emission) + register new key over uid3 let new_key: u64 = n as u64; // register a new key while at max capacity, which means the least incentive uid will be deregistered @@ -1994,48 +1683,41 @@ fn test_outdated_weights() { } else { SubtensorModule::epoch_dense(netuid, 1_000_000_000); } - /* - Number of Neurons in Network: 4 - current_block: 3 - activity_cutoff: 5000 - Last update: [3, 2, 2, 2] - Block at registration: [1, 1, 1, 2] - validator_permits: [true, true, true, true] - max_allowed_validators: 4 - new_validator_permits: [true, true, true, true] - Active Stake: [0.3333333333, 0.3333333333, 0.3333333333, 0] - Weights: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - Weights (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] - Weights (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] - Weights (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535)], [], []] - Weights (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 1)], [], []] - Ranks (before): [0, 0, 0.5555544249, 0.1111122412] - Consensus: [0, 0, 0.6666632756, 0] - Clipped Weights: [[(2, 0.6666632756)], [(2, 0.6666632756)], [], []] - Validator Trust: [0.6666632756, 0.6666632756, 0, 0] - Ranks (after): [0, 0, 0.4444421832, 0] - Trust: [0, 0, 0.799997558, 0] - Incentive (=Rank): [0, 0, 1, 0] - Bonds: [[(2, 3276), (3, 3276)], [(2, 3276), (3, 3276)], [], []] - Bonds: (mask+norm) [[(2, 0.0499885557), (3, 0.0499885557)], [(2, 0.0499885557)], [], []] - weights_for_bonds: [[(2, 0.6666632756)], [(2, 0.6666632756)], [], []] - emaB: [[(2, 0.0949897), (3, 0.0449897)], [(2, 0.0949897)], [], []] - emaB norm: [[(2, 0.5), (3, 1)], [(2, 0.5)], [], []] - total_bonds_per_validator: [0.5, 0.5, 0, 0] - Dividends: [0.5, 0.5, 0, 0] - Normalized Server Emission: [0, 0, 0.5, 0] - Server Emission: [0, 0, 500000000, 0] - Normalized Validator Emission: [0.25, 0.25, 0, 0] - Validator Emission: [250000000, 250000000, 0, 0] - Normalized Combined Emission: [0.25, 0.25, 0.5, 0] - Combined Emission: [250000000, 250000000, 500000000, 0] - Pruning Scores: [0.25, 0.25, 0.5, 0] - */ + /* current_block: 2; activity_cutoff: 5000 + Last update: [2, 1, 1, 1]; Inactive: [false, false, false, false]; Block at registration: [0, 0, 0, 1] + S: [0.3333333333, 0.3333333333, 0.3333333333, 0] + S (mask): [0.3333333333, 0.3333333333, 0.3333333333, 0] + S (mask+norm): [0.3333333333, 0.3333333333, 0.3333333333, 0] + validator_permits: [true, true, true, false]; max_allowed_validators: 4; new_validator_permits: [true, true, true, true] + W: [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + W (permit): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [(2, 65535)], [(3, 65535)]] + W (permit+diag): [[(2, 65535), (3, 32768)], [(2, 65535), (3, 32768)], [], []] + W (permit+diag+outdate): [[(2, 65535), (3, 32768)], [(2, 65535)], [], []] + W (mask+norm): [[(2, 0.6666632756), (3, 0.3333367242)], [(2, 1)], [], []] + R (before): [0, 0, 0.5555544249, 0.1111122412] + C: [0, 0, 0.6666632756, 0] + W: [[(2, 0.6666632756)], [(2, 0.6666632756)], [], []] + Tv: [0.6666632756, 0.6666632756, 0, 0] + R (after): [0, 0, 0.4444421832, 0] + T: [0, 0, 0.799997558, 0] + I (=R): [0, 0, 1, 0] + B: [[(2, 65535), (3, 65535)], [(2, 65535), (3, 65535)], [], []] + B (outdatedmask): [[(2, 65535), (3, 65535)], [(2, 65535)], [], []] + B (mask+norm): [[(2, 0.5), (3, 1)], [(2, 0.5)], [], []] + ΔB: [[(2, 0.2222210916)], [(2, 0.2222210916)], [], []] + ΔB (norm): [[(2, 0.5)], [(2, 0.5)], [], []] + emaB: [[(2, 0.5), (3, 1)], [(2, 0.5)], [], []] + emaB (max-upscale): [[(2, 1), (3, 1)], [(2, 1)], [], []] + D: [0.5, 0.5, 0, 0] + nE: [0.25, 0.25, 0.5, 0] + E: [250000000, 250000000, 500000000, 0] + P: [0.25, 0.25, 0.5, 0] + P (u16): [32767, 32767, 65535, 0] */ let bonds = SubtensorModule::get_bonds(netuid); assert_eq!(SubtensorModule::get_dividends_for_uid(netuid, 0), 32767); // Note D = floor(0.5 * 65_535) assert_eq!(SubtensorModule::get_emission_for_uid(netuid, 0), 250000000); // Note E = 0.5 * 0.5 * 1_000_000_000 = 249311245 - assert_eq!(bonds[0][2], I32F32::from_num(6225)); - assert_eq!(bonds[0][3], I32F32::from_num(2948)); + assert_eq!(bonds[0][2], I32F32::from_num(65_535)); // floor(0.5*(2^16-1))/(2^16-1), then max-upscale + assert_eq!(bonds[0][3], I32F32::from_num(65_535)); // only uid0 has updated weights for new reg }); } @@ -2993,6 +2675,9 @@ fn setup_yuma_3_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak SubtensorModule::set_liquid_alpha_enabled(netuid, true); SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.1), I32F32::from_num(0.3)); + // Enable Yuma3 + SubtensorModule::set_yuma3_enabled(netuid, true); + // === Issue validator permits SubtensorModule::set_max_allowed_validators(netuid, 3); From f511bbbbcac70f0b7e447f91f1f0241831d71a19 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 9 Apr 2025 18:16:51 +0100 Subject: [PATCH 045/226] fix liquid_alpha disabled --- pallets/subtensor/src/epoch/run_epoch.rs | 36 ++-------- pallets/subtensor/src/tests/epoch.rs | 90 ++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 32 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index a8885047b9..667ffc17f9 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -206,13 +206,7 @@ impl Pallet { log::trace!("B: {:?}", &bonds); // Compute the Exponential Moving Average (EMA) of bonds. - ema_bonds = Self::compute_bonds( - netuid, - &weights_for_bonds, - &bonds, - &consensus, - &active_stake, - ); + ema_bonds = Self::compute_bonds(netuid, &weights_for_bonds, &bonds, &consensus); log::trace!("emaB: {:?}", &ema_bonds); // Normalize EMA bonds. @@ -623,13 +617,7 @@ impl Pallet { // Compute the Exponential Moving Average (EMA) of bonds. log::trace!("weights_for_bonds: {:?}", &weights_for_bonds); - ema_bonds = Self::compute_bonds_sparse( - netuid, - &weights_for_bonds, - &bonds, - &consensus, - &active_stake, - ); + ema_bonds = Self::compute_bonds_sparse(netuid, &weights_for_bonds, &bonds, &consensus); log::trace!("emaB: {:?}", &ema_bonds); // Normalize EMA bonds. @@ -1066,7 +1054,6 @@ impl Pallet { weights: &[Vec], // weights_for_bonds bonds: &[Vec], consensus: &[I32F32], - active_stake: &[I32F32], ) -> Vec> { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) @@ -1086,13 +1073,8 @@ impl Pallet { // Liquid Alpha is disabled, compute the liquid alpha value. let alpha: I32F32 = Self::compute_disabled_liquid_alpha(netuid); - // Compute bonds delta column normalized. - let mut bonds_delta: Vec> = row_hadamard(weights, active_stake); // ΔB = W◦S - inplace_col_normalize(&mut bonds_delta); // sum_i b_ij = 1 - log::trace!("ΔB: {:?}", &bonds_delta); - // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - mat_ema(&bonds_delta, bonds, alpha) + mat_ema(weights, bonds, alpha) } } @@ -1112,7 +1094,6 @@ impl Pallet { weights: &[Vec<(u16, I32F32)>], bonds: &[Vec<(u16, I32F32)>], consensus: &[I32F32], - active_stake: &[I32F32], ) -> Vec> { // Check if Liquid Alpha is enabled, consensus is not empty, and contains non-zero values. if LiquidAlphaOn::::get(netuid) @@ -1129,19 +1110,11 @@ impl Pallet { // Compute the Exponential Moving Average (EMA) of bonds using the provided clamped alpha values. mat_ema_alpha_sparse(weights, bonds, &alphas) } else { - let n: u16 = Self::get_subnetwork_n(netuid); - // Liquid Alpha is disabled, compute the liquid alpha value. let alpha: I32F32 = Self::compute_disabled_liquid_alpha(netuid); - // Compute bonds delta column normalized. - let mut bonds_delta: Vec> = - row_hadamard_sparse(weights, active_stake); // ΔB = W◦S - inplace_col_normalize_sparse(&mut bonds_delta, n); // sum_i b_ij = 1 - log::trace!("ΔB: {:?}", &bonds_delta); - // Compute the Exponential Moving Average (EMA) of bonds using the calculated alpha value. - mat_ema_sparse(&bonds_delta, bonds, alpha) + mat_ema_sparse(weights, bonds, alpha) } } @@ -1303,7 +1276,6 @@ impl Pallet { // Alpha is derived by subtracting the scaled bonds moving average from 1. let alpha: I32F32 = I32F32::from_num(1).saturating_sub(I32F32::from_num(bonds_moving_average)); - alpha } diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 9b9e3e8727..24a20fd16a 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2641,6 +2641,7 @@ fn setup_yuma_3_scenario(netuid: u16, n: u16, sparse: bool, max_stake: u64, stak SubtensorModule::set_max_weight_limit(netuid, u16::MAX); SubtensorModule::set_bonds_penalty(netuid, 0); SubtensorModule::set_alpha_sigmoid_steepness(netuid, 10); + SubtensorModule::set_bonds_moving_average(netuid, 975_000); // === Register for key in 0..n as u64 { @@ -3128,6 +3129,95 @@ fn test_yuma_3_one_epoch_switch() { } } +#[test] +fn test_yuma_3_liquid_alpha_disabled() { + for sparse in [true, false].iter() { + new_test_ext(1).execute_with(|| { + let netuid: u16 = 1; + let n: u16 = 5; // 3 validators, 2 servers + let max_stake: u64 = 8; + + // Equal stake validators + let stakes: Vec = vec![33, 33, 34, 0, 0]; + + setup_yuma_3_scenario(netuid, n, *sparse, max_stake, stakes); + + // disable liquid alpha + SubtensorModule::set_liquid_alpha_enabled(netuid, false); + + let targets_bonds = [ + vec![ + vec![0.0000, 0.0250, 0.0000], + vec![0.0000, 0.0250, 0.0000], + vec![0.0000, 0.0250, 0.0000], + ], + vec![ + vec![0.0000, 0.0494, 0.0000], + vec![0.0000, 0.0494, 0.0000], + vec![0.0000, 0.0494, 0.0000], + ], + vec![ + vec![0.0000, 0.0731, 0.0000], + vec![0.0000, 0.0731, 0.0000], + vec![0.0000, 0.0481, 0.0250], + ], + vec![ + vec![0.0000, 0.0963, 0.0000], + vec![0.0000, 0.0963, 0.0000], + vec![0.0000, 0.0719, 0.0244], + ], + vec![ + vec![0.0000, 0.1189, 0.0000], + vec![0.0000, 0.1189, 0.0000], + vec![0.0000, 0.0951, 0.0238], + ], + vec![ + vec![0.0000, 0.1409, 0.0000], + vec![0.0000, 0.1409, 0.0000], + vec![0.0000, 0.1178, 0.0232], + ], + ]; + let targets_dividends = [ + vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], + vec![0.3300, 0.3300, 0.3400, 0.0000, 0.0000], + vec![0.3734, 0.3734, 0.2532, 0.0000, 0.0000], + vec![0.3611, 0.3611, 0.2779, 0.0000, 0.0000], + vec![0.3541, 0.3541, 0.2919, 0.0000, 0.0000], + vec![0.3495, 0.3495, 0.3009, 0.0000, 0.0000], + ]; + + for (epoch, (target_bonds, target_dividends)) in targets_bonds + .iter() + .zip(targets_dividends.iter()) + .enumerate() + { + match epoch { + 2 => { + // Validator A -> Server 1 + // Validator B -> Server 1 + // Validator C -> Server 2 + set_yuma_3_weights( + netuid, + vec![vec![u16::MAX, 0], vec![u16::MAX, 0], vec![0, u16::MAX]], + vec![3, 4], + ); + } + _ => { + // All validators -> Server 1 + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); + } + }; + run_epoch_and_check_bonds_dividends( + netuid, + *sparse, + target_bonds, + target_dividends, + ); + } + }) + } +} + #[test] fn test_yuma_3_stable_miner() { for sparse in [true, false].iter() { From 2a807b5bc7aa4213a406baf33ca8f70b6997a6db Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 14 Apr 2025 20:50:46 +0900 Subject: [PATCH 046/226] Use sp_std::vec::Vec --- pallets/subtensor/src/utils/evm.rs | 1 + precompiles/src/uid_lookup.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index fe6927ffd1..3b31c86fe7 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -3,6 +3,7 @@ use super::*; use frame_support::ensure; use frame_system::ensure_signed; use sp_core::{H160, ecdsa::Signature, hashing::keccak_256}; +use sp_std::vec::Vec; impl Pallet { /// Associate an EVM key with a hotkey. diff --git a/precompiles/src/uid_lookup.rs b/precompiles/src/uid_lookup.rs index 61ada80e32..b8af073f49 100644 --- a/precompiles/src/uid_lookup.rs +++ b/precompiles/src/uid_lookup.rs @@ -4,6 +4,7 @@ use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; use pallet_evm::PrecompileHandle; use precompile_utils::{prelude::Address, EvmResult}; use sp_runtime::traits::{Dispatchable, StaticLookup}; +use sp_std::vec::Vec; use crate::PrecompileExt; From c9c3f6c401676ff478ed2f176015eaf65e962b67 Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 14 Apr 2025 21:25:34 +0900 Subject: [PATCH 047/226] cargo fmt --- precompiles/src/uid_lookup.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/precompiles/src/uid_lookup.rs b/precompiles/src/uid_lookup.rs index b8af073f49..61fb9d6d7f 100644 --- a/precompiles/src/uid_lookup.rs +++ b/precompiles/src/uid_lookup.rs @@ -2,7 +2,7 @@ use core::marker::PhantomData; use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; use pallet_evm::PrecompileHandle; -use precompile_utils::{prelude::Address, EvmResult}; +use precompile_utils::{EvmResult, prelude::Address}; use sp_runtime::traits::{Dispatchable, StaticLookup}; use sp_std::vec::Vec; @@ -44,6 +44,10 @@ where evm_address: Address, limit: u16, ) -> EvmResult> { - Ok(pallet_subtensor::Pallet::::uid_lookup(netuid, evm_address.0, limit)) + Ok(pallet_subtensor::Pallet::::uid_lookup( + netuid, + evm_address.0, + limit, + )) } } From 2ceeaacc7e493e09b4cdc64d2dbf22b54415bc51 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 16 Apr 2025 23:33:58 +0900 Subject: [PATCH 048/226] Add precompile test for UID lookup --- evm-tests/src/contracts/uidLookup.ts | 45 +++++++++ evm-tests/src/utils.ts | 25 ++++- .../neuron.precompile.reveal-weights.test.ts | 2 +- .../neuron.precompile.set-weights.test.ts | 2 +- evm-tests/test/uid.precompile.lookup.test.ts | 98 +++++++++++++++++++ 5 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 evm-tests/src/contracts/uidLookup.ts create mode 100644 evm-tests/test/uid.precompile.lookup.test.ts diff --git a/evm-tests/src/contracts/uidLookup.ts b/evm-tests/src/contracts/uidLookup.ts new file mode 100644 index 0000000000..06c68805e6 --- /dev/null +++ b/evm-tests/src/contracts/uidLookup.ts @@ -0,0 +1,45 @@ +export const IUID_LOOKUP_ADDRESS = "0x0000000000000000000000000000000000000806"; + +export const IUIDLookupABI = [ + { + inputs: [ + { + internalType: "uint16", + name: "netuid", + type: "uint16" + }, + { + internalType: "address", + name: "evm_address", + type: "address" + }, + { + internalType: "uint16", + name: "limit", + type: "uint16" + } + ], + name: "uidLookup", + outputs: [ + { + components: [ + { + internalType: "uint16", + name: "uid", + type: "uint16" + }, + { + internalType: "uint64", + name: "block_associated", + type: "uint64" + } + ], + internalType: "struct LookupItem[]", + name: "", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + } +]; diff --git a/evm-tests/src/utils.ts b/evm-tests/src/utils.ts index 36e922b49e..321ef2d441 100644 --- a/evm-tests/src/utils.ts +++ b/evm-tests/src/utils.ts @@ -2,6 +2,7 @@ import { defineChain, http, publicActions, createPublicClient } from "viem" import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts' import { ethers } from "ethers" import { ETH_LOCAL_URL } from "./config" +import { FixedSizeBinary } from "polkadot-api"; export type ClientUrlType = 'http://localhost:9944'; @@ -52,4 +53,26 @@ export function generateRandomEthersWallet() { const wallet = new ethers.Wallet(account.privateKey, provider); return wallet; -} \ No newline at end of file +} + +export function convertToFixedSizeBinary(hexString: string, size: T): FixedSizeBinary { + // Convert hex string to a byte array + const byteArray = hexStringToUint8Array(hexString); + + // Ensure the byte array is exactly the specified size + if (byteArray.length !== size) { + throw new Error(`The provided string "${hexString}" does not convert to exactly ${size} bytes.`); + } + + return new FixedSizeBinary(byteArray); +} + +export function hexStringToUint8Array(hexString: string): Uint8Array { + if (hexString.startsWith('0x')) hexString = hexString.slice(2); + if (hexString.length % 2 !== 0) hexString = '0' + hexString; + const bytes = new Uint8Array(hexString.length / 2); + for (let i = 0; i < bytes.length; i++) { + bytes[i] = parseInt(hexString.substring(i * 2, i * 2 + 2), 16); + } + return bytes; +} diff --git a/evm-tests/test/neuron.precompile.reveal-weights.test.ts b/evm-tests/test/neuron.precompile.reveal-weights.test.ts index 85125f0956..cbbad36172 100644 --- a/evm-tests/test/neuron.precompile.reveal-weights.test.ts +++ b/evm-tests/test/neuron.precompile.reveal-weights.test.ts @@ -129,7 +129,7 @@ describe("Test neuron precompile reveal weights", () => { ss58Address ) - const weights = await api.query.SubtensorModule.Weights.getValue(netuid, neuron_uid) + const weights = await api.query.SubtensorModule.Weights.getValue(netuid, neuron_uid!) if (weights === undefined) { throw new Error("weights not available onchain") diff --git a/evm-tests/test/neuron.precompile.set-weights.test.ts b/evm-tests/test/neuron.precompile.set-weights.test.ts index 393c2b97b8..81f34b4a93 100644 --- a/evm-tests/test/neuron.precompile.set-weights.test.ts +++ b/evm-tests/test/neuron.precompile.set-weights.test.ts @@ -53,7 +53,7 @@ describe("Test neuron precompile contract, set weights function", () => { const tx = await contract.setWeights(netuid, dests, weights, version_key); await tx.wait(); - const weightsOnChain = await api.query.SubtensorModule.Weights.getValue(netuid, uid) + const weightsOnChain = await api.query.SubtensorModule.Weights.getValue(netuid, uid!) weightsOnChain.forEach((weight, _) => { const uidInWeight = weight[0]; diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts new file mode 100644 index 0000000000..45429c10dc --- /dev/null +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -0,0 +1,98 @@ +import * as assert from "assert"; + +import { getAliceSigner, getClient, getDevnetApi, waitForTransactionCompletion, convertPublicKeyToMultiAddress, getRandomSubstrateKeypair, getSignerFromKeypair } from "../src/substrate" +import { convertToFixedSizeBinary, generateRandomEthersWallet, getPublicClient, hexStringToUint8Array } from "../src/utils"; +import { ETH_LOCAL_URL, SUB_LOCAL_URL } from "../src/config"; +import { devnet } from "@polkadot-api/descriptors" +import { PublicClient } from "viem"; +import { PolkadotSigner, TypedApi } from "polkadot-api"; +import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" +import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "../src/contracts/uidLookup" +import { keccak256 } from 'ethers'; + +describe("Test the UID Lookup precompile", () => { + // init substrate part + const hotkey = getRandomSubstrateKeypair(); + const coldkey = getRandomSubstrateKeypair(); + const evmWallet = generateRandomEthersWallet(); + let publicClient: PublicClient; + + let api: TypedApi + + // sudo account alice as signer + let alice: PolkadotSigner; + + // init other variable + let subnetId = 0; + + before(async () => { + // init variables got from await and async + publicClient = await getPublicClient(ETH_LOCAL_URL) + const subClient = await getClient(SUB_LOCAL_URL) + api = await getDevnetApi() + alice = await getAliceSigner(); + + // Fund the hotkey account + { + const multiAddress = convertPublicKeyToMultiAddress(hotkey.publicKey) + const internalCall = api.tx.Balances.force_set_balance({ who: multiAddress, new_free: BigInt(1e12) }) + const tx = api.tx.Sudo.sudo({ call: internalCall.decodedCall }) + + await waitForTransactionCompletion(api, tx, alice) + .then(() => { }) + .catch((error) => { console.log(`transaction error ${error}`) }); + } + + // Fund the coldkey account + { + const multiAddress = convertPublicKeyToMultiAddress(coldkey.publicKey) + const internalCall = api.tx.Balances.force_set_balance({ who: multiAddress, new_free: BigInt(1e12) }) + const tx = api.tx.Sudo.sudo({ call: internalCall.decodedCall }) + + await waitForTransactionCompletion(api, tx, alice) + .then(() => { }) + .catch((error) => { console.log(`transaction error ${error}`) }); + } + + // Register neuron + const signer = getSignerFromKeypair(coldkey) + const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) + const tx = api.tx.SubtensorModule.burned_register({ hotkey: hotkeyAddress, netuid: subnetId }) + await waitForTransactionCompletion(api, tx, signer) + .then(() => { }) + .catch((error) => { console.log(`transaction error ${error}`) }); + + // Associate EVM key + const blockNumber = await api.query.System.Number.getValue(); + const blockNumberBytes = hexStringToUint8Array("0x" + blockNumber.toString(16)); + const blockNumberHash = hexStringToUint8Array(keccak256(blockNumberBytes)); + const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); + const concatenatedHash = keccak256(concatenatedArray); + const signature = await evmWallet.signMessage(concatenatedHash); + const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ + netuid: subnetId, + hotkey: convertPublicKeyToSs58(hotkey.publicKey), + evm_key: convertToFixedSizeBinary(evmWallet.address, 20), + block_number: BigInt(blockNumber), + signature: convertToFixedSizeBinary(signature, 65) + }); + await waitForTransactionCompletion(api, associateEvmKeyTx, alice) + .then(() => { }) + .catch((error) => { console.log(`transaction error ${error}`) }); + }) + + it("UID lookup via precompile contract works correctly", async () => { + // Get UID for the EVM address + const uidArray = await publicClient.readContract({ + abi: IUIDLookupABI, + address: toViemAddress(IUID_LOOKUP_ADDRESS), + functionName: "uidLookup", + args: [subnetId, evmWallet.address, 1024] + }) + + console.info(uidArray) + assert.ok(uidArray !== undefined, "UID should be defined") + assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`) + assert.ok(uidArray.length > 0, "UID array should not be empty") + }) +}); From 8df61d81fc4ce85afbca8fe597f3470faab86f57 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 16 Apr 2025 23:36:40 +0900 Subject: [PATCH 049/226] Remove unused code --- evm-tests/test/uid.precompile.lookup.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 45429c10dc..13d0e840e6 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -1,6 +1,6 @@ import * as assert from "assert"; -import { getAliceSigner, getClient, getDevnetApi, waitForTransactionCompletion, convertPublicKeyToMultiAddress, getRandomSubstrateKeypair, getSignerFromKeypair } from "../src/substrate" +import { getAliceSigner, getDevnetApi, waitForTransactionCompletion, convertPublicKeyToMultiAddress, getRandomSubstrateKeypair, getSignerFromKeypair } from "../src/substrate" import { convertToFixedSizeBinary, generateRandomEthersWallet, getPublicClient, hexStringToUint8Array } from "../src/utils"; import { ETH_LOCAL_URL, SUB_LOCAL_URL } from "../src/config"; import { devnet } from "@polkadot-api/descriptors" @@ -28,7 +28,6 @@ describe("Test the UID Lookup precompile", () => { before(async () => { // init variables got from await and async publicClient = await getPublicClient(ETH_LOCAL_URL) - const subClient = await getClient(SUB_LOCAL_URL) api = await getDevnetApi() alice = await getAliceSigner(); From e0d18dd7b47fc66f4ad03f7c167fec2465bb7dfa Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 17 Apr 2025 01:35:41 +0900 Subject: [PATCH 050/226] Assert the right things --- evm-tests/test/uid.precompile.lookup.test.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 13d0e840e6..7f127d07a6 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -22,6 +22,9 @@ describe("Test the UID Lookup precompile", () => { // sudo account alice as signer let alice: PolkadotSigner; + let uid: number; + let blockNumber: number; + // init other variable let subnetId = 0; @@ -61,8 +64,10 @@ describe("Test the UID Lookup precompile", () => { .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); + uid = (await api.query.SubtensorModule.Uids.getValue(subnetId, convertPublicKeyToSs58(hotkey.publicKey)))! + // Associate EVM key - const blockNumber = await api.query.System.Number.getValue(); + blockNumber = await api.query.System.Number.getValue(); const blockNumberBytes = hexStringToUint8Array("0x" + blockNumber.toString(16)); const blockNumberHash = hexStringToUint8Array(keccak256(blockNumberBytes)); const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); @@ -78,6 +83,9 @@ describe("Test the UID Lookup precompile", () => { await waitForTransactionCompletion(api, associateEvmKeyTx, alice) .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); + + const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(subnetId, uid) + assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) }) it("UID lookup via precompile contract works correctly", async () => { @@ -90,8 +98,9 @@ describe("Test the UID Lookup precompile", () => { }) console.info(uidArray) - assert.ok(uidArray !== undefined, "UID should be defined") + assert.notEqual(uidArray, undefined, "UID should be defined") assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`) assert.ok(uidArray.length > 0, "UID array should not be empty") + assert.equal(uidArray[0], [uid, BigInt(blockNumber)]) }) }); From 2eb3c8cfbbb2dea014a748aa23b42959b8e2c632 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 17 Apr 2025 18:03:26 -0400 Subject: [PATCH 051/226] impl --- evm-tests/src/contracts/staking.ts | 68 +++++++++++++++++++++++- precompiles/src/solidity/stakingV2.abi | 68 +++++++++++++++++++++++- precompiles/src/solidity/stakingV2.sol | 71 +++++++++++++++++++++++--- precompiles/src/staking.rs | 50 ++++++++++++++++++ 4 files changed, 247 insertions(+), 10 deletions(-) diff --git a/evm-tests/src/contracts/staking.ts b/evm-tests/src/contracts/staking.ts index af4422ca96..0ba37c5a94 100644 --- a/evm-tests/src/contracts/staking.ts +++ b/evm-tests/src/contracts/staking.ts @@ -287,5 +287,71 @@ export const IStakingV2ABI = [ "outputs": [], "stateMutability": "nonpayable", "type": "function" - } + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "hotkey", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit_price", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "allow_partial", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "netuid", + "type": "uint256" + } + ], + "name": "addStakeLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "hotkey", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit_price", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "allow_partial", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "netuid", + "type": "uint256" + } + ], + "name": "removeStakeLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, ]; \ No newline at end of file diff --git a/precompiles/src/solidity/stakingV2.abi b/precompiles/src/solidity/stakingV2.abi index 16adb1d8a8..20cc9c90fe 100644 --- a/precompiles/src/solidity/stakingV2.abi +++ b/precompiles/src/solidity/stakingV2.abi @@ -251,5 +251,71 @@ "outputs": [], "stateMutability": "nonpayable", "type": "function" - } + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "hotkey", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit_price", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "allow_partial", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "netuid", + "type": "uint256" + } + ], + "name": "addStakeLimit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "hotkey", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "limit_price", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "allow_partial", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "netuid", + "type": "uint256" + } + ], + "name": "removeStakeLimit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, ] diff --git a/precompiles/src/solidity/stakingV2.sol b/precompiles/src/solidity/stakingV2.sol index dd033cfca8..202615af62 100644 --- a/precompiles/src/solidity/stakingV2.sol +++ b/precompiles/src/solidity/stakingV2.sol @@ -51,12 +51,12 @@ interface IStaking { ) external; /** - * @dev Moves a subtensor stake `amount` associated with the `hotkey` to a different hotkey + * @dev Moves a subtensor stake `amount` associated with the `hotkey` to a different hotkey * `destination_hotkey`. * * This function allows external accounts and contracts to move staked TAO from one hotkey to another, - * which effectively calls `move_stake` on the subtensor pallet with specified origin and destination - * hotkeys as parameters being the hashed address mappings of H160 sender address to Substrate ss58 + * which effectively calls `move_stake` on the subtensor pallet with specified origin and destination + * hotkeys as parameters being the hashed address mappings of H160 sender address to Substrate ss58 * address as implemented in Frontier HashedAddressMapping: * https://github.com/polkadot-evm/frontier/blob/2e219e17a526125da003e64ef22ec037917083fa/frame/evm/src/lib.rs#L739 * @@ -67,7 +67,7 @@ interface IStaking { * @param amount The amount to move in rao. * * Requirements: - * - `origin_hotkey` and `destination_hotkey` must be valid hotkeys registered on the network, ensuring + * - `origin_hotkey` and `destination_hotkey` must be valid hotkeys registered on the network, ensuring * that the stake is correctly attributed. */ function moveStake( @@ -79,12 +79,12 @@ interface IStaking { ) external; /** - * @dev Transfer a subtensor stake `amount` associated with the transaction signer to a different coldkey + * @dev Transfer a subtensor stake `amount` associated with the transaction signer to a different coldkey * `destination_coldkey`. * * This function allows external accounts and contracts to transfer staked TAO to another coldkey, - * which effectively calls `transfer_stake` on the subtensor pallet with specified destination - * coldkey as a parameter being the hashed address mapping of H160 sender address to Substrate ss58 + * which effectively calls `transfer_stake` on the subtensor pallet with specified destination + * coldkey as a parameter being the hashed address mapping of H160 sender address to Substrate ss58 * address as implemented in Frontier HashedAddressMapping: * https://github.com/polkadot-evm/frontier/blob/2e219e17a526125da003e64ef22ec037917083fa/frame/evm/src/lib.rs#L739 * @@ -95,7 +95,7 @@ interface IStaking { * @param amount The amount to move in rao. * * Requirements: - * - `origin_hotkey` and `destination_hotkey` must be valid hotkeys registered on the network, ensuring + * - `origin_hotkey` and `destination_hotkey` must be valid hotkeys registered on the network, ensuring * that the stake is correctly attributed. */ function transferStake( @@ -194,4 +194,59 @@ interface IStaking { bytes32 hotkey, uint256 netuid ) external view returns (uint256); + + /** + * @dev Adds a subtensor stake `amount` associated with the `hotkey` within a price limit. + * + * This function allows external accounts and contracts to stake TAO into the subtensor pallet, + * which effectively calls `add_stake_limit` on the subtensor pallet with specified hotkey as a parameter + * and coldkey being the hashed address mapping of H160 sender address to Substrate ss58 address as + * implemented in Frontier HashedAddressMapping: + * https://github.com/polkadot-evm/frontier/blob/2e219e17a526125da003e64ef22ec037917083fa/frame/evm/src/lib.rs#L739 + * + * @param hotkey The hotkey public key (32 bytes). + * @param amount The amount to stake in rao. + * @param limit_price The price limit to stake at in rao. Number of rao per alpha. + * @param allow_partial Whether to allow partial stake. + * @param netuid The subnet to stake to (uint256). + * + * Requirements: + * - `hotkey` must be a valid hotkey registered on the network, ensuring that the stake is + * correctly attributed. + */ + function addStakeLimit( + bytes32 hotkey, + uint256 amount, + uint256 limit_price, + bool allow_partial, + uint256 netuid + ) external payable; + + /** + * @dev Removes a subtensor stake `amount` from the specified `hotkey` within a price limit. + * + * This function allows external accounts and contracts to unstake TAO from the subtensor pallet, + * which effectively calls `remove_stake_limit` on the subtensor pallet with specified hotkey as a parameter + * and coldkey being the hashed address mapping of H160 sender address to Substrate ss58 address as + * implemented in Frontier HashedAddressMapping: + * https://github.com/polkadot-evm/frontier/blob/2e219e17a526125da003e64ef22ec037917083fa/frame/evm/src/lib.rs#L739 + * + * @param hotkey The hotkey public key (32 bytes). + * @param amount The amount to unstake in alpha. + * @param limit_price The price limit to unstake at in rao. Number of rao per alpha. + * @param allow_partial Whether to allow partial unstake. + * @param netuid The subnet to stake to (uint256). + * + * Requirements: + * - `hotkey` must be a valid hotkey registered on the network, ensuring that the stake is + * correctly attributed. + * - The existing stake amount must be not lower than specified amount + */ + function removeStakeLimit( + bytes32 hotkey, + uint256 amount, + uint256 limit_price, + bool allow_partial, + uint256 netuid + ) external; } diff --git a/precompiles/src/staking.rs b/precompiles/src/staking.rs index 8f797a7476..20a7bccf19 100644 --- a/precompiles/src/staking.rs +++ b/precompiles/src/staking.rs @@ -276,6 +276,56 @@ where handle.try_dispatch_runtime_call::(call, RawOrigin::Signed(account_id)) } + + #[precompile::public("addStakeLimit(bytes32,uint256,uint256,bool,uint256)")] + fn add_stake_limit( + handle: &mut impl PrecompileHandle, + address: H256, + amount_rao: U256, + limit_price_rao: U256, + allow_partial: bool, + netuid: U256, + ) -> EvmResult<()> { + let account_id = handle.caller_account_id::(); + let amount_staked = amount_rao.unique_saturated_into(); + let limit_price = limit_price_rao.unique_saturated_into(); + let hotkey = R::AccountId::from(address.0); + let netuid = try_u16_from_u256(netuid)?; + let call = pallet_subtensor::Call::::add_stake_limit { + hotkey, + netuid, + amount_staked, + limit_price, + allow_partial, + }; + + handle.try_dispatch_runtime_call::(call, RawOrigin::Signed(account_id)) + } + + #[precompile::public("removeStakeLimit(bytes32,uint256,uint256,bool,uint256)")] + fn remove_stake_limit( + handle: &mut impl PrecompileHandle, + address: H256, + amount_alpha: U256, + limit_price_rao: U256, + allow_partial: bool, + netuid: U256, + ) -> EvmResult<()> { + let account_id = handle.caller_account_id::(); + let hotkey = R::AccountId::from(address.0); + let netuid = try_u16_from_u256(netuid)?; + let amount_unstaked = amount_alpha.unique_saturated_into(); + let limit_price = limit_price_rao.unique_saturated_into(); + let call = pallet_subtensor::Call::::remove_stake_limit { + hotkey, + netuid, + amount_unstaked, + limit_price, + allow_partial, + }; + + handle.try_dispatch_runtime_call::(call, RawOrigin::Signed(account_id)) + } } // Deprecated, exists for backward compatibility. From 13c3466e95734df5f969c7a23e9a5c271850da95 Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 21 Apr 2025 21:04:39 +0900 Subject: [PATCH 052/226] Use SCALE codec to encode block number --- evm-tests/package-lock.json | 1249 ++++++++++++++---- evm-tests/package.json | 2 + evm-tests/src/utils.ts | 13 +- evm-tests/test/uid.precompile.lookup.test.ts | 10 +- 4 files changed, 969 insertions(+), 305 deletions(-) diff --git a/evm-tests/package-lock.json b/evm-tests/package-lock.json index 0a4a52bf57..68fae940bf 100644 --- a/evm-tests/package-lock.json +++ b/evm-tests/package-lock.json @@ -16,6 +16,7 @@ "ethers": "^6.13.5", "mocha": "^11.1.0", "polkadot-api": "^1.9.5", + "scale-ts": "^1.6.1", "viem": "2.23.4" }, "devDependencies": { @@ -31,7 +32,7 @@ }, ".papi/descriptors": { "name": "@polkadot-api/descriptors", - "version": "0.1.0-autogenerated.1047499684690955440", + "version": "0.1.0-autogenerated.7914363913476982777", "peerDependencies": { "polkadot-api": "*" } @@ -87,10 +88,266 @@ "node": ">=12" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz", + "integrity": "sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.2.tgz", + "integrity": "sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.2.tgz", + "integrity": "sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.2.tgz", + "integrity": "sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.2.tgz", + "integrity": "sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.2.tgz", + "integrity": "sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.2.tgz", + "integrity": "sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.2.tgz", + "integrity": "sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.2.tgz", + "integrity": "sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.2.tgz", + "integrity": "sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.2.tgz", + "integrity": "sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.2.tgz", + "integrity": "sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.2.tgz", + "integrity": "sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.2.tgz", + "integrity": "sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.2.tgz", + "integrity": "sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.2.tgz", + "integrity": "sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/linux-x64": { - "version": "0.25.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.1.tgz", - "integrity": "sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==", + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.2.tgz", + "integrity": "sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg==", "cpu": [ "x64" ], @@ -103,6 +360,134 @@ "node": ">=18" } }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.2.tgz", + "integrity": "sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.2.tgz", + "integrity": "sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.2.tgz", + "integrity": "sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.2.tgz", + "integrity": "sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.2.tgz", + "integrity": "sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.2.tgz", + "integrity": "sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.2.tgz", + "integrity": "sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.2.tgz", + "integrity": "sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -296,18 +681,18 @@ } }, "node_modules/@polkadot-api/cli": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/@polkadot-api/cli/-/cli-0.11.2.tgz", - "integrity": "sha512-W5ycHU/RGmKzs9Myzs2hv2eR555Z+/5Pd+Iguu2WEShC2Kxq1bxEc+XPCSSEF24apMGdlywBVRrh1D5LfpleFA==", + "version": "0.11.9", + "resolved": "https://registry.npmjs.org/@polkadot-api/cli/-/cli-0.11.9.tgz", + "integrity": "sha512-5Qt+YRf/kOCZGiFoWzgyxoZYA9OpN28AFE4jQ4nZI33lty8oH4FR62IF2iLF+KdafhgF9k9l1Kj24zuBFH3Vrw==", "license": "MIT", "dependencies": { "@commander-js/extra-typings": "^13.1.0", - "@polkadot-api/codegen": "0.13.1", + "@polkadot-api/codegen": "0.13.3", "@polkadot-api/ink-contracts": "0.2.6", "@polkadot-api/json-rpc-provider": "0.0.4", - "@polkadot-api/known-chains": "0.7.1", - "@polkadot-api/metadata-compatibility": "0.1.16", - "@polkadot-api/observable-client": "0.8.2", + "@polkadot-api/known-chains": "0.7.3", + "@polkadot-api/metadata-compatibility": "0.2.0", + "@polkadot-api/observable-client": "0.8.6", "@polkadot-api/polkadot-sdk-compat": "2.3.2", "@polkadot-api/sm-provider": "0.1.7", "@polkadot-api/smoldot": "0.3.8", @@ -316,7 +701,7 @@ "@polkadot-api/utils": "0.1.2", "@polkadot-api/wasm-executor": "^0.1.2", "@polkadot-api/ws-provider": "0.4.0", - "@types/node": "^22.13.9", + "@types/node": "^22.14.0", "commander": "^13.1.0", "execa": "^9.5.2", "fs.promises.exists": "^1.1.4", @@ -325,7 +710,7 @@ "rxjs": "^7.8.2", "tsc-prog": "^2.3.0", "tsup": "^8.4.0", - "typescript": "^5.8.2", + "typescript": "^5.8.3", "write-package": "^7.1.0" }, "bin": { @@ -333,192 +718,15 @@ "polkadot-api": "dist/main.js" } }, - "node_modules/@polkadot-api/cli/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.35.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.35.0.tgz", - "integrity": "sha512-Pim1T8rXOri+0HmV4CdKSGrqcBWX0d1HoPnQ0uw0bdp1aP5SdQVNBy8LjYncvnLgu3fnnCt17xjWGd4cqh8/hA==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@polkadot-api/cli/node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.35.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.35.0.tgz", - "integrity": "sha512-QysqXzYiDvQWfUiTm8XmJNO2zm9yC9P/2Gkrwg2dH9cxotQzunBHYr6jk4SujCTqnfGxduOmQcI7c2ryuW8XVg==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@polkadot-api/cli/node_modules/@types/node": { - "version": "22.13.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz", - "integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==", - "license": "MIT", - "dependencies": { - "undici-types": "~6.20.0" - } - }, - "node_modules/@polkadot-api/cli/node_modules/chokidar": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", - "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", - "license": "MIT", - "dependencies": { - "readdirp": "^4.0.1" - }, - "engines": { - "node": ">= 14.16.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@polkadot-api/cli/node_modules/readdirp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", - "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", - "license": "MIT", - "engines": { - "node": ">= 14.18.0" - }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@polkadot-api/cli/node_modules/rollup": { - "version": "4.35.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.35.0.tgz", - "integrity": "sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg==", - "license": "MIT", - "dependencies": { - "@types/estree": "1.0.6" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.35.0", - "@rollup/rollup-android-arm64": "4.35.0", - "@rollup/rollup-darwin-arm64": "4.35.0", - "@rollup/rollup-darwin-x64": "4.35.0", - "@rollup/rollup-freebsd-arm64": "4.35.0", - "@rollup/rollup-freebsd-x64": "4.35.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.35.0", - "@rollup/rollup-linux-arm-musleabihf": "4.35.0", - "@rollup/rollup-linux-arm64-gnu": "4.35.0", - "@rollup/rollup-linux-arm64-musl": "4.35.0", - "@rollup/rollup-linux-loongarch64-gnu": "4.35.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.35.0", - "@rollup/rollup-linux-riscv64-gnu": "4.35.0", - "@rollup/rollup-linux-s390x-gnu": "4.35.0", - "@rollup/rollup-linux-x64-gnu": "4.35.0", - "@rollup/rollup-linux-x64-musl": "4.35.0", - "@rollup/rollup-win32-arm64-msvc": "4.35.0", - "@rollup/rollup-win32-ia32-msvc": "4.35.0", - "@rollup/rollup-win32-x64-msvc": "4.35.0", - "fsevents": "~2.3.2" - } - }, - "node_modules/@polkadot-api/cli/node_modules/tsc-prog": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tsc-prog/-/tsc-prog-2.3.0.tgz", - "integrity": "sha512-ycET2d75EgcX7y8EmG4KiZkLAwUzbY4xRhA6NU0uVbHkY4ZjrAAuzTMxXI85kOwATqPnBI5C/7y7rlpY0xdqHA==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "typescript": ">=4" - } - }, - "node_modules/@polkadot-api/cli/node_modules/tsup": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.4.0.tgz", - "integrity": "sha512-b+eZbPCjz10fRryaAA7C8xlIHnf8VnsaRqydheLIqwG/Mcpfk8Z5zp3HayX7GaTygkigHl5cBUs+IhcySiIexQ==", - "license": "MIT", - "dependencies": { - "bundle-require": "^5.1.0", - "cac": "^6.7.14", - "chokidar": "^4.0.3", - "consola": "^3.4.0", - "debug": "^4.4.0", - "esbuild": "^0.25.0", - "joycon": "^3.1.1", - "picocolors": "^1.1.1", - "postcss-load-config": "^6.0.1", - "resolve-from": "^5.0.0", - "rollup": "^4.34.8", - "source-map": "0.8.0-beta.0", - "sucrase": "^3.35.0", - "tinyexec": "^0.3.2", - "tinyglobby": "^0.2.11", - "tree-kill": "^1.2.2" - }, - "bin": { - "tsup": "dist/cli-default.js", - "tsup-node": "dist/cli-node.js" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@microsoft/api-extractor": "^7.36.0", - "@swc/core": "^1", - "postcss": "^8.4.12", - "typescript": ">=4.5.0" - }, - "peerDependenciesMeta": { - "@microsoft/api-extractor": { - "optional": true - }, - "@swc/core": { - "optional": true - }, - "postcss": { - "optional": true - }, - "typescript": { - "optional": true - } - } - }, - "node_modules/@polkadot-api/cli/node_modules/typescript": { - "version": "5.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", - "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/@polkadot-api/codegen": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/@polkadot-api/codegen/-/codegen-0.13.1.tgz", - "integrity": "sha512-pqJI2gFrk5rfaO8IyGw59DvJH2PyvWXx/dTxev6VsX3BLvYVdb/vISQjdrHpsCk4BHqmWrlLnhw1/jFVotf4ew==", + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/@polkadot-api/codegen/-/codegen-0.13.3.tgz", + "integrity": "sha512-+8mp9k5L9myFSLv6Ad5r63JSIeq80/tKbk67rczDq6Co0PlJHqxult+wZHohHuyJSdtu8dHW9JQktTtM2RZT1w==", "license": "MIT", "dependencies": { "@polkadot-api/ink-contracts": "0.2.6", "@polkadot-api/metadata-builders": "0.10.2", - "@polkadot-api/metadata-compatibility": "0.1.16", + "@polkadot-api/metadata-compatibility": "0.2.0", "@polkadot-api/substrate-bindings": "0.11.1", "@polkadot-api/utils": "0.1.2" } @@ -551,9 +759,9 @@ "license": "MIT" }, "node_modules/@polkadot-api/known-chains": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@polkadot-api/known-chains/-/known-chains-0.7.1.tgz", - "integrity": "sha512-65hwgOrS0dFi4J6LQy043fZoBv29ctvAO91gQjSyhQdTionpoNVEizUWZwJj2qx3U4+sSovQXP+s71QBpv8NZA==", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@polkadot-api/known-chains/-/known-chains-0.7.3.tgz", + "integrity": "sha512-yBRVbOLn0e36+EGWE2/hX8mhTKvfdZtbk2VCgTM9djkz28eDFfiDjEl6biQA8Q0Kd7t3iRzoNbBzpzyBwTMXUg==", "license": "MIT" }, "node_modules/@polkadot-api/logs-provider": { @@ -576,9 +784,9 @@ } }, "node_modules/@polkadot-api/metadata-compatibility": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/@polkadot-api/metadata-compatibility/-/metadata-compatibility-0.1.16.tgz", - "integrity": "sha512-30qCfWUtxdaCy/9vwnBf4CGrtZ4KGSZDGz+d3fBSx7S2o5ezFmauld4NCKNo4SQiS1S0I7eixV2/JlkMhGqxBQ==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@polkadot-api/metadata-compatibility/-/metadata-compatibility-0.2.0.tgz", + "integrity": "sha512-ZvHj4KDQy/JFqV51UN6Gk5xnG0qt/BUS4kjYosLWT9y6p5bHg/4ge7QF5lMloInQqV3Rul9NQo4cKUz3SlSQMQ==", "license": "MIT", "dependencies": { "@polkadot-api/metadata-builders": "0.10.2", @@ -586,9 +794,9 @@ } }, "node_modules/@polkadot-api/observable-client": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/@polkadot-api/observable-client/-/observable-client-0.8.2.tgz", - "integrity": "sha512-yMjKKOcToHYtOU+V1xWE7D0Ddhqn7uNPj3Zv1kHR+AhhHR4bEbG1S5CtUAyQOgJDQxaAHDRNujXNxsLcT9nqmw==", + "version": "0.8.6", + "resolved": "https://registry.npmjs.org/@polkadot-api/observable-client/-/observable-client-0.8.6.tgz", + "integrity": "sha512-ci5HC8TYjGxoTG/QM+LLuGrfIsn+dtR7BBQz483c/ML8K/Hxl9v+evgZzPi9xNMwZ25mytn9lhA5dovYSEauSA==", "license": "MIT", "dependencies": { "@polkadot-api/metadata-builders": "0.10.2", @@ -1280,7 +1488,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1294,7 +1501,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1565,12 +1771,12 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.13.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.5.tgz", - "integrity": "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg==", + "version": "22.14.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.1.tgz", + "integrity": "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==", "license": "MIT", "dependencies": { - "undici-types": "~6.20.0" + "undici-types": "~6.21.0" } }, "node_modules/@types/normalize-package-data": { @@ -2027,9 +2233,9 @@ } }, "node_modules/consola": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.0.tgz", - "integrity": "sha512-EiPU8G6dQG0GFHNR8ljnZFki/8a+cQwEQ+7wpxdChl02Q8HXlwEZWD5lqAF8vC2sEC3Tehr8hy7vErz88LHyUA==", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", "license": "MIT", "engines": { "node": "^14.18.0 || >=16.10.0" @@ -2247,9 +2453,9 @@ } }, "node_modules/esbuild": { - "version": "0.25.1", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", - "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.2.tgz", + "integrity": "sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ==", "hasInstallScript": true, "license": "MIT", "bin": { @@ -2259,31 +2465,31 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.25.1", - "@esbuild/android-arm": "0.25.1", - "@esbuild/android-arm64": "0.25.1", - "@esbuild/android-x64": "0.25.1", - "@esbuild/darwin-arm64": "0.25.1", - "@esbuild/darwin-x64": "0.25.1", - "@esbuild/freebsd-arm64": "0.25.1", - "@esbuild/freebsd-x64": "0.25.1", - "@esbuild/linux-arm": "0.25.1", - "@esbuild/linux-arm64": "0.25.1", - "@esbuild/linux-ia32": "0.25.1", - "@esbuild/linux-loong64": "0.25.1", - "@esbuild/linux-mips64el": "0.25.1", - "@esbuild/linux-ppc64": "0.25.1", - "@esbuild/linux-riscv64": "0.25.1", - "@esbuild/linux-s390x": "0.25.1", - "@esbuild/linux-x64": "0.25.1", - "@esbuild/netbsd-arm64": "0.25.1", - "@esbuild/netbsd-x64": "0.25.1", - "@esbuild/openbsd-arm64": "0.25.1", - "@esbuild/openbsd-x64": "0.25.1", - "@esbuild/sunos-x64": "0.25.1", - "@esbuild/win32-arm64": "0.25.1", - "@esbuild/win32-ia32": "0.25.1", - "@esbuild/win32-x64": "0.25.1" + "@esbuild/aix-ppc64": "0.25.2", + "@esbuild/android-arm": "0.25.2", + "@esbuild/android-arm64": "0.25.2", + "@esbuild/android-x64": "0.25.2", + "@esbuild/darwin-arm64": "0.25.2", + "@esbuild/darwin-x64": "0.25.2", + "@esbuild/freebsd-arm64": "0.25.2", + "@esbuild/freebsd-x64": "0.25.2", + "@esbuild/linux-arm": "0.25.2", + "@esbuild/linux-arm64": "0.25.2", + "@esbuild/linux-ia32": "0.25.2", + "@esbuild/linux-loong64": "0.25.2", + "@esbuild/linux-mips64el": "0.25.2", + "@esbuild/linux-ppc64": "0.25.2", + "@esbuild/linux-riscv64": "0.25.2", + "@esbuild/linux-s390x": "0.25.2", + "@esbuild/linux-x64": "0.25.2", + "@esbuild/netbsd-arm64": "0.25.2", + "@esbuild/netbsd-x64": "0.25.2", + "@esbuild/openbsd-arm64": "0.25.2", + "@esbuild/openbsd-x64": "0.25.2", + "@esbuild/sunos-x64": "0.25.2", + "@esbuild/win32-arm64": "0.25.2", + "@esbuild/win32-ia32": "0.25.2", + "@esbuild/win32-x64": "0.25.2" } }, "node_modules/escalade": { @@ -2793,9 +2999,9 @@ } }, "node_modules/human-signals": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-8.0.0.tgz", - "integrity": "sha512-/1/GPCpDUCCYwlERiYjxoczfP0zfvZMU/OWgQPMya9AbAE24vseigFdhAMObpc8Q4lc/kjutPfUddDYyAmejnA==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-8.0.1.tgz", + "integrity": "sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ==", "license": "Apache-2.0", "engines": { "node": ">=18.18.0" @@ -2811,9 +3017,9 @@ } }, "node_modules/index-to-position": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/index-to-position/-/index-to-position-0.1.2.tgz", - "integrity": "sha512-MWDKS3AS1bGCHLBA2VLImJz42f7bJh8wQsTGCzI3j519/CASStoDONUBVz2I/VID0MpiX3SGSnbOD2xUalbE5g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/index-to-position/-/index-to-position-1.1.0.tgz", + "integrity": "sha512-XPdx9Dq4t9Qk1mTMbWONJqU7boCoumEH7fRET37HX5+khDUl3J2W6PdALxhILYlIYx2amlwYcRPp28p0tSiojg==", "license": "MIT", "engines": { "node": ">=18" @@ -3508,18 +3714,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/npm-run-path/node_modules/unicorn-magic": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz", - "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -3765,14 +3959,14 @@ "license": "BlueOak-1.0.0" }, "node_modules/parse-json": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.1.0.tgz", - "integrity": "sha512-rum1bPifK5SSar35Z6EKZuYPJx85pkNaFrxBK3mwdfSJ1/WKbYrjoW/zTPSjRRamfmVX1ACBIdFAO0VRErW/EA==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.3.0.tgz", + "integrity": "sha512-ybiGyvspI+fAoRQbIPRddCcSTV9/LsJbf0e/S85VLowVGzRmokfneg2kwVW/KU5rOXrPSbF1qAKPMgNTqqROQQ==", "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "index-to-position": "^0.1.2", - "type-fest": "^4.7.1" + "@babel/code-frame": "^7.26.2", + "index-to-position": "^1.1.0", + "type-fest": "^4.39.1" }, "engines": { "node": ">=18" @@ -3856,28 +4050,28 @@ } }, "node_modules/pirates": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", - "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", "license": "MIT", "engines": { "node": ">= 6" } }, "node_modules/polkadot-api": { - "version": "1.9.5", - "resolved": "https://registry.npmjs.org/polkadot-api/-/polkadot-api-1.9.5.tgz", - "integrity": "sha512-wHe2TFqBVbiAE9CDLZA/xMbMCfOtch6++kSmDIWY7i9MmcWJwZhDHpHlfvRUsVgI/VL36QPEjBH+Kjt3KNLLhw==", + "version": "1.9.12", + "resolved": "https://registry.npmjs.org/polkadot-api/-/polkadot-api-1.9.12.tgz", + "integrity": "sha512-gYhpef5YnLEPZ3Uxeha5sHIIejINONSGBXTgFyEWsYi4y2DEUlv2ISlNZ9/0AGG6b6ZFDd56mLop/Fohl8vA4Q==", "license": "MIT", "dependencies": { - "@polkadot-api/cli": "0.11.2", + "@polkadot-api/cli": "0.11.9", "@polkadot-api/ink-contracts": "0.2.6", "@polkadot-api/json-rpc-provider": "0.0.4", - "@polkadot-api/known-chains": "0.7.1", + "@polkadot-api/known-chains": "0.7.3", "@polkadot-api/logs-provider": "0.0.6", "@polkadot-api/metadata-builders": "0.10.2", - "@polkadot-api/metadata-compatibility": "0.1.16", - "@polkadot-api/observable-client": "0.8.2", + "@polkadot-api/metadata-compatibility": "0.2.0", + "@polkadot-api/observable-client": "0.8.6", "@polkadot-api/pjs-signer": "0.6.5", "@polkadot-api/polkadot-sdk-compat": "2.3.2", "@polkadot-api/polkadot-signer": "0.1.6", @@ -4056,6 +4250,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/read-pkg/node_modules/unicorn-magic": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", + "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -4106,7 +4312,6 @@ "version": "4.34.8", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.8.tgz", "integrity": "sha512-489gTVMzAYdiZHFVA/ig/iYFllCcWFHMvUHI1rpFmkoUtRlQxqh6/yiNqnYibjMZ2b/+FUQwldG+aLsEt6bglQ==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "1.0.6" @@ -4630,16 +4835,107 @@ } } }, + "node_modules/tsc-prog": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tsc-prog/-/tsc-prog-2.3.0.tgz", + "integrity": "sha512-ycET2d75EgcX7y8EmG4KiZkLAwUzbY4xRhA6NU0uVbHkY4ZjrAAuzTMxXI85kOwATqPnBI5C/7y7rlpY0xdqHA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "typescript": ">=4" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/tsup": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.4.0.tgz", + "integrity": "sha512-b+eZbPCjz10fRryaAA7C8xlIHnf8VnsaRqydheLIqwG/Mcpfk8Z5zp3HayX7GaTygkigHl5cBUs+IhcySiIexQ==", + "license": "MIT", + "dependencies": { + "bundle-require": "^5.1.0", + "cac": "^6.7.14", + "chokidar": "^4.0.3", + "consola": "^3.4.0", + "debug": "^4.4.0", + "esbuild": "^0.25.0", + "joycon": "^3.1.1", + "picocolors": "^1.1.1", + "postcss-load-config": "^6.0.1", + "resolve-from": "^5.0.0", + "rollup": "^4.34.8", + "source-map": "0.8.0-beta.0", + "sucrase": "^3.35.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.11", + "tree-kill": "^1.2.2" + }, + "bin": { + "tsup": "dist/cli-default.js", + "tsup-node": "dist/cli-node.js" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@microsoft/api-extractor": "^7.36.0", + "@swc/core": "^1", + "postcss": "^8.4.12", + "typescript": ">=4.5.0" + }, + "peerDependenciesMeta": { + "@microsoft/api-extractor": { + "optional": true + }, + "@swc/core": { + "optional": true + }, + "postcss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/tsup/node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/tsup/node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/type-fest": { - "version": "4.35.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.35.0.tgz", - "integrity": "sha512-2/AwEFQDFEy30iOLjrvHDIH7e4HEWH+f1Yl1bI5XMqzuoCUqwYCdxachgsgv0og/JdVZUhbfjcJAoHj5L1753A==", + "version": "4.40.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.40.0.tgz", + "integrity": "sha512-ABHZ2/tS2JkvH1PEjxFDTUWC8dB5OsIGZP4IFLhR293GqT5Y5qB1WwL2kMPYhQW9DVgVD8Hd7I8gjwPIf5GFkw==", "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=16" @@ -4649,10 +4945,9 @@ } }, "node_modules/typescript": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", - "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", - "devOptional": true, + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -4663,17 +4958,17 @@ } }, "node_modules/undici-types": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", - "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "license": "MIT" }, "node_modules/unicorn-magic": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", - "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", - "license": "MIT", - "engines": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz", + "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==", + "license": "MIT", + "engines": { "node": ">=18" }, "funding": { @@ -4822,6 +5117,278 @@ } } }, + "node_modules/vite/node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/vite/node_modules/@esbuild/linux-x64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", @@ -4839,6 +5406,108 @@ "node": ">=12" } }, + "node_modules/vite/node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/vite/node_modules/esbuild": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", diff --git a/evm-tests/package.json b/evm-tests/package.json index 45f03c0b49..ca35fe2d1b 100644 --- a/evm-tests/package.json +++ b/evm-tests/package.json @@ -6,6 +6,7 @@ "author": "", "license": "ISC", "dependencies": { + "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", @@ -15,6 +16,7 @@ "ethers": "^6.13.5", "mocha": "^11.1.0", "polkadot-api": "^1.9.5", + "scale-ts": "^1.6.1", "viem": "2.23.4" }, "devDependencies": { diff --git a/evm-tests/src/utils.ts b/evm-tests/src/utils.ts index 321ef2d441..1ba191d833 100644 --- a/evm-tests/src/utils.ts +++ b/evm-tests/src/utils.ts @@ -3,6 +3,7 @@ import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts' import { ethers } from "ethers" import { ETH_LOCAL_URL } from "./config" import { FixedSizeBinary } from "polkadot-api"; +import { hexToU8a } from "@polkadot/util"; export type ClientUrlType = 'http://localhost:9944'; @@ -57,7 +58,7 @@ export function generateRandomEthersWallet() { export function convertToFixedSizeBinary(hexString: string, size: T): FixedSizeBinary { // Convert hex string to a byte array - const byteArray = hexStringToUint8Array(hexString); + const byteArray = hexToU8a(hexString); // Ensure the byte array is exactly the specified size if (byteArray.length !== size) { @@ -66,13 +67,3 @@ export function convertToFixedSizeBinary(hexString: string, si return new FixedSizeBinary(byteArray); } - -export function hexStringToUint8Array(hexString: string): Uint8Array { - if (hexString.startsWith('0x')) hexString = hexString.slice(2); - if (hexString.length % 2 !== 0) hexString = '0' + hexString; - const bytes = new Uint8Array(hexString.length / 2); - for (let i = 0; i < bytes.length; i++) { - bytes[i] = parseInt(hexString.substring(i * 2, i * 2 + 2), 16); - } - return bytes; -} diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 7f127d07a6..5fa5043fd2 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -1,9 +1,11 @@ import * as assert from "assert"; import { getAliceSigner, getDevnetApi, waitForTransactionCompletion, convertPublicKeyToMultiAddress, getRandomSubstrateKeypair, getSignerFromKeypair } from "../src/substrate" -import { convertToFixedSizeBinary, generateRandomEthersWallet, getPublicClient, hexStringToUint8Array } from "../src/utils"; -import { ETH_LOCAL_URL, SUB_LOCAL_URL } from "../src/config"; +import { convertToFixedSizeBinary, generateRandomEthersWallet, getPublicClient } from "../src/utils"; +import { ETH_LOCAL_URL } from "../src/config"; import { devnet } from "@polkadot-api/descriptors" +import { hexToU8a } from "@polkadot/util"; +import { u64 } from "scale-ts"; import { PublicClient } from "viem"; import { PolkadotSigner, TypedApi } from "polkadot-api"; import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" @@ -68,8 +70,8 @@ describe("Test the UID Lookup precompile", () => { // Associate EVM key blockNumber = await api.query.System.Number.getValue(); - const blockNumberBytes = hexStringToUint8Array("0x" + blockNumber.toString(16)); - const blockNumberHash = hexStringToUint8Array(keccak256(blockNumberBytes)); + const blockNumberBytes = u64.enc(BigInt(blockNumber)); + const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); const concatenatedHash = keccak256(concatenatedArray); const signature = await evmWallet.signMessage(concatenatedHash); From 9f6df3bbc354638891e8f8bcaf007abed944ac3d Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 21 Apr 2025 21:09:24 +0900 Subject: [PATCH 053/226] Remove papi --- evm-tests/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/evm-tests/package.json b/evm-tests/package.json index ca35fe2d1b..0e90cdb976 100644 --- a/evm-tests/package.json +++ b/evm-tests/package.json @@ -6,7 +6,6 @@ "author": "", "license": "ISC", "dependencies": { - "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", From a6a70f96d3e10c68f72c81c41b214338fbaab6aa Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 21 Apr 2025 22:48:29 +0900 Subject: [PATCH 054/226] Debug --- evm-tests/test/uid.precompile.lookup.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 5fa5043fd2..0ce5dd7d49 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -68,6 +68,8 @@ describe("Test the UID Lookup precompile", () => { uid = (await api.query.SubtensorModule.Uids.getValue(subnetId, convertPublicKeyToSs58(hotkey.publicKey)))! + console.info(`UID: ${uid}`) + // Associate EVM key blockNumber = await api.query.System.Number.getValue(); const blockNumberBytes = u64.enc(BigInt(blockNumber)); From 27bcd46baac7dec5bdef6ca82f14b2f187be152a Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 21 Apr 2025 23:29:58 +0900 Subject: [PATCH 055/226] Fixes --- evm-tests/package-lock.json | 6 +--- evm-tests/test/uid.precompile.lookup.test.ts | 31 ++++---------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/evm-tests/package-lock.json b/evm-tests/package-lock.json index 68fae940bf..ce2766fb4e 100644 --- a/evm-tests/package-lock.json +++ b/evm-tests/package-lock.json @@ -6,7 +6,6 @@ "": { "license": "ISC", "dependencies": { - "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", @@ -33,6 +32,7 @@ ".papi/descriptors": { "name": "@polkadot-api/descriptors", "version": "0.1.0-autogenerated.7914363913476982777", + "extraneous": true, "peerDependencies": { "polkadot-api": "*" } @@ -731,10 +731,6 @@ "@polkadot-api/utils": "0.1.2" } }, - "node_modules/@polkadot-api/descriptors": { - "resolved": ".papi/descriptors", - "link": true - }, "node_modules/@polkadot-api/ink-contracts": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/@polkadot-api/ink-contracts/-/ink-contracts-0.2.6.tgz", diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 0ce5dd7d49..732af65f2f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -11,6 +11,7 @@ import { PolkadotSigner, TypedApi } from "polkadot-api"; import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "../src/contracts/uidLookup" import { keccak256 } from 'ethers'; +import { burnedRegister, forceSetBalanceToSs58Address } from "../src/subtensor"; describe("Test the UID Lookup precompile", () => { // init substrate part @@ -37,38 +38,18 @@ describe("Test the UID Lookup precompile", () => { alice = await getAliceSigner(); // Fund the hotkey account - { - const multiAddress = convertPublicKeyToMultiAddress(hotkey.publicKey) - const internalCall = api.tx.Balances.force_set_balance({ who: multiAddress, new_free: BigInt(1e12) }) - const tx = api.tx.Sudo.sudo({ call: internalCall.decodedCall }) - - await waitForTransactionCompletion(api, tx, alice) - .then(() => { }) - .catch((error) => { console.log(`transaction error ${error}`) }); - } + await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(hotkey.publicKey)) // Fund the coldkey account - { - const multiAddress = convertPublicKeyToMultiAddress(coldkey.publicKey) - const internalCall = api.tx.Balances.force_set_balance({ who: multiAddress, new_free: BigInt(1e12) }) - const tx = api.tx.Sudo.sudo({ call: internalCall.decodedCall }) - - await waitForTransactionCompletion(api, tx, alice) - .then(() => { }) - .catch((error) => { console.log(`transaction error ${error}`) }); - } + await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey)) // Register neuron - const signer = getSignerFromKeypair(coldkey) const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) - const tx = api.tx.SubtensorModule.burned_register({ hotkey: hotkeyAddress, netuid: subnetId }) - await waitForTransactionCompletion(api, tx, signer) - .then(() => { }) - .catch((error) => { console.log(`transaction error ${error}`) }); + await burnedRegister(api, subnetId, hotkeyAddress, coldkey) - uid = (await api.query.SubtensorModule.Uids.getValue(subnetId, convertPublicKeyToSs58(hotkey.publicKey)))! + uid = await api.query.SubtensorModule.Uids.getValue(subnetId, hotkeyAddress) - console.info(`UID: ${uid}`) + assert.notEqual(uid, undefined, "UID should be defined") // Associate EVM key blockNumber = await api.query.System.Number.getValue(); From 41947cf3faea0eabeed5c1195d86dd0759d3378c Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 22 Apr 2025 00:20:04 +0900 Subject: [PATCH 056/226] Fixes --- evm-tests/test/uid.precompile.lookup.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 732af65f2f..ac2370f5d4 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -47,7 +47,7 @@ describe("Test the UID Lookup precompile", () => { const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) await burnedRegister(api, subnetId, hotkeyAddress, coldkey) - uid = await api.query.SubtensorModule.Uids.getValue(subnetId, hotkeyAddress) + uid = (await api.query.SubtensorModule.Uids.getValue(subnetId, hotkeyAddress))! assert.notEqual(uid, undefined, "UID should be defined") From 8621f453f21f080ef410a3546e07fd8b75fc2dba Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 22 Apr 2025 00:53:31 +0900 Subject: [PATCH 057/226] Create new subnet --- evm-tests/test/uid.precompile.lookup.test.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index ac2370f5d4..343673e8b3 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -11,7 +11,7 @@ import { PolkadotSigner, TypedApi } from "polkadot-api"; import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "../src/contracts/uidLookup" import { keccak256 } from 'ethers'; -import { burnedRegister, forceSetBalanceToSs58Address } from "../src/subtensor"; +import { addNewSubnetwork, burnedRegister, forceSetBalanceToSs58Address } from "../src/subtensor"; describe("Test the UID Lookup precompile", () => { // init substrate part @@ -29,7 +29,7 @@ describe("Test the UID Lookup precompile", () => { let blockNumber: number; // init other variable - let subnetId = 0; + let netuid: number; before(async () => { // init variables got from await and async @@ -43,11 +43,14 @@ describe("Test the UID Lookup precompile", () => { // Fund the coldkey account await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey)) + // Add new subnet + netuid = await addNewSubnetwork(api, hotkey, coldkey) + // Register neuron const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) - await burnedRegister(api, subnetId, hotkeyAddress, coldkey) + await burnedRegister(api, netuid, hotkeyAddress, coldkey) - uid = (await api.query.SubtensorModule.Uids.getValue(subnetId, hotkeyAddress))! + uid = (await api.query.SubtensorModule.Uids.getValue(netuid, hotkeyAddress))! assert.notEqual(uid, undefined, "UID should be defined") @@ -59,7 +62,7 @@ describe("Test the UID Lookup precompile", () => { const concatenatedHash = keccak256(concatenatedArray); const signature = await evmWallet.signMessage(concatenatedHash); const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ - netuid: subnetId, + netuid: netuid, hotkey: convertPublicKeyToSs58(hotkey.publicKey), evm_key: convertToFixedSizeBinary(evmWallet.address, 20), block_number: BigInt(blockNumber), @@ -69,7 +72,7 @@ describe("Test the UID Lookup precompile", () => { .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); - const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(subnetId, uid) + const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) }) @@ -79,10 +82,9 @@ describe("Test the UID Lookup precompile", () => { abi: IUIDLookupABI, address: toViemAddress(IUID_LOOKUP_ADDRESS), functionName: "uidLookup", - args: [subnetId, evmWallet.address, 1024] + args: [netuid, evmWallet.address, 1024] }) - console.info(uidArray) assert.notEqual(uidArray, undefined, "UID should be defined") assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`) assert.ok(uidArray.length > 0, "UID array should not be empty") From b6b7473fcf14362fe4941bea4e24153e2aa2f0ae Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 21 Apr 2025 13:35:26 -0400 Subject: [PATCH 058/226] cargo lock --- Cargo.lock | 1425 ++++++++++++++++++++++++++-------------------------- 1 file changed, 718 insertions(+), 707 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce6924d7b4..d7b618fb7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,18 +23,18 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ - "gimli 0.31.0", + "gimli 0.29.0", ] [[package]] -name = "adler2" -version = "2.0.0" +name = "adler" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" @@ -68,7 +68,7 @@ dependencies = [ "cipher 0.4.4", "ctr", "ghash", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", @@ -142,33 +142,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "approx" @@ -200,7 +200,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -381,7 +381,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version 0.4.1", + "rustc_version 0.4.0", "zeroize", ] @@ -545,15 +545,15 @@ checksum = "5d5dde061bd34119e902bbb2d9b90c5692635cf59fb91d582c2b68043f1b8293" [[package]] name = "arrayref" -version = "0.3.9" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" -version = "0.7.6" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" @@ -567,7 +567,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror", + "thiserror 1.0.61", "time", ] @@ -583,7 +583,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror", + "thiserror 1.0.61", "time", ] @@ -607,7 +607,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", "synstructure 0.13.1", ] @@ -630,7 +630,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -652,9 +652,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.4" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" dependencies = [ "async-lock", "cfg-if", @@ -663,10 +663,10 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 0.38.37", + "rustix 0.38.34", "slab", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -682,13 +682,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -732,34 +732,34 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "autocfg" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ - "addr2line 0.24.1", + "addr2line 0.22.0", + "cc", "cfg-if", "libc", "miniz_oxide", - "object 0.36.4", + "object 0.36.0", "rustc-demangle", - "windows-targets 0.52.6", ] [[package]] @@ -819,13 +819,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.22", + "prettyplease 0.2.20", "proc-macro2", "quote", "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -852,9 +852,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitvec" @@ -913,9 +913,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.4" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" dependencies = [ "arrayref", "arrayvec", @@ -998,9 +998,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -1010,9 +1010,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "bzip2-sys" @@ -1037,9 +1037,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.9" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] @@ -1064,7 +1064,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -1075,9 +1075,9 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.2.16" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" dependencies = [ "jobserver", "libc", @@ -1160,7 +1160,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-targets 0.52.5", ] [[package]] @@ -1222,9 +1222,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.19" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -1232,9 +1232,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.19" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -1245,21 +1245,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "codespan-reporting" @@ -1273,9 +1273,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "combine" @@ -1293,7 +1293,7 @@ version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ - "strum 0.26.3", + "strum 0.26.2", "strum_macros 0.26.4", "unicode-width", ] @@ -1354,9 +1354,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "constcat" @@ -1382,9 +1382,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.7" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core2" @@ -1406,9 +1406,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -1583,7 +1583,7 @@ checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array 0.14.7", "rand_core", - "subtle 2.6.1", + "subtle 2.6.0", "zeroize", ] @@ -1615,7 +1615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.7", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -1638,8 +1638,8 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version 0.4.1", - "subtle 2.6.1", + "rustc_version 0.4.0", + "subtle 2.6.0", "zeroize", ] @@ -1651,14 +1651,14 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "cxx" -version = "1.0.128" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ccead7d199d584d139148b04b4a368d1ec7556a1d9ea2548febb1b9d49f9a4" +checksum = "273dcfd3acd4e1e276af13ed2a43eea7001318823e7a726a6b3ed39b4acc0b82" dependencies = [ "cc", "cxxbridge-flags", @@ -1668,9 +1668,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.128" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77953e99f01508f89f55c494bfa867171ef3a6c8cea03d26975368f2121a5c1" +checksum = "d8b2766fbd92be34e9ed143898fce6c572dc009de39506ed6903e5a05b68914e" dependencies = [ "cc", "codespan-reporting", @@ -1678,31 +1678,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "cxxbridge-flags" -version = "1.0.128" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65777e06cc48f0cb0152024c77d6cf9e4bdb4408e7b48bea993d42fa0f5b02b6" +checksum = "839fcd5e43464614ffaa989eaf1c139ef1f0c51672a1ed08023307fa1b909ccd" [[package]] name = "cxxbridge-macro" -version = "1.0.128" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98532a60dedaebc4848cb2cba5023337cc9ea3af16a5b062633fabfd9f18fb60" +checksum = "4b2c1c1776b986979be68bb2285da855f8d8a35851a769fca8740df7c3d07877" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "darling" -version = "0.20.10" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ "darling_core", "darling_macro", @@ -1710,27 +1710,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.10" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "darling_macro" -version = "0.20.10" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -1839,7 +1839,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -1851,8 +1851,8 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.1", - "syn 2.0.90", + "rustc_version 0.4.0", + "syn 2.0.100", ] [[package]] @@ -1888,7 +1888,7 @@ dependencies = [ "block-buffer 0.10.4", "const-oid", "crypto-common", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -1941,7 +1941,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -1965,9 +1965,9 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.90", + "syn 2.0.100", "termcolor", - "toml 0.8.19", + "toml 0.8.14", "walkdir", ] @@ -2052,7 +2052,7 @@ dependencies = [ "rand_core", "serde", "sha2 0.10.8", - "subtle 2.6.1", + "subtle 2.6.0", "zeroize", ] @@ -2073,9 +2073,9 @@ dependencies = [ [[package]] name = "either" -version = "1.13.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" dependencies = [ "serde", ] @@ -2096,7 +2096,7 @@ dependencies = [ "rand_core", "sec1", "serdect", - "subtle 2.6.1", + "subtle 2.6.0", "zeroize", ] @@ -2127,7 +2127,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -2147,7 +2147,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -2337,10 +2337,10 @@ dependencies = [ "blake2 0.10.6", "file-guard", "fs-err", - "prettyplease 0.2.22", + "prettyplease 0.2.20", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -2357,9 +2357,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fc-api" @@ -2386,7 +2386,7 @@ dependencies = [ "sp-block-builder", "sp-consensus", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -2492,7 +2492,7 @@ dependencies = [ "sp-storage 21.0.0", "sp-timestamp", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", "tokio", ] @@ -2535,7 +2535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -2545,7 +2545,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -2576,14 +2576,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.25" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "libredox", - "windows-sys 0.59.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -2648,9 +2648,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "foreign-types" @@ -2691,7 +2691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9" dependencies = [ "nonempty", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -2864,7 +2864,7 @@ dependencies = [ "sp-storage 21.0.0", "sp-trie", "sp-wasm-interface 21.0.1", - "thiserror", + "thiserror 1.0.61", "thousands", ] @@ -2971,7 +2971,7 @@ dependencies = [ "proc-macro2", "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -2981,10 +2981,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3363df38464c47a73eb521a4f648bfcc7537a82d70347ef8af3f73b6d019e910" dependencies = [ "frame-support-procedural-tools-derive 11.0.0", - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -2993,10 +2993,10 @@ version = "13.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ "frame-support-procedural-tools-derive 12.0.0", - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -3007,7 +3007,7 @@ checksum = "68672b9ec6fe72d259d3879dc212c5e42e977588cdac830c76f54d9f492aeb58" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -3017,7 +3017,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -3102,9 +3102,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -3127,9 +3127,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -3137,15 +3137,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -3166,9 +3166,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -3182,13 +3182,13 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -3203,15 +3203,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -3221,9 +3221,9 @@ checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -3330,9 +3330,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "glob" @@ -3368,7 +3368,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -3383,7 +3383,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.6.0", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -3392,17 +3392,17 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "http 1.1.0", - "indexmap 2.6.0", + "http 1.3.1", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -3426,7 +3426,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -3494,11 +3494,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.2", ] [[package]] @@ -3618,9 +3618,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -3645,27 +3645,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.3.1", ] [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", - "futures-util", - "http 1.1.0", + "futures-core", + "http 1.3.1", "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.9.5" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -3681,9 +3681,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -3705,15 +3705,15 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", - "http 1.1.0", + "h2 0.4.9", + "http 1.3.1", "http-body 1.0.1", "httparse", "httpdate", @@ -3731,7 +3731,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.29", "log", "rustls 0.21.12", "rustls-native-certs", @@ -3741,15 +3741,15 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.3.1", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.6.0", "pin-project-lite", "tokio", "tower-service", @@ -3757,9 +3757,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.61" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3855,7 +3855,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.29", "log", "rand", "tokio", @@ -3933,12 +3933,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown 0.14.5", ] [[package]] @@ -3999,26 +3999,26 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.13" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.4.0", + "hermit-abi 0.3.9", "libc", "windows-sys 0.52.0", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "itertools" @@ -4055,27 +4055,27 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5c71d8c1a731cc4227c2f698d377e7848ca12c8a48866fc5e6951c43a4db843" +checksum = "37b26c20e2178756451cfeb0661fb74c47dd5988cb7e3939de7e9241fd604d42" dependencies = [ "jsonrpsee-core", "jsonrpsee-proc-macros", @@ -4087,51 +4087,51 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2882f6f8acb9fdaec7cefc4fd607119a9bd709831df7d7672a1d3b644628280" +checksum = "456196007ca3a14db478346f58c7238028d55ee15c1df15115596e411ff27925" dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.1.0", + "http 1.3.1", "http-body 1.0.1", "http-body-util", "jsonrpsee-types", "parking_lot 0.12.3", "rand", - "rustc-hash 2.0.0", + "rustc-hash 2.1.1", "serde", "serde_json", - "thiserror", + "thiserror 1.0.61", "tokio", "tracing", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06c01ae0007548e73412c08e2285ffe5d723195bf268bce67b1b77c3bb2a14d" +checksum = "5e65763c942dfc9358146571911b0cd1c361c2d63e2d2305622d40d36376ca80" dependencies = [ "heck 0.5.0", - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "jsonrpsee-server" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82ad8ddc14be1d4290cd68046e7d1d37acd408efed6d3ca08aefcc3ad6da069c" +checksum = "55e363146da18e50ad2b51a0a7925fc423137a0b1371af8235b1c231a0647328" dependencies = [ "futures-util", - "http 1.1.0", + "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.6.0", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", @@ -4140,7 +4140,7 @@ dependencies = [ "serde", "serde_json", "soketto", - "thiserror", + "thiserror 1.0.61", "tokio", "tokio-stream", "tokio-util", @@ -4150,21 +4150,21 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a178c60086f24cc35bb82f57c651d0d25d99c4742b4d335de04e97fa1f08a8a1" +checksum = "08a8e70baf945b6b5752fc8eb38c918a48f1234daf11355e07106d963f860089" dependencies = [ - "http 1.1.0", + "http 1.3.1", "serde", "serde_json", - "thiserror", + "thiserror 1.0.61", ] [[package]] name = "k256" -version = "0.13.4" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -4224,9 +4224,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.5.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" @@ -4236,18 +4236,18 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.52.5", ] [[package]] @@ -4290,7 +4290,7 @@ dependencies = [ "multiaddr 0.18.2", "pin-project", "rw-stream-sink", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -4331,7 +4331,7 @@ dependencies = [ "libp2p-identity", "log", "multiaddr 0.18.2", - "multihash 0.19.2", + "multihash 0.19.3", "multistream-select", "once_cell", "parking_lot 0.12.3", @@ -4340,7 +4340,7 @@ dependencies = [ "rand", "rw-stream-sink", "smallvec", - "thiserror", + "thiserror 1.0.61", "unsigned-varint 0.7.2", "void", ] @@ -4380,24 +4380,24 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "smallvec", - "thiserror", + "thiserror 1.0.61", "void", ] [[package]] name = "libp2p-identity" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cca1eb2bc1fd29f099f3daaab7effd01e1a54b7c577d0ed082521034d912e8" +checksum = "257b5621d159b32282eac446bed6670c39c7dc68a200a992d8f056afa0066f6d" dependencies = [ "bs58 0.5.1", "ed25519-dalek", "hkdf", - "multihash 0.19.2", + "multihash 0.19.3", "quick-protobuf", "rand", "sha2 0.10.8", - "thiserror", + "thiserror 1.0.61", "tracing", "zeroize", ] @@ -4425,7 +4425,7 @@ dependencies = [ "rand", "sha2 0.10.8", "smallvec", - "thiserror", + "thiserror 1.0.61", "uint", "unsigned-varint 0.7.2", "void", @@ -4482,14 +4482,14 @@ dependencies = [ "libp2p-identity", "log", "multiaddr 0.18.2", - "multihash 0.19.2", + "multihash 0.19.3", "once_cell", "quick-protobuf", "rand", "sha2 0.10.8", "snow", "static_assertions", - "thiserror", + "thiserror 1.0.61", "x25519-dalek", "zeroize", ] @@ -4532,7 +4532,7 @@ dependencies = [ "ring 0.16.20", "rustls 0.21.12", "socket2 0.5.7", - "thiserror", + "thiserror 1.0.61", "tokio", ] @@ -4587,7 +4587,7 @@ dependencies = [ "proc-macro-warning 0.4.2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -4621,7 +4621,7 @@ dependencies = [ "ring 0.16.20", "rustls 0.21.12", "rustls-webpki", - "thiserror", + "thiserror 1.0.61", "x509-parser 0.15.1", "yasna", ] @@ -4672,7 +4672,7 @@ dependencies = [ "pin-project-lite", "rw-stream-sink", "soketto", - "thiserror", + "thiserror 1.0.61", "url", "webpki-roots", ] @@ -4686,7 +4686,7 @@ dependencies = [ "futures", "libp2p-core", "log", - "thiserror", + "thiserror 1.0.61", "yamux", ] @@ -4696,9 +4696,8 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", "libc", - "redox_syscall 0.5.7", ] [[package]] @@ -4743,7 +4742,7 @@ checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" dependencies = [ "crunchy", "digest 0.9.0", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -4777,9 +4776,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.20" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +checksum = "c15da26e5af7e25c90b37a2d75cdbf940cf4a55316de9d84c679c9b8bfabf82e" dependencies = [ "cc", "pkg-config", @@ -4857,7 +4856,7 @@ dependencies = [ "futures", "futures-timer", "hex-literal", - "indexmap 2.6.0", + "indexmap 2.2.6", "libc", "mockall 0.12.1", "multiaddr 0.17.1", @@ -4881,7 +4880,7 @@ dependencies = [ "socket2 0.5.7", "static_assertions", "str0m", - "thiserror", + "thiserror 1.0.61", "tokio", "tokio-stream", "tokio-tungstenite", @@ -4910,9 +4909,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" @@ -4943,18 +4942,19 @@ dependencies = [ [[package]] name = "lz4" -version = "1.28.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725" +checksum = "d6eab492fe7f8651add23237ea56dbf11b3c4ff762ab83d40a47f11433421f91" dependencies = [ + "libc", "lz4-sys", ] [[package]] name = "lz4-sys" -version = "1.11.1+lz4-1.10.0" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" +checksum = "e9764018d143cc854c9f17f0b907de70f14393b1f502da6375dce70f00514eb3" dependencies = [ "cc", "libc", @@ -4978,7 +4978,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -4992,7 +4992,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -5003,7 +5003,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -5014,7 +5014,7 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -5040,9 +5040,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.9" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ "autocfg", "rawpointer", @@ -5060,7 +5060,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.37", + "rustix 0.38.34", ] [[package]] @@ -5074,9 +5074,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -5133,23 +5133,22 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ - "adler2", + "adler", ] [[package]] name = "mio" -version = "1.0.2" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ - "hermit-abi 0.3.9", "libc", "wasi", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] @@ -5172,8 +5171,8 @@ dependencies = [ "rand", "rand_chacha", "rand_distr", - "subtle 2.6.1", - "thiserror", + "subtle 2.6.0", + "thiserror 1.0.61", "zeroize", ] @@ -5203,7 +5202,7 @@ dependencies = [ "fragile", "lazy_static", "mockall_derive 0.12.1", - "predicates 3.1.2", + "predicates 3.1.3", "predicates-tree", ] @@ -5228,7 +5227,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -5261,7 +5260,7 @@ dependencies = [ "data-encoding", "libp2p-identity", "multibase", - "multihash 0.19.2", + "multihash 0.19.3", "percent-encoding", "serde", "static_assertions", @@ -5316,9 +5315,9 @@ dependencies = [ [[package]] name = "multihash" -version = "0.19.2" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc41f430805af9d1cf4adae4ed2149c759b877b01d909a1f40256188d09345d2" +checksum = "6b430e7953c29dd6a09afc29ff0bb69c6e306329ee6794700aee27b76a1aea8d" dependencies = [ "core2", "unsigned-varint 0.8.0", @@ -5376,13 +5375,13 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 1.0.109", ] [[package]] @@ -5396,9 +5395,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" dependencies = [ "libc", "log", @@ -5459,7 +5458,7 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -5473,7 +5472,7 @@ dependencies = [ "log", "netlink-packet-core", "netlink-sys", - "thiserror", + "thiserror 1.0.61", "tokio", ] @@ -5498,7 +5497,7 @@ checksum = "a4a43439bf756eed340bdf8feba761e2d50c7d47175d87545cd5cbe4a137c4d1" dependencies = [ "cc", "libc", - "thiserror", + "thiserror 1.0.61", "winapi", ] @@ -5542,7 +5541,7 @@ dependencies = [ "futures", "hex", "jsonrpsee", - "memmap2 0.9.5", + "memmap2 0.9.4", "node-subtensor-runtime", "num-traits", "pallet-commitments", @@ -5598,7 +5597,7 @@ dependencies = [ "subtensor-custom-rpc", "subtensor-custom-rpc-runtime-api", "subtensor-runtime-common", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -5742,9 +5741,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.6" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ "num-integer", "num-traits", @@ -5841,10 +5840,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -5870,9 +5869,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -5897,12 +5896,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -5922,7 +5918,7 @@ version = "0.10.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -5939,7 +5935,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -5950,9 +5946,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.4.0+3.4.0" +version = "300.5.0+3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" +checksum = "e8ce546f549326b0e6052b649198487d91320875da901e7bd11a06d1ee3f9c2f" dependencies = [ "cc", ] @@ -6659,7 +6655,7 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", @@ -6702,9 +6698,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.2.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -6749,9 +6745,9 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.7", + "redox_syscall 0.5.2", "smallvec", - "windows-targets 0.52.6", + "windows-targets 0.52.5", ] [[package]] @@ -6768,7 +6764,7 @@ checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", "rand_core", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -6810,20 +6806,20 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.13" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.61", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.13" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -6831,22 +6827,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.13" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "pest_meta" -version = "2.7.13" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -6860,7 +6856,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.6.0", + "indexmap 2.2.6", ] [[package]] @@ -6880,7 +6876,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -6907,9 +6903,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "polkavm" @@ -6960,7 +6956,7 @@ dependencies = [ "polkavm-common", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -6970,7 +6966,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ "polkavm-derive-impl", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -6996,17 +6992,17 @@ checksum = "26e85d3456948e650dff0cfc85603915847faf893ed1e66b020bb82ef4557120" [[package]] name = "polling" -version = "3.7.3" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.37", + "rustix 0.38.34", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -7034,9 +7030,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "powerfmt" @@ -7046,12 +7042,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "precompile-utils" @@ -7084,7 +7077,7 @@ source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac88233 dependencies = [ "case", "num_enum", - "prettyplease 0.2.22", + "prettyplease 0.2.20", "proc-macro2", "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", @@ -7107,9 +7100,9 @@ dependencies = [ [[package]] name = "predicates" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" dependencies = [ "anstyle", "predicates-core", @@ -7117,15 +7110,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.8" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.11" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -7143,12 +7136,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -7171,17 +7164,17 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "thiserror", + "thiserror 1.0.61", "toml 0.5.11", ] [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit", + "toml_edit 0.21.1", ] [[package]] @@ -7216,7 +7209,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -7227,14 +7220,14 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -7255,7 +7248,7 @@ dependencies = [ "quote", "regex", "sp-crypto-hashing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -7269,7 +7262,7 @@ dependencies = [ "lazy_static", "memchr", "parking_lot 0.12.3", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -7292,7 +7285,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -7350,11 +7343,11 @@ dependencies = [ "multimap", "once_cell", "petgraph", - "prettyplease 0.2.22", + "prettyplease 0.2.20", "prost 0.12.6", "prost-types 0.12.6", "regex", - "syn 2.0.90", + "syn 2.0.100", "tempfile", ] @@ -7381,7 +7374,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -7404,9 +7397,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.23" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" dependencies = [ "cc", ] @@ -7450,7 +7443,7 @@ dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", - "thiserror", + "thiserror 1.0.61", "unsigned-varint 0.7.2", ] @@ -7466,7 +7459,7 @@ dependencies = [ "quinn-udp 0.3.2", "rustc-hash 1.1.0", "rustls 0.20.9", - "thiserror", + "thiserror 1.0.61", "tokio", "tracing", "webpki", @@ -7485,7 +7478,7 @@ dependencies = [ "quinn-udp 0.4.1", "rustc-hash 1.1.0", "rustls 0.21.12", - "thiserror", + "thiserror 1.0.61", "tokio", "tracing", ] @@ -7502,7 +7495,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.20.9", "slab", - "thiserror", + "thiserror 1.0.61", "tinyvec", "tracing", "webpki", @@ -7520,7 +7513,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.21.12", "slab", - "thiserror", + "thiserror 1.0.61", "tinyvec", "tracing", ] @@ -7553,9 +7546,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -7617,11 +7610,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.2.0" +version = "11.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" +checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", ] [[package]] @@ -7673,22 +7666,31 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags 2.6.0", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +dependencies = [ + "bitflags 2.5.0", ] [[package]] name = "redox_users" -version = "0.4.6" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -7708,7 +7710,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -7738,14 +7740,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", - "regex-syntax 0.8.5", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -7759,13 +7761,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax 0.8.4", ] [[package]] @@ -7776,9 +7778,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "resolv-conf" @@ -7797,7 +7799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ "hmac 0.12.1", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -7817,14 +7819,15 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.13" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", "getrandom", "libc", + "spin 0.9.8", "untrusted 0.9.0", "windows-sys 0.52.0", ] @@ -7898,7 +7901,7 @@ dependencies = [ "netlink-packet-route", "netlink-proto", "nix", - "thiserror", + "thiserror 1.0.61", "tokio", ] @@ -7926,9 +7929,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustc-hex" @@ -7947,9 +7950,9 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ "semver 1.0.23", ] @@ -7979,11 +7982,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys 0.4.14", @@ -8008,7 +8011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", - "ring 0.17.13", + "ring 0.17.8", "rustls-webpki", "sct", ] @@ -8040,7 +8043,7 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.13", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -8111,7 +8114,7 @@ dependencies = [ "log", "sp-core", "sp-wasm-interface 21.0.1", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8159,7 +8162,7 @@ dependencies = [ "array-bytes", "docify", "log", - "memmap2 0.9.5", + "memmap2 0.9.4", "parity-scale-codec", "sc-chain-spec-derive", "sc-client-api", @@ -8183,10 +8186,10 @@ name = "sc-chain-spec-derive" version = "12.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -8226,7 +8229,7 @@ dependencies = [ "sp-panic-handler", "sp-runtime", "sp-version", - "thiserror", + "thiserror 1.0.61", "tokio", ] @@ -8304,7 +8307,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8333,7 +8336,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8369,7 +8372,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8426,7 +8429,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8446,7 +8449,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8481,7 +8484,7 @@ dependencies = [ "sp-runtime", "sp-timestamp", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8539,7 +8542,7 @@ dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface 21.0.1", - "thiserror", + "thiserror 1.0.61", "wasm-instrument", ] @@ -8600,7 +8603,7 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-keystore", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8629,7 +8632,7 @@ dependencies = [ "sp-keystore", "sp-mixnet", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8674,7 +8677,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", "tokio", "tokio-stream", "unsigned-varint 0.7.2", @@ -8738,7 +8741,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8773,7 +8776,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", "tokio", "tokio-stream", ] @@ -8808,9 +8811,9 @@ dependencies = [ "litep2p", "log", "multiaddr 0.18.2", - "multihash 0.19.2", + "multihash 0.19.3", "rand", - "thiserror", + "thiserror 1.0.61", "zeroize", ] @@ -8824,7 +8827,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "hyper 0.14.30", + "hyper 0.14.29", "hyper-rustls", "log", "num_cpus", @@ -8906,7 +8909,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -8918,9 +8921,9 @@ dependencies = [ "forwarded-header-value", "futures", "governor", - "http 1.1.0", + "http 1.3.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.6.0", "ip_network", "jsonrpsee", "log", @@ -8960,7 +8963,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror", + "thiserror 1.0.61", "tokio", "tokio-stream", ] @@ -9023,7 +9026,7 @@ dependencies = [ "static_init", "substrate-prometheus-endpoint", "tempfile", - "thiserror", + "thiserror 1.0.61", "tokio", "tracing", "tracing-futures", @@ -9077,7 +9080,7 @@ dependencies = [ "sc-utils", "serde", "serde_json", - "thiserror", + "thiserror 1.0.61", "wasm-timer", ] @@ -9104,7 +9107,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-tracing 17.0.1", - "thiserror", + "thiserror 1.0.61", "tracing", "tracing-log", "tracing-subscriber 0.3.18", @@ -9115,10 +9118,10 @@ name = "sc-tracing-proc-macro" version = "11.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -9145,7 +9148,7 @@ dependencies = [ "sp-tracing 17.0.1", "sp-transaction-pool", "substrate-prometheus-endpoint", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -9161,7 +9164,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -9222,7 +9225,7 @@ version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", @@ -9236,11 +9239,11 @@ checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -9269,7 +9272,7 @@ dependencies = [ "rand_core", "serde_bytes", "sha2 0.10.8", - "subtle 2.6.1", + "subtle 2.6.0", "zeroize", ] @@ -9291,7 +9294,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.13", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -9307,7 +9310,7 @@ dependencies = [ "log", "rand", "slab", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -9321,7 +9324,7 @@ dependencies = [ "generic-array 0.14.7", "pkcs8", "serdect", - "subtle 2.6.1", + "subtle 2.6.0", "zeroize", ] @@ -9354,11 +9357,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -9367,9 +9370,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -9416,9 +9419,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.216" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -9434,9 +9437,9 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.15" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ "serde", ] @@ -9453,20 +9456,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -9476,9 +9479,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -9520,7 +9523,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -9661,7 +9664,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cae9a3fcdadafb6d97f4c0e007e4247b114ee0f119f650c3cbf3a8b3a1479694" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", ] [[package]] @@ -9714,10 +9717,10 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek", "rand_core", - "ring 0.17.13", - "rustc_version 0.4.1", + "ring 0.17.8", + "rustc_version 0.4.0", "sha2 0.10.8", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -9742,14 +9745,14 @@ dependencies = [ [[package]] name = "soketto" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" +checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721" dependencies = [ "base64 0.22.1", "bytes", "futures", - "http 1.1.0", + "http 1.3.1", "httparse", "log", "rand", @@ -9775,7 +9778,7 @@ dependencies = [ "sp-state-machine", "sp-trie", "sp-version", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -9786,10 +9789,10 @@ dependencies = [ "Inflector", "blake2 0.10.6", "expander", - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -9821,7 +9824,7 @@ dependencies = [ [[package]] name = "sp-ark-bls12-381" version = "0.4.2" -source = "git+https://github.com/paritytech/substrate-curves#caa2eed74beb885dd07c7db5f916f2281dad818f" +source = "git+https://github.com/paritytech/substrate-curves#f08093a5f7c32778eae1295430ec064dccd062a6" dependencies = [ "ark-bls12-381-ext", "sp-crypto-ec-utils 0.10.0", @@ -9852,7 +9855,7 @@ dependencies = [ "sp-database", "sp-runtime", "sp-state-machine", - "thiserror", + "thiserror 1.0.61", "tracing", ] @@ -9868,7 +9871,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -9973,7 +9976,7 @@ dependencies = [ "sp-storage 21.0.0", "ss58-registry", "substrate-bip39", - "thiserror", + "thiserror 1.0.61", "tracing", "w3f-bls", "zeroize", @@ -9982,7 +9985,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -10053,7 +10056,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -10072,23 +10075,23 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "environmental", "parity-scale-codec", @@ -10127,7 +10130,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -10163,7 +10166,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "sp-core", "sp-runtime", - "strum 0.26.3", + "strum 0.26.2", ] [[package]] @@ -10182,7 +10185,7 @@ name = "sp-maybe-compressed-blob" version = "11.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "thiserror", + "thiserror 1.0.61", "zstd 0.12.4", ] @@ -10266,7 +10269,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10304,14 +10307,14 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "Inflector", "expander", - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -10321,10 +10324,10 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "Inflector", "expander", - "proc-macro-crate 3.2.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -10369,7 +10372,7 @@ dependencies = [ "sp-externalities 0.29.0", "sp-panic-handler", "sp-trie", - "thiserror", + "thiserror 1.0.61", "tracing", "trie-db", ] @@ -10394,7 +10397,7 @@ dependencies = [ "sp-externalities 0.29.0", "sp-runtime", "sp-runtime-interface 28.0.0", - "thiserror", + "thiserror 1.0.61", "x25519-dalek", ] @@ -10406,12 +10409,12 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10441,13 +10444,13 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "thiserror", + "thiserror 1.0.61", ] [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ "parity-scale-codec", "tracing", @@ -10506,7 +10509,7 @@ dependencies = [ "schnellru", "sp-core", "sp-externalities 0.29.0", - "thiserror", + "thiserror 1.0.61", "tracing", "trie-db", "trie-root", @@ -10526,7 +10529,7 @@ dependencies = [ "sp-runtime", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", "sp-version-proc-macro", - "thiserror", + "thiserror 1.0.61", ] [[package]] @@ -10537,15 +10540,14 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" +source = "git+https://github.com/paritytech/polkadot-sdk#c4b3c1c6c6e492c4196e06fbba824a58e8119a3b" dependencies = [ - "anyhow", "impl-trait-for-tuples", "log", "parity-scale-codec", @@ -10611,21 +10613,11 @@ dependencies = [ "der", ] -[[package]] -name = "sqlformat" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790" -dependencies = [ - "nom", - "unicode_categories", -] - [[package]] name = "sqlx" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" +checksum = "f3c3a85280daca669cfd3bcb68a337882a8bc57ec882f72c5d13a430613a738e" dependencies = [ "sqlx-core", "sqlx-macros", @@ -10634,37 +10626,32 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" +checksum = "f743f2a3cea30a58cd479013f75550e879009e3a02f616f18ca699335aa248c3" dependencies = [ - "atoi", - "byteorder", + "base64 0.22.1", "bytes", "crc", "crossbeam-queue", "either", "event-listener 5.3.1", - "futures-channel", "futures-core", "futures-intrusive", "futures-io", "futures-util", - "hashbrown 0.14.5", - "hashlink 0.9.1", - "hex", - "indexmap 2.6.0", + "hashbrown 0.15.2", + "hashlink 0.10.0", + "indexmap 2.2.6", "log", "memchr", "native-tls", "once_cell", - "paste", "percent-encoding", "serde", "sha2 0.10.8", "smallvec", - "sqlformat", - "thiserror", + "thiserror 2.0.12", "tokio", "tokio-stream", "tracing", @@ -10673,22 +10660,22 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" +checksum = "7f4200e0fde19834956d4252347c12a083bdcb237d7a1a1446bffd8768417dce" dependencies = [ "proc-macro2", "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "sqlx-macros-core" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" +checksum = "882ceaa29cade31beca7129b6beeb05737f44f82dbe2a9806ecea5a7093d00b7" dependencies = [ "dotenvy", "either", @@ -10702,7 +10689,7 @@ dependencies = [ "sha2 0.10.8", "sqlx-core", "sqlx-sqlite", - "syn 2.0.90", + "syn 2.0.100", "tempfile", "tokio", "url", @@ -10710,9 +10697,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" +checksum = "c26083e9a520e8eb87a06b12347679b142dc2ea29e6e409f805644a7a979a5bc" dependencies = [ "atoi", "flume", @@ -10727,15 +10714,16 @@ dependencies = [ "serde", "serde_urlencoded", "sqlx-core", + "thiserror 2.0.12", "tracing", "url", ] [[package]] name = "ss58-registry" -version = "1.50.0" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43fce22ed1df64d04b262351c8f9d5c6da4f76f79f25ad15529792f893fad25d" +checksum = "4743ce898933fbff7bbf414f497c459a782d496269644b3d650a398ae6a487ba" dependencies = [ "Inflector", "num-format", @@ -10821,7 +10809,7 @@ dependencies = [ "sctp-proto", "serde", "sha-1", - "thiserror", + "thiserror 1.0.61", "tracing", ] @@ -10839,9 +10827,9 @@ checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum" -version = "0.26.3" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ "strum_macros 0.26.4", ] @@ -10869,7 +10857,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -10926,11 +10914,11 @@ version = "0.17.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ "http-body-util", - "hyper 1.5.0", + "hyper 1.6.0", "hyper-util", "log", "prometheus", - "thiserror", + "thiserror 1.0.61", "tokio", ] @@ -10956,9 +10944,9 @@ dependencies = [ "sp-maybe-compressed-blob", "sp-tracing 17.0.1", "sp-version", - "strum 0.26.3", + "strum 0.26.2", "tempfile", - "toml 0.8.19", + "toml 0.8.14", "walkdir", "wasm-opt", ] @@ -10973,7 +10961,7 @@ dependencies = [ "quote", "rayon", "subtensor-linting", - "syn 2.0.90", + "syn 2.0.100", "walkdir", ] @@ -11011,7 +10999,7 @@ dependencies = [ "proc-macro2", "procedural-fork", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -11021,7 +11009,7 @@ dependencies = [ "ahash 0.8.11", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -11066,7 +11054,7 @@ dependencies = [ "anyhow", "clap", "semver 1.0.23", - "toml_edit", + "toml_edit 0.22.14", ] [[package]] @@ -11077,9 +11065,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.6.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "syn" @@ -11094,9 +11082,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -11123,7 +11111,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -11155,21 +11143,20 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.16" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tempfile" -version = "3.13.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "once_cell", - "rustix 0.38.37", - "windows-sys 0.59.0", + "rustix 0.38.34", + "windows-sys 0.52.0", ] [[package]] @@ -11183,12 +11170,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.37", - "windows-sys 0.59.0", + "rustix 0.38.34", + "windows-sys 0.48.0", ] [[package]] @@ -11199,22 +11186,42 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl 1.0.61", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ - "thiserror-impl", + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -11294,9 +11301,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] @@ -11337,31 +11344,32 @@ dependencies = [ [[package]] name = "tokio" -version = "1.40.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", "libc", "mio", + "num_cpus", "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", "socket2 0.5.7", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -11376,9 +11384,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -11403,9 +11411,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -11426,36 +11434,47 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.22.14", ] [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +dependencies = [ + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.13", ] [[package]] @@ -11479,9 +11498,9 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.5.0", "bytes", - "http 1.1.0", + "http 1.3.1", "http-body 1.0.1", "http-body-util", "pin-project-lite", @@ -11491,15 +11510,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" [[package]] name = "tower-service" -version = "0.3.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" @@ -11521,7 +11540,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -11624,7 +11643,7 @@ dependencies = [ "rand", "smallvec", "socket2 0.4.10", - "thiserror", + "thiserror 1.0.61", "tinyvec", "tokio", "tracing", @@ -11649,7 +11668,7 @@ dependencies = [ "once_cell", "rand", "smallvec", - "thiserror", + "thiserror 1.0.61", "tinyvec", "tokio", "tracing", @@ -11671,7 +11690,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror", + "thiserror 1.0.61", "tokio", "tracing", "trust-dns-proto 0.23.2", @@ -11704,7 +11723,7 @@ dependencies = [ "rand", "rustls 0.21.12", "sha1", - "thiserror", + "thiserror 1.0.61", "url", "utf-8", ] @@ -11738,9 +11757,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -11756,15 +11775,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.17" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -11777,21 +11796,15 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.14" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - -[[package]] -name = "unicode_categories" -version = "0.1.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" @@ -11800,7 +11813,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", - "subtle 2.6.1", + "subtle 2.6.0", ] [[package]] @@ -11874,9 +11887,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -11904,7 +11917,7 @@ dependencies = [ "rand_core", "sha2 0.10.8", "sha3", - "thiserror", + "thiserror 1.0.61", "zeroize", ] @@ -11935,35 +11948,34 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", - "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -11973,9 +11985,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -11983,22 +11995,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-instrument" @@ -12020,7 +12032,7 @@ dependencies = [ "strum 0.24.1", "strum_macros 0.24.3", "tempfile", - "thiserror", + "thiserror 1.0.61", "wasm-opt-cxx-sys", "wasm-opt-sys", ] @@ -12147,7 +12159,7 @@ dependencies = [ "log", "object 0.30.4", "target-lexicon", - "thiserror", + "thiserror 1.0.61", "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", @@ -12182,7 +12194,7 @@ dependencies = [ "object 0.30.4", "serde", "target-lexicon", - "thiserror", + "thiserror 1.0.61", "wasmparser", "wasmtime-types", ] @@ -12265,15 +12277,15 @@ checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", - "thiserror", + "thiserror 1.0.61", "wasmparser", ] [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -12285,7 +12297,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.13", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -12304,14 +12316,14 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.37", + "rustix 0.38.34", ] [[package]] name = "wide" -version = "0.7.28" +version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b828f995bf1e9622031f8009f8481a85406ce1f4d4588ff746d872043e855690" +checksum = "8a040b111774ab63a19ef46bbc149398ab372b4ccdcfd719e9814dbd7dfd76c8" dependencies = [ "bytemuck", "safe_arch", @@ -12341,11 +12353,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -12379,7 +12391,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.52.5", ] [[package]] @@ -12421,16 +12433,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.52.5", ] [[package]] @@ -12465,18 +12468,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -12493,9 +12496,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -12511,9 +12514,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -12529,15 +12532,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] name = "windows_i686_gnullvm" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -12553,9 +12556,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -12571,9 +12574,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -12589,9 +12592,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -12607,15 +12610,24 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.6" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.20" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -12664,7 +12676,7 @@ dependencies = [ "nom", "oid-registry 0.6.1", "rusticata-macros", - "thiserror", + "thiserror 1.0.61", "time", ] @@ -12681,7 +12693,7 @@ dependencies = [ "nom", "oid-registry 0.7.1", "rusticata-macros", - "thiserror", + "thiserror 1.0.61", "time", ] @@ -12693,14 +12705,14 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] name = "xml-rs" -version = "0.8.22" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" +checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda" [[package]] name = "xmltree" @@ -12737,23 +12749,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ - "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -12773,7 +12784,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.100", ] [[package]] @@ -12816,9 +12827,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" +version = "2.0.11+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" dependencies = [ "cc", "pkg-config", From 8fdee515a6ad8d92bd2f5a3b1e4d07d2d62aa255 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 21 Apr 2025 13:35:35 -0400 Subject: [PATCH 059/226] fmt --- pallets/admin-utils/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index f462d5cd14..f1fbcc405d 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1528,11 +1528,11 @@ pub mod pallet { "Yuma3EnableToggled( netuid: {:?}, Enabled: {:?} ) ", netuid, enabled - ); + ); Ok(()) } - /// Enables or disables subtoken trading for a given subnet. + /// Enables or disables subtoken trading for a given subnet. /// /// # Arguments /// * `origin` - The origin of the call, which must be the root account. @@ -1542,11 +1542,11 @@ pub mod pallet { /// # Errors /// * `BadOrigin` - If the caller is not the root account. /// - /// # Weight + /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. - #[pallet::call_index(66)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - pub fn sudo_set_subtoken_enabled( + #[pallet::call_index(66)] + #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + pub fn sudo_set_subtoken_enabled( origin: OriginFor, netuid: u16, subtoken_enabled: bool, From 12527c9a1aa49c469dcad41202a7dc16a09cd83c Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 22 Apr 2025 23:54:32 +0900 Subject: [PATCH 060/226] Fund alice account --- evm-tests/test/uid.precompile.lookup.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 343673e8b3..3abf9cb07f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -37,10 +37,8 @@ describe("Test the UID Lookup precompile", () => { api = await getDevnetApi() alice = await getAliceSigner(); - // Fund the hotkey account + await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(alice.publicKey)) await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(hotkey.publicKey)) - - // Fund the coldkey account await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey)) // Add new subnet From f06fe52896eaced5fc01a0fe80668766f9f71603 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 25 Apr 2025 00:27:25 +0900 Subject: [PATCH 061/226] Refactor --- evm-tests/test/uid.precompile.lookup.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 3abf9cb07f..3dfa25963f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -48,9 +48,10 @@ describe("Test the UID Lookup precompile", () => { const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) await burnedRegister(api, netuid, hotkeyAddress, coldkey) - uid = (await api.query.SubtensorModule.Uids.getValue(netuid, hotkeyAddress))! + const maybeUid = await api.query.SubtensorModule.Uids.getValue(netuid, hotkeyAddress) - assert.notEqual(uid, undefined, "UID should be defined") + assert.notEqual(maybeUid, undefined, "UID should be defined") + uid = maybeUid // Associate EVM key blockNumber = await api.query.System.Number.getValue(); From 1d373e54a6db26fc09621e105ba60eaeb0a2d76c Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 25 Apr 2025 00:55:28 +0900 Subject: [PATCH 062/226] Fixes --- evm-tests/test/uid.precompile.lookup.test.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 3dfa25963f..6609f1d594 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -14,7 +14,6 @@ import { keccak256 } from 'ethers'; import { addNewSubnetwork, burnedRegister, forceSetBalanceToSs58Address } from "../src/subtensor"; describe("Test the UID Lookup precompile", () => { - // init substrate part const hotkey = getRandomSubstrateKeypair(); const coldkey = getRandomSubstrateKeypair(); const evmWallet = generateRandomEthersWallet(); @@ -22,17 +21,13 @@ describe("Test the UID Lookup precompile", () => { let api: TypedApi - // sudo account alice as signer let alice: PolkadotSigner; let uid: number; let blockNumber: number; - - // init other variable let netuid: number; before(async () => { - // init variables got from await and async publicClient = await getPublicClient(ETH_LOCAL_URL) api = await getDevnetApi() alice = await getAliceSigner(); @@ -50,7 +45,9 @@ describe("Test the UID Lookup precompile", () => { const maybeUid = await api.query.SubtensorModule.Uids.getValue(netuid, hotkeyAddress) - assert.notEqual(maybeUid, undefined, "UID should be defined") + if (maybeUid === undefined) { + throw new Error("UID should be defined") + } uid = maybeUid // Associate EVM key From 9a97f26b57c3e1b130544d93aafa454a37d9e288 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 25 Apr 2025 02:07:59 +0900 Subject: [PATCH 063/226] Add startCall --- evm-tests/test/uid.precompile.lookup.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 6609f1d594..9d1fc4a29d 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -1,6 +1,6 @@ import * as assert from "assert"; -import { getAliceSigner, getDevnetApi, waitForTransactionCompletion, convertPublicKeyToMultiAddress, getRandomSubstrateKeypair, getSignerFromKeypair } from "../src/substrate" +import { getAliceSigner, getDevnetApi, waitForTransactionCompletion, getRandomSubstrateKeypair } from "../src/substrate" import { convertToFixedSizeBinary, generateRandomEthersWallet, getPublicClient } from "../src/utils"; import { ETH_LOCAL_URL } from "../src/config"; import { devnet } from "@polkadot-api/descriptors" @@ -11,7 +11,7 @@ import { PolkadotSigner, TypedApi } from "polkadot-api"; import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "../src/contracts/uidLookup" import { keccak256 } from 'ethers'; -import { addNewSubnetwork, burnedRegister, forceSetBalanceToSs58Address } from "../src/subtensor"; +import { addNewSubnetwork, burnedRegister, forceSetBalanceToSs58Address, startCall } from "../src/subtensor"; describe("Test the UID Lookup precompile", () => { const hotkey = getRandomSubstrateKeypair(); @@ -36,8 +36,8 @@ describe("Test the UID Lookup precompile", () => { await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(hotkey.publicKey)) await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey)) - // Add new subnet netuid = await addNewSubnetwork(api, hotkey, coldkey) + await startCall(api, netuid, coldkey) // Register neuron const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) From 61f08945218bedc9114f0bb892a75ad593957538 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 25 Apr 2025 22:51:25 +0900 Subject: [PATCH 064/226] Remove burnedRegister --- evm-tests/test/uid.precompile.lookup.test.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 9d1fc4a29d..88a11f0e5e 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -39,11 +39,7 @@ describe("Test the UID Lookup precompile", () => { netuid = await addNewSubnetwork(api, hotkey, coldkey) await startCall(api, netuid, coldkey) - // Register neuron - const hotkeyAddress = convertPublicKeyToSs58(hotkey.publicKey) - await burnedRegister(api, netuid, hotkeyAddress, coldkey) - - const maybeUid = await api.query.SubtensorModule.Uids.getValue(netuid, hotkeyAddress) + const maybeUid = await api.query.SubtensorModule.Uids.getValue(netuid, convertPublicKeyToSs58(hotkey.publicKey)) if (maybeUid === undefined) { throw new Error("UID should be defined") From e01fc60d33ef36be11d4a44e12d6596544c5d4f8 Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 28 Apr 2025 15:21:53 +0900 Subject: [PATCH 065/226] Remove unusued dependency --- evm-tests/test/uid.precompile.lookup.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 88a11f0e5e..f3cdd0531f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -11,7 +11,7 @@ import { PolkadotSigner, TypedApi } from "polkadot-api"; import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" import { IUIDLookupABI, IUID_LOOKUP_ADDRESS } from "../src/contracts/uidLookup" import { keccak256 } from 'ethers'; -import { addNewSubnetwork, burnedRegister, forceSetBalanceToSs58Address, startCall } from "../src/subtensor"; +import { addNewSubnetwork, forceSetBalanceToSs58Address, startCall } from "../src/subtensor"; describe("Test the UID Lookup precompile", () => { const hotkey = getRandomSubstrateKeypair(); From 8ea01512cef41c126456f1780a8f00987e01394d Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 28 Apr 2025 18:46:56 +0900 Subject: [PATCH 066/226] Debug --- evm-tests/test/uid.precompile.lookup.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index f3cdd0531f..eb832b55a7 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -47,12 +47,16 @@ describe("Test the UID Lookup precompile", () => { uid = maybeUid // Associate EVM key - blockNumber = await api.query.System.Number.getValue(); + blockNumber = 0; const blockNumberBytes = u64.enc(BigInt(blockNumber)); const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); + console.info(blockNumberHash) const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); + console.info(concatenatedArray) const concatenatedHash = keccak256(concatenatedArray); + console.info(concatenatedHash) const signature = await evmWallet.signMessage(concatenatedHash); + console.info(signature) const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, hotkey: convertPublicKeyToSs58(hotkey.publicKey), From b4ed3646f6dde6531e66bdf2b021d0e9c64fcacf Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 28 Apr 2025 18:47:38 +0900 Subject: [PATCH 067/226] Debug --- evm-tests/test/uid.precompile.lookup.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index eb832b55a7..5cc3aee6a9 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -52,6 +52,7 @@ describe("Test the UID Lookup precompile", () => { const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); console.info(blockNumberHash) const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); + console.info(hotkey.publicKey) console.info(concatenatedArray) const concatenatedHash = keccak256(concatenatedArray); console.info(concatenatedHash) From 31758706d51432132d372ffa8b456c4af60ed8ef Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 28 Apr 2025 22:52:17 +0900 Subject: [PATCH 068/226] Remove log statements --- evm-tests/test/uid.precompile.lookup.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 5cc3aee6a9..f3cdd0531f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -47,17 +47,12 @@ describe("Test the UID Lookup precompile", () => { uid = maybeUid // Associate EVM key - blockNumber = 0; + blockNumber = await api.query.System.Number.getValue(); const blockNumberBytes = u64.enc(BigInt(blockNumber)); const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); - console.info(blockNumberHash) const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); - console.info(hotkey.publicKey) - console.info(concatenatedArray) const concatenatedHash = keccak256(concatenatedArray); - console.info(concatenatedHash) const signature = await evmWallet.signMessage(concatenatedHash); - console.info(signature) const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, hotkey: convertPublicKeyToSs58(hotkey.publicKey), From 944b0ad3bfe4655e5c037dc6c3a6d5f4966ef3cb Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 28 Apr 2025 23:23:40 +0900 Subject: [PATCH 069/226] Comment out assertion --- evm-tests/test/uid.precompile.lookup.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index f3cdd0531f..8848d808dd 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -64,8 +64,8 @@ describe("Test the UID Lookup precompile", () => { .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); - const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) - assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) + // const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) + // assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) }) it("UID lookup via precompile contract works correctly", async () => { From 7d8cd02a6981bfbdca6ac88277fff74093c9a176 Mon Sep 17 00:00:00 2001 From: Keith Date: Mon, 28 Apr 2025 23:59:24 +0900 Subject: [PATCH 070/226] Re-add assertion --- evm-tests/test/uid.precompile.lookup.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 8848d808dd..f3cdd0531f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -64,8 +64,8 @@ describe("Test the UID Lookup precompile", () => { .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); - // const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) - // assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) + const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) + assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) }) it("UID lookup via precompile contract works correctly", async () => { From a737fb346e8381060c651a0f19f5fc8cb3383c9e Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 28 Apr 2025 10:12:43 -0700 Subject: [PATCH 071/226] rerun benchmarks on label change --- .github/workflows/run-benchmarks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 71f69fcd75..160ee7df8b 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -3,6 +3,11 @@ name: Validate-Benchmarks on: pull_request: + types: + - labeled + - unlabeled + - synchronize + - opened workflow_dispatch: concurrency: From 38bb052a873f29c6c69c40d30528ef0f89514e66 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 29 Apr 2025 21:09:21 +0800 Subject: [PATCH 072/226] test passed --- .../test/staking.precompile.limit.test.ts | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 evm-tests/test/staking.precompile.limit.test.ts diff --git a/evm-tests/test/staking.precompile.limit.test.ts b/evm-tests/test/staking.precompile.limit.test.ts new file mode 100644 index 0000000000..759aaecce2 --- /dev/null +++ b/evm-tests/test/staking.precompile.limit.test.ts @@ -0,0 +1,113 @@ +import * as assert from "assert"; +import { getDevnetApi, getRandomSubstrateKeypair } from "../src/substrate"; +import { devnet } from "@polkadot-api/descriptors"; +import { TypedApi } from "polkadot-api"; +import { + convertH160ToSS58, + convertPublicKeyToSs58, +} from "../src/address-utils"; +import { tao, raoToEth } from "../src/balance-math"; +import { + addNewSubnetwork, + addStake, + forceSetBalanceToEthAddress, + forceSetBalanceToSs58Address, + startCall, +} from "../src/subtensor"; +import { ethers } from "ethers"; +import { generateRandomEthersWallet } from "../src/utils"; +import { ISTAKING_V2_ADDRESS, IStakingV2ABI } from "../src/contracts/staking"; +import { log } from "console"; + +describe("Test staking precompile add remove limit methods", () => { + const hotkey = getRandomSubstrateKeypair(); + const coldkey = getRandomSubstrateKeypair(); + const wallet1 = generateRandomEthersWallet(); + + let api: TypedApi; + + before(async () => { + api = await getDevnetApi(); + await forceSetBalanceToSs58Address( + api, + convertPublicKeyToSs58(hotkey.publicKey), + ); + await forceSetBalanceToSs58Address( + api, + convertPublicKeyToSs58(coldkey.publicKey), + ); + await forceSetBalanceToEthAddress(api, wallet1.address); + await addNewSubnetwork(api, hotkey, coldkey); + let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; + await startCall(api, netuid, coldkey); + console.log("will test in subnet: ", netuid); + }); + + it("Staker add limit", async () => { + let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; + let ss58Address = convertH160ToSS58(wallet1.address); + + const alpha = await api.query.SubtensorModule.Alpha.getValue( + convertPublicKeyToSs58(hotkey.publicKey), + ss58Address, + netuid, + ); + + const contract = new ethers.Contract( + ISTAKING_V2_ADDRESS, + IStakingV2ABI, + wallet1, + ); + + const tx = await contract.addStakeLimit( + hotkey.publicKey, + tao(2000), + tao(1000), + true, + netuid, + ); + await tx.wait(); + + const alphaAfterAddStake = await api.query.SubtensorModule.Alpha.getValue( + convertPublicKeyToSs58(hotkey.publicKey), + ss58Address, + netuid, + ); + + assert.ok(alphaAfterAddStake > alpha); + }); + + it("Staker remove limit", async () => { + let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; + let ss58Address = convertH160ToSS58(wallet1.address); + + const alpha = await api.query.SubtensorModule.Alpha.getValue( + convertPublicKeyToSs58(hotkey.publicKey), + ss58Address, + netuid, + ); + + const contract = new ethers.Contract( + ISTAKING_V2_ADDRESS, + IStakingV2ABI, + wallet1, + ); + + const tx = await contract.removeStakeLimit( + hotkey.publicKey, + tao(100), + tao(1), + true, + netuid, + ); + await tx.wait(); + + const alphaAfterRemoveStake = await api.query.SubtensorModule.Alpha.getValue( + convertPublicKeyToSs58(hotkey.publicKey), + ss58Address, + netuid, + ); + + assert.ok(alphaAfterRemoveStake < alpha); + }); +}); From 5602316677c036c96fd9a7f49255185b32ad9b1f Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 29 Apr 2025 14:30:42 +0400 Subject: [PATCH 073/226] Introduce ZeroMaxAmount error. --- pallets/subtensor/src/lib.rs | 20 +- pallets/subtensor/src/macros/errors.rs | 3 + pallets/subtensor/src/staking/add_stake.rs | 23 ++- pallets/subtensor/src/staking/move_stake.rs | 3 +- pallets/subtensor/src/tests/staking.rs | 196 ++++++++++++++------ 5 files changed, 179 insertions(+), 66 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 2e0b479c0f..cbfc14b550 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1779,6 +1779,7 @@ pub enum CustomTransactionError { ServingRateLimitExceeded, InvalidPort, BadRequest, + ZeroMaxAmount, } impl From for u8 { @@ -1799,6 +1800,7 @@ impl From for u8 { CustomTransactionError::ServingRateLimitExceeded => 12, CustomTransactionError::InvalidPort => 13, CustomTransactionError::BadRequest => 255, + CustomTransactionError::ZeroMaxAmount => 14, } } } @@ -2075,8 +2077,13 @@ where .into(); } - // Calcaulate the maximum amount that can be executed with price limit - let max_amount = Pallet::::get_max_amount_add(*netuid, *limit_price); + // Calculate the maximum amount that can be executed with price limit + let Ok(max_amount) = Pallet::::get_max_amount_add(*netuid, *limit_price) else { + return InvalidTransaction::Custom( + CustomTransactionError::ZeroMaxAmount.into(), + ) + .into(); + }; // Fully validate the user input Self::result_to_validity( @@ -2170,8 +2177,13 @@ where .into(); } - //Calculate the maximum amount that can be executed with price limit - let max_amount = Pallet::::get_max_amount_add(*netuid, *limit_price); + // Calculate the maximum amount that can be executed with price limit + let Ok(max_amount) = Pallet::::get_max_amount_add(*netuid, *limit_price) else { + return InvalidTransaction::Custom( + CustomTransactionError::ZeroMaxAmount.into(), + ) + .into(); + }; // Fully validate the user input Self::result_to_validity( diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index 089c741c33..8ace006010 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -4,6 +4,7 @@ use frame_support::pallet_macros::pallet_section; /// This can later be imported into the pallet using [`import_section`]. #[pallet_section] mod errors { + #[derive(PartialEq)] #[pallet::error] pub enum Error { /// The subnet does not exist. @@ -209,5 +210,7 @@ mod errors { InvalidRecoveredPublicKey, /// SubToken disabled now SubtokenDisabled, + /// Zero max stake amout + ZeroMaxStakeAmount, } } diff --git a/pallets/subtensor/src/staking/add_stake.rs b/pallets/subtensor/src/staking/add_stake.rs index ad8c356d50..8886806cd9 100644 --- a/pallets/subtensor/src/staking/add_stake.rs +++ b/pallets/subtensor/src/staking/add_stake.rs @@ -288,7 +288,7 @@ impl Pallet { ); // 2. Calculate the maximum amount that can be executed with price limit - let max_amount = Self::get_max_amount_add(netuid, limit_price); + let max_amount = Self::get_max_amount_add(netuid, limit_price)?; let mut possible_stake = stake_to_be_added; if possible_stake > max_amount { possible_stake = max_amount; @@ -329,29 +329,29 @@ impl Pallet { } // Returns the maximum amount of RAO that can be executed with price limit - pub fn get_max_amount_add(netuid: u16, limit_price: u64) -> u64 { + pub fn get_max_amount_add(netuid: u16, limit_price: u64) -> Result> { // Corner case: root and stao // There's no slippage for root or stable subnets, so if limit price is 1e9 rao or // higher, then max_amount equals u64::MAX, otherwise it is 0. if (netuid == Self::get_root_netuid()) || (SubnetMechanism::::get(netuid)) == 0 { if limit_price >= 1_000_000_000 { - return u64::MAX; + return Ok(u64::MAX); } else { - return 0; + return Err(Error::ZeroMaxStakeAmount); } } // Corner case: SubnetAlphaIn is zero. Staking can't happen, so max amount is zero. let alpha_in = SubnetAlphaIn::::get(netuid); if alpha_in == 0 { - return 0; + return Err(Error::ZeroMaxStakeAmount); } let alpha_in_u128 = alpha_in as u128; // Corner case: SubnetTAO is zero. Staking can't happen, so max amount is zero. let tao_reserve = SubnetTAO::::get(netuid); if tao_reserve == 0 { - return 0; + return Err(Error::ZeroMaxStakeAmount); } let tao_reserve_u128 = tao_reserve as u128; @@ -364,7 +364,7 @@ impl Pallet { .saturating_mul(tao)) || (limit_price == 0u64) { - return 0; + return Err(Error::ZeroMaxStakeAmount); } // Main case: return limit_price * SubnetAlphaIn - SubnetTAO @@ -375,10 +375,15 @@ impl Pallet { .checked_div(tao) .unwrap_or(0) .saturating_sub(tao_reserve_u128); + + if result == 0 { + return Err(Error::ZeroMaxStakeAmount); + } + if result < u64::MAX as u128 { - result as u64 + Ok(result as u64) } else { - u64::MAX + Ok(u64::MAX) } } } diff --git a/pallets/subtensor/src/staking/move_stake.rs b/pallets/subtensor/src/staking/move_stake.rs index 4198d29efc..22b7650093 100644 --- a/pallets/subtensor/src/staking/move_stake.rs +++ b/pallets/subtensor/src/staking/move_stake.rs @@ -433,7 +433,8 @@ impl Pallet { .safe_div(U64F64::saturating_from_num(limit_price)) .saturating_mul(tao) .saturating_to_num::(); - return Self::get_max_amount_add(destination_netuid, destination_subnet_price); + return Self::get_max_amount_add(destination_netuid, destination_subnet_price) + .unwrap_or(0); } } diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index bc64a740fd..5073746f7a 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -3838,27 +3838,33 @@ fn test_unstake_low_liquidity_validate() { fn test_max_amount_add_root() { new_test_ext(0).execute_with(|| { // 0 price on root => max is 0 - assert_eq!(SubtensorModule::get_max_amount_add(0, 0), 0); + assert_eq!( + SubtensorModule::get_max_amount_add(0, 0), + Err(Error::::ZeroMaxStakeAmount) + ); // 0.999999... price on root => max is 0 - assert_eq!(SubtensorModule::get_max_amount_add(0, 999_999_999), 0); + assert_eq!( + SubtensorModule::get_max_amount_add(0, 999_999_999), + Err(Error::::ZeroMaxStakeAmount) + ); // 1.0 price on root => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_add(0, 1_000_000_000), - u64::MAX + Ok(u64::MAX) ); // 1.000...001 price on root => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_add(0, 1_000_000_001), - u64::MAX + Ok(u64::MAX) ); // 2.0 price on root => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_add(0, 2_000_000_000), - u64::MAX + Ok(u64::MAX) ); }); } @@ -3870,27 +3876,33 @@ fn test_max_amount_add_stable() { add_network(netuid, 1, 0); // 0 price => max is 0 - assert_eq!(SubtensorModule::get_max_amount_add(netuid, 0), 0); + assert_eq!( + SubtensorModule::get_max_amount_add(netuid, 0), + Err(Error::::ZeroMaxStakeAmount) + ); // 0.999999... price => max is 0 - assert_eq!(SubtensorModule::get_max_amount_add(netuid, 999_999_999), 0); + assert_eq!( + SubtensorModule::get_max_amount_add(netuid, 999_999_999), + Err(Error::::ZeroMaxStakeAmount) + ); // 1.0 price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_add(netuid, 1_000_000_000), - u64::MAX + Ok(u64::MAX) ); // 1.000...001 price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_add(netuid, 1_000_000_001), - u64::MAX + Ok(u64::MAX) ); // 2.0 price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_add(netuid, 2_000_000_000), - u64::MAX + Ok(u64::MAX) ); }); } @@ -3915,101 +3927,148 @@ fn test_max_amount_add_dynamic() { // tao_in, alpha_in, limit_price, expected_max_swappable [ // Zero handling (no panics) - (0, 1_000_000_000, 100, 0), - (1_000_000_000, 0, 100, 0), - (1_000_000_000, 1_000_000_000, 0, 0), + ( + 0, + 1_000_000_000, + 100, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000_000, + 0, + 100, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000_000, + 1_000_000_000, + 0, + Err(Error::::ZeroMaxStakeAmount), + ), // Low bounds - (1, 1, 0, 0), - (1, 1, 1, 0), - (1, 1, 2, 0), - (1, 1, 50_000_000_000, 49), + (1, 1, 0, Err(Error::::ZeroMaxStakeAmount)), + (1, 1, 1, Err(Error::::ZeroMaxStakeAmount)), + (1, 1, 2, Err(Error::::ZeroMaxStakeAmount)), + (1, 1, 50_000_000_000, Ok(49)), // Basic math - (1_000, 1_000, 2_000_000_000, 1_000), - (1_000, 1_000, 4_000_000_000, 3_000), - (1_000, 1_000, 16_000_000_000, 15_000), + (1_000, 1_000, 2_000_000_000, Ok(1_000)), + (1_000, 1_000, 4_000_000_000, Ok(3_000)), + (1_000, 1_000, 16_000_000_000, Ok(15_000)), ( 1_000_000_000_000, 1_000_000_000_000, 16_000_000_000, - 15_000_000_000_000, + Ok(15_000_000_000_000), ), // Normal range values with edge cases - (150_000_000_000, 100_000_000_000, 0, 0), - (150_000_000_000, 100_000_000_000, 100_000_000, 0), - (150_000_000_000, 100_000_000_000, 500_000_000, 0), - (150_000_000_000, 100_000_000_000, 1_499_999_999, 0), - (150_000_000_000, 100_000_000_000, 1_500_000_000, 0), - (150_000_000_000, 100_000_000_000, 1_500_000_001, 100), ( 150_000_000_000, 100_000_000_000, - 3_000_000_000, + 0, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 150_000_000_000, + 100_000_000_000, + 100_000_000, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 150_000_000_000, + 100_000_000_000, + 500_000_000, + Err(Error::::ZeroMaxStakeAmount), + ), + ( 150_000_000_000, + 100_000_000_000, + 1_499_999_999, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 150_000_000_000, + 100_000_000_000, + 1_500_000_000, + Err(Error::::ZeroMaxStakeAmount), + ), + (150_000_000_000, 100_000_000_000, 1_500_000_001, Ok(100)), + ( + 150_000_000_000, + 100_000_000_000, + 3_000_000_000, + Ok(150_000_000_000), ), // Miscellaneous overflows and underflows - (150_000_000_000, 100_000_000_000, u64::MAX, u64::MAX), - (150_000_000_000, 100_000_000_000, u64::MAX / 2, u64::MAX), - (1_000_000, 1_000_000_000_000_000_000_u64, 1, 999_000_000), - (1_000_000, 1_000_000_000_000_000_000_u64, 2, 1_999_000_000), + (150_000_000_000, 100_000_000_000, u64::MAX, Ok(u64::MAX)), + (150_000_000_000, 100_000_000_000, u64::MAX / 2, Ok(u64::MAX)), + (1_000_000, 1_000_000_000_000_000_000_u64, 1, Ok(999_000_000)), + ( + 1_000_000, + 1_000_000_000_000_000_000_u64, + 2, + Ok(1_999_000_000), + ), ( 1_000_000, 1_000_000_000_000_000_000_u64, 10_000, - 9_999_999_000_000, + Ok(9_999_999_000_000), ), ( 1_000_000, 1_000_000_000_000_000_000_u64, 100_000, - 99_999_999_000_000, + Ok(99_999_999_000_000), ), ( 1_000_000, 1_000_000_000_000_000_000_u64, 1_000_000, - 999_999_999_000_000, + Ok(999_999_999_000_000), ), ( 1_000_000, 1_000_000_000_000_000_000_u64, 1_000_000_000, - 999_999_999_999_000_000, + Ok(999_999_999_999_000_000), ), ( 21_000_000_000_000_000, 10_000_000, 4_200_000_000_000_000_000, - 21_000_000_000_000_000, + Ok(21_000_000_000_000_000), ), ( 21_000_000_000_000_000, 1_000_000_000_000_000_000_u64, u64::MAX, - u64::MAX, + Ok(u64::MAX), ), ( 21_000_000_000_000_000, 1_000_000_000_000_000_000_u64, 42_000_000, - 21_000_000_000_000_000, + Ok(21_000_000_000_000_000), ), ] .iter() - .for_each(|&(tao_in, alpha_in, limit_price, expected_max_swappable)| { - // Forse-set alpha in and tao reserve to achieve relative price of subnets - SubnetTAO::::insert(netuid, tao_in); - SubnetAlphaIn::::insert(netuid, alpha_in); + .for_each( + |&(tao_in, alpha_in, limit_price, ref expected_max_swappable)| { + // Forse-set alpha in and tao reserve to achieve relative price of subnets + SubnetTAO::::insert(netuid, tao_in); + SubnetAlphaIn::::insert(netuid, alpha_in); - if alpha_in != 0 { - let expected_price = I96F32::from_num(tao_in) / I96F32::from_num(alpha_in); - assert_eq!(SubtensorModule::get_alpha_price(netuid), expected_price); - } + if alpha_in != 0 { + let expected_price = I96F32::from_num(tao_in) / I96F32::from_num(alpha_in); + assert_eq!(SubtensorModule::get_alpha_price(netuid), expected_price); + } - assert_eq!( - SubtensorModule::get_max_amount_add(netuid, limit_price), - expected_max_swappable, - ); - }); + assert_eq!( + SubtensorModule::get_max_amount_add(netuid, limit_price), + *expected_max_swappable, + ); + }, + ); }); } @@ -4890,6 +4949,39 @@ fn test_add_stake_limit_fill_or_kill() { }); } +#[test] +fn test_add_stake_limit_partial_zero_max_stake_amount_error() { + new_test_ext(1).execute_with(|| { + let hotkey_account_id = U256::from(533453); + let coldkey_account_id = U256::from(55453); + + // Exact values from the error: + // https://taostats.io/extrinsic/5338471-0009?network=finney + let amount = 19980000000; + let limit_price = 26953618; + let tao_reserve: U96F32 = U96F32::from_num(5_032_494_439_940_u64); + let alpha_in: U96F32 = U96F32::from_num(186_268_425_402_874_u64); + + let netuid: u16 = add_dynamic_network(&hotkey_account_id, &coldkey_account_id); + SubnetTAO::::insert(netuid, tao_reserve.to_num::()); + SubnetAlphaIn::::insert(netuid, alpha_in.to_num::()); + + SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, amount); + + assert_noop!( + SubtensorModule::add_stake_limit( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + netuid, + amount, + limit_price, + true + ), + Error::::ZeroMaxStakeAmount + ); + }); +} + #[test] fn test_remove_stake_limit_ok() { new_test_ext(1).execute_with(|| { From a269acc04ce4d9df619b00404773855131f6bc23 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 29 Apr 2025 23:02:17 -0400 Subject: [PATCH 074/226] wip --- pallets/admin-utils/src/tests/mock.rs | 2 + pallets/subtensor/src/lib.rs | 30 ++++++- pallets/subtensor/src/macros/config.rs | 3 + pallets/subtensor/src/macros/dispatches.rs | 15 ++-- .../migrate_coldkey_swap_scheduled.rs | 88 +++++++++++++++++++ pallets/subtensor/src/migrations/mod.rs | 1 + pallets/subtensor/src/tests/mock.rs | 2 + pallets/subtensor/src/tests/swap_coldkey.rs | 65 ++++++++++++++ runtime/src/lib.rs | 2 + 9 files changed, 200 insertions(+), 8 deletions(-) create mode 100644 pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 99c11b7165..570ece3d43 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -132,6 +132,7 @@ parameter_types! { // pub const InitialHotkeyEmissionTempo: u64 = 1; // (DEPRECATED) // pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days + pub const InitialColdkeySwapRescheduleDuration: u64 = 1 * 24 * 60 * 60 / 12; // 1 day pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks @@ -197,6 +198,7 @@ impl pallet_subtensor::Config for Test { type LiquidAlphaOn = InitialLiquidAlphaOn; type Preimages = (); type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration; + type InitialColdkeySwapRescheduleDuration = InitialColdkeySwapRescheduleDuration; type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration; type InitialTaoWeight = InitialTaoWeight; type InitialEmaPriceHalvingPeriod = InitialEmaPriceHalvingPeriod; diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 2905375d9b..cafd6bf47f 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -810,6 +810,12 @@ pub mod pallet { T::InitialColdkeySwapScheduleDuration::get() } + #[pallet::type_value] + /// Default value for coldkey swap reschedule duration + pub fn DefaultColdkeySwapRescheduleDuration() -> BlockNumberFor { + T::InitialColdkeySwapRescheduleDuration::get() + } + #[pallet::type_value] /// Default value for applying pending items (e.g. childkeys). pub fn DefaultPendingCooldown() -> u64 { @@ -874,6 +880,14 @@ pub mod pallet { 360 } + #[pallet::type_value] + /// Default value for coldkey swap scheduled + pub fn DefaultColdkeySwapScheduled() -> (BlockNumberFor, T::AccountId) { + let default_account = T::AccountId::decode(&mut TrailingZeroInput::zeroes()) + .expect("trailing zeroes always produce a valid account ID; qed"); + (BlockNumberFor::::from(0_i32), default_account) + } + #[pallet::storage] pub type MinActivityCutoff = StorageValue<_, u16, ValueQuery, DefaultMinActivityCutoff>; @@ -882,6 +896,10 @@ pub mod pallet { pub type ColdkeySwapScheduleDuration = StorageValue<_, BlockNumberFor, ValueQuery, DefaultColdkeySwapScheduleDuration>; + #[pallet::storage] + pub type ColdkeySwapRescheduleDuration = + StorageValue<_, BlockNumberFor, ValueQuery, DefaultColdkeySwapRescheduleDuration>; + #[pallet::storage] pub type DissolveNetworkScheduleDuration = StorageValue<_, BlockNumberFor, ValueQuery, DefaultDissolveNetworkScheduleDuration>; @@ -1098,9 +1116,15 @@ pub mod pallet { pub type OwnedHotkeys = StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; - #[pallet::storage] // --- DMAP ( cold ) --> () | Maps coldkey to if a coldkey swap is scheduled. - pub type ColdkeySwapScheduled = - StorageMap<_, Blake2_128Concat, T::AccountId, (), ValueQuery>; + #[pallet::storage] // --- DMAP ( cold ) --> (block_expected, new_coldkey) | Maps coldkey to the block to swap at and new coldkey. + pub type ColdkeySwapScheduled = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + (BlockNumberFor, T::AccountId), + ValueQuery, + DefaultColdkeySwapScheduled, + >; #[pallet::storage] // --- DMAP ( hot, netuid ) --> alpha | Returns the total amount of alpha a hotkey owns. pub type TotalHotkeyAlpha = StorageDoubleMap< diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index cf4d97b65b..4291b67c6f 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -201,6 +201,9 @@ mod config { /// Coldkey swap schedule duartion. #[pallet::constant] type InitialColdkeySwapScheduleDuration: Get>; + /// Coldkey swap reschedule duration. + #[pallet::constant] + type InitialColdkeySwapRescheduleDuration: Get>; /// Dissolve network schedule duration #[pallet::constant] type InitialDissolveNetworkScheduleDuration: Get>; diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 30041e037f..8d72c85ada 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1330,10 +1330,15 @@ mod dispatches { new_coldkey: T::AccountId, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; - ensure!( - !ColdkeySwapScheduled::::contains_key(&who), - Error::::SwapAlreadyScheduled - ); + let current_block = >::block_number(); + + // If the coldkey has a scheduled swap, check if we can reschedule it + if ColdkeySwapScheduled::::contains_key(&who) { + let reschedule_duration = ColdkeySwapRescheduleDuration::::get(); + let redo_when = current_block.saturating_add(reschedule_duration); + + ensure!(redo_when <= current_block, Error::::SwapAlreadyScheduled); + } // Calculate the swap cost and ensure sufficient balance let swap_cost = Self::get_key_swap_cost(); @@ -1364,7 +1369,7 @@ mod dispatches { ) .map_err(|_| Error::::FailedToSchedule)?; - ColdkeySwapScheduled::::insert(&who, ()); + ColdkeySwapScheduled::::insert(&who, (when, new_coldkey.clone())); // Emit the SwapScheduled event Self::deposit_event(Event::ColdkeySwapScheduled { old_coldkey: who.clone(), diff --git a/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs b/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs new file mode 100644 index 0000000000..103a01008a --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs @@ -0,0 +1,88 @@ +use super::*; +use alloc::collections::BTreeMap; +use frame_support::{ + pallet_prelude::{Blake2_128Concat, ValueQuery}, + storage_alias, + traits::Get, + weights::Weight, +}; + +/// Module containing deprecated storage format for LoadedEmission +pub mod deprecated_coldkey_swap_scheduled_format { + use super::*; + + #[storage_alias] + pub(super) type ColdkeySwapScheduled = + StorageMap, Blake2_128Concat, AccountIdOf, (), ValueQuery>; +} + +/// Migrate the ColdkeySwapScheduled map to the new storage format +pub fn migrate_coldkey_swap_scheduled() -> Weight { + use deprecated_coldkey_swap_scheduled_format as old; + + let migration_name = b"migrate_coldkey_swap_scheduled".to_vec(); + let mut weight = T::DbWeight::get().reads(1); + + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); + return weight; + } + + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + // ------------------------------ + // Step 1: Migrate ColdkeySwapScheduled map + // ------------------------------ + let mut scheduled_map: BTreeMap, (BlockNumberFor, AccountIdOf)> = + BTreeMap::new(); + + for (block, scheduled_tasks) in [].iter() { + for task in scheduled_tasks { + + //scheduled_map.insert(task.to, (block, new_coldkey)); + } + } + + let curr_keys: Vec> = old::ColdkeySwapScheduled::::iter_keys().collect(); + + // Remove any undecodable entries + for coldkey in curr_keys { + weight.saturating_accrue(T::DbWeight::get().reads(1)); + if old::ColdkeySwapScheduled::::try_get(coldkey).is_err() { + weight.saturating_accrue(T::DbWeight::get().writes(1)); + old::ColdkeySwapScheduled::::remove(coldkey); + log::warn!( + "Was unable to decode old coldkey_swap_scheduled for coldkey {:?}", + coldkey + ); + } + } + + ColdkeySwapScheduled::::translate::<(), _>(|coldkey: AccountIdOf, _: ()| { + let (when, new_coldkey) = scheduled_map + .get(&coldkey) + .unwrap_or(&DefaultColdkeySwapScheduled::::get()); + + Some((when, new_coldkey)) + }); + + // ------------------------------ + // Step 2: Mark Migration as Completed + // ------------------------------ + + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed successfully.", + String::from_utf8_lossy(&migration_name) + ); + + weight +} diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index 39f9cd428a..69079d16e9 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -1,5 +1,6 @@ use super::*; pub mod migrate_chain_identity; +pub mod migrate_coldkey_swap_scheduled; pub mod migrate_commit_reveal_v2; pub mod migrate_create_root_network; pub mod migrate_delete_subnet_21; diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index a8ab96be8c..7ebe149781 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -182,6 +182,7 @@ parameter_types! { pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn // pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days + pub const InitialColdkeySwapRescheduleDuration: u64 = 1 * 24 * 60 * 60 / 12; // Default as 1 day pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days pub const InitialTaoWeight: u64 = 0; // 100% global weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks @@ -406,6 +407,7 @@ impl crate::Config for Test { type LiquidAlphaOn = InitialLiquidAlphaOn; type Preimages = Preimage; type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration; + type InitialColdkeySwapRescheduleDuration = InitialColdkeySwapRescheduleDuration; type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration; type InitialTaoWeight = InitialTaoWeight; type InitialEmaPriceHalvingPeriod = InitialEmaPriceHalvingPeriod; diff --git a/pallets/subtensor/src/tests/swap_coldkey.rs b/pallets/subtensor/src/tests/swap_coldkey.rs index beb4df59a5..d1a6a87b14 100644 --- a/pallets/subtensor/src/tests/swap_coldkey.rs +++ b/pallets/subtensor/src/tests/swap_coldkey.rs @@ -1883,6 +1883,71 @@ fn test_schedule_swap_coldkey_with_pending_swap() { }); } +// SKIP_WASM_BUILD=1 RUST_LOG=info cargo test --test swap_coldkey -- test_schedule_swap_coldkey_failure_and_reschedule --exact --nocapture +#[test] +fn test_schedule_swap_coldkey_failure_and_reschedule() { + new_test_ext(1).execute_with(|| { + let old_coldkey = U256::from(1); + let new_coldkey1 = U256::from(2); + let new_coldkey2 = U256::from(3); + + let swap_cost = SubtensorModule::get_key_swap_cost(); + + // Two swaps + SubtensorModule::add_balance_to_coldkey_account(&old_coldkey, swap_cost + 1_000 * 2); + + assert_ok!(SubtensorModule::schedule_swap_coldkey( + <::RuntimeOrigin>::signed(old_coldkey), + new_coldkey1 + )); + + let current_block = >::block_number(); + let duration = ColdkeySwapScheduleDuration::::get(); + let when = current_block.saturating_add(duration); + + // Setup first key to fail + // -- will fail if the new coldkey is already a hotkey (has an Owner) + Owner::::insert(new_coldkey1, U256::from(4)); + + // First swap fails + run_to_block(when - 1); + next_block(); + + // Check the failure + next_block(); // Still in the scheduled-swap map + assert!(ColdkeySwapScheduled::::contains_key(&old_coldkey)); + + // Try to schedule the second swap + assert_noop!( + SubtensorModule::schedule_swap_coldkey( + <::RuntimeOrigin>::signed(old_coldkey), + new_coldkey2 + ), + Error::::SwapAlreadyScheduled + ); + + // Wait for correct duration after first swap fails + let fail_duration = ColdkeySwapRescheduleDuration::::get(); + run_to_block(when + fail_duration); + + // Schedule the second swap + assert_ok!(SubtensorModule::schedule_swap_coldkey( + <::RuntimeOrigin>::signed(old_coldkey), + new_coldkey2 + )); + + let current_block = >::block_number(); + let duration = ColdkeySwapScheduleDuration::::get(); + let when = current_block.saturating_add(duration); + run_to_block(when - 1); + next_block(); + + // Check the success + next_block(); // Now in the scheduled-swap map + assert!(!ColdkeySwapScheduled::::contains_key(&old_coldkey)); + }); +} + #[test] fn test_coldkey_swap_delegate_identity_updated() { new_test_ext(1).execute_with(|| { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 55c2d957f8..8c825faa42 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1065,6 +1065,7 @@ parameter_types! { pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn // pub const SubtensorInitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days + pub const InitialColdkeySwapRescheduleDuration: BlockNumber = 1 * 24 * 60 * 60 / 12; // 1 day pub const InitialDissolveNetworkScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days pub const SubtensorInitialTaoWeight: u64 = 971_718_665_099_567_868; // 0.05267697438728329% tao weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks @@ -1135,6 +1136,7 @@ impl pallet_subtensor::Config for Runtime { type InitialTaoWeight = SubtensorInitialTaoWeight; type Preimages = Preimage; type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration; + type InitialColdkeySwapRescheduleDuration = InitialColdkeySwapRescheduleDuration; type InitialDissolveNetworkScheduleDuration = InitialDissolveNetworkScheduleDuration; type InitialEmaPriceHalvingPeriod = InitialEmaPriceHalvingPeriod; type DurationOfStartCall = DurationOfStartCall; From 68760cea5ccf1ad24655ba1b8e0ab11c6eae1714 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 30 Apr 2025 12:57:34 +0800 Subject: [PATCH 075/226] fix weights --- .../migrate_coldkey_swap_scheduled.rs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs b/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs index c73809c6ec..9ec5786d39 100644 --- a/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs +++ b/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs @@ -1,6 +1,5 @@ use super::*; use crate::AccountIdOf; -use alloc::collections::BTreeMap; use frame_support::{ pallet_prelude::{Blake2_128Concat, ValueQuery}, storage_alias, @@ -41,23 +40,13 @@ pub fn migrate_coldkey_swap_scheduled() -> Weight { // ------------------------------ // Step 1: Migrate ColdkeySwapScheduled map // ------------------------------ - let mut scheduled_map: BTreeMap, (BlockNumberFor, AccountIdOf)> = - BTreeMap::new(); - - // for (block, scheduled_tasks) in old::ColdkeySwapScheduled::iter() { - // for task in old::ColdkeySwapScheduled::::iter() { - - // //scheduled_map.insert(task.to, (block, new_coldkey)); - // } - // } let curr_keys: Vec> = old::ColdkeySwapScheduled::::iter_keys().collect(); // Remove any undecodable entries - for coldkey in curr_keys { + for coldkey in &curr_keys { weight.saturating_accrue(T::DbWeight::get().reads(1)); if old::ColdkeySwapScheduled::::try_get(&coldkey).is_err() { - weight.saturating_accrue(T::DbWeight::get().writes(1)); old::ColdkeySwapScheduled::::remove(&coldkey); log::warn!( "Was unable to decode old coldkey_swap_scheduled for coldkey {:?}", @@ -67,11 +56,11 @@ pub fn migrate_coldkey_swap_scheduled() -> Weight { } let default_value = DefaultColdkeySwapScheduled::::get(); - ColdkeySwapScheduled::::translate::<(), _>(|coldkey: AccountIdOf, _: ()| { - let (when, new_coldkey) = scheduled_map.get(&coldkey).unwrap_or(&default_value); - - Some((*when, new_coldkey.clone())) + ColdkeySwapScheduled::::translate::<(), _>(|_coldkey: AccountIdOf, _: ()| { + Some((default_value.0, default_value.1.clone())) }); + // write once for each item in the map, no matter remove or translate + weight.saturating_accrue(T::DbWeight::get().writes(curr_keys.len() as u64)); // ------------------------------ // Step 2: Mark Migration as Completed From 4fc60ff490941051ae0bf9d755851b561d0b088d Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 30 Apr 2025 13:00:24 +0800 Subject: [PATCH 076/226] cargo clippy --- pallets/admin-utils/src/tests/mock.rs | 2 +- .../src/migrations/migrate_coldkey_swap_scheduled.rs | 4 ++-- pallets/subtensor/src/tests/mock.rs | 2 +- pallets/subtensor/src/tests/swap_coldkey.rs | 4 ++-- runtime/src/lib.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 570ece3d43..738ff568c6 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -132,7 +132,7 @@ parameter_types! { // pub const InitialHotkeyEmissionTempo: u64 = 1; // (DEPRECATED) // pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days - pub const InitialColdkeySwapRescheduleDuration: u64 = 1 * 24 * 60 * 60 / 12; // 1 day + pub const InitialColdkeySwapRescheduleDuration: u64 = 24 * 60 * 60 / 12; // 1 day pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks diff --git a/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs b/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs index 9ec5786d39..e15f468ddc 100644 --- a/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs +++ b/pallets/subtensor/src/migrations/migrate_coldkey_swap_scheduled.rs @@ -46,8 +46,8 @@ pub fn migrate_coldkey_swap_scheduled() -> Weight { // Remove any undecodable entries for coldkey in &curr_keys { weight.saturating_accrue(T::DbWeight::get().reads(1)); - if old::ColdkeySwapScheduled::::try_get(&coldkey).is_err() { - old::ColdkeySwapScheduled::::remove(&coldkey); + if old::ColdkeySwapScheduled::::try_get(coldkey).is_err() { + old::ColdkeySwapScheduled::::remove(coldkey); log::warn!( "Was unable to decode old coldkey_swap_scheduled for coldkey {:?}", &coldkey diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 7ebe149781..37154d7b02 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -182,7 +182,7 @@ parameter_types! { pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn // pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days - pub const InitialColdkeySwapRescheduleDuration: u64 = 1 * 24 * 60 * 60 / 12; // Default as 1 day + pub const InitialColdkeySwapRescheduleDuration: u64 = 24 * 60 * 60 / 12; // Default as 1 day pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days pub const InitialTaoWeight: u64 = 0; // 100% global weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks diff --git a/pallets/subtensor/src/tests/swap_coldkey.rs b/pallets/subtensor/src/tests/swap_coldkey.rs index d1a6a87b14..385830904c 100644 --- a/pallets/subtensor/src/tests/swap_coldkey.rs +++ b/pallets/subtensor/src/tests/swap_coldkey.rs @@ -1915,7 +1915,7 @@ fn test_schedule_swap_coldkey_failure_and_reschedule() { // Check the failure next_block(); // Still in the scheduled-swap map - assert!(ColdkeySwapScheduled::::contains_key(&old_coldkey)); + assert!(ColdkeySwapScheduled::::contains_key(old_coldkey)); // Try to schedule the second swap assert_noop!( @@ -1944,7 +1944,7 @@ fn test_schedule_swap_coldkey_failure_and_reschedule() { // Check the success next_block(); // Now in the scheduled-swap map - assert!(!ColdkeySwapScheduled::::contains_key(&old_coldkey)); + assert!(!ColdkeySwapScheduled::::contains_key(old_coldkey)); }); } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4e939bed42..dd0f66d213 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1074,7 +1074,7 @@ parameter_types! { pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn // pub const SubtensorInitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED) pub const InitialColdkeySwapScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days - pub const InitialColdkeySwapRescheduleDuration: BlockNumber = 1 * 24 * 60 * 60 / 12; // 1 day + pub const InitialColdkeySwapRescheduleDuration: BlockNumber = 24 * 60 * 60 / 12; // 1 day pub const InitialDissolveNetworkScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days pub const SubtensorInitialTaoWeight: u64 = 971_718_665_099_567_868; // 0.05267697438728329% tao weight. pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks From ed23c36e74dea1097fc549177f42f234e5cf47d7 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 30 Apr 2025 13:39:20 +0800 Subject: [PATCH 077/226] fix test case --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index e22553b289..3052de0b7a 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1339,9 +1339,9 @@ mod dispatches { // If the coldkey has a scheduled swap, check if we can reschedule it if ColdkeySwapScheduled::::contains_key(&who) { + let (scheduled_block, _scheduled_coldkey) = ColdkeySwapScheduled::::get(&who); let reschedule_duration = ColdkeySwapRescheduleDuration::::get(); - let redo_when = current_block.saturating_add(reschedule_duration); - + let redo_when = scheduled_block.saturating_add(reschedule_duration); ensure!(redo_when <= current_block, Error::::SwapAlreadyScheduled); } From eb57c0f71786dd1e12600a36b438e9256b9504a7 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 30 Apr 2025 14:14:05 +0800 Subject: [PATCH 078/226] update version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index dd0f66d213..5f41341546 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 264, + spec_version: 265, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 74d43734484d3864a35bf77f9ea5880ed4782557 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 30 Apr 2025 17:24:08 +0400 Subject: [PATCH 079/226] Refactor get_max_amount_move using ZeroMaxStakeAmount error. --- pallets/subtensor/src/benchmarks.rs | 51 +++++++------ pallets/subtensor/src/lib.rs | 9 ++- pallets/subtensor/src/staking/move_stake.rs | 33 ++++---- pallets/subtensor/src/tests/staking.rs | 85 +++++++++++++-------- 4 files changed, 108 insertions(+), 70 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index b5ff1197e0..faa0b46a6d 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -821,32 +821,35 @@ benchmark_adjust_senate { Uids::::insert(root, &hotkey, 0u16); }: adjust_senate(RawOrigin::Signed(coldkey), hotkey.clone()) -benchmark_add_stake_limit { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey : T::AccountId = account("Alice", 0, 1); - let netuid : u16 = 1; - let amount : u64 = 1_000_000; - let limit : u64 = 1_000_000; - let allow : bool = true; - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); + benchmark_add_stake_limit { + let caller: T::AccountId = whitelisted_caller::>(); + let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); + let netuid: u16 = 1; + let tempo: u16 = 1; + let modality: u16 = 0; + let seed : u32 = 1; - let bond = Subtensor::::get_burn_as_u64(netuid); - let deposit = (amount + bond + DefaultStakingFee::::get()) * 10; - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone() - ) - ); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); + Subtensor::::init_new_network(netuid, tempo); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_network_registration_allowed( netuid, true ); + Subtensor::::set_max_allowed_uids( netuid, 4096 ); + + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + + let amount = 900_000_000_000; + let limit: u64 = 6_000_000_000; + let amount_to_be_staked = 440_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount); + + let tao_reserve = 150_000_000_000_u64; + let alpha_in = 100_000_000_000_u64; + SubnetTAO::::insert(netuid, tao_reserve); + SubnetAlphaIn::::insert(netuid, alpha_in); -}: add_stake_limit(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), netuid, amount, limit, allow) + assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); + }: add_stake_limit(RawOrigin::Signed( coldkey.clone() ), hotkey, netuid, amount_to_be_staked, limit, false) benchmark_move_stake { let coldkey: T::AccountId = whitelisted_caller::>(); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index cbfc14b550..b782d37723 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2347,11 +2347,16 @@ where } // Get the max amount possible to exchange - let max_amount = Pallet::::get_max_amount_move( + let Ok(max_amount) = Pallet::::get_max_amount_move( *origin_netuid, *destination_netuid, *limit_price, - ); + ) else { + return InvalidTransaction::Custom( + CustomTransactionError::ZeroMaxAmount.into(), + ) + .into(); + }; // Fully validate the user input Self::result_to_validity( diff --git a/pallets/subtensor/src/staking/move_stake.rs b/pallets/subtensor/src/staking/move_stake.rs index 22b7650093..75b84b205e 100644 --- a/pallets/subtensor/src/staking/move_stake.rs +++ b/pallets/subtensor/src/staking/move_stake.rs @@ -311,7 +311,7 @@ impl Pallet { ) -> Result> { // Calculate the maximum amount that can be executed let max_amount = if let Some(limit_price) = maybe_limit_price { - Self::get_max_amount_move(origin_netuid, destination_netuid, limit_price) + Self::get_max_amount_move(origin_netuid, destination_netuid, limit_price)? } else { alpha_amount }; @@ -401,7 +401,7 @@ impl Pallet { origin_netuid: u16, destination_netuid: u16, limit_price: u64, - ) -> u64 { + ) -> Result> { let tao: U64F64 = U64F64::saturating_from_num(1_000_000_000); // Corner case: both subnet IDs are root or stao @@ -413,9 +413,9 @@ impl Pallet { || (SubnetMechanism::::get(destination_netuid)) == 0) { if limit_price > tao.saturating_to_num::() { - return 0; + return Err(Error::ZeroMaxStakeAmount); } else { - return u64::MAX; + return Ok(u64::MAX); } } @@ -426,15 +426,14 @@ impl Pallet { && ((SubnetMechanism::::get(destination_netuid)) == 1) { if limit_price == 0 { - return u64::MAX; + return Ok(u64::MAX); } else { // The destination price is reverted because the limit_price is origin_price / destination_price let destination_subnet_price = tao .safe_div(U64F64::saturating_from_num(limit_price)) .saturating_mul(tao) .saturating_to_num::(); - return Self::get_max_amount_add(destination_netuid, destination_subnet_price) - .unwrap_or(0); + return Self::get_max_amount_add(destination_netuid, destination_subnet_price); } } @@ -444,14 +443,14 @@ impl Pallet { || (SubnetMechanism::::get(destination_netuid)) == 0) && ((SubnetMechanism::::get(origin_netuid)) == 1) { - return Self::get_max_amount_remove(origin_netuid, limit_price); + return Ok(Self::get_max_amount_remove(origin_netuid, limit_price)); } // Corner case: SubnetTAO for any of two subnets is zero let subnet_tao_1 = SubnetTAO::::get(origin_netuid); let subnet_tao_2 = SubnetTAO::::get(destination_netuid); if (subnet_tao_1 == 0) || (subnet_tao_2 == 0) { - return 0; + return Err(Error::ZeroMaxStakeAmount); } let subnet_tao_1_float: U64F64 = U64F64::saturating_from_num(subnet_tao_1); let subnet_tao_2_float: U64F64 = U64F64::saturating_from_num(subnet_tao_2); @@ -460,7 +459,7 @@ impl Pallet { let alpha_in_1 = SubnetAlphaIn::::get(origin_netuid); let alpha_in_2 = SubnetAlphaIn::::get(destination_netuid); if (alpha_in_1 == 0) || (alpha_in_2 == 0) { - return 0; + return Err(Error::ZeroMaxStakeAmount); } let alpha_in_1_float: U64F64 = U64F64::saturating_from_num(alpha_in_1); let alpha_in_2_float: U64F64 = U64F64::saturating_from_num(alpha_in_2); @@ -475,12 +474,12 @@ impl Pallet { let current_price = Self::get_alpha_price(origin_netuid) .safe_div(Self::get_alpha_price(destination_netuid)); if limit_price_float > current_price { - return 0; + return Err(Error::ZeroMaxStakeAmount); } // Corner case: limit_price is zero if limit_price == 0 { - return u64::MAX; + return Ok(u64::MAX); } // Main case @@ -492,10 +491,16 @@ impl Pallet { let t1_over_sum: U64F64 = subnet_tao_1_float.safe_div(tao_sum); let t2_over_sum: U64F64 = subnet_tao_2_float.safe_div(tao_sum); - alpha_in_2_float + let final_result = alpha_in_2_float .saturating_mul(t1_over_sum) .safe_div(limit_price_float) .saturating_sub(alpha_in_1_float.saturating_mul(t2_over_sum)) - .saturating_to_num::() + .saturating_to_num::(); + + if final_result != 0 { + Ok(final_result) + } else { + Err(Error::ZeroMaxStakeAmount) + } } } diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index 5073746f7a..a2c3517ca7 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -4246,31 +4246,37 @@ fn test_max_amount_remove_dynamic() { fn test_max_amount_move_root_root() { new_test_ext(0).execute_with(|| { // 0 price on (root, root) exchange => max is u64::MAX - assert_eq!(SubtensorModule::get_max_amount_move(0, 0, 0), u64::MAX); + assert_eq!(SubtensorModule::get_max_amount_move(0, 0, 0), Ok(u64::MAX)); // 0.5 price on (root, root) => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(0, 0, 500_000_000), - u64::MAX + Ok(u64::MAX) ); // 0.999999... price on (root, root) => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(0, 0, 999_999_999), - u64::MAX + Ok(u64::MAX) ); // 1.0 price on (root, root) => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(0, 0, 1_000_000_000), - u64::MAX + Ok(u64::MAX) ); // 1.000...001 price on (root, root) => max is 0 - assert_eq!(SubtensorModule::get_max_amount_move(0, 0, 1_000_000_001), 0); + assert_eq!( + SubtensorModule::get_max_amount_move(0, 0, 1_000_000_001), + Err(Error::::ZeroMaxStakeAmount) + ); // 2.0 price on (root, root) => max is 0 - assert_eq!(SubtensorModule::get_max_amount_move(0, 0, 2_000_000_000), 0); + assert_eq!( + SubtensorModule::get_max_amount_move(0, 0, 2_000_000_000), + Err(Error::::ZeroMaxStakeAmount) + ); }); } @@ -4282,36 +4288,39 @@ fn test_max_amount_move_root_stable() { add_network(netuid, 1, 0); // 0 price on (root, stable) exchange => max is u64::MAX - assert_eq!(SubtensorModule::get_max_amount_move(0, netuid, 0), u64::MAX); + assert_eq!( + SubtensorModule::get_max_amount_move(0, netuid, 0), + Ok(u64::MAX) + ); // 0.5 price on (root, stable) => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(0, netuid, 500_000_000), - u64::MAX + Ok(u64::MAX) ); // 0.999999... price on (root, stable) => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(0, netuid, 999_999_999), - u64::MAX + Ok(u64::MAX) ); // 1.0 price on (root, stable) => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(0, netuid, 1_000_000_000), - u64::MAX + Ok(u64::MAX) ); // 1.000...001 price on (root, stable) => max is 0 assert_eq!( SubtensorModule::get_max_amount_move(0, netuid, 1_000_000_001), - 0 + Err(Error::::ZeroMaxStakeAmount) ); // 2.0 price on (root, stable) => max is 0 assert_eq!( SubtensorModule::get_max_amount_move(0, netuid, 2_000_000_000), - 0 + Err(Error::::ZeroMaxStakeAmount) ); }); } @@ -4343,24 +4352,25 @@ fn test_max_amount_move_stable_dynamic() { // 0 price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 0), - u64::MAX + Ok(u64::MAX) ); // 2.0 price => max is 0 assert_eq!( SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 2_000_000_000), - 0 + Err(Error::::ZeroMaxStakeAmount) ); // 3.0 price => max is 0 assert_eq!( SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 3_000_000_000), - 0 + Err(Error::::ZeroMaxStakeAmount) ); // 2x price => max is 1x TAO assert_abs_diff_eq!( - SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 1_000_000_000), + SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 1_000_000_000) + .unwrap(), 50_000_000_000, epsilon = 10_000, ); @@ -4368,21 +4378,23 @@ fn test_max_amount_move_stable_dynamic() { // Precision test: // 1.99999..9000 price => max > 0 assert!( - SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 1_999_999_000) > 0 + SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, 1_999_999_000) + .unwrap() + > 0 ); // Max price doesn't panic and returns something meaningful assert_eq!( SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, u64::MAX), - 0 + Err(Error::::ZeroMaxStakeAmount) ); assert_eq!( SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, u64::MAX - 1), - 0 + Err(Error::::ZeroMaxStakeAmount) ); assert_eq!( SubtensorModule::get_max_amount_move(stable_netuid, dynamic_netuid, u64::MAX / 2), - 0 + Err(Error::::ZeroMaxStakeAmount) ); }); } @@ -4414,30 +4426,38 @@ fn test_max_amount_move_dynamic_stable() { // 0 price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 0), - u64::MAX + Ok(u64::MAX) ); // Low price values don't blow things up - assert!(SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1) > 0); - assert!(SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 2) > 0); - assert!(SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 3) > 0); + assert!( + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1).unwrap() > 0 + ); + assert!( + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 2).unwrap() > 0 + ); + assert!( + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 3).unwrap() > 0 + ); // 1.5000...1 price => max is 0 assert_eq!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1_500_000_001), - 0 + Err(Error::::ZeroMaxStakeAmount) ); // 1.5 price => max is 0 because of non-zero slippage assert_abs_diff_eq!( - SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1_500_000_000), + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1_500_000_000) + .unwrap(), 0, epsilon = 10_000 ); // 1/2 price => max is 1x Alpha assert_abs_diff_eq!( - SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 750_000_000), + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 750_000_000) + .unwrap(), 100_000_000_000, epsilon = 10_000, ); @@ -4445,20 +4465,24 @@ fn test_max_amount_move_dynamic_stable() { // Precision test: // 1.499999.. price => max > 0 assert!( - SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1_499_999_999) > 0 + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1_499_999_999) + .unwrap() + > 0 ); // Max price doesn't panic and returns something meaningful assert!( - SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX) + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX).unwrap() < 21_000_000_000_000_000 ); assert!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX - 1) + .unwrap() < 21_000_000_000_000_000 ); assert!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX / 2) + .unwrap() < 21_000_000_000_000_000 ); }); @@ -4682,7 +4706,8 @@ fn test_max_amount_move_dynamic_dynamic() { origin_netuid, destination_netuid, limit_price - ), + ) + .unwrap_or(0u64), expected_max_swappable, epsilon = precision ); From 2ce5dd97826e6f72788fddca1fd4b18283d06d35 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 30 Apr 2025 22:52:28 +0900 Subject: [PATCH 080/226] Debug --- evm-tests/test/uid.precompile.lookup.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index f3cdd0531f..e1e75837a9 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -52,6 +52,10 @@ describe("Test the UID Lookup precompile", () => { const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); const concatenatedHash = keccak256(concatenatedArray); + console.info(hotkey.publicKey) + console.info(concatenatedArray) + console.info(concatenatedHash) + console.info(convertPublicKeyToSs58(hotkey.publicKey)) const signature = await evmWallet.signMessage(concatenatedHash); const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, From 6a0aed58ad84d01f54ed47aa51621f66df969486 Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 1 May 2025 00:31:27 +0900 Subject: [PATCH 081/226] Debug --- evm-tests/test/uid.precompile.lookup.test.ts | 5 +---- pallets/subtensor/src/utils/evm.rs | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index e1e75837a9..39b695775f 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -52,10 +52,6 @@ describe("Test the UID Lookup precompile", () => { const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); const concatenatedHash = keccak256(concatenatedArray); - console.info(hotkey.publicKey) - console.info(concatenatedArray) - console.info(concatenatedHash) - console.info(convertPublicKeyToSs58(hotkey.publicKey)) const signature = await evmWallet.signMessage(concatenatedHash); const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, @@ -69,6 +65,7 @@ describe("Test the UID Lookup precompile", () => { .catch((error) => { console.log(`transaction error ${error}`) }); const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) + console.info(storedEvmKey) assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) }) diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 3b31c86fe7..85686f738f 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -54,10 +54,10 @@ impl Pallet { let uncompressed = secp_pubkey.serialize(); let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); - ensure!( - evm_key == hashed_evm_key, - Error::::InvalidRecoveredPublicKey - ); + // ensure!( + // evm_key == hashed_evm_key, + // Error::::InvalidRecoveredPublicKey + // ); let current_block_number = Self::get_current_block_as_u64(); From 7878f019a6d406f184d669e113f4f73ac2ba6764 Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 1 May 2025 02:22:12 +0900 Subject: [PATCH 082/226] Debug --- pallets/subtensor/src/utils/evm.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 85686f738f..a9d4d9c108 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -35,10 +35,10 @@ impl Pallet { ) -> dispatch::DispatchResult { let coldkey = ensure_signed(origin)?; - ensure!( - Self::get_owning_coldkey_for_hotkey(&hotkey) == coldkey, - Error::::NonAssociatedColdKey - ); + // ensure!( + // Self::get_owning_coldkey_for_hotkey(&hotkey) == coldkey, + // Error::::NonAssociatedColdKey + // ); let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; From 6d1a8f38885c6586451905b23127f289b1ae94c2 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 12:29:34 -0700 Subject: [PATCH 083/226] Upgrade benchmarks to V2 --- pallets/subtensor/src/benchmarks.rs | 2632 ++++++++++++++------------- 1 file changed, 1404 insertions(+), 1228 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index b5ff1197e0..9201a73fc5 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -5,7 +5,7 @@ use crate::Pallet as Subtensor; use crate::*; use codec::Compact; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v2::*; use frame_support::assert_ok; use frame_system::{RawOrigin, pallet_prelude::BlockNumberFor}; pub use pallet::*; @@ -16,1276 +16,1452 @@ use sp_runtime::{ }; use sp_std::vec; -benchmarks! { - // Add individual benchmarks here - benchmark_register { - let netuid: u16 = 1; //11 is the benchmark network. - let tempo: u16 = 1; - let modality: u16 = 0; - let hotkey: T::AccountId = account("Alice", 0, 1); - let coldkey: T::AccountId = account("Test", 0, 2); - - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_registration_allowed(netuid, true); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - - let block_number: u64 = Subtensor::::get_current_block_as_u64(); - let (nonce, work): (u64, Vec) = Subtensor::::create_work_for_block_number( - netuid, - block_number, - 3, - &hotkey, - ); - - - }: register( RawOrigin::Signed( hotkey.clone() ), netuid, block_number, nonce, work, hotkey.clone(), coldkey.clone() ) - - benchmark_set_weights { - - // This is a whitelisted caller who can make transaction without weights. - let netuid: u16 = 1; - let version_key: u64 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_network_registration_allowed( netuid, true ); - Subtensor::::set_max_registrations_per_block( netuid, 4096 ); - Subtensor::::set_target_registrations_per_interval( netuid, 4096 ); - - let mut seed : u32 = 1; - let mut dests: Vec = vec![]; - let mut weights: Vec = vec![]; - let signer : T::AccountId = account("Alice", 0, seed); - - for id in 0..4096_u16 { - let hotkey: T::AccountId = account("Alice", 0, seed); - let coldkey: T::AccountId = account("Test", 0, seed); - seed += 1; +#[frame_benchmarking::v2::benchmarks] +mod pallet_benchmarks { + use super::*; + + #[benchmark] + fn register() { + let netuid: u16 = 1; + let tempo: u16 = 1; + let hotkey: T::AccountId = account("Alice", 0, 1); + let coldkey: T::AccountId = account("Test", 0, 2); + + Subtensor::::init_new_network(netuid, tempo); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + + let block_number: u64 = Subtensor::::get_current_block_as_u64(); + let (nonce, work): (u64, Vec) = + Subtensor::::create_work_for_block_number(netuid, block_number, 3, &hotkey); + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuid, + block_number, + nonce, + work, + hotkey.clone(), + coldkey.clone(), + ); + } + + #[benchmark] + fn set_weights() { + let netuid: u16 = 1; + let version_key: u64 = 1; + let tempo: u16 = 1; + + Subtensor::::init_new_network(netuid, tempo); + Subtensor::::set_max_allowed_uids(netuid, 4096); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_max_registrations_per_block(netuid, 4096); + Subtensor::::set_target_registrations_per_interval(netuid, 4096); + + let mut seed: u32 = 1; + let mut dests = Vec::new(); + let mut weights = Vec::new(); + let signer: T::AccountId = account("Alice", 0, seed); + + for _ in 0..4096 { + let hotkey: T::AccountId = account("Alice", 0, seed); + let coldkey: T::AccountId = account("Test", 0, seed); + seed += 1; + + Subtensor::::set_burn(netuid, 1); + let amount_to_be_staked: u64 = 1_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + let uid = Subtensor::::get_uid_for_net_and_hotkey(netuid, &hotkey).unwrap(); + Subtensor::::set_validator_permit_for_uid(netuid, uid, true); + + dests.push(uid); + weights.push(uid); + } + + #[extrinsic_call] + _( + RawOrigin::Signed(signer.clone()), + netuid, + dests, + weights, + version_key, + ); + } + + #[benchmark] + fn become_delegate() { + let netuid: u16 = 1; + let tempo: u16 = 1; + + Subtensor::::init_new_network(netuid, tempo); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_max_allowed_uids(netuid, 4096); + Subtensor::::set_network_registration_allowed(netuid, true); + + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + let amount_to_be_staked: u64 = 1_000_000_000; + + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); + } + + #[benchmark] + fn add_stake() { + let netuid: u16 = 1; + let tempo: u16 = 1; + + Subtensor::::init_new_network(netuid, tempo); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + let total_stake: u64 = 1_000_000_000; + let amount: u64 = 60_000_000; + + Subtensor::::add_balance_to_coldkey_account(&coldkey, total_stake); + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + amount, + ); + } + + #[benchmark] + fn add_stake_aggregate() { + let netuid: u16 = 1; + let tempo: u16 = 1; + + Subtensor::::init_new_network(netuid, tempo); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + let total_stake: u64 = 1_000_000_000; + let amount: u64 = 600_000; + + Subtensor::::add_balance_to_coldkey_account(&coldkey, total_stake); + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + amount, + ); + } + + #[benchmark] + fn remove_stake_limit_aggregate() { + let netuid: u16 = 1; + + Subtensor::::increase_total_stake(1_000_000_000_000); + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + Subtensor::::set_burn(netuid, 1); + + let limit: u64 = 1_000_000_000; + let tao_reserve: u64 = 150_000_000_000; + let alpha_in: u64 = 100_000_000_000; + SubnetTAO::::insert(netuid, tao_reserve); + SubnetAlphaIn::::insert(netuid, alpha_in); + + let wallet_bal: u64 = 1_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, wallet_bal); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + Subtensor::::add_balance_to_coldkey_account(&coldkey, 100_000_000_000u64); + assert_ok!(Subtensor::::add_stake( + RawOrigin::Signed(coldkey.clone()).into(), + hotkey.clone(), + netuid, + 100_000_000_000u64 + )); + + let amount_unstaked: u64 = 30_000_000_000; + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + amount_unstaked, + limit, + false, + ); + } + + #[benchmark] + fn remove_stake_aggregate() { + let netuid: u16 = 1; + + Subtensor::::increase_total_stake(1_000_000_000_000); + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); Subtensor::::set_burn(netuid, 1); - let amount_to_be_staked = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); - Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())?; + let wallet_bal: u64 = 1_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, wallet_bal); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + Subtensor::::add_balance_to_coldkey_account(&coldkey, 100_000_000_000u64); + assert_ok!(Subtensor::::add_stake( + RawOrigin::Signed(coldkey.clone()).into(), + hotkey.clone(), + netuid, + 100_000_000_000u64 + )); + + let amount_unstaked: u64 = 600_000; + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + amount_unstaked, + ); + } + + #[benchmark] + fn add_stake_limit_aggregate() { + let netuid: u16 = 1; + + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + + let amount: u64 = 900_000_000_000; + let limit: u64 = 6_000_000_000; + let stake_amt: u64 = 440_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount); + + let tao_reserve: u64 = 150_000_000_000; + let alpha_in: u64 = 100_000_000_000; + SubnetTAO::::insert(netuid, tao_reserve); + SubnetAlphaIn::::insert(netuid, alpha_in); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + stake_amt, + limit, + false, + ); + } + + #[benchmark] + fn serve_axon() { + let netuid: u16 = 1; + let caller: T::AccountId = whitelisted_caller(); + let version: u32 = 2; + let ip: u128 = 1676056785; + let port: u16 = 128; + let ip_type: u8 = 4; + let protocol: u8 = 0; + let placeholder1: u8 = 0; + let placeholder2: u8 = 0; + + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + + let reg_fee: u64 = Subtensor::::get_burn_as_u64(netuid); + let deposit = reg_fee.saturating_mul(2); + Subtensor::::add_balance_to_coldkey_account(&caller, deposit); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(caller.clone()).into(), + netuid, + caller.clone() + )); + Subtensor::::set_serving_rate_limit(netuid, 0); + + #[extrinsic_call] + _( + RawOrigin::Signed(caller.clone()), + netuid, + version, + ip, + port, + ip_type, + protocol, + placeholder1, + placeholder2, + ); + } + + #[benchmark] + fn serve_prometheus() { + let netuid: u16 = 1; + let caller: T::AccountId = whitelisted_caller(); + let version: u32 = 2; + let ip: u128 = 1676056785; + let port: u16 = 128; + let ip_type: u8 = 4; + + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + + let reg_fee: u64 = Subtensor::::get_burn_as_u64(netuid); + let deposit = reg_fee.saturating_mul(2); + Subtensor::::add_balance_to_coldkey_account(&caller, deposit); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(caller.clone()).into(), + netuid, + caller.clone() + )); + Subtensor::::set_serving_rate_limit(netuid, 0); + + #[extrinsic_call] + _( + RawOrigin::Signed(caller.clone()), + netuid, + version, + ip, + port, + ip_type, + ); + } + + #[benchmark] + fn burned_register() { + let netuid: u16 = 1; + let seed: u32 = 1; + let hotkey: T::AccountId = account("Alice", 0, seed); + let coldkey: T::AccountId = account("Test", 0, seed); + + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + + let amount: u64 = 1_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), netuid, hotkey.clone()); + } + + #[benchmark] + fn root_register() { + let netuid: u16 = 1; + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); + assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + + let amount: u64 = 100_000_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); + } + + #[benchmark] + fn register_network() { + let seed: u32 = 1; + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("TestHotkey", 0, seed); + + Subtensor::::set_network_rate_limit(1); + let amount: u64 = 100_000_000_000_000u64.saturating_mul(2); + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount); - let uid = Subtensor::::get_uid_for_net_and_hotkey(netuid, &hotkey.clone()).unwrap(); - Subtensor::::set_validator_permit_for_uid(netuid, uid, true); - dests.push(id); - weights.push(id); + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); } - }: set_weights(RawOrigin::Signed( signer.clone() ), netuid, dests, weights, version_key) + #[benchmark] + fn commit_weights() { + let tempo: u16 = 1; + let netuid: u16 = 1; + let version_key: u64 = 0; + let uids: Vec = vec![0]; + let weight_values: Vec = vec![10]; + let hotkey: T::AccountId = account("hot", 0, 1); + let coldkey: T::AccountId = account("cold", 0, 2); + let start_nonce: u64 = 300_000; + + let commit_hash: H256 = BlakeTwo256::hash_of(&( + hotkey.clone(), + netuid, + uids.clone(), + weight_values.clone(), + version_key, + )); + + Subtensor::::init_new_network(netuid, tempo); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + + let block_number: u64 = Subtensor::::get_current_block_as_u64(); + let (nonce, work) = Subtensor::::create_work_for_block_number( + netuid, + block_number, + start_nonce, + &hotkey, + ); + assert_ok!(Subtensor::::register( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + block_number, + nonce, + work, + hotkey.clone(), + coldkey.clone() + )); + Subtensor::::set_validator_permit_for_uid(netuid, 0, true); + Subtensor::::set_commit_reveal_weights_enabled(netuid, true); + + #[extrinsic_call] + _(RawOrigin::Signed(hotkey.clone()), netuid, commit_hash); + } + #[benchmark] + fn reveal_weights() { + let tempo: u16 = 0; + let netuid: u16 = 1; + let version_key: u64 = 0; + let uids: Vec = vec![0]; + let weight_values: Vec = vec![10]; + let salt: Vec = vec![8]; + let hotkey: T::AccountId = account("hot", 0, 1); + let coldkey: T::AccountId = account("cold", 1, 2); + + Subtensor::::init_new_network(netuid, tempo); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + + let block_number: u64 = Subtensor::::get_current_block_as_u64(); + let (nonce, work) = + Subtensor::::create_work_for_block_number(netuid, block_number, 3, &hotkey); + + let _ = Subtensor::::register( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + block_number, + nonce, + work.clone(), + hotkey.clone(), + coldkey.clone(), + ); + + Subtensor::::set_validator_permit_for_uid(netuid, 0, true); + Subtensor::::set_commit_reveal_weights_enabled(netuid, true); + + let commit_hash: H256 = BlakeTwo256::hash_of(&( + hotkey.clone(), + netuid, + uids.clone(), + weight_values.clone(), + salt.clone(), + version_key, + )); + let _ = Subtensor::::commit_weights( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + commit_hash, + ); + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuid, + uids.clone(), + weight_values.clone(), + salt.clone(), + version_key, + ); + } - benchmark_become_delegate { - // This is a whitelisted caller who can make transaction without weights. - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let version_key: u64 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let seed : u32 = 1; + #[benchmark] + fn schedule_swap_coldkey() { + let old_coldkey: T::AccountId = account("old_cold", 0, 1); + let new_coldkey: T::AccountId = account("new_cold", 1, 2); + let amount: u64 = 100_000_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&old_coldkey, amount); - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); + #[extrinsic_call] + _(RawOrigin::Signed(old_coldkey.clone()), new_coldkey.clone()); + } - Subtensor::::set_network_registration_allowed( netuid, true); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + #[benchmark] + fn sudo_set_tx_childkey_take_rate_limit() { + let new_rate_limit: u64 = 100; - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); + #[extrinsic_call] + _(RawOrigin::Root, new_rate_limit); + } - let amount_to_be_staked = 1000000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); + #[benchmark] + fn set_childkey_take() { + let netuid: u16 = 1; + let coldkey: T::AccountId = account("Cold", 0, 1); + let hotkey: T::AccountId = account("Hot", 0, 1); + let take: u16 = 1000; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let reg_fee: u64 = Subtensor::::get_burn_as_u64(netuid); + let deposit = reg_fee.saturating_mul(2); + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + take, + ); + } - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - }: become_delegate(RawOrigin::Signed( coldkey.clone() ), hotkey.clone()) + #[benchmark] + fn swap_coldkey() { + let old_coldkey: T::AccountId = account("old_coldkey", 0, 0); + let new_coldkey: T::AccountId = account("new_coldkey", 0, 0); + let hotkey1: T::AccountId = account("hotkey1", 0, 0); + let netuid: u16 = 1; + let swap_cost: u64 = Subtensor::::get_key_swap_cost(); + let free_balance_old: u64 = 12345 + swap_cost; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + + let block_number: u64 = Subtensor::::get_current_block_as_u64(); + let (nonce, work) = + Subtensor::::create_work_for_block_number(netuid, block_number, 3, &hotkey1); + let _ = Subtensor::::register( + RawOrigin::Signed(old_coldkey.clone()).into(), + netuid, + block_number, + nonce, + work.clone(), + hotkey1.clone(), + old_coldkey.clone(), + ); + + Subtensor::::add_balance_to_coldkey_account(&old_coldkey, free_balance_old); + let name: Vec = b"The fourth Coolest Identity".to_vec(); + let identity = ChainIdentity { + name, + url: vec![], + image: vec![], + discord: vec![], + description: vec![], + additional: vec![], + }; + Identities::::insert(&old_coldkey, identity); + + #[extrinsic_call] + _( + RawOrigin::Root, + old_coldkey.clone(), + new_coldkey.clone(), + swap_cost, + ); + } - benchmark_add_stake { - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let version_key: u64 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let seed : u32 = 1; + #[benchmark] + fn batch_reveal_weights() { + let tempo: u16 = 0; + let netuid: u16 = 1; + let num_commits: usize = 10; + + let hotkey: T::AccountId = account("hot", 0, 1); + let coldkey: T::AccountId = account("cold", 0, 2); + + Subtensor::::init_new_network(netuid, tempo); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + Subtensor::::set_commit_reveal_weights_enabled(netuid, true); + Subtensor::::set_weights_set_rate_limit(netuid, 0); + + let block_number: u64 = Subtensor::::get_current_block_as_u64(); + let (nonce, work) = + Subtensor::::create_work_for_block_number(netuid, block_number, 3, &hotkey); + let origin = T::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())); + assert_ok!(Subtensor::::register( + origin.clone(), + netuid, + block_number, + nonce, + work.clone(), + hotkey.clone(), + coldkey.clone() + )); + Subtensor::::set_validator_permit_for_uid(netuid, 0, true); + + let mut uids_list = Vec::new(); + let mut values_list = Vec::new(); + let mut salts_list = Vec::new(); + let mut version_keys = Vec::new(); + + for i in 0..num_commits { + let uids = vec![0u16]; + let values = vec![i as u16]; + let salts = vec![i as u16]; + let version_key_i: u64 = i as u64; + + let commit_hash: H256 = BlakeTwo256::hash_of(&( + hotkey.clone(), + netuid, + uids.clone(), + values.clone(), + salts.clone(), + version_key_i, + )); + + assert_ok!(Subtensor::::commit_weights( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + commit_hash + )); + + uids_list.push(uids); + values_list.push(values); + salts_list.push(salts); + version_keys.push(version_key_i); + } + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuid, + uids_list, + values_list, + salts_list, + version_keys, + ); + } - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); + #[benchmark] + fn recycle_alpha() { + let netuid: u16 = 1; - Subtensor::::set_burn(netuid, 1); - Subtensor::::set_network_registration_allowed( netuid, true ); + let coldkey: T::AccountId = account("Test", 0, 1); + let hotkey: T::AccountId = account("Alice", 0, 1); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_burn(netuid, 1); - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); + let amount_to_be_staked: u64 = 1_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + let alpha_amount: u64 = 1_000_000; + SubnetAlphaOut::::insert(netuid, alpha_amount * 2); + + Subtensor::::increase_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey, + &coldkey, + netuid, + alpha_amount, + ); + + assert_eq!(TotalHotkeyAlpha::::get(&hotkey, netuid), alpha_amount); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + alpha_amount, + netuid, + ); + } - let amount: u64 = 60000000; - let amount_to_be_staked = 1000000000u64; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); + #[benchmark] + fn burn_alpha() { + let netuid: u16 = 1; + let coldkey: T::AccountId = account("Test", 0, 1); + let hotkey: T::AccountId = account("Alice", 0, 1); - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - }: add_stake(RawOrigin::Signed( coldkey.clone() ), hotkey, netuid, amount) + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_burn(netuid, 1); - benchmark_add_stake_aggregate { - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let version_key: u64 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let seed : u32 = 1; + let amount_to_be_staked: u64 = 1_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + let alpha_amount: u64 = 1_000_000; + SubnetAlphaOut::::insert(netuid, alpha_amount * 2); + Subtensor::::increase_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey, + &coldkey, + netuid, + alpha_amount, + ); + assert_eq!(TotalHotkeyAlpha::::get(&hotkey, netuid), alpha_amount); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + alpha_amount, + netuid, + ); + } - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1); - Subtensor::::set_network_registration_allowed( netuid, true ); + #[benchmark] + fn start_call() { + let netuid: u16 = 1; + let coldkey: T::AccountId = account("Test", 0, 1); + let hotkey: T::AccountId = account("Alice", 0, 1); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_network_registration_allowed(netuid, true); - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); + Subtensor::::set_burn(netuid, 1); + let amount_to_be_staked: u64 = 1_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); + SubnetOwner::::set(netuid, coldkey.clone()); + + assert_ok!(Subtensor::::do_burned_registration( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + assert_eq!(SubnetOwner::::get(netuid), coldkey.clone()); + assert_eq!(FirstEmissionBlockNumber::::get(netuid), None); + + let current_block: u64 = Subtensor::::get_current_block_as_u64(); + let duration = ::DurationOfStartCall::get(); + let block: BlockNumberFor = (current_block + duration) + .try_into() + .ok() + .expect("can't convert to block number"); + frame_system::Pallet::::set_block_number(block); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), netuid); + } - let amount: u64 = 600000; - let amount_to_be_staked = 1000000000u64; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); + #[benchmark] + fn adjust_senate() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 1); + let root: u16 = Subtensor::::get_root_netuid(); - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - }: add_stake_aggregate(RawOrigin::Signed( coldkey.clone() ), hotkey, netuid, amount) + Subtensor::::init_new_network(root, 1); + Uids::::insert(root, &hotkey, 0u16); - benchmark_remove_stake_limit_aggregate{ - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let seed : u32 = 1; + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); + } - // Set our total stake to 1000 TAO - Subtensor::::increase_total_stake(1_000_000_000_000); + #[benchmark] + fn add_stake_limit() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 1); + let netuid: u16 = 1; + let amount: u64 = 1_000_000; + let limit: u64 = 1_000_000; + let allow: bool = true; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let bond = Subtensor::::get_burn_as_u64(netuid); + let deposit = (amount + bond + DefaultStakingFee::::get()) * 10; + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + SubnetTAO::::insert(netuid, deposit); + SubnetAlphaIn::::insert(netuid, deposit); + TotalStake::::set(deposit); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + amount, + limit, + allow, + ); + } - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_registration_allowed( netuid, true ); - SubtokenEnabled::::insert(netuid, true); + #[benchmark] + fn move_stake() { + let coldkey: T::AccountId = whitelisted_caller(); + let origin: T::AccountId = account("A", 0, 1); + let destination: T::AccountId = account("B", 0, 2); + let netuid: u16 = 1; + + SubtokenEnabled::::insert(netuid, true); + Subtensor::::init_new_network(netuid, 1); + + let burn_fee = Subtensor::::get_burn_as_u64(netuid); + let stake_tao: u64 = 1_000_000; + let deposit = burn_fee.saturating_mul(2).saturating_add(stake_tao); + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + origin.clone() + )); + + SubnetTAO::::insert(netuid, deposit); + SubnetAlphaIn::::insert(netuid, deposit); + TotalStake::::set(deposit); + + assert_ok!(Subtensor::::add_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + origin.clone(), + netuid, + stake_tao, + u64::MAX, + false + )); + + let alpha_to_move: u64 = + Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&origin, &coldkey, netuid); + + Subtensor::::create_account_if_non_existent(&coldkey, &destination); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + origin.clone(), + destination.clone(), + netuid, + netuid, + alpha_to_move, + ); + } - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); - - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - Subtensor::::set_burn(netuid, 1); - - let limit: u64 = 1_000_000_000; - let tao_reserve = 150_000_000_000_u64; - let alpha_in = 100_000_000_000_u64; - SubnetTAO::::insert(netuid, tao_reserve); - SubnetAlphaIn::::insert(netuid, alpha_in); - - let wallet_bal = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), wallet_bal); - - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); + #[benchmark] + fn remove_stake_limit() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 1); + let netuid: u16 = 1; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let bond = Subtensor::::get_burn_as_u64(netuid); + let fee = DefaultStakingFee::::get(); + let amount: u64 = 1_000_000; + let deposit = (amount + bond + fee).saturating_mul(10); + + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hotkey.clone() + )); + + SubnetTAO::::insert(netuid, deposit); + SubnetAlphaIn::::insert(netuid, deposit); + SubnetAlphaOut::::insert(netuid, deposit); + TotalStake::::set(deposit); + + assert_ok!(Subtensor::::add_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + hotkey.clone(), + netuid, + amount, + u64::MAX, + false + )); + + let alpha: u64 = + Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); + assert_ok!(Subtensor::::remove_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + hotkey.clone(), + netuid, + alpha, + u64::MAX, + true + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + netuid, + alpha, + u64::MAX, + true, + ); + } - let u64_staked_amt = 100_000_000_000; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), u64_staked_amt); + #[benchmark] + fn swap_stake_limit() { + let coldkey: T::AccountId = whitelisted_caller(); + let hot: T::AccountId = account("A", 0, 1); + let netuid: u16 = 1; + let allow: bool = true; + + SubtokenEnabled::::insert(netuid, true); + Subtensor::::init_new_network(netuid, 1); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + let stake_tao: u64 = 1_000_000; + let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hot.clone() + )); + + SubnetTAO::::insert(netuid, deposit); + SubnetAlphaIn::::insert(netuid, deposit); + TotalStake::::set(deposit); + + assert_ok!(Subtensor::::add_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + hot.clone(), + netuid, + stake_tao, + u64::MAX, + allow + )); + + let alpha_to_swap: u64 = + Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hot, &coldkey, netuid); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hot.clone(), + netuid, + netuid, + alpha_to_swap, + u64::MAX, + allow, + ); + } - assert_ok!(Subtensor::::add_stake(RawOrigin::Signed( coldkey.clone() ).into() , hotkey.clone(), netuid, u64_staked_amt)); + #[benchmark] + fn transfer_stake() { + let coldkey: T::AccountId = whitelisted_caller(); + let dest: T::AccountId = account("B", 0, 2); + let hot: T::AccountId = account("A", 0, 1); + let netuid: u16 = 1; + + SubtokenEnabled::::insert(netuid, true); + Subtensor::::init_new_network(netuid, 1); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + let stake_tao: u64 = 1_000_000; + let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hot.clone() + )); + + SubnetTAO::::insert(netuid, deposit); + SubnetAlphaIn::::insert(netuid, deposit); + TotalStake::::set(deposit); + + assert_ok!(Subtensor::::add_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + hot.clone(), + netuid, + stake_tao, + u64::MAX, + false + )); + + let alpha_to_transfer: u64 = + Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hot, &coldkey, netuid); + + Subtensor::::create_account_if_non_existent(&dest, &hot); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + dest.clone(), + hot.clone(), + netuid, + netuid, + alpha_to_transfer, + ); + } - let amount_unstaked: u64 = 30_000_000_000; - }: remove_stake_limit_aggregate(RawOrigin::Signed( coldkey.clone() ), hotkey.clone(), netuid, amount_unstaked, limit, false) + #[benchmark] + fn swap_stake() { + let coldkey: T::AccountId = whitelisted_caller(); + let hot: T::AccountId = account("A", 0, 9); + let netuid: u16 = 1; + + SubtokenEnabled::::insert(netuid, true); + Subtensor::::init_new_network(netuid, 1); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + let stake_tao: u64 = 1_000_000; + let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid, + hot.clone() + )); + + SubnetTAO::::insert(netuid, deposit); + SubnetAlphaIn::::insert(netuid, deposit); + TotalStake::::set(deposit); + + assert_ok!(Subtensor::::add_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + hot.clone(), + netuid, + stake_tao, + u64::MAX, + false + )); + + let alpha_to_swap: u64 = + Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hot, &coldkey, netuid); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hot.clone(), + netuid, + netuid, + alpha_to_swap, + ); + } - benchmark_remove_stake_aggregate{ - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let version_key: u64 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let seed : u32 = 1; - - // Set our total stake to 1000 TAO - Subtensor::::increase_total_stake(1_000_000_000_000); + #[benchmark] + fn batch_commit_weights() { + let hotkey: T::AccountId = whitelisted_caller(); + let netuid: u16 = 1; + let count: usize = 3; + let mut netuids: Vec> = Vec::new(); + let mut hashes: Vec = Vec::new(); + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.saturating_mul(2)); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + hotkey.clone() + )); + + Subtensor::::set_validator_permit_for_uid(netuid, 0, true); + Subtensor::::set_commit_reveal_weights_enabled(netuid, true); + + for i in 0..count { + netuids.push(Compact(netuid)); + hashes.push(H256::repeat_byte(i as u8)); + } + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuids.clone(), + hashes.clone(), + ); + } - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_registration_allowed( netuid, true ); - SubtokenEnabled::::insert(netuid, true); + #[benchmark] + fn batch_set_weights() { + let hotkey: T::AccountId = whitelisted_caller(); + let netuid: u16 = 1; + let version: u64 = 1; + let entries: Vec<(Compact, Compact)> = vec![(Compact(0u16), Compact(0u16))]; + let netuids: Vec> = vec![Compact(netuid)]; + let weights: Vec, Compact)>> = vec![entries.clone()]; + let keys: Vec> = vec![Compact(version)]; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.saturating_mul(2)); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + hotkey.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuids.clone(), + weights.clone(), + keys.clone(), + ); + } + + #[benchmark] + fn commit_crv3_weights() { + let hotkey: T::AccountId = whitelisted_caller(); + let netuid: u16 = 1; + let vec_commit: Vec = vec![0; MAX_CRV3_COMMIT_SIZE_BYTES as usize]; + let commit: BoundedVec<_, _> = vec_commit.try_into().unwrap(); + let round: u64 = 0; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.saturating_mul(2)); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + hotkey.clone() + )); + + Subtensor::::set_commit_reveal_weights_enabled(netuid, true); + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuid, + commit.clone(), + round, + ); + } + + #[benchmark] + fn decrease_take() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 1); + let take: u16 = 100; + + Delegates::::insert(&hotkey, 200u16); + Owner::::insert(&hotkey, &coldkey); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), take); + } + + #[benchmark] + fn increase_take() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 2); + let take: u16 = 150; + + Delegates::::insert(&hotkey, 100u16); + Owner::::insert(&hotkey, &coldkey); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), take); + } - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + #[benchmark] + fn register_network_with_identity() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 1); + let identity: Option = None; + + Subtensor::::set_network_registration_allowed(1, true); + Subtensor::::set_network_rate_limit(1); + let amount: u64 = 9_999_999_999_999; + Subtensor::::add_balance_to_coldkey_account(&coldkey, amount); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + hotkey.clone(), + identity.clone(), + ); + } - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - Subtensor::::set_burn(netuid, 1); - - let wallet_bal = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), wallet_bal); - - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - - // Stake 10% of our current total staked TAO - let u64_staked_amt = 100_000_000_000; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), u64_staked_amt); - - assert_ok!( Subtensor::::add_stake(RawOrigin::Signed( coldkey.clone() ).into() , hotkey.clone(), netuid, u64_staked_amt)); - - let amount_unstaked: u64 = 600000; - }: remove_stake_aggregate(RawOrigin::Signed( coldkey.clone() ), hotkey.clone(), netuid, amount_unstaked) - - benchmark_add_stake_limit_aggregate { - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let seed : u32 = 1; - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1); - Subtensor::::set_network_registration_allowed( netuid, true ); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - - let amount = 900_000_000_000; - let limit: u64 = 6_000_000_000; - let amount_to_be_staked = 440_000_000_000; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount); - - let tao_reserve = 150_000_000_000_u64; - let alpha_in = 100_000_000_000_u64; - SubnetTAO::::insert(netuid, tao_reserve); - SubnetAlphaIn::::insert(netuid, alpha_in); - - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - }: add_stake_limit_aggregate(RawOrigin::Signed( coldkey.clone() ), hotkey, netuid, amount_to_be_staked, limit, false) + #[benchmark] + fn serve_axon_tls() { + let caller: T::AccountId = whitelisted_caller(); + let netuid: u16 = 1; + let version: u32 = 1; + let ip: u128 = 0xC0A8_0001; + let port: u16 = 30333; + let ip_type: u8 = 4; + let proto: u8 = 0; + let p1: u8 = 0; + let p2: u8 = 0; + let cert: Vec = vec![]; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let reg_fee = Subtensor::::get_burn_as_u64(netuid); + let deposit: u64 = reg_fee.saturating_mul(2); + Subtensor::::add_balance_to_coldkey_account(&caller, deposit); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(caller.clone()).into(), + netuid, + caller.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(caller.clone()), + netuid, + version, + ip, + port, + ip_type, + proto, + p1, + p2, + cert.clone(), + ); + } + #[benchmark] + fn set_identity() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("Alice", 0, 5); + let name = b"n".to_vec(); + let url = vec![]; + let repo = vec![]; + let img = vec![]; + let disc = vec![]; + let descr = vec![]; + let add = vec![]; + + Subtensor::::create_account_if_non_existent(&coldkey, &hotkey); + Subtensor::::init_new_network(1, 1); + let deposit: u64 = 1_000_000_000u64.saturating_mul(2); + Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + SubtokenEnabled::::insert(1, true); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + 1, + hotkey.clone() + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + name.clone(), + url.clone(), + repo.clone(), + img.clone(), + disc.clone(), + descr.clone(), + add.clone(), + ); + } - benchmark_serve_axon{ - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - - let version: u32 = 2; - let ip: u128 = 1676056785; - let port: u16 = 128; - let ip_type: u8 = 4; - let protocol: u8 = 0; - let placeholder1: u8 = 0; - let placeholder2: u8 = 0; - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); - - Subtensor::::set_burn(netuid, 1); - let amount_to_be_staked = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&caller.clone(), amount_to_be_staked); - - assert_ok!(Subtensor::::do_burned_registration(caller_origin.clone(), netuid, caller.clone())); - - Subtensor::::set_serving_rate_limit(netuid, 0); - - }: serve_axon(RawOrigin::Signed( caller.clone() ), netuid, version, ip, port, ip_type, protocol, placeholder1, placeholder2) - - benchmark_serve_prometheus { - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; + #[benchmark] + fn set_subnet_identity() { + let coldkey: T::AccountId = whitelisted_caller(); + let netuid: u16 = 1; + let name = b"n".to_vec(); + let repo = vec![]; + let contact = vec![]; + let url = vec![]; + let disc = vec![]; + let descr = vec![]; + let add = vec![]; + + SubnetOwner::::insert(netuid, coldkey.clone()); + SubtokenEnabled::::insert(netuid, true); + + #[extrinsic_call] + _( + RawOrigin::Signed(coldkey.clone()), + netuid, + name.clone(), + repo.clone(), + contact.clone(), + url.clone(), + disc.clone(), + descr.clone(), + add.clone(), + ); + } - let version: u32 = 2; - let ip: u128 = 1676056785; - let port: u16 = 128; - let ip_type: u8 = 4; + #[benchmark] + fn set_tao_weights() { + let netuid: u16 = 1; + let hotkey: T::AccountId = account("A", 0, 6); + let dests = vec![0u16]; + let weights = vec![0u16]; + let version: u64 = 1; + + Subtensor::::init_new_network(netuid, 1); + + #[extrinsic_call] + _( + RawOrigin::None, + netuid, + hotkey.clone(), + dests.clone(), + weights.clone(), + version, + ); + } - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + #[benchmark] + fn swap_hotkey() { + let coldkey: T::AccountId = whitelisted_caller(); + let old: T::AccountId = account("A", 0, 7); + let new: T::AccountId = account("B", 0, 8); + Owner::::insert(&old, &coldkey); + let cost: u64 = Subtensor::::get_key_swap_cost(); + Subtensor::::add_balance_to_coldkey_account(&coldkey, cost); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), old.clone(), new.clone()); + } - Subtensor::::set_burn(netuid, 1); - let amount_to_be_staked = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&caller.clone(), amount_to_be_staked); + #[benchmark] + fn try_associate_hotkey() { + let coldkey: T::AccountId = whitelisted_caller(); + let hot: T::AccountId = account("A", 0, 1); - assert_ok!(Subtensor::::do_burned_registration(caller_origin.clone(), netuid, caller.clone())); - Subtensor::::set_serving_rate_limit(netuid, 0); + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hot.clone()); + } + + #[benchmark] + fn unstake_all() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("A", 0, 14); + Subtensor::::create_account_if_non_existent(&coldkey, &hotkey); - }: serve_prometheus(RawOrigin::Signed( caller.clone() ), netuid, version, ip, port, ip_type) + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); + } - /* - benchmark_sudo_register { - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let tempo: u16 = 0; - let modality: u16 = 0; - let stake: u64 = 10; - let balance: u64 = 1000000000; - - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); - - let seed : u32 = 1; - let block_number: u64 = Subtensor::::get_current_block_as_u64(); - let hotkey: T::AccountId = account("Alice", 0, seed); - let coldkey: T::AccountId = account("Test", 0, seed); - - let amount_to_be_staked = balance.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); - - }: sudo_register(RawOrigin::>::Root, netuid, hotkey, coldkey, stake, balance) - */ - benchmark_burned_register { - let netuid: u16 = 1; - let seed : u32 = 1; - let hotkey: T::AccountId = account("Alice", 0, seed); - let coldkey: T::AccountId = account("Test", 0, seed); - let modality: u16 = 0; - let tempo: u16 = 1; - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1); - - let amount_to_be_staked = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); - - }: burned_register(RawOrigin::Signed( coldkey.clone() ), netuid, hotkey) - - - benchmark_root_register { - let netuid: u16 = 1; - let version_key: u64 = 1; - let tempo: u16 = 1; - let seed : u32 = 1; - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1); - Subtensor::::set_network_registration_allowed( netuid, true); - - Subtensor::::set_max_allowed_uids( netuid, 4096 ); - assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); - - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - - let amount_to_be_staked = 100_000_000_000_000u64; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); - - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - }: root_register(RawOrigin::Signed(coldkey), hotkey) - - benchmark_register_network { - let seed : u32 = 1; - - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("TestHotkey", 0, seed); - - Subtensor::::set_network_rate_limit(1); - - let amount_to_be_staked = 100_000_000_000_000u64; - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked.saturating_mul(2)); - }: register_network(RawOrigin::Signed(coldkey), hotkey.clone()) - - // benchmark_dissolve_network { - // let seed : u32 = 1; - - // let coldkey: T::AccountId = account("Test", 0, seed); - // let hotkey: T::AccountId = account("TestHotkey", 0, seed); - - // Subtensor::::set_network_rate_limit(0); - - // let amount_to_be_staked = 100_000_000_000_000u64; - // Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); - // assert_ok!(Subtensor::::register_network(RawOrigin::Root.into(), hotkey.clone())); - // }: dissolve_network(RawOrigin::Root, coldkey.clone(), 1) - - - // swap_hotkey { - // let seed: u32 = 1; - // let coldkey: T::AccountId = account("Alice", 0, seed); - // let old_hotkey: T::AccountId = account("Bob", 0, seed); - // let new_hotkey: T::AccountId = account("Charlie", 0, seed); - - // let netuid = 1u16; - // Subtensor::::init_new_network(netuid, 100); - // Subtensor::::set_min_burn(netuid, 1); - // Subtensor::::set_max_burn(netuid, 1); - // Subtensor::::set_target_registrations_per_interval(netuid, 256); - // Subtensor::::set_max_registrations_per_block(netuid, 256); - - // Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), 10_000_000_000u64); - // assert_ok!(Subtensor::::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, old_hotkey.clone())); - // assert_ok!(Subtensor::::become_delegate(RawOrigin::Signed(coldkey.clone()).into(), old_hotkey.clone())); - - // let max_uids = Subtensor::::get_max_allowed_uids(netuid) as u32; - // for i in 0..max_uids - 1 { - // let coldkey: T::AccountId = account("Axon", 0, i); - // let hotkey: T::AccountId = account("Hotkey", 0, i); - - // Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), 10_000_000_000u64); - // assert_ok!(Subtensor::::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey)); - // assert_ok!(Subtensor::::add_stake(RawOrigin::Signed(coldkey).into(), old_hotkey.clone(), 1_000_000_000)); - // } - // }: _(RawOrigin::Signed(coldkey), old_hotkey, new_hotkey) - - commit_weights { - let tempo: u16 = 1; - let netuid: u16 = 1; - let version_key: u64 = 0; - let uids: Vec = vec![0]; - let weight_values: Vec = vec![10]; - let hotkey: T::AccountId = account("hot", 0, 1); - let coldkey: T::AccountId = account("cold", 0, 2); - let start_nonce = 300000; - - let commit_hash: H256 = BlakeTwo256::hash_of(&( - hotkey.clone(), - netuid, - uids.clone(), - weight_values.clone(), - version_key, - )); - - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - - let block_number: u64 = Subtensor::::get_current_block_as_u64(); - let (nonce, work): (u64, Vec) = Subtensor::::create_work_for_block_number( - netuid, - block_number, - start_nonce, - &hotkey, - ); - let result = Subtensor::::register( - ::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())), - netuid, - block_number, - nonce, - work, - hotkey.clone(), - coldkey, - ); - assert_ok!(result); - Subtensor::::set_validator_permit_for_uid(netuid, 0, true); - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); - -}: commit_weights(RawOrigin::Signed(hotkey.clone()), netuid, commit_hash) - -reveal_weights { - let tempo: u16 = 0; - let netuid: u16 = 1; - let version_key: u64 = 0; - let uids: Vec = vec![0]; - let weight_values: Vec = vec![10]; - let salt: Vec = vec![8]; - let hotkey: T::AccountId = account("hot", 0, 1); - let coldkey: T::AccountId = account("cold", 1, 2); - - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_registration_allowed(netuid, true); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - - let block_number: u64 = Subtensor::::get_current_block_as_u64(); - let (nonce, work): (u64, Vec) = Subtensor::::create_work_for_block_number( - netuid, - block_number, - 3, - &hotkey, - ); - - let _ = Subtensor::::register( - ::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())), - netuid, - block_number, - nonce, - work.clone(), - hotkey.clone(), - coldkey.clone(), - ); - - Subtensor::::set_validator_permit_for_uid(netuid, 0, true); - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); - - let commit_hash: H256 = BlakeTwo256::hash_of(&( - hotkey.clone(), - netuid, - uids.clone(), - weight_values.clone(), - salt.clone(), - version_key, - )); - let _ = Subtensor::::commit_weights(::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())), netuid, commit_hash); - - }: reveal_weights(RawOrigin::Signed(hotkey.clone()), netuid, uids, weight_values, salt, version_key) - - schedule_swap_coldkey { - let old_coldkey: T::AccountId = account("old_cold", 0, 1); - let new_coldkey: T::AccountId = account("new_cold", 1, 2); - Subtensor::::add_balance_to_coldkey_account(&old_coldkey.clone(), 100_000_000_000_000u64); - }: schedule_swap_coldkey(RawOrigin::Signed(old_coldkey.clone()), new_coldkey.clone()) - -// schedule_dissolve_network { -// let coldkey: T::AccountId = account("coldkey", 0, 1); -// let netuid = 1; -// }: schedule_dissolve_network(RawOrigin::Signed(coldkey.clone()), netuid) - - benchmark_sudo_set_tx_childkey_take_rate_limit { - // We don't need to set up any initial state for this benchmark - // as it's a simple setter function that only requires root origin - let new_rate_limit: u64 = 100; -}: sudo_set_tx_childkey_take_rate_limit(RawOrigin::Root, new_rate_limit) - - benchmark_set_childkey_take { - // Setup - let netuid: u16 = 1; - let tempo: u16 = 1; - let seed: u32 = 1; - let coldkey: T::AccountId = account("Cold", 0, seed); - let hotkey: T::AccountId = account("Hot", 0, seed); - let take: u16 = 1000; // 10% in basis points - - // Initialize the network - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - - // Register the hotkey - Subtensor::::set_burn(netuid, 1); - let amount_to_be_staked = 1_000_000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); -}: set_childkey_take(RawOrigin::Signed(coldkey), hotkey, netuid, take) - - swap_coldkey { - // Set up initial state - let old_coldkey: T::AccountId = account("old_coldkey", 0, 0); - let new_coldkey: T::AccountId = account("new_coldkey", 0, 0); - let hotkey1: T::AccountId = account("hotkey1", 0, 0); - let netuid = 1u16; - let stake_amount1 = 1000u64; - let stake_amount2 = 2000u64; - let swap_cost = Subtensor::::get_key_swap_cost(); - let free_balance_old = 12345u64 + swap_cost; - let tempo: u16 = 1; - - // Setup initial state - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_registration_allowed(netuid, true); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - - let block_number: u64 = Subtensor::::get_current_block_as_u64(); - let (nonce, work): (u64, Vec) = Subtensor::::create_work_for_block_number( - netuid, - block_number, - 3, - &hotkey1, - ); - - let _ = Subtensor::::register( - ::RuntimeOrigin::from(RawOrigin::Signed(old_coldkey.clone())), - netuid, - block_number, - nonce, - work.clone(), - hotkey1.clone(), - old_coldkey.clone(), - ); - - // Add balance to old coldkey - Subtensor::::add_balance_to_coldkey_account( - &old_coldkey, - stake_amount1 + stake_amount2 + free_balance_old, - ); - - // Insert an Identity - let name: Vec = b"The fourth Coolest Identity".to_vec(); - let identity: ChainIdentity = ChainIdentity { - name: name.clone(), - url: vec![], - image: vec![], - discord: vec![], - description: vec![], - additional: vec![], - }; - - Identities::::insert(&old_coldkey, identity); - - // Benchmark setup complete, now execute the extrinsic -}: swap_coldkey(RawOrigin::Root, old_coldkey.clone(), new_coldkey.clone(), swap_cost) - -batch_reveal_weights { - let tempo: u16 = 0; - let netuid: u16 = 1; - let num_commits: usize = 10; - - let hotkey: T::AccountId = account("hot", 0, 1); - let coldkey: T::AccountId = account("cold", 0, 2); - - Subtensor::::init_new_network(netuid, tempo); - Subtensor::::set_network_registration_allowed(netuid, true); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); - Subtensor::::set_weights_set_rate_limit(netuid, 0); // Disable rate limiting for benchmarking - - let block_number: u64 = Subtensor::::get_current_block_as_u64(); - let (nonce, work): (u64, Vec) = Subtensor::::create_work_for_block_number( - netuid, - block_number, - 3, - &hotkey, - ); - - let origin = T::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())); - assert_ok!(Subtensor::::register( - origin.clone(), - netuid, - block_number, - nonce, - work.clone(), - hotkey.clone(), - coldkey.clone(), - )); - - let uid: u16 = 0; - - Subtensor::::set_validator_permit_for_uid(netuid, uid, true); - - let mut uids_list = Vec::new(); - let mut values_list = Vec::new(); - let mut salts_list = Vec::new(); - let mut version_keys = Vec::new(); - - for i in 0..num_commits { - let uids: Vec = vec![uid]; - let values: Vec = vec![i as u16]; - let salt: Vec = vec![i as u16]; - let version_key_i: u64 = i as u64; - - let commit_hash: H256 = BlakeTwo256::hash_of(&( - hotkey.clone(), - netuid, - uids.clone(), - values.clone(), - salt.clone(), - version_key_i, - )); - - assert_ok!(Subtensor::::commit_weights( - T::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())), - netuid, - commit_hash, - )); - - uids_list.push(uids); - values_list.push(values); - salts_list.push(salt); - version_keys.push(version_key_i); - } -}: batch_reveal_weights( - RawOrigin::Signed(hotkey.clone()), - netuid, - uids_list, - values_list, - salts_list, - version_keys -) - -benchmark_recycle_alpha { - let caller: T::AccountId = whitelisted_caller::(); - let netuid: u16 = 1; - let tempo: u16 = 1; - let seed: u32 = 1; - - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_network_registration_allowed(netuid, true); - Subtensor::::set_burn(netuid, 1); - - let amount_to_be_staked = 1_000_000_000u64.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); - - assert_ok!(Subtensor::::do_burned_registration( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone() - )); - - let alpha_amount: u64 = 1_000_000; - SubnetAlphaOut::::insert(netuid, alpha_amount * 2); - - Subtensor::::increase_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey, - &coldkey, - netuid, - alpha_amount - ); - - assert_eq!(TotalHotkeyAlpha::::get(&hotkey, netuid), alpha_amount); -}: recycle_alpha(RawOrigin::Signed(coldkey), hotkey, alpha_amount, netuid) - -benchmark_burn_alpha { - let caller: T::AccountId = whitelisted_caller::(); - let netuid: u16 = 1; - let tempo: u16 = 1; - let seed: u32 = 1; - - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_network_registration_allowed(netuid, true); - Subtensor::::set_burn(netuid, 1); - - let amount_to_be_staked = 1_000_000_000u64.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); - - assert_ok!(Subtensor::::do_burned_registration( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone() - )); - - let alpha_amount: u64 = 1_000_000; - SubnetAlphaOut::::insert(netuid, alpha_amount * 2); - - Subtensor::::increase_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey, - &coldkey, - netuid, - alpha_amount - ); - - assert_eq!(TotalHotkeyAlpha::::get(&hotkey, netuid), alpha_amount); - -}: burn_alpha(RawOrigin::Signed(coldkey), hotkey, alpha_amount, netuid) - - -benchmark_start_call { - let caller: T::AccountId = whitelisted_caller::>(); - let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); - let netuid: u16 = 1; - let tempo: u16 = 1; - let seed: u32 = 1; - - // Set up coldkey and hotkey - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - - // Initialize network - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_network_registration_allowed(netuid, true); - - // Register the neuron - Subtensor::::set_burn(netuid, 1); - let amount_to_be_staked = 1000000u32.into(); - Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked); - SubnetOwner::::set(netuid, coldkey.clone()); - - assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); - assert_eq!(SubnetOwner::::get(netuid), coldkey.clone()); - assert_eq!(FirstEmissionBlockNumber::::get(netuid), None); - let current_block: u64 = Subtensor::::get_current_block_as_u64(); - let duration = ::DurationOfStartCall::get(); - let block: BlockNumberFor = (current_block + duration).try_into().ok().expect("can't convert to block number"); - frame_system::Pallet::::set_block_number(block); - -}: start_call(RawOrigin::Signed(coldkey), netuid) - -benchmark_adjust_senate { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 1); - let root: u16 = Subtensor::::get_root_netuid(); - Subtensor::::init_new_network(root, 1); - Uids::::insert(root, &hotkey, 0u16); -}: adjust_senate(RawOrigin::Signed(coldkey), hotkey.clone()) - -benchmark_add_stake_limit { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey : T::AccountId = account("Alice", 0, 1); - let netuid : u16 = 1; - let amount : u64 = 1_000_000; - let limit : u64 = 1_000_000; - let allow : bool = true; - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let bond = Subtensor::::get_burn_as_u64(netuid); - let deposit = (amount + bond + DefaultStakingFee::::get()) * 10; - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone() - ) - ); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); - -}: add_stake_limit(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), netuid, amount, limit, allow) - -benchmark_move_stake { - let coldkey: T::AccountId = whitelisted_caller::>(); - let origin: T::AccountId = account("A", 0, 1); - let destination: T::AccountId = account("B", 0, 2); - let netuid: u16 = 1; - - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); - let burn_fee = Subtensor::::get_burn_as_u64(netuid); - let stake_tao = 1_000_000; - let deposit = burn_fee.saturating_mul(2).saturating_add(stake_tao); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - origin.clone() - ) - ); - - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); - - assert_ok!( - Subtensor::::add_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - origin.clone(), - netuid, - stake_tao, - u64::MAX, - false - ) - ); - - let alpha_to_move: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &origin, &coldkey, netuid - ); - - Subtensor::::create_account_if_non_existent(&coldkey, &destination); -}: move_stake(RawOrigin::Signed(coldkey.clone()),origin.clone(),destination.clone(),netuid,netuid,alpha_to_move) - -benchmark_remove_stake_limit { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 1); - let netuid: u16 = 1; - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let bond = Subtensor::::get_burn_as_u64(netuid); - let fee = DefaultStakingFee::::get(); - let amount: u64 = 1_000_000; - let deposit = (amount + bond + fee).saturating_mul(10); - - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone(), - ) - ); - - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - SubnetAlphaOut::::insert(netuid, deposit); - TotalStake::::set(deposit); - - assert_ok!( - Subtensor::::add_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hotkey.clone(), - netuid, - amount, - u64::MAX, - false, - ) - ); - - let alpha: u64 = Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey, &coldkey, netuid - ); - - assert_ok!( - Subtensor::::remove_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hotkey.clone(), - netuid, - alpha, - u64::MAX, - true, - ) - ); -}: remove_stake_limit(RawOrigin::Signed(coldkey.clone()),hotkey.clone(),netuid,alpha,u64::MAX,true) - -benchmark_swap_stake_limit { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hot: T::AccountId = account("A", 0, 1); - let netuid: u16 = 1; - let allow: bool = true; - - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - let stake_tao = 1_000_000; - let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hot.clone() - ) - ); - - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); - - assert_ok!( - Subtensor::::add_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hot.clone(), - netuid, - stake_tao, - u64::MAX, - allow - ) - ); - - let alpha_to_swap: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &hot, &coldkey, netuid - ); -}: swap_stake_limit(RawOrigin::Signed(coldkey.clone()),hot.clone(),netuid,netuid,alpha_to_swap,u64::MAX,allow) - -benchmark_transfer_stake { - let coldkey: T::AccountId = whitelisted_caller::>(); - let dest: T::AccountId = account("B", 0, 2); - let hot: T::AccountId = account("A", 0, 1); - let netuid: u16 = 1; - - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - let stake_tao = 1_000_000; - let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hot.clone() - ) - ); - - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); - - assert_ok!( - Subtensor::::add_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hot.clone(), - netuid, - stake_tao, - u64::MAX, - false - ) - ); - - let alpha_to_transfer: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &hot, &coldkey, netuid - ); - - Subtensor::::create_account_if_non_existent(&dest, &hot); -}: transfer_stake(RawOrigin::Signed(coldkey.clone()),dest.clone(),hot.clone(),netuid,netuid,alpha_to_transfer) - -benchmark_swap_stake { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hot: T::AccountId = account("A", 0, 9); - let netuid: u16 = 1; - - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - let stake_tao = 1_000_000; - let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hot.clone() - ) - ); - - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); - - assert_ok!( - Subtensor::::add_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hot.clone(), - netuid, - stake_tao, - u64::MAX, - false - ) - ); - - let alpha_to_swap: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &hot, &coldkey, netuid - ); -}: swap_stake(RawOrigin::Signed(coldkey.clone()),hot.clone(),netuid,netuid,alpha_to_swap) - -benchmark_batch_commit_weights { - let hotkey: T::AccountId = whitelisted_caller::>(); - let netuid: u16 = 1; - let count: usize = 3; - let mut netuids: Vec> = Vec::new(); - let mut hashes: Vec = Vec::new(); - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.saturating_mul(2)); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(hotkey.clone()).into(), - netuid, - hotkey.clone() - ) - ); - - Subtensor::::set_validator_permit_for_uid(netuid, 0, true); - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); - - for i in 0..count { - netuids.push( Compact(netuid) ); - hashes.push( H256::repeat_byte(i as u8) ); - } -}: batch_commit_weights(RawOrigin::Signed(hotkey.clone()),netuids, hashes) - -benchmark_batch_set_weights { - let hotkey: T::AccountId = whitelisted_caller::>(); - let netuid: u16 = 1; - let version: u64 = 1; - let entries: Vec<(Compact, Compact)> = vec![ - (Compact(0u16), Compact(0u16)) - ]; - let netuids: Vec> = - vec![ Compact(netuid) ]; - let weights: Vec, Compact)>> = - vec![ entries.clone() ]; - let keys: Vec> = - vec![ Compact(version) ]; - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.saturating_mul(2)); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(hotkey.clone()).into(), - netuid, - hotkey.clone() - ) - ); -}: batch_set_weights(RawOrigin::Signed(hotkey.clone()),netuids, weights, keys) - -benchmark_commit_crv3_weights { - let hotkey: T::AccountId = whitelisted_caller::>(); - let netuid: u16 = 1; - let vec_commit: Vec = vec![0; MAX_CRV3_COMMIT_SIZE_BYTES as usize]; - let commit: BoundedVec<_, _> = - vec_commit.try_into().unwrap(); - let round: u64 = 0; - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.saturating_mul(2)); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(hotkey.clone()).into(), - netuid, - hotkey.clone() - ) - ); - - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); -}: commit_crv3_weights(RawOrigin::Signed(hotkey.clone()),netuid, commit, round) - -benchmark_decrease_take { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 1); - let take: u16 = 100; - - Delegates::::insert(&hotkey, 200u16); - Owner::::insert(&hotkey, &coldkey); -}: decrease_take(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), take) - -benchmark_increase_take { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 2); - let take: u16 = 150; - - Delegates::::insert(&hotkey, 100u16); - Owner::::insert(&hotkey, &coldkey); -}: increase_take(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), take) - -benchmark_register_network_with_identity { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 1); - let identity: Option = None; - Subtensor::::set_network_registration_allowed( 1, true ); - Subtensor::::set_network_rate_limit(1); - Subtensor::::add_balance_to_coldkey_account(&coldkey, 9_999_999_999_999u64); -}: register_network_with_identity(RawOrigin::Signed(coldkey.clone()), hotkey.clone(), identity) - -benchmark_serve_axon_tls { - let caller: T::AccountId = whitelisted_caller::>(); - let netuid: u16 = 1; - let version: u32 = 1; - let ip: u128 = 0xC0A8_0001; - let port: u16 = 30333; - let ip_type: u8 = 4; - let proto: u8 = 0; - let p1: u8 = 0; - let p2: u8 = 0; - let cert: Vec = vec![]; - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - Subtensor::::add_balance_to_coldkey_account(&caller, reg_fee.saturating_mul(2)); - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(caller.clone()).into(), - netuid, - caller.clone() - ) - ); -}: serve_axon_tls(RawOrigin::Signed(caller.clone()),netuid,version,ip,port,ip_type,proto,p1,p2,cert) - -benchmark_set_identity { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 5); - let name = b"n".to_vec(); - let url = vec![]; - let repo = vec![]; - let img = vec![]; - let disc = vec![]; - let descr= vec![]; - let add = vec![]; - - Subtensor::::create_account_if_non_existent(&coldkey, &hotkey); - Subtensor::::init_new_network(1, 1); - Subtensor::::add_balance_to_coldkey_account(&coldkey, 1_000_000_000u64.saturating_mul(2)); - SubtokenEnabled::::insert(1, true); - assert_ok!( Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - 1, hotkey.clone() - )); -}: set_identity(RawOrigin::Signed(coldkey.clone()),name, url, repo, img, disc, descr, add) - -benchmark_set_subnet_identity { - let coldkey: T::AccountId = whitelisted_caller::>(); - let netuid: u16 = 1; - let name = b"n".to_vec(); - let repo = vec![]; - let contact = vec![]; - let url = vec![]; - let disc = vec![]; - let descr = vec![]; - let add = vec![]; - - SubnetOwner::::insert(netuid, coldkey.clone()); - SubtokenEnabled::::insert(netuid, true); -}: set_subnet_identity(RawOrigin::Signed(coldkey.clone()), netuid, name, repo, contact, url, disc, descr, add) - -benchmark_set_tao_weights { - let netuid: u16 = 1; - let hotkey: T::AccountId = account("A", 0, 6); - let dests = vec![0u16]; - let weights = vec![0u16]; - let version: u64 = 1; - - Subtensor::::init_new_network(netuid, 1); -}: set_tao_weights(RawOrigin::None, netuid, hotkey.clone(), dests, weights, version) - -benchmark_swap_hotkey { - let coldkey: T::AccountId = whitelisted_caller::>(); - let old: T::AccountId = account("A", 0, 7); - let new: T::AccountId = account("B", 0, 8); - Owner::::insert(&old, &coldkey); - let cost = Subtensor::::get_key_swap_cost(); - Subtensor::::add_balance_to_coldkey_account(&coldkey, cost); -}: swap_hotkey(RawOrigin::Signed(coldkey.clone()), old.clone(), new.clone()) - -benchmark_try_associate_hotkey { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hot: T::AccountId = account("A", 0, 1); -}: try_associate_hotkey(RawOrigin::Signed(coldkey.clone()), hot.clone()) - -benchmark_unstake_all { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("A", 0, 14); - Subtensor::::create_account_if_non_existent(&coldkey, &hotkey); -}: unstake_all(RawOrigin::Signed(coldkey.clone()), hotkey.clone()) - -benchmark_unstake_all_alpha { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("A", 0, 15); - Subtensor::::create_account_if_non_existent(&coldkey, &hotkey); -}: unstake_all_alpha(RawOrigin::Signed(coldkey.clone()), hotkey.clone()) + #[benchmark] + fn unstake_all_alpha() { + let coldkey: T::AccountId = whitelisted_caller(); + let hotkey: T::AccountId = account("A", 0, 15); + Subtensor::::create_account_if_non_existent(&coldkey, &hotkey); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); + } } From 0638ee27d417d7dd117e1909b2fe2f55c58d763b Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 14:22:38 -0700 Subject: [PATCH 084/226] update benchmark.sh for V2 --- scripts/benchmark.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh index 14ade547ea..4a1c99a62c 100755 --- a/scripts/benchmark.sh +++ b/scripts/benchmark.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -EXTRINSIC="${1:-benchmark_register}" +EXTRINSIC="${1:-register}" cargo build \ --profile production \ From e28a8ab0fabe7456aae849a6b5aa63ce2a92fe47 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 14:22:57 -0700 Subject: [PATCH 085/226] update benchmark_action for V2 --- scripts/benchmark_action.sh | 260 +++++++++++++++++++++++++----------- 1 file changed, 181 insertions(+), 79 deletions(-) diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index 9989f66c52..1d529f2eb0 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -26,6 +26,144 @@ echo "──────────────────────── MAX_RETRIES=3 attempt=1 +################################################################################ +# Helper function to "finalize" an extrinsic. We look up the code-side +# reads/writes/weight in dispatches.rs, then compare to measured values. +################################################################################ +summary_lines=() +failures=() +fail=0 + +function process_extr() { + local e="$1" + local us="$2" + local rd="$3" + local wr="$4" + + # If any piece is empty, skip + if [[ -z "$e" || -z "$us" || -z "$rd" || -z "$wr" ]]; then + return + fi + + # Convert microseconds to picoseconds + local meas_ps + meas_ps=$(awk -v x="$us" 'BEGIN{printf("%.0f", x * 1000000)}') + + # --------------------------------------------------------------------------- + # Code-side lookup from $DISPATCH + # --------------------------------------------------------------------------- + # We find the matching "pub fn (" line in dispatches.rs, + # then parse the preceding Weight::from_parts, .reads, .writes lines. + + local code_record + code_record=$(awk -v extr="$e" ' + /^\s*#\[pallet::call_index\(/ { next } + + /Weight::from_parts/ { + lw = $0 + sub(/.*Weight::from_parts\(\s*/, "", lw) + sub(/[^0-9_].*$/, "", lw) + gsub(/_/, "", lw) + w = lw + } + + /reads_writes\(/ { + lw = $0 + sub(/.*reads_writes\(/, "", lw) + sub(/\).*/, "", lw) + split(lw, io, ",") + gsub(/^[ \t]+|[ \t]+$/, "", io[1]) + gsub(/^[ \t]+|[ \t]+$/, "", io[2]) + r = io[1] + wri = io[2] + next + } + + /\.reads\(/ { + lw = $0 + sub(/.*\.reads\(/, "", lw) + sub(/\).*/, "", lw) + r = lw + next + } + + /\.writes\(/ { + lw = $0 + sub(/.*\.writes\(/, "", lw) + sub(/\).*/, "", lw) + wri = lw + next + } + + # main condition: function name must match "pub fn (" + $0 ~ ("pub fn[[:space:]]+" extr "\\(") { + print w, r, wri + exit + } + ' "$DISPATCH") + + # separate into variables + local code_w code_reads code_writes + read code_w code_reads code_writes <<<"$code_record" + + # strip underscores or non-digits + code_w="${code_w//_/}" + code_w="${code_w%%[^0-9]*}" + code_reads="${code_reads//_/}" + code_reads="${code_reads%%[^0-9]*}" + code_writes="${code_writes//_/}" + code_writes="${code_writes%%[^0-9]*}" + + # default them if empty + [[ -z "$code_w" ]] && code_w="0" + [[ -z "$code_reads" ]] && code_reads="0" + [[ -z "$code_writes" ]] && code_writes="0" + + # compute drift + local drift + drift=$(awk -v a="$meas_ps" -v b="$code_w" 'BEGIN { + if (b == "" || b == 0) { + print 99999 + exit + } + printf("%.1f", (a - b) / b * 100) + }') + + # produce summary line + summary_lines+=("$(printf "%-30s | reads code=%3s measured=%3s | writes code=%3s measured=%3s | weight code=%12s measured=%12s | drift %6s%%" \ + "$e" \ + "$code_reads" \ + "$rd" \ + "$code_writes" \ + "$wr" \ + "$code_w" \ + "$meas_ps" \ + "$drift")") + + # validations + if (( rd != code_reads )); then + failures+=("[${e}] reads mismatch code=${code_reads}, measured=${rd}") + fail=1 + fi + if (( wr != code_writes )); then + failures+=("[${e}] writes mismatch code=${code_writes}, measured=${wr}") + fail=1 + fi + if [[ "$code_w" == "0" ]]; then + failures+=("[${e}] zero code weight") + fail=1 + fi + + local abs_drift=${drift#-} + local drift_int=${abs_drift%%.*} + if (( drift_int > THRESHOLD )); then + failures+=("[${e}] weight code=${code_w}, measured=${meas_ps}, drift=${drift}%") + fail=1 + fi +} + +################################################################################ + while (( attempt <= MAX_RETRIES )); do echo echo "Attempt #$attempt" @@ -34,6 +172,7 @@ while (( attempt <= MAX_RETRIES )); do # run benchmarks and capture output TMP="$(mktemp)" trap "rm -f \"$TMP\"" EXIT + ./target/production/node-subtensor benchmark pallet \ --runtime "$RUNTIME_WASM" \ --genesis-builder=runtime \ @@ -43,99 +182,62 @@ while (( attempt <= MAX_RETRIES )); do --extrinsic "*" \ --steps 50 \ --repeat 5 \ - | tee "$TMP" + | tee "$TMP" - # reset counters - declare -a summary_lines=() - declare -a failures=() + # reset arrays + summary_lines=() + failures=() fail=0 + + # Current extrinsic data extr="" + meas_us="" + meas_reads="" + meas_writes="" + + # We'll finalize an extrinsic each time we see a new "Extrinsic: " + # or at the end of parsing. + function finalize_extr() { + process_extr "$extr" "$meas_us" "$meas_reads" "$meas_writes" + # reset + extr="" + meas_us="" + meas_reads="" + meas_writes="" + } - # parse output + # parse the file line-by-line while IFS= read -r line; do - if [[ $line =~ Extrinsic:\ \"benchmark_([[:alnum:]_]+)\" ]]; then + # match new extrinsic name + if [[ $line =~ Extrinsic:\ \"([[:alnum:]_]+)\" ]]; then + # finalize the old extrinsic if any + finalize_extr extr="${BASH_REMATCH[1]}" continue fi + # match "Time ~= ..." if [[ $line =~ Time\ ~=\ *([0-9]+(\.[0-9]+)?) ]]; then - [[ -z "$extr" ]] && continue - meas_us="${BASH_REMATCH[1]}" - meas_ps=$(awk -v u="$meas_us" 'BEGIN{printf("%.0f", u * 1000000)}') - - # grab reads & writes - meas_reads="" meas_writes="" - while IFS= read -r sub; do - [[ $sub =~ Reads[[:space:]]*=[[:space:]]*([0-9]+) ]] && meas_reads="${BASH_REMATCH[1]}" && continue - [[ $sub =~ Writes[[:space:]]*=[[:space:]]*([0-9]+) ]] && meas_writes="${BASH_REMATCH[1]}" && break - done - - # extract code-side values - code_record=$( - awk -v extr="$extr" ' - /^\s*#\[pallet::call_index\(/ { next } - /Weight::from_parts/ { - lw=$0; sub(/.*Weight::from_parts\(\s*/, "", lw); - sub(/[^0-9_].*$/, "", lw); gsub(/_/, "", lw); - w=lw - } - /reads_writes\(/ { - lw=$0; sub(/.*reads_writes\(/, "", lw); - sub(/\).*/, "", lw); - split(lw,io,/,/); - gsub(/^[ \t]+|[ \t]+$/, "", io[1]); - gsub(/^[ \t]+|[ \t]+$/, "", io[2]); - r=io[1]; wri=io[2]; next - } - /\.reads\(/ { - lw=$0; sub(/.*\.reads\(/, "", lw); - sub(/\).*/, "", lw); - r=lw; next - } - /\.writes\(/ { - lw=$0; sub(/.*\.writes\(/, "", lw); - sub(/\).*/, "", lw); - wri=lw; next - } - $0 ~ ("pub fn[[:space:]]+" extr "\\(") { print w, r, wri; exit } - ' "$DISPATCH" - ) - read code_w code_reads code_writes <<<"$code_record" - - # strip any non-digit (e.g. "_u64") so math works - code_w=${code_w//_/} - code_w=${code_w%%[^0-9]*} - code_reads=${code_reads//_/} - code_reads=${code_reads%%[^0-9]*} - code_writes=${code_writes//_/} - code_writes=${code_writes%%[^0-9]*} - - # compute drift % - drift=$(awk -v a="$meas_ps" -v b="$code_w" 'BEGIN{printf("%.1f", (a-b)/b*100)}') - - summary_lines+=("$(printf "%-30s | reads code=%3s measured=%3s | writes code=%3s measured=%3s | weight code=%12s measured=%12s | drift %6s%%" \ - "$extr" "$code_reads" "$meas_reads" "$code_writes" "$meas_writes" "$code_w" "$meas_ps" "$drift")") - - # validations - [[ -z "$code_w" ]] && failures+=("[${extr}] missing code weight") && fail=1 - [[ -z "$meas_reads" ]] && failures+=("[${extr}] missing measured reads") && fail=1 - [[ -z "$meas_writes" ]] && failures+=("[${extr}] missing measured writes") && fail=1 - (( meas_reads != code_reads )) && failures+=("[${extr}] reads mismatch code=${code_reads}, measured=${meas_reads}") && fail=1 - (( meas_writes != code_writes )) && failures+=("[${extr}] writes mismatch code=${code_writes}, measured=${meas_writes}") && fail=1 - [[ "$code_w" == "0" ]] && failures+=("[${extr}] zero code weight") && fail=1 - - abs_drift=${drift#-} - drift_int=${abs_drift%%.*} - if (( drift_int > THRESHOLD )); then - failures+=("[${extr}] weight code=${code_w}, measured=${meas_ps}, drift=${drift}%") - fail=1 - fi - - extr="" + continue + fi + + # match "Reads = n" + if [[ $line =~ Reads[[:space:]]*=[[:space:]]*([0-9]+) ]]; then + meas_reads="${BASH_REMATCH[1]}" + continue + fi + + # match "Writes = n" + if [[ $line =~ Writes[[:space:]]*=[[:space:]]*([0-9]+) ]]; then + meas_writes="${BASH_REMATCH[1]}" + continue fi done < "$TMP" + # finalize the last extrinsic if we have one + finalize_extr + # summary output echo echo "Benchmark Summary for attempt #$attempt:" From ef14fc41e4b4d81c8c54b38f5727e71cb32990a8 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:11:42 -0700 Subject: [PATCH 086/226] update weight values for v2 --- pallets/subtensor/src/macros/dispatches.rs | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 98b83791e8..1fc8d8e2eb 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -152,9 +152,9 @@ mod dispatches { /// - Attempting to commit when the user has more than the allowed limit of unrevealed commits. /// #[pallet::call_index(96)] - #[pallet::weight((Weight::from_parts(46_000_000, 0) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(72_300_000, 0) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn commit_weights( origin: T::RuntimeOrigin, netuid: u16, @@ -235,9 +235,9 @@ mod dispatches { /// - The revealed hash does not match any committed hash. /// #[pallet::call_index(97)] - #[pallet::weight((Weight::from_parts(103_000_000, 0) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(3)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(122_000_000, 0) + .saturating_add(T::DbWeight::get().reads(16)) + .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn reveal_weights( origin: T::RuntimeOrigin, netuid: u16, @@ -332,8 +332,8 @@ mod dispatches { /// - The input vectors are of mismatched lengths. #[pallet::call_index(98)] #[pallet::weight((Weight::from_parts(367_612_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(3)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().reads(16)) + .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn batch_reveal_weights( origin: T::RuntimeOrigin, netuid: u16, @@ -454,7 +454,7 @@ mod dispatches { /// - The hotkey we are delegating is not owned by the calling coldket. /// #[pallet::call_index(1)] - #[pallet::weight((Weight::from_parts(4_428_000, 0) + #[pallet::weight((Weight::from_parts(5_110_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::No))] pub fn become_delegate(_origin: OriginFor, _hotkey: T::AccountId) -> DispatchResult { @@ -964,10 +964,9 @@ mod dispatches { /// /// Weight is calculated based on the number of database reads and writes. #[pallet::call_index(71)] - #[pallet::weight((Weight::from_parts(127_713_000, 0) - .saturating_add(Weight::from_parts(111_100_000, 11645)) - .saturating_add(T::DbWeight::get().reads(18)) - .saturating_add(T::DbWeight::get().writes(12)), DispatchClass::Operational, Pays::No))] + #[pallet::weight((Weight::from_parts(179_500_000, 0) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(9)), DispatchClass::Operational, Pays::No))] pub fn swap_coldkey( origin: OriginFor, old_coldkey: T::AccountId, @@ -1327,9 +1326,9 @@ mod dispatches { /// - Consider adding checks to prevent scheduling too far into the future. /// TODO: Benchmark this call #[pallet::call_index(73)] - #[pallet::weight((Weight::from_parts(119_000_000, 0) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(31)), DispatchClass::Operational, Pays::Yes))] + #[pallet::weight((Weight::from_parts(44_520_000, 0) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Operational, Pays::Yes))] pub fn schedule_swap_coldkey( origin: OriginFor, new_coldkey: T::AccountId, From 7a8882809558132e7ee05fd8eea7ba66bbe58253 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:13:10 -0700 Subject: [PATCH 087/226] bump spec --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a7a89608c9..88dabca33c 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 264, + spec_version: 265, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 393539949c8d6ec37330f4442e927e8284411a68 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:04:37 -0700 Subject: [PATCH 088/226] update more weight values --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 1fc8d8e2eb..932618c396 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -331,7 +331,7 @@ mod dispatches { /// * `InvalidInputLengths`: /// - The input vectors are of mismatched lengths. #[pallet::call_index(98)] - #[pallet::weight((Weight::from_parts(367_612_000, 0) + #[pallet::weight((Weight::from_parts(420_500_000, 0) .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn batch_reveal_weights( @@ -454,7 +454,7 @@ mod dispatches { /// - The hotkey we are delegating is not owned by the calling coldket. /// #[pallet::call_index(1)] - #[pallet::weight((Weight::from_parts(5_110_000, 0) + #[pallet::weight((Weight::from_parts(4_709_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::No))] pub fn become_delegate(_origin: OriginFor, _hotkey: T::AccountId) -> DispatchResult { From 7c78a1067eeee1f328118805618fa5b48e7fa837 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 17:09:13 -0700 Subject: [PATCH 089/226] update weight --- pallets/subtensor/src/macros/dispatches.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 932618c396..01eb7d7599 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -889,7 +889,7 @@ mod dispatches { /// - The seal is incorrect. /// #[pallet::call_index(6)] - #[pallet::weight((Weight::from_parts(192_000_000, 0) + #[pallet::weight((Weight::from_parts(216_200_000, 0) .saturating_add(T::DbWeight::get().reads(26)) .saturating_add(T::DbWeight::get().writes(23)), DispatchClass::Normal, Pays::No))] pub fn register( From 50b00c12d8c41ee440f0bed6c2deb7413b5e5085 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 30 Apr 2025 17:47:31 -0700 Subject: [PATCH 090/226] update test --- pallets/subtensor/src/tests/registration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/tests/registration.rs b/pallets/subtensor/src/tests/registration.rs index 498cce15b2..3a8ce39ba3 100644 --- a/pallets/subtensor/src/tests/registration.rs +++ b/pallets/subtensor/src/tests/registration.rs @@ -37,7 +37,7 @@ fn test_registration_subscribe_ok_dispatch_info_ok() { assert_eq!( call.get_dispatch_info(), DispatchInfo { - weight: frame_support::weights::Weight::from_parts(3_142_000_000, 0), + weight: frame_support::weights::Weight::from_parts(3_166_200_000, 0), class: DispatchClass::Normal, pays_fee: Pays::No } From ff8c1f2a392959c08712c3db103ab40a45271fad Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 1 May 2025 14:57:54 +0800 Subject: [PATCH 091/226] put migration in hook --- pallets/subtensor/src/macros/hooks.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 4d26994f05..24de5db98b 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -4,6 +4,9 @@ use frame_support::pallet_macros::pallet_section; /// This can later be imported into the pallet using [`import_section`]. #[pallet_section] mod hooks { + use frame_system::migrations; + use num_traits::ops::saturating; + // ================ // ==== Hooks ===== // ================ @@ -101,6 +104,7 @@ mod hooks { .saturating_add(migrations::migrate_set_subtoken_enabled::migrate_set_subtoken_enabled::()) // Remove all entries in TotalHotkeyColdkeyStakesThisInterval .saturating_add(migrations::migrate_remove_total_hotkey_coldkey_stakes_this_interval::migrate_remove_total_hotkey_coldkey_stakes_this_interval::()); + weight // Remove all entries in orphaned storage items .saturating_add( @@ -110,7 +114,9 @@ mod hooks { // Reset bonds moving average .saturating_add(migrations::migrate_reset_bonds_moving_average::migrate_reset_bonds_moving_average::()) // Reset max burn - .saturating_add(migrations::migrate_reset_max_burn::migrate_reset_max_burn::()); + .saturating_add(migrations::migrate_reset_max_burn::migrate_reset_max_burn::()) + // Migrate ColdkeySwapScheduled structure to new format + .saturating_add(migrations::migrate_coldkey_swap_scheduled::migrate_coldkey_swap_scheduled::()); weight } From b311ee1a9b42a70cea962fc14e29c26e333baa5b Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 1 May 2025 15:21:15 +0800 Subject: [PATCH 092/226] remove wrong imports --- pallets/subtensor/src/macros/hooks.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 24de5db98b..ce798456cf 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -4,9 +4,6 @@ use frame_support::pallet_macros::pallet_section; /// This can later be imported into the pallet using [`import_section`]. #[pallet_section] mod hooks { - use frame_system::migrations; - use num_traits::ops::saturating; - // ================ // ==== Hooks ===== // ================ From e5b269bf1ff4541e5673a5dead6089a401d53c2a Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 1 May 2025 19:37:11 +0900 Subject: [PATCH 093/226] Debug --- pallets/subtensor/src/utils/evm.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index a9d4d9c108..5dc3353500 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -33,7 +33,7 @@ impl Pallet { block_number: u64, signature: Signature, ) -> dispatch::DispatchResult { - let coldkey = ensure_signed(origin)?; + // let coldkey = ensure_signed(origin)?; // ensure!( // Self::get_owning_coldkey_for_hotkey(&hotkey) == coldkey, @@ -42,17 +42,17 @@ impl Pallet { let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; - let mut message = [0u8; 64]; - let block_hash = keccak_256(block_number.encode().as_ref()); - message[..32].copy_from_slice(&hotkey.encode()[..]); - message[32..].copy_from_slice(block_hash.as_ref()); - let public = signature - .recover_prehashed(&keccak_256(message.as_ref())) - .ok_or(Error::::UnableToRecoverPublicKey)?; - let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) - .map_err(|_| Error::::UnableToRecoverPublicKey)?; - let uncompressed = secp_pubkey.serialize(); - let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); + // let mut message = [0u8; 64]; + // let block_hash = keccak_256(block_number.encode().as_ref()); + // message[..32].copy_from_slice(&hotkey.encode()[..]); + // message[32..].copy_from_slice(block_hash.as_ref()); + // let public = signature + // .recover_prehashed(&keccak_256(message.as_ref())) + // .ok_or(Error::::UnableToRecoverPublicKey)?; + // let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) + // .map_err(|_| Error::::UnableToRecoverPublicKey)?; + // let uncompressed = secp_pubkey.serialize(); + // let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); // ensure!( // evm_key == hashed_evm_key, From aae7de287570dcf647429f36c8585f6567a73a03 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 14:59:28 +0200 Subject: [PATCH 094/226] fix update_cap/update_min_deposit minimum value check --- pallets/crowdloan/src/lib.rs | 4 ++-- pallets/crowdloan/src/tests.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 5413bd689b..bc020deab7 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -698,7 +698,7 @@ pub mod pallet { // The new min contribution should be greater than absolute minimum contribution. ensure!( - new_min_contribution > T::AbsoluteMinimumContribution::get(), + new_min_contribution >= T::AbsoluteMinimumContribution::get(), Error::::MinimumContributionTooLow ); @@ -771,7 +771,7 @@ pub mod pallet { ensure!(who == crowdloan.creator, Error::::InvalidOrigin); // The new cap should be greater than the actual raised amount. - ensure!(new_cap > crowdloan.raised, Error::::CapTooLow); + ensure!(new_cap >= crowdloan.raised, Error::::CapTooLow); crowdloan.cap = new_cap; Crowdloans::::insert(crowdloan_id, &crowdloan); diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 59bfea6b83..14f4043c19 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -1932,7 +1932,7 @@ fn test_update_min_contribution_fails_if_new_min_contribution_is_too_low() { )); let crowdloan_id: CrowdloanId = 0; - let new_min_contribution: BalanceOf = 10; + let new_min_contribution: BalanceOf = 9; // try update the min contribution assert_err!( @@ -2389,7 +2389,7 @@ fn test_update_cap_fails_if_new_cap_is_too_low() { // try update the cap let crowdloan_id: CrowdloanId = 0; - let new_cap: BalanceOf = 50; + let new_cap: BalanceOf = 49; assert_err!( Crowdloan::update_cap(RuntimeOrigin::signed(creator), crowdloan_id, new_cap), pallet_crowdloan::Error::::CapTooLow From 0b4194e12a8db39d2ce4e6d21d043caa464cd2dd Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 15:10:59 +0200 Subject: [PATCH 095/226] fix withdraw to restrict from the origin and not someone else --- pallets/crowdloan/src/lib.rs | 18 ++-- pallets/crowdloan/src/tests.rs | 149 ++++++++------------------------- 2 files changed, 43 insertions(+), 124 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index bc020deab7..4534c0d9e9 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -261,7 +261,7 @@ pub mod pallet { /// /// The initial deposit will be transfered to the crowdloan account and will be refunded /// in case the crowdloan fails to raise the cap. Additionally, the creator will pay for - /// the execution of the call + /// the execution of the call. /// /// The dispatch origin for this call must be _Signed_. /// @@ -446,47 +446,43 @@ pub mod pallet { /// Withdraw a contribution from an active (not yet finalized or dissolved) crowdloan. /// - /// The origin doesn't needs to be the contributor, it can be any account, - /// making it possible for someone to trigger a refund for a contributor. + /// Only contributions over the deposit can be withdrawn by the creator. /// /// The dispatch origin for this call must be _Signed_. /// /// Parameters: - /// - `contributor`: The contributor to withdraw from. /// - `crowdloan_id`: The id of the crowdloan to withdraw from. #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::withdraw())] pub fn withdraw( origin: OriginFor, - contributor: T::AccountId, #[pallet::compact] crowdloan_id: CrowdloanId, ) -> DispatchResult { - ensure_signed(origin)?; + let who = ensure_signed(origin)?; let mut crowdloan = Self::ensure_crowdloan_exists(crowdloan_id)?; ensure!(!crowdloan.finalized, Error::::AlreadyFinalized); // Ensure contributor has balance left in the crowdloan account - let amount = - Contributions::::get(crowdloan_id, &contributor).unwrap_or_else(Zero::zero); + let amount = Contributions::::get(crowdloan_id, &who).unwrap_or_else(Zero::zero); ensure!(amount > Zero::zero(), Error::::NoContribution); CurrencyOf::::transfer( &crowdloan.funds_account, - &contributor, + &who, amount, Preservation::Expendable, )?; // Remove the contribution from the contributions map and update // crowdloan raised amount to reflect the withdrawal. - Contributions::::remove(crowdloan_id, &contributor); + Contributions::::remove(crowdloan_id, &who); crowdloan.raised = crowdloan.raised.saturating_sub(amount); Crowdloans::::insert(crowdloan_id, &crowdloan); Self::deposit_event(Event::::Withdrew { - contributor, + contributor: who, crowdloan_id, amount, }); diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 14f4043c19..4cd645ae43 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -695,7 +695,7 @@ fn test_contribute_fails_if_contributor_has_insufficient_balance() { } #[test] -fn test_withdraw_succeeds() { +fn test_withdraw_from_contributor_succeeds() { TestState::default() .with_balance(U256::from(1), 100) .with_balance(U256::from(2), 100) @@ -723,121 +723,65 @@ fn test_withdraw_succeeds() { // contribute to the crowdloan let crowdloan_id: CrowdloanId = 0; - let contributor: AccountOf = U256::from(2); - let amount: BalanceOf = 100; + let contributor1: AccountOf = U256::from(2); + let amount1: BalanceOf = 100; assert_ok!(Crowdloan::contribute( - RuntimeOrigin::signed(contributor), + RuntimeOrigin::signed(contributor1), crowdloan_id, - amount + amount1 + )); + + let contributor2: AccountOf = U256::from(3); + let amount2: BalanceOf = 100; + assert_ok!(Crowdloan::contribute( + RuntimeOrigin::signed(contributor2), + crowdloan_id, + amount2 )); // run some more blocks past the end of the contribution period run_to_block(60); - // withdraw from creator + // withdraw from contributor1 assert_ok!(Crowdloan::withdraw( - RuntimeOrigin::signed(creator), - creator, + RuntimeOrigin::signed(contributor1), crowdloan_id )); - // ensure the creator contribution has been removed + // ensure the contributor1 contribution has been removed assert_eq!( - pallet_crowdloan::Contributions::::get(crowdloan_id, creator), + pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), None, ); - // ensure the creator has the correct amount - assert_eq!(pallet_balances::Pallet::::free_balance(creator), 100); + // ensure the contributor1 has the correct amount + assert_eq!( + pallet_balances::Pallet::::free_balance(contributor1), + 100 + ); - // withdraw from contributor + // withdraw from contributor2 assert_ok!(Crowdloan::withdraw( - RuntimeOrigin::signed(contributor), - contributor, + RuntimeOrigin::signed(contributor2), crowdloan_id )); - // ensure the creator contribution has been removed + // ensure the contributor2 contribution has been removed assert_eq!( - pallet_crowdloan::Contributions::::get(crowdloan_id, contributor), + pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), None, ); - // ensure the contributor has the correct amount + // ensure the contributor2 has the correct amount assert_eq!( - pallet_balances::Pallet::::free_balance(contributor), + pallet_balances::Pallet::::free_balance(contributor2), 100 ); // ensure the crowdloan account has the correct amount let funds_account = pallet_crowdloan::Pallet::::funds_account(crowdloan_id); - assert_eq!(Balances::free_balance(funds_account), 0); - // ensure the crowdloan raised amount is updated correctly - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.raised == 0) - ); - }); -} - -#[test] -fn test_withdraw_succeeds_for_another_contributor() { - TestState::default() - .with_balance(U256::from(1), 100) - .with_balance(U256::from(2), 100) - .build_and_execute(|| { - // create a crowdloan - let creator: AccountOf = U256::from(1); - let initial_deposit: BalanceOf = 50; - let min_contribution: BalanceOf = 10; - let cap: BalanceOf = 300; - let end: BlockNumberFor = 50; - - assert_ok!(Crowdloan::create( - RuntimeOrigin::signed(creator), - initial_deposit, - min_contribution, - cap, - end, - Some(noop_call()), - None - )); - - // run some blocks - run_to_block(10); - - // contribute to the crowdloan - let crowdloan_id: CrowdloanId = 0; - let contributor: AccountOf = U256::from(2); - let amount: BalanceOf = 100; - - assert_ok!(Crowdloan::contribute( - RuntimeOrigin::signed(contributor), - crowdloan_id, - amount - )); - - // run some more blocks past the end of the contribution period - run_to_block(60); - - // withdraw for creator as a contributor - assert_ok!(Crowdloan::withdraw( - RuntimeOrigin::signed(contributor), - creator, - crowdloan_id - )); - // ensure the creator has the correct amount - assert_eq!(pallet_balances::Pallet::::free_balance(creator), 100); - // ensure the contributor has the correct amount - assert_eq!( - pallet_balances::Pallet::::free_balance(contributor), - 0 - ); - - // ensure the crowdloan account has the correct amount - let funds_account = pallet_crowdloan::Pallet::::funds_account(crowdloan_id); - assert_eq!(Balances::free_balance(funds_account), 100); + assert_eq!(Balances::free_balance(funds_account), initial_deposit); // ensure the crowdloan raised amount is updated correctly assert!( pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.raised == 100) + .is_some_and(|c| c.raised == initial_deposit) ); }); } @@ -848,12 +792,12 @@ fn test_withdraw_fails_if_bad_origin() { let crowdloan_id: CrowdloanId = 0; assert_err!( - Crowdloan::withdraw(RuntimeOrigin::none(), U256::from(1), crowdloan_id), + Crowdloan::withdraw(RuntimeOrigin::none(), crowdloan_id), DispatchError::BadOrigin ); assert_err!( - Crowdloan::withdraw(RuntimeOrigin::root(), U256::from(1), crowdloan_id), + Crowdloan::withdraw(RuntimeOrigin::root(), crowdloan_id), DispatchError::BadOrigin ); }); @@ -866,11 +810,7 @@ fn test_withdraw_fails_if_crowdloan_does_not_exists() { let crowdloan_id: CrowdloanId = 0; assert_err!( - Crowdloan::withdraw( - RuntimeOrigin::signed(contributor), - contributor, - crowdloan_id - ), + Crowdloan::withdraw(RuntimeOrigin::signed(contributor), crowdloan_id), pallet_crowdloan::Error::::InvalidCrowdloanId ); }); @@ -900,31 +840,14 @@ fn test_withdraw_fails_if_no_contribution_exists() { None )); - // run some blocks - run_to_block(10); - - // contribute to the crowdloan - let contributor: AccountOf = U256::from(2); - let crowdloan_id: CrowdloanId = 0; - let amount: BalanceOf = 100; - - assert_ok!(Crowdloan::contribute( - RuntimeOrigin::signed(contributor), - crowdloan_id, - amount - )); - // run some more blocks past the end of the contribution period run_to_block(60); // try to withdraw - let contributor2: AccountOf = U256::from(3); + let crowdloan_id: CrowdloanId = 0; + let contributor: AccountOf = U256::from(2); assert_err!( - Crowdloan::withdraw( - RuntimeOrigin::signed(contributor2), - contributor2, - crowdloan_id - ), + Crowdloan::withdraw(RuntimeOrigin::signed(contributor), crowdloan_id), pallet_crowdloan::Error::::NoContribution ); }); From 93d7d7fe7da08567d81ccf836a6336b3a2e05174 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 15:35:31 +0200 Subject: [PATCH 096/226] fixed withdraw logic for creator --- pallets/crowdloan/src/lib.rs | 18 ++-- pallets/crowdloan/src/tests.rs | 153 ++++++++++++++++++++++++++++++++- 2 files changed, 165 insertions(+), 6 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 4534c0d9e9..f241f41ced 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -251,6 +251,8 @@ pub mod pallet { CallUnavailable, /// The crowdloan is not ready to be dissolved, it still has contributions. NotReadyToDissolve, + /// The deposit cannot be withdrawn from the crowdloan. + DepositCannotBeWithdrawn, } #[pallet::call] @@ -464,9 +466,18 @@ pub mod pallet { ensure!(!crowdloan.finalized, Error::::AlreadyFinalized); // Ensure contributor has balance left in the crowdloan account - let amount = Contributions::::get(crowdloan_id, &who).unwrap_or_else(Zero::zero); + let mut amount = Contributions::::get(crowdloan_id, &who).unwrap_or_else(Zero::zero); ensure!(amount > Zero::zero(), Error::::NoContribution); + if who == crowdloan.creator { + // Ensure the deposit is left + amount = amount.saturating_sub(crowdloan.deposit); + ensure!(amount > Zero::zero(), Error::::DepositCannotBeWithdrawn); + Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); + } else { + Contributions::::remove(crowdloan_id, &who); + } + CurrencyOf::::transfer( &crowdloan.funds_account, &who, @@ -474,11 +485,8 @@ pub mod pallet { Preservation::Expendable, )?; - // Remove the contribution from the contributions map and update - // crowdloan raised amount to reflect the withdrawal. - Contributions::::remove(crowdloan_id, &who); + // Update the crowdloan raised amount to reflect the withdrawal. crowdloan.raised = crowdloan.raised.saturating_sub(amount); - Crowdloans::::insert(crowdloan_id, &crowdloan); Self::deposit_event(Event::::Withdrew { diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 4cd645ae43..7c4053566e 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -786,6 +786,107 @@ fn test_withdraw_from_contributor_succeeds() { }); } +#[test] +fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { + TestState::default() + .with_balance(U256::from(1), 200) + .build_and_execute(|| { + // create a crowdloan + let creator: AccountOf = U256::from(1); + let initial_deposit: BalanceOf = 50; + let min_contribution: BalanceOf = 10; + let cap: BalanceOf = 300; + let end: BlockNumberFor = 50; + + assert_ok!(Crowdloan::create( + RuntimeOrigin::signed(creator), + initial_deposit, + min_contribution, + cap, + end, + Some(noop_call()), + None + )); + + // contribute to the crowdloan as the creator + let crowdloan_id: CrowdloanId = 0; + + let amount: BalanceOf = 100; + assert_ok!(Crowdloan::contribute( + RuntimeOrigin::signed(creator), + crowdloan_id, + amount + )); + + // withdraw + let crowdloan_id: CrowdloanId = 0; + assert_ok!(Crowdloan::withdraw( + RuntimeOrigin::signed(creator), + crowdloan_id + )); + + // ensure the creator has the correct amount + assert_eq!( + pallet_balances::Pallet::::free_balance(creator), + 200 - initial_deposit + ); + // ensure the creator contribution has been removed + assert_eq!( + pallet_crowdloan::Contributions::::get(crowdloan_id, creator), + Some(initial_deposit), + ); + + // ensure the crowdloan account has the correct amount + let funds_account = pallet_crowdloan::Pallet::::funds_account(crowdloan_id); + assert_eq!(Balances::free_balance(funds_account), initial_deposit); + // ensure the crowdloan raised amount is updated correctly + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.raised == initial_deposit) + ); + }); +} +#[test] +fn test_withdraw_fails_from_creator_with_no_contribution_over_deposit() { + TestState::default() + .with_balance(U256::from(1), 100) + .with_balance(U256::from(2), 200) + .build_and_execute(|| { + // create a crowdloan + let creator: AccountOf = U256::from(1); + let initial_deposit: BalanceOf = 50; + let min_contribution: BalanceOf = 10; + let cap: BalanceOf = 300; + let end: BlockNumberFor = 50; + + assert_ok!(Crowdloan::create( + RuntimeOrigin::signed(creator), + initial_deposit, + min_contribution, + cap, + end, + Some(noop_call()), + None + )); + + // try to withdraw + let crowdloan_id: CrowdloanId = 0; + assert_err!( + Crowdloan::withdraw(RuntimeOrigin::signed(creator), crowdloan_id), + pallet_crowdloan::Error::::DepositCannotBeWithdrawn + ); + + // ensure the crowdloan account has the correct amount + let funds_account = pallet_crowdloan::Pallet::::funds_account(crowdloan_id); + assert_eq!(Balances::free_balance(funds_account), initial_deposit); + // ensure the crowdloan raised amount is updated correctly + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.raised == initial_deposit) + ); + }); +} + #[test] fn test_withdraw_fails_if_bad_origin() { TestState::default().build_and_execute(|| { @@ -816,12 +917,62 @@ fn test_withdraw_fails_if_crowdloan_does_not_exists() { }); } +#[test] +fn test_withdraw_fails_if_crowdloan_has_already_been_finalized() { + TestState::default() + .with_balance(U256::from(1), 100) + .with_balance(U256::from(2), 200) + .build_and_execute(|| { + // create a crowdloan + let creator: AccountOf = U256::from(1); + let deposit: BalanceOf = 50; + let min_contribution: BalanceOf = 10; + let cap: BalanceOf = 100; + let end: BlockNumberFor = 50; + + assert_ok!(Crowdloan::create( + RuntimeOrigin::signed(creator), + deposit, + min_contribution, + cap, + end, + Some(noop_call()), + None, + )); + + // some contribution + let crowdloan_id: CrowdloanId = 0; + let contributor: AccountOf = U256::from(2); + let amount: BalanceOf = 50; + + assert_ok!(Crowdloan::contribute( + RuntimeOrigin::signed(contributor), + crowdloan_id, + amount + )); + + // run some more blocks past the end of the contribution period + run_to_block(60); + + // finalize the crowdloan + assert_ok!(Crowdloan::finalize( + RuntimeOrigin::signed(creator), + crowdloan_id + )); + + // try to withdraw + assert_err!( + Crowdloan::withdraw(RuntimeOrigin::signed(creator), crowdloan_id), + pallet_crowdloan::Error::::AlreadyFinalized + ); + }); +} + #[test] fn test_withdraw_fails_if_no_contribution_exists() { TestState::default() .with_balance(U256::from(1), 100) .with_balance(U256::from(2), 200) - .with_balance(U256::from(3), 100) .build_and_execute(|| { // create a crowdloan let creator: AccountOf = U256::from(1); From 541d227b2f5720ebd16ba51172cd8f2eecd0f098 Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 1 May 2025 22:36:20 +0900 Subject: [PATCH 097/226] Ensure coldkey is signing the tx --- evm-tests/test/uid.precompile.lookup.test.ts | 11 ++++-- pallets/subtensor/src/utils/evm.rs | 40 ++++++++++---------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 39b695775f..7df803c2cc 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -1,6 +1,6 @@ import * as assert from "assert"; -import { getAliceSigner, getDevnetApi, waitForTransactionCompletion, getRandomSubstrateKeypair } from "../src/substrate" +import { getAliceSigner, getDevnetApi, waitForTransactionCompletion, getRandomSubstrateKeypair, getSignerFromKeypair } from "../src/substrate" import { convertToFixedSizeBinary, generateRandomEthersWallet, getPublicClient } from "../src/utils"; import { ETH_LOCAL_URL } from "../src/config"; import { devnet } from "@polkadot-api/descriptors" @@ -60,13 +60,16 @@ describe("Test the UID Lookup precompile", () => { block_number: BigInt(blockNumber), signature: convertToFixedSizeBinary(signature, 65) }); - await waitForTransactionCompletion(api, associateEvmKeyTx, alice) + const signer = getSignerFromKeypair(coldkey); + await waitForTransactionCompletion(api, associateEvmKeyTx, signer) .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) - console.info(storedEvmKey) - assert.equal(storedEvmKey, [convertToFixedSizeBinary(evmWallet.address, 20), BigInt(blockNumber)]) + assert.notEqual(storedEvmKey, undefined, "storedEvmKey should be defined") + if (storedEvmKey !== undefined) { + assert.equal(storedEvmKey[0], convertToFixedSizeBinary(evmWallet.address, 20)) + } }) it("UID lookup via precompile contract works correctly", async () => { diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 5dc3353500..3b31c86fe7 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -33,31 +33,31 @@ impl Pallet { block_number: u64, signature: Signature, ) -> dispatch::DispatchResult { - // let coldkey = ensure_signed(origin)?; + let coldkey = ensure_signed(origin)?; - // ensure!( - // Self::get_owning_coldkey_for_hotkey(&hotkey) == coldkey, - // Error::::NonAssociatedColdKey - // ); + ensure!( + Self::get_owning_coldkey_for_hotkey(&hotkey) == coldkey, + Error::::NonAssociatedColdKey + ); let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; - // let mut message = [0u8; 64]; - // let block_hash = keccak_256(block_number.encode().as_ref()); - // message[..32].copy_from_slice(&hotkey.encode()[..]); - // message[32..].copy_from_slice(block_hash.as_ref()); - // let public = signature - // .recover_prehashed(&keccak_256(message.as_ref())) - // .ok_or(Error::::UnableToRecoverPublicKey)?; - // let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) - // .map_err(|_| Error::::UnableToRecoverPublicKey)?; - // let uncompressed = secp_pubkey.serialize(); - // let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); + let mut message = [0u8; 64]; + let block_hash = keccak_256(block_number.encode().as_ref()); + message[..32].copy_from_slice(&hotkey.encode()[..]); + message[32..].copy_from_slice(block_hash.as_ref()); + let public = signature + .recover_prehashed(&keccak_256(message.as_ref())) + .ok_or(Error::::UnableToRecoverPublicKey)?; + let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) + .map_err(|_| Error::::UnableToRecoverPublicKey)?; + let uncompressed = secp_pubkey.serialize(); + let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); - // ensure!( - // evm_key == hashed_evm_key, - // Error::::InvalidRecoveredPublicKey - // ); + ensure!( + evm_key == hashed_evm_key, + Error::::InvalidRecoveredPublicKey + ); let current_block_number = Self::get_current_block_as_u64(); From fd710f704868802248c5b6ff973cea7e113c3baf Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 15:56:07 +0200 Subject: [PATCH 098/226] fix refund/dissolve + tests --- pallets/crowdloan/src/lib.rs | 30 ++++++++++++++++++++++++------ pallets/crowdloan/src/tests.rs | 25 +++++++++++++++++++++---- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index f241f41ced..02e37b59a9 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -574,7 +574,7 @@ pub mod pallet { /// Refund a failed crowdloan. /// - /// The call will try to refund all contributors up to the limit defined by the `RefundContributorsLimit`. + /// The call will try to refund all contributors (excluding the creator) up to the limit defined by the `RefundContributorsLimit`. /// If the limit is reached, the call will stop and the crowdloan will be marked as partially refunded. /// It may be needed to dispatch this call multiple times to refund all contributors. /// @@ -599,9 +599,13 @@ pub mod pallet { let mut refunded_contributors: Vec = vec![]; let mut refund_count = 0; + // Assume everyone can be refunded let mut all_refunded = true; - let contributions = Contributions::::iter_prefix(crowdloan_id); + + // We try to refund all contributors (excluding the creator) + let contributions = Contributions::::iter_prefix(crowdloan_id) + .filter(|(contributor, _)| *contributor != crowdloan.creator); for (contributor, amount) in contributions { if refund_count >= T::RefundContributorsLimit::get() { // Not everyone can be refunded @@ -642,7 +646,7 @@ pub mod pallet { /// Dissolve a crowdloan. /// /// The crowdloan will be removed from the storage. - /// All contributions must have been refunded before the crowdloan can be dissolved. + /// All contributions must have been refunded before the crowdloan can be dissolved (except the creator's one). /// /// The dispatch origin for this call must be _Signed_ and must be the creator of the crowdloan. /// @@ -661,9 +665,23 @@ pub mod pallet { // Only the creator can dissolve the crowdloan ensure!(who == crowdloan.creator, Error::::InvalidOrigin); - // It can only be dissolved if the raised amount is 0, meaning - // there is no contributions or every contribution has been refunded - ensure!(crowdloan.raised == 0, Error::::NotReadyToDissolve); + + // It can only be dissolved if the raised amount is the creator's contribution, + // meaning there is no contributions or every contribution has been refunded + let creator_contribution = Contributions::::get(crowdloan_id, &crowdloan.creator) + .ok_or(Error::::NoContribution)?; + ensure!( + creator_contribution == crowdloan.raised, + Error::::NotReadyToDissolve + ); + + // Refund the creator's contribution + CurrencyOf::::transfer( + &crowdloan.funds_account, + &crowdloan.creator, + creator_contribution, + Preservation::Expendable, + )?; // Clear the call from the preimage storage if let Some(call) = crowdloan.call { diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 7c4053566e..45bc61e40a 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -1513,16 +1513,19 @@ fn test_refund_succeeds() { // ensure the crowdloan account has the correct amount assert_eq!( pallet_balances::Pallet::::free_balance(funds_account), - 0 + initial_deposit ); // ensure the raised amount is updated correctly assert!( pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.raised == 0) + .is_some_and(|c| c.raised == initial_deposit) ); // ensure creator has the correct amount - assert_eq!(pallet_balances::Pallet::::free_balance(creator), 100); + assert_eq!( + pallet_balances::Pallet::::free_balance(creator), + initial_deposit + ); // ensure each contributor has been refunded and removed from the crowdloan for i in 2..8 { @@ -1780,6 +1783,7 @@ fn test_dissolve_fails_if_origin_is_not_creator() { fn test_dissolve_fails_if_not_everyone_has_been_refunded() { TestState::default() .with_balance(U256::from(1), 100) + .with_balance(U256::from(2), 100) .build_and_execute(|| { // create a crowdloan let creator: AccountOf = U256::from(1); @@ -1798,7 +1802,20 @@ fn test_dissolve_fails_if_not_everyone_has_been_refunded() { None, )); - // run some blocks past end + // run some blocks + run_to_block(10); + + // some contribution + let crowdloan_id: CrowdloanId = 0; + let contributor: AccountOf = U256::from(2); + let amount: BalanceOf = 50; + assert_ok!(Crowdloan::contribute( + RuntimeOrigin::signed(contributor), + crowdloan_id, + amount + )); + + // run some blocks run_to_block(10); // try to dissolve the crowdloan From 121e4f71068853552dc8e14f98a65173aaecc3b2 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 16:02:17 +0200 Subject: [PATCH 099/226] fix doc --- pallets/crowdloan/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/crowdloan/README.md b/pallets/crowdloan/README.md index f0b084b9ce..3d67fee33a 100644 --- a/pallets/crowdloan/README.md +++ b/pallets/crowdloan/README.md @@ -4,11 +4,11 @@ A pallet that enables the creation and management of generic crowdloans for tran Users of this pallet can create a crowdloan by providing a deposit, a cap, an end block, an optional target address and an optional call. -Users can contribute to a crowdloan by providing funds to the crowdloan they choose to support. +Users can contribute to a crowdloan by providing funds to the crowdloan they choose to support. The contribution can be withdrawn while the crowdloan is not finalized. Once the crowdloan is finalized, the funds will be transferred to the target address if provided; otherwise, the end user is expected to transfer them manually on-chain if the call is a pallet extrinsic. The call will be dispatched with the current crowdloan ID stored as a temporary item. -If the crowdloan fails to reach the cap, the initial deposit will be returned to the creator, and contributions will be refunded to the contributors. +If the crowdloan fails to reach the cap, the creator can decide to refund all contributors and dissolve the crowdloan. The initial deposit will be refunded. ## Overview From 392e677b4c4e1301686fc63dcff579f36bc6675d Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 1 May 2025 22:44:13 +0900 Subject: [PATCH 100/226] Check that the block number associated is correct --- evm-tests/test/uid.precompile.lookup.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 7df803c2cc..ed82b72a6b 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -26,6 +26,7 @@ describe("Test the UID Lookup precompile", () => { let uid: number; let blockNumber: number; let netuid: number; + let blockNumberAssociated: bigint; before(async () => { publicClient = await getPublicClient(ETH_LOCAL_URL) @@ -69,6 +70,7 @@ describe("Test the UID Lookup precompile", () => { assert.notEqual(storedEvmKey, undefined, "storedEvmKey should be defined") if (storedEvmKey !== undefined) { assert.equal(storedEvmKey[0], convertToFixedSizeBinary(evmWallet.address, 20)) + blockNumberAssociated = storedEvmKey[1] } }) @@ -84,6 +86,6 @@ describe("Test the UID Lookup precompile", () => { assert.notEqual(uidArray, undefined, "UID should be defined") assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`) assert.ok(uidArray.length > 0, "UID array should not be empty") - assert.equal(uidArray[0], [uid, BigInt(blockNumber)]) + assert.equal(uidArray[0], [uid, blockNumberAssociated]) }) }); From 3ffc87437feff449adefc1c2dba97dafd878a3d1 Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 1 May 2025 23:44:12 +0900 Subject: [PATCH 101/226] Debug --- pallets/subtensor/src/utils/evm.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 3b31c86fe7..bed21ab38d 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -42,22 +42,22 @@ impl Pallet { let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; - let mut message = [0u8; 64]; - let block_hash = keccak_256(block_number.encode().as_ref()); - message[..32].copy_from_slice(&hotkey.encode()[..]); - message[32..].copy_from_slice(block_hash.as_ref()); - let public = signature - .recover_prehashed(&keccak_256(message.as_ref())) - .ok_or(Error::::UnableToRecoverPublicKey)?; - let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) - .map_err(|_| Error::::UnableToRecoverPublicKey)?; - let uncompressed = secp_pubkey.serialize(); - let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); + // let mut message = [0u8; 64]; + // let block_hash = keccak_256(block_number.encode().as_ref()); + // message[..32].copy_from_slice(&hotkey.encode()[..]); + // message[32..].copy_from_slice(block_hash.as_ref()); + // let public = signature + // .recover_prehashed(&keccak_256(message.as_ref())) + // .ok_or(Error::::UnableToRecoverPublicKey)?; + // let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) + // .map_err(|_| Error::::UnableToRecoverPublicKey)?; + // let uncompressed = secp_pubkey.serialize(); + // let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); - ensure!( - evm_key == hashed_evm_key, - Error::::InvalidRecoveredPublicKey - ); + // ensure!( + // evm_key == hashed_evm_key, + // Error::::InvalidRecoveredPublicKey + // ); let current_block_number = Self::get_current_block_as_u64(); From 50550abcbc7a1c423d829c4e40978d2771449a40 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 16:47:34 +0200 Subject: [PATCH 102/226] update weights --- pallets/crowdloan/src/benchmarking.rs | 19 ++-- pallets/crowdloan/src/weights.rs | 124 +++++++++++++------------- 2 files changed, 72 insertions(+), 71 deletions(-) diff --git a/pallets/crowdloan/src/benchmarking.rs b/pallets/crowdloan/src/benchmarking.rs index 5dab0c1b91..07186061d8 100644 --- a/pallets/crowdloan/src/benchmarking.rs +++ b/pallets/crowdloan/src/benchmarking.rs @@ -190,11 +190,7 @@ mod benchmarks { frame_system::Pallet::::set_block_number(end); #[extrinsic_call] - _( - RawOrigin::Signed(contributor.clone()), - contributor.clone(), - crowdloan_id, - ); + _(RawOrigin::Signed(contributor.clone()), crowdloan_id); // ensure the creator contribution has been removed assert_eq!(Contributions::::get(crowdloan_id, &contributor), None); @@ -310,9 +306,12 @@ mod benchmarks { #[extrinsic_call] _(RawOrigin::Signed(creator.clone()), crowdloan_id); - // ensure the creator has been refunded and the contributions is removed - assert_eq!(CurrencyOf::::balance(&creator), deposit); - assert_eq!(Contributions::::get(crowdloan_id, &creator), None); + // ensure the creator has not been refunded and the contributions is removed + assert_eq!(CurrencyOf::::balance(&creator), 0); + assert_eq!( + Contributions::::get(crowdloan_id, &creator), + Some(deposit) + ); // ensure each contributor has been refunded and the contributions is removed for i in 0..contributors { let contributor: T::AccountId = account::("contributor", i, SEED); @@ -322,10 +321,10 @@ mod benchmarks { // ensure the crowdloan account has been deducted the contributions assert_eq!( CurrencyOf::::balance(&Pallet::::funds_account(crowdloan_id)), - 0 + deposit ); // ensure the raised amount is updated correctly - assert!(Crowdloans::::get(crowdloan_id).is_some_and(|c| c.raised == 0)); + assert!(Crowdloans::::get(crowdloan_id).is_some_and(|c| c.raised == deposit)); // ensure the event is emitted assert_last_event::(Event::::AllRefunded { crowdloan_id }.into()); } diff --git a/pallets/crowdloan/src/weights.rs b/pallets/crowdloan/src/weights.rs index 988f7a4efa..927e078d34 100644 --- a/pallets/crowdloan/src/weights.rs +++ b/pallets/crowdloan/src/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_crowdloan` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0 -//! DATE: 2025-04-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-05-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Ubuntu-2404-noble-amd64-base`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: `1024` @@ -57,8 +57,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `156` // Estimated: `6148` - // Minimum execution time: 40_556_000 picoseconds. - Weight::from_parts(41_318_000, 6148) + // Minimum execution time: 42_128_000 picoseconds. + Weight::from_parts(42_930_000, 6148) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -72,8 +72,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `476` // Estimated: `6148` - // Minimum execution time: 42_900_000 picoseconds. - Weight::from_parts(43_682_000, 6148) + // Minimum execution time: 43_161_000 picoseconds. + Weight::from_parts(44_192_000, 6148) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -87,8 +87,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `436` // Estimated: `6148` - // Minimum execution time: 41_037_000 picoseconds. - Weight::from_parts(41_968_000, 6148) + // Minimum execution time: 40_235_000 picoseconds. + Weight::from_parts(40_907_000, 6148) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -104,44 +104,45 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `376` // Estimated: `6148` - // Minimum execution time: 41_567_000 picoseconds. - Weight::from_parts(42_088_000, 6148) + // Minimum execution time: 40_986_000 picoseconds. + Weight::from_parts(41_858_000, 6148) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: `Crowdloan::Crowdloans` (r:1 w:1) /// Proof: `Crowdloan::Crowdloans` (`max_values`: None, `max_size`: Some(278), added: 2753, mode: `MaxEncodedLen`) - /// Storage: `Crowdloan::Contributions` (r:51 w:50) + /// Storage: `Crowdloan::Contributions` (r:51 w:49) /// Proof: `Crowdloan::Contributions` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:51 w:51) + /// Storage: `System::Account` (r:50 w:50) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(104), added: 2579, mode: `MaxEncodedLen`) /// The range of component `k` is `[3, 50]`. fn refund(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `440 + k * (48 ±0)` + // Measured: `372 + k * (49 ±0)` // Estimated: `3743 + k * (2579 ±0)` - // Minimum execution time: 97_612_000 picoseconds. - Weight::from_parts(36_327_787, 3743) - // Standard Error: 81_635 - .saturating_add(Weight::from_parts(25_989_645, 0).saturating_mul(k.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Minimum execution time: 78_938_000 picoseconds. + Weight::from_parts(2_729_302, 3743) + // Standard Error: 351_422 + .saturating_add(Weight::from_parts(31_033_274, 0).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(k.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 2579).saturating_mul(k.into())) } /// Storage: `Crowdloan::Crowdloans` (r:1 w:1) /// Proof: `Crowdloan::Crowdloans` (`max_values`: None, `max_size`: Some(278), added: 2753, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) + /// Storage: `Crowdloan::Contributions` (r:1 w:0) + /// Proof: `Crowdloan::Contributions` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(104), added: 2579, mode: `MaxEncodedLen`) fn dissolve() -> Weight { // Proof Size summary in bytes: - // Measured: `321` - // Estimated: `3743` - // Minimum execution time: 11_832_000 picoseconds. - Weight::from_parts(12_293_000, 3743) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `450` + // Estimated: `6148` + // Minimum execution time: 43_341_000 picoseconds. + Weight::from_parts(44_402_000, 6148) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Crowdloan::Crowdloans` (r:1 w:1) /// Proof: `Crowdloan::Crowdloans` (`max_values`: None, `max_size`: Some(278), added: 2753, mode: `MaxEncodedLen`) @@ -149,8 +150,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `224` // Estimated: `3743` - // Minimum execution time: 8_776_000 picoseconds. - Weight::from_parts(9_057_000, 3743) + // Minimum execution time: 8_876_000 picoseconds. + Weight::from_parts(9_137_000, 3743) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -160,8 +161,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `224` // Estimated: `3743` - // Minimum execution time: 9_067_000 picoseconds. - Weight::from_parts(9_368_000, 3743) + // Minimum execution time: 9_117_000 picoseconds. + Weight::from_parts(9_438_000, 3743) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -171,8 +172,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `224` // Estimated: `3743` - // Minimum execution time: 8_636_000 picoseconds. - Weight::from_parts(9_027_000, 3743) + // Minimum execution time: 8_766_000 picoseconds. + Weight::from_parts(9_087_000, 3743) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -192,8 +193,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `156` // Estimated: `6148` - // Minimum execution time: 40_556_000 picoseconds. - Weight::from_parts(41_318_000, 6148) + // Minimum execution time: 42_128_000 picoseconds. + Weight::from_parts(42_930_000, 6148) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -207,8 +208,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `476` // Estimated: `6148` - // Minimum execution time: 42_900_000 picoseconds. - Weight::from_parts(43_682_000, 6148) + // Minimum execution time: 43_161_000 picoseconds. + Weight::from_parts(44_192_000, 6148) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -222,8 +223,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `436` // Estimated: `6148` - // Minimum execution time: 41_037_000 picoseconds. - Weight::from_parts(41_968_000, 6148) + // Minimum execution time: 40_235_000 picoseconds. + Weight::from_parts(40_907_000, 6148) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -239,44 +240,45 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `376` // Estimated: `6148` - // Minimum execution time: 41_567_000 picoseconds. - Weight::from_parts(42_088_000, 6148) + // Minimum execution time: 40_986_000 picoseconds. + Weight::from_parts(41_858_000, 6148) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// Storage: `Crowdloan::Crowdloans` (r:1 w:1) /// Proof: `Crowdloan::Crowdloans` (`max_values`: None, `max_size`: Some(278), added: 2753, mode: `MaxEncodedLen`) - /// Storage: `Crowdloan::Contributions` (r:51 w:50) + /// Storage: `Crowdloan::Contributions` (r:51 w:49) /// Proof: `Crowdloan::Contributions` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:51 w:51) + /// Storage: `System::Account` (r:50 w:50) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(104), added: 2579, mode: `MaxEncodedLen`) /// The range of component `k` is `[3, 50]`. fn refund(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `440 + k * (48 ±0)` + // Measured: `372 + k * (49 ±0)` // Estimated: `3743 + k * (2579 ±0)` - // Minimum execution time: 97_612_000 picoseconds. - Weight::from_parts(36_327_787, 3743) - // Standard Error: 81_635 - .saturating_add(Weight::from_parts(25_989_645, 0).saturating_mul(k.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Minimum execution time: 78_938_000 picoseconds. + Weight::from_parts(2_729_302, 3743) + // Standard Error: 351_422 + .saturating_add(Weight::from_parts(31_033_274, 0).saturating_mul(k.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(k.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 2579).saturating_mul(k.into())) } /// Storage: `Crowdloan::Crowdloans` (r:1 w:1) /// Proof: `Crowdloan::Crowdloans` (`max_values`: None, `max_size`: Some(278), added: 2753, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) + /// Storage: `Crowdloan::Contributions` (r:1 w:0) + /// Proof: `Crowdloan::Contributions` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(104), added: 2579, mode: `MaxEncodedLen`) fn dissolve() -> Weight { // Proof Size summary in bytes: - // Measured: `321` - // Estimated: `3743` - // Minimum execution time: 11_832_000 picoseconds. - Weight::from_parts(12_293_000, 3743) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Measured: `450` + // Estimated: `6148` + // Minimum execution time: 43_341_000 picoseconds. + Weight::from_parts(44_402_000, 6148) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Crowdloan::Crowdloans` (r:1 w:1) /// Proof: `Crowdloan::Crowdloans` (`max_values`: None, `max_size`: Some(278), added: 2753, mode: `MaxEncodedLen`) @@ -284,8 +286,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `224` // Estimated: `3743` - // Minimum execution time: 8_776_000 picoseconds. - Weight::from_parts(9_057_000, 3743) + // Minimum execution time: 8_876_000 picoseconds. + Weight::from_parts(9_137_000, 3743) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -295,8 +297,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `224` // Estimated: `3743` - // Minimum execution time: 9_067_000 picoseconds. - Weight::from_parts(9_368_000, 3743) + // Minimum execution time: 9_117_000 picoseconds. + Weight::from_parts(9_438_000, 3743) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -306,8 +308,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `224` // Estimated: `3743` - // Minimum execution time: 8_636_000 picoseconds. - Weight::from_parts(9_027_000, 3743) + // Minimum execution time: 8_766_000 picoseconds. + Weight::from_parts(9_087_000, 3743) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } From da99c5b3f56b646ebe6973ce6112bcab009fb3d9 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 16:54:57 +0200 Subject: [PATCH 103/226] fix comments --- pallets/crowdloan/src/benchmarking.rs | 2 +- pallets/crowdloan/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/crowdloan/src/benchmarking.rs b/pallets/crowdloan/src/benchmarking.rs index 07186061d8..e36f792261 100644 --- a/pallets/crowdloan/src/benchmarking.rs +++ b/pallets/crowdloan/src/benchmarking.rs @@ -306,7 +306,7 @@ mod benchmarks { #[extrinsic_call] _(RawOrigin::Signed(creator.clone()), crowdloan_id); - // ensure the creator has not been refunded and the contributions is removed + // ensure the creator has not been refunded and contribution is the actual initial deposit assert_eq!(CurrencyOf::::balance(&creator), 0); assert_eq!( Contributions::::get(crowdloan_id, &creator), diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 02e37b59a9..9b49d5e778 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -470,7 +470,7 @@ pub mod pallet { ensure!(amount > Zero::zero(), Error::::NoContribution); if who == crowdloan.creator { - // Ensure the deposit is left + // Ensure the deposit is kept amount = amount.saturating_sub(crowdloan.deposit); ensure!(amount > Zero::zero(), Error::::DepositCannotBeWithdrawn); Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); From ca4d2ef7d9c70d28cef49fdd2260083fdfc87e27 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 1 May 2025 10:57:26 -0400 Subject: [PATCH 104/226] fmt --- pallets/subtensor/src/subnets/symbols.rs | 1026 +++++++++++----------- 1 file changed, 513 insertions(+), 513 deletions(-) diff --git a/pallets/subtensor/src/subnets/symbols.rs b/pallets/subtensor/src/subnets/symbols.rs index 048c35c4f4..7d224e208c 100644 --- a/pallets/subtensor/src/subnets/symbols.rs +++ b/pallets/subtensor/src/subnets/symbols.rs @@ -3,527 +3,527 @@ use super::*; /// Returns the Unicode symbol as a Vec for a given netuid. impl Pallet { pub fn get_name_for_subnet(netuid: u16) -> Vec { - SubnetIdentitiesV2::::tr y_get(netuid) + SubnetIdentitiesV2::::try_get(netuid) .and_then(|identity| { if !identity.subnet_name.is_empty() { Ok(identity.subnet_name) } else { - Err(()) + Err(()) } }) .unwrap_or_else(|_| { match netuid { - 0 => b"root".to_vec(), // Τ (Upper case Tau) - 1 => b"apex".to_vec(), // α (Alpha) - 2 => b"omron".to_vec(), // β (Beta) - 3 => b"templar".to_vec(), // γ (Gamma) - 4 => b"targon".to_vec(), // δ (Delta) - 5 => b"kaito".to_vec(), // ε (Epsilon) - 6 => b"infinite".to_vec(), // ζ (Zeta) - 7 => b"subvortex".to_vec(), // η (Eta) - 8 => b"ptn".to_vec(), // θ (Theta) - 9 => b"pretrain".to_vec(), // ι (Iota) - 10 => b"sturdy".to_vec(), // κ (Kappa) - 11 => b"dippy".to_vec(), // λ (Lambda) - 12 => b"horde".to_vec(), // μ (Mu) - 13 => b"dataverse".to_vec(), // ν (Nu) - 14 => b"palaidn".to_vec(), // ξ (Xi) - 15 => b"deval".to_vec(), // ο (Omicron) - 16 => b"bitads".to_vec(), // π (Pi) - 17 => b"3gen".to_vec(), // ρ (Rho) - 18 => b"cortex".to_vec(), // σ (Sigma) - 19 => b"inference".to_vec(), // t (Tau) - 20 => b"bitagent".to_vec(), // υ (Upsilon) - 21 => b"any-any".to_vec(), // φ (Phi) - 22 => b"meta".to_vec(), // χ (Chi) - 23 => b"social".to_vec(), // ψ (Psi) - 24 => b"omega".to_vec(), // ω (Omega) - 25 => b"protein".to_vec(), // א (Aleph) - 26 => b"alchemy".to_vec(), // ב (Bet) - 27 => b"compute".to_vec(), // ג (Gimel) - 28 => b"oracle".to_vec(), // ד (Dalet) - 29 => b"coldint".to_vec(), // ה (He) - 30 => b"bet".to_vec(), // ו (Vav) - 31 => b"naschain".to_vec(), // ז (Zayin) - 32 => b"itsai".to_vec(), // ח (Het) - 33 => b"ready".to_vec(), // ט (Tet) - 34 => b"mind".to_vec(), // י (Yod) - 35 => b"logic".to_vec(), // ך (Final Kaf) - 36 => b"automata".to_vec(), // כ (Kaf) - 37 => b"tuning".to_vec(), // ל (Lamed) - 38 => b"distributed".to_vec(), // ם (Final Mem) - 39 => b"edge".to_vec(), // מ (Mem) - 40 => b"chunk".to_vec(), // ן (Final Nun) - 41 => b"sportsensor".to_vec(), // נ (Nun) - 42 => b"masa".to_vec(), // ס (Samekh) - 43 => b"graphite".to_vec(), // ע (Ayin) - 44 => b"score".to_vec(), // ף (Final Pe) - 45 => b"gen42".to_vec(), // פ (Pe) - 46 => b"neural".to_vec(), // ץ (Final Tsadi) - 47 => b"condense".to_vec(), // צ (Tsadi) - 48 => b"nextplace".to_vec(), // ק (Qof) - 49 => b"automl".to_vec(), // ר (Resh) - 50 => b"audio".to_vec(), // ש (Shin) - 51 => b"celium".to_vec(), // ת (Tav) - 52 => b"dojo".to_vec(), // ا (Alif) - 53 => b"frontier".to_vec(), // ب (Ba) - 54 => b"safescan".to_vec(), // ت (Ta) - 55 => b"unknown".to_vec(), // ث (Tha) - 56 => b"gradients".to_vec(), // ج (Jim) - 57 => b"gaia".to_vec(), // ح (Ha) - 58 => b"dippy-speach".to_vec(), // خ (Kha) - 59 => b"agent-arena".to_vec(), // د (Dal) - 60 => b"unknown".to_vec(), // ذ (Dhal) - 61 => b"red team".to_vec(), // ر (Ra) - 62 => b"agentao".to_vec(), // ز (Zay) - 63 => b"lean-in".to_vec(), // س (Sin) - 64 => b"chutes".to_vec(), // ش (Shin) - 65 => b"sad".to_vec(), - 66 => b"dad".to_vec(), - 67 => b"ta".to_vec(), - 68 => b"dha".to_vec(), - 69 => b"ain".to_vec(), - 70 => b"ghayn".to_vec(), - 71 => b"fa".to_vec(), - 72 => b"qaf".to_vec(), - 73 => b"kaf".to_vec(), - 74 => b"lam".to_vec(), - 75 => b"mim".to_vec(), - 76 => b"nun".to_vec(), - 77 => b"ha".to_vec(), - 78 => b"waw".to_vec(), - 79 => b"ya".to_vec(), - 80 => b"alef".to_vec(), - 81 => b"fehu".to_vec(), - 82 => b"uruz".to_vec(), - 83 => b"thurisaz".to_vec(), - 84 => b"ansuz".to_vec(), - 85 => b"raidho".to_vec(), - 86 => b"kaunan".to_vec(), - 87 => b"cyr_yeru".to_vec(), - 88 => b"algiz".to_vec(), - 89 => b"berkanan".to_vec(), - 90 => b"ogham".to_vec(), - 91 => b"beith".to_vec(), - 92 => b"luis".to_vec(), - 93 => b"fearn".to_vec(), - 94 => b"sail".to_vec(), - 95 => b"nion".to_vec(), - 96 => b"forfeda".to_vec(), - 97 => b"ani".to_vec(), - 98 => b"bani".to_vec(), - 99 => b"gani".to_vec(), - 100 => b"doni".to_vec(), - 101 => b"eni".to_vec(), - 102 => b"vini".to_vec(), - 103 => b"ayp".to_vec(), - 104 => b"ben".to_vec(), - 105 => b"gim".to_vec(), - 106 => b"da".to_vec(), - 107 => b"ech".to_vec(), - 108 => b"za".to_vec(), - 109 => b"armeni".to_vec(), - 110 => b"grave".to_vec(), - 111 => b"io".to_vec(), - 112 => b"dje".to_vec(), - 113 => b"gje".to_vec(), - 114 => b"ie".to_vec(), - 115 => b"dze".to_vec(), - 116 => b"hard_sign".to_vec(), - 117 => b"alfa".to_vec(), - 118 => b"alfas".to_vec(), - 119 => b"vida".to_vec(), // Ⲃ (Vida, 119) - 120 => b"vida_small".to_vec(), // ⲃ (Small Vida, 120) - 121 => b"gamma".to_vec(), // Ⲅ (Gamma, 121) - 122 => b"gamma_small".to_vec(), // ⲅ (Small Gamma, 122) - 123 => b"brahmi_a".to_vec(), // 𑀀 (A, 123) - 124 => b"brahmi_aa".to_vec(), // 𑀁 (Aa, 124) - 125 => b"brahmi_i".to_vec(), // 𑀂 (I, 125) - 126 => b"brahmi_ii".to_vec(), // 𑀃 (Ii, 126) - 127 => b"brahmi_u".to_vec(), // 𑀅 (U, 127) - 128 => b"la".to_vec(), - 129 => b"va".to_vec(), - 130 => b"sha".to_vec(), - 131 => b"ssa".to_vec(), - 132 => b"sa".to_vec(), - 133 => b"ha".to_vec(), - 134 => b"glagolitic_az".to_vec(), // Ⰰ (Az, 134) - 135 => b"glagolitic_buky".to_vec(), // Ⰱ (Buky, 135) - 136 => b"glagolitic_vede".to_vec(), // Ⰲ (Vede, 136) - 137 => b"glagolitic_glagoli".to_vec(), // Ⰳ (Glagoli, 137) - 138 => b"glagolitic_dobro".to_vec(), // Ⰴ (Dobro, 138) - 139 => b"glagolitic_yest".to_vec(), // Ⰵ (Yest, 139) - 140 => b"glagolitic_zhivete".to_vec(), // Ⰶ (Zhivete, 140) - 141 => b"glagolitic_zemlja".to_vec(), // Ⰷ (Zemlja, 141) - 142 => b"glagolitic_izhe".to_vec(), // Ⰸ (Izhe, 142) - 143 => b"glagolitic_initial_izhe".to_vec(), // Ⰹ (Initial Izhe, 143) - 144 => b"glagolitic_i".to_vec(), // Ⰺ (I, 144) - 145 => b"glagolitic_djerv".to_vec(), // Ⰻ (Djerv, 145) - 146 => b"glagolitic_kako".to_vec(), // Ⰼ (Kako, 146) - 147 => b"glagolitic_ljudije".to_vec(), // Ⰽ (Ljudije, 147) - 148 => b"glagolitic_myse".to_vec(), // Ⰾ (Myse, 148) - 149 => b"glagolitic_nash".to_vec(), // Ⰿ (Nash, 149) - 150 => b"glagolitic_on".to_vec(), // Ⱀ (On, 150) - 151 => b"glagolitic_pokoj".to_vec(), // Ⱁ (Pokoj, 151) - 152 => b"glagolitic_rtsy".to_vec(), // Ⱂ (Rtsy, 152) - 153 => b"glagolitic_slovo".to_vec(), // Ⱃ (Slovo, 153) - 154 => b"glagolitic_tvrido".to_vec(), // Ⱄ (Tvrido, 154) - 155 => b"glagolitic_uku".to_vec(), // Ⱅ (Uku, 155) - 156 => b"glagolitic_fert".to_vec(), // Ⱆ (Fert, 156) - 157 => b"glagolitic_xrivi".to_vec(), // Ⱇ (Xrivi, 157) - 158 => b"glagolitic_ot".to_vec(), // Ⱈ (Ot, 158) - 159 => b"glagolitic_cy".to_vec(), // Ⱉ (Cy, 159) - 160 => b"glagolitic_shcha".to_vec(), // Ⱊ (Shcha, 160) - 161 => b"glagolitic_er".to_vec(), // Ⱋ (Er, 161) - 162 => b"glagolitic_yeru".to_vec(), // Ⱌ (Yeru, 162) - 163 => b"glagolitic_small_yer".to_vec(), // Ⱍ (Small Yer, 163) - 164 => b"glagolitic_yo".to_vec(), // Ⱎ (Yo, 164) - 165 => b"glagolitic_yu".to_vec(), // Ⱏ (Yu, 165) - 166 => b"glagolitic_ja".to_vec(), // Ⱐ (Ja, 166) - 167 => b"thai_ko_kai".to_vec(), // ก (Ko Kai, 167) - 168 => b"thai_kho_khai".to_vec(), // ข (Kho Khai, 168) - 169 => b"thai_kho_khuat".to_vec(), // ฃ (Kho Khuat, 169) - 170 => b"thai_kho_khon".to_vec(), // ค (Kho Khon, 170) - 171 => b"thai_kho_rakhang".to_vec(), // ฅ (Kho Rakhang, 171) - 172 => b"thai_kho_khwai".to_vec(), // ฆ (Kho Khwai, 172) - 173 => b"thai_ngo_ngu".to_vec(), // ง (Ngo Ngu, 173) - 174 => b"thai_cho_chan".to_vec(), // จ (Cho Chan, 174) - 175 => b"thai_cho_ching".to_vec(), // ฉ (Cho Ching, 175) - 176 => b"thai_cho_chang".to_vec(), // ช (Cho Chang, 176) - 177 => b"thai_so_so".to_vec(), // ซ (So So, 177) - 178 => b"thai_cho_choe".to_vec(), // ฌ (Cho Choe, 178) - 179 => b"thai_yo_ying".to_vec(), // ญ (Yo Ying, 179) - 180 => b"thai_do_chada".to_vec(), // ฎ (Do Chada, 180) - 181 => b"thai_to_patak".to_vec(), // ฏ (To Patak, 181) - 182 => b"thai_tho_than".to_vec(), // ฐ (Tho Than, 182) - 183 => b"thai_tho_nangmontho".to_vec(), // ฑ (Tho Nangmontho, 183) - 184 => b"thai_tho_phuthao".to_vec(), // ฒ (Tho Phuthao, 184) - 185 => b"thai_no_nen".to_vec(), // ณ (No Nen, 185) - 186 => b"thai_do_dek".to_vec(), // ด (Do Dek, 186) - 187 => b"thai_to_tao".to_vec(), // ต (To Tao, 187) - 188 => b"thai_tho_thung".to_vec(), // ถ (Tho Thung, 188) - 189 => b"thai_tho_thahan".to_vec(), // ท (Tho Thahan, 189) - 190 => b"thai_tho_thong".to_vec(), // ธ (Tho Thong, 190) - 191 => b"thai_no_nu".to_vec(), // น (No Nu, 191) - 192 => b"thai_bo_baimai".to_vec(), // บ (Bo Baimai, 192) - 193 => b"thai_po_pla".to_vec(), // ป (Po Pla, 193) - 194 => b"thai_pho_phung".to_vec(), // ผ (Pho Phung, 194) - 195 => b"thai_fo_fa".to_vec(), // ฝ (Fo Fa, 195) - 196 => b"thai_pho_phan".to_vec(), // พ (Pho Phan, 196) - 197 => b"thai_fo_fan".to_vec(), // ฟ (Fo Fan, 197) - 198 => b"thai_pho_samphao".to_vec(), // ภ (Pho Samphao, 198) - 199 => b"thai_mo_ma".to_vec(), // ม (Mo Ma, 199) - 200 => b"thai_yo_yak".to_vec(), // ย (Yo Yak, 200) - 201 => b"thai_ro_rua".to_vec(), // ร (Ro Rua, 201) - 202 => b"thai_lo_ling".to_vec(), // ล (Lo Ling, 202) - 203 => b"thai_wo_waen".to_vec(), // ว (Wo Waen, 203) - 204 => b"thai_so_sala".to_vec(), // ศ (So Sala, 204) - 205 => b"thai_so_rusi".to_vec(), // ษ (So Rusi, 205) - 206 => b"thai_so_sua".to_vec(), // ส (So Sua, 206) - 207 => b"thai_ho_hip".to_vec(), // ห (Ho Hip, 207) - 208 => b"thai_lo_chula".to_vec(), // ฬ (Lo Chula, 208) - 209 => b"thai_o_ang".to_vec(), // อ (O Ang, 209) - 210 => b"thai_ho_nokhuk".to_vec(), // ฮ (Ho Nokhuk, 210) - 211 => b"hangul_giyeok".to_vec(), // ㄱ (Giyeok, 211) - 212 => b"hangul_nieun".to_vec(), // ㄴ (Nieun, 212) - 213 => b"hangul_digeut".to_vec(), // ㄷ (Digeut, 213) - 214 => b"hangul_rieul".to_vec(), // ㄹ (Rieul, 214) - 215 => b"hangul_mieum".to_vec(), // ㅁ (Mieum, 215) - 216 => b"hangul_bieup".to_vec(), // ㅂ (Bieup, 216) - 217 => b"hangul_siot".to_vec(), // ㅅ (Siot, 217) - 218 => b"hangul_ieung".to_vec(), // ㅇ (Ieung, 218) - 219 => b"hangul_jieut".to_vec(), // ㅈ (Jieut, 219) - 220 => b"hangul_chieut".to_vec(), // ㅊ (Chieut, 220) - 221 => b"hangul_kieuk".to_vec(), // ㅋ (Kieuk, 221) - 222 => b"hangul_tieut".to_vec(), // ㅌ (Tieut, 222) - 223 => b"hangul_pieup".to_vec(), // ㅍ (Pieup, 223) - 224 => b"hangul_hieut".to_vec(), // ㅎ (Hieut, 224) - 225 => b"hangul_a".to_vec(), // ㅏ (A, 225) - 226 => b"hangul_ae".to_vec(), // ㅐ (Ae, 226) - 227 => b"hangul_ya".to_vec(), // ㅑ (Ya, 227) - 228 => b"hangul_yae".to_vec(), // ㅒ (Yae, 228) - 229 => b"hangul_eo".to_vec(), // ㅓ (Eo, 229) - 230 => b"hangul_e".to_vec(), // ㅔ (E, 230) - 231 => b"hangul_yeo".to_vec(), // ㅕ (Yeo, 231) - 232 => b"hangul_ye".to_vec(), // ㅖ (Ye, 232) - 233 => b"hangul_o".to_vec(), // ㅗ (O, 233) - 234 => b"hangul_wa".to_vec(), // ㅘ (Wa, 234) - 235 => b"hangul_wae".to_vec(), // ㅙ (Wae, 235) - 236 => b"hangul_oe".to_vec(), // ㅚ (Oe, 236) - 237 => b"hangul_yo".to_vec(), // ㅛ (Yo, 237) - 238 => b"hangul_u".to_vec(), // ㅜ (U, 238) - 239 => b"hangul_weo".to_vec(), // ㅝ (Weo, 239) - 240 => b"hangul_we".to_vec(), // ㅞ (We, 240) - 241 => b"hangul_wi".to_vec(), // ㅟ (Wi, 241) - 242 => b"hangul_yu".to_vec(), // ㅠ (Yu, 242) - 243 => b"hangul_eu".to_vec(), // ㅡ (Eu, 243) - 244 => b"hangul_ui".to_vec(), // ㅢ (Ui, 244) - 245 => b"hangul_i".to_vec(), // ㅣ (I, 245) - 246 => b"ethiopic_glottal_a".to_vec(), // አ (Glottal A, 246) - 247 => b"ethiopic_glottal_u".to_vec(), // ኡ (Glottal U, 247) - 248 => b"ethiopic_glottal_i".to_vec(), // ኢ (Glottal I, 248) - 249 => b"ethiopic_glottal_aa".to_vec(), // ኣ (Glottal Aa, 249) - 250 => b"ethiopic_glottal_e".to_vec(), // ኤ (Glottal E, 250) - 251 => b"ethiopic_glottal_ie".to_vec(), // እ (Glottal Ie, 251) - 252 => b"ethiopic_glottal_o".to_vec(), // ኦ (Glottal O, 252) - 253 => b"ethiopic_glottal_wa".to_vec(), // ኧ (Glottal Wa, 253) - 254 => b"ethiopic_wa".to_vec(), // ወ (Wa, 254) - 255 => b"ethiopic_wu".to_vec(), // ዉ (Wu, 255) - 256 => b"ethiopic_wi".to_vec(), // ዊ (Wi, 256) - 257 => b"ethiopic_waa".to_vec(), // ዋ (Waa, 257) - 258 => b"ethiopic_we".to_vec(), // ዌ (We, 258) - 259 => b"ethiopic_wye".to_vec(), // ው (Wye, 259) - 260 => b"ethiopic_wo".to_vec(), // ዎ (Wo, 260) - 261 => b"ethiopic_ko".to_vec(), // ኰ (Ko, 261) - 262 => b"ethiopic_ku".to_vec(), // ኱ (Ku, 262) - 263 => b"ethiopic_ki".to_vec(), // ኲ (Ki, 263) - 264 => b"ethiopic_kua".to_vec(), // ኳ (Kua, 264) - 265 => b"ethiopic_ke".to_vec(), // ኴ (Ke, 265) - 266 => b"ethiopic_kwe".to_vec(), // ኵ (Kwe, 266) - 267 => b"ethiopic_ko_alt".to_vec(), // ኶ (Ko, 267) - 268 => b"ethiopic_go".to_vec(), // ጐ (Go, 268) - 269 => b"ethiopic_gu".to_vec(), // ጑ (Gu, 269) - 270 => b"ethiopic_gi".to_vec(), // ጒ (Gi, 270) - 271 => b"ethiopic_gua".to_vec(), // መ (Gua, 271) - 272 => b"ethiopic_ge".to_vec(), // ጔ (Ge, 272) - 273 => b"ethiopic_gwe".to_vec(), // ጕ (Gwe, 273) - 274 => b"ethiopic_go_alt".to_vec(), // ጖ (Go, 274) - 275 => b"devanagari_a".to_vec(), // अ (A, 275) - 276 => b"devanagari_aa".to_vec(), // आ (Aa, 276) - 277 => b"devanagari_i".to_vec(), // इ (I, 277) - 278 => b"devanagari_ii".to_vec(), // ई (Ii, 278) - 279 => b"devanagari_u".to_vec(), // उ (U, 279) - 280 => b"devanagari_uu".to_vec(), // ऊ (Uu, 280) - 281 => b"devanagari_r".to_vec(), // ऋ (R, 281) - 282 => b"devanagari_e".to_vec(), // ए (E, 282) - 283 => b"devanagari_ai".to_vec(), // ऐ (Ai, 283) - 284 => b"devanagari_o".to_vec(), // ओ (O, 284) - 285 => b"devanagari_au".to_vec(), // औ (Au, 285) - 286 => b"devanagari_ka".to_vec(), // क (Ka, 286) - 287 => b"devanagari_kha".to_vec(), // ख (Kha, 287) - 288 => b"devanagari_ga".to_vec(), // ग (Ga, 288) - 289 => b"devanagari_gha".to_vec(), // घ (Gha, 289) - 290 => b"devanagari_nga".to_vec(), // ङ (Nga, 290) - 291 => b"devanagari_cha".to_vec(), // च (Cha, 291) - 292 => b"devanagari_chha".to_vec(), // छ (Chha, 292) - 293 => b"devanagari_ja".to_vec(), // ज (Ja, 293) - 294 => b"devanagari_jha".to_vec(), // झ (Jha, 294) - 295 => b"devanagari_nya".to_vec(), // ञ (Nya, 295) - 296 => b"devanagari_ta".to_vec(), // ट (Ta, 296) - 297 => b"devanagari_tha".to_vec(), // ठ (Tha, 297) - 298 => b"devanagari_da".to_vec(), // ड (Da, 298) - 299 => b"devanagari_dha".to_vec(), // ढ (Dha, 299) - 300 => b"devanagari_na".to_vec(), // ण (Na, 300) - 301 => b"devanagari_ta_alt".to_vec(), // त (Ta, 301) - 302 => b"devanagari_tha_alt".to_vec(), // थ (Tha, 302) - 303 => b"devanagari_da_alt".to_vec(), // द (Da, 303) - 304 => b"devanagari_dha_alt".to_vec(), // ध (Dha, 304) - 305 => b"devanagari_na_alt".to_vec(), // न (Na, 305) - 306 => b"devanagari_pa".to_vec(), // प (Pa, 306) - 307 => b"devanagari_pha".to_vec(), // फ (Pha, 307) - 308 => b"devanagari_ba".to_vec(), // ब (Ba, 308) - 309 => b"devanagari_bha".to_vec(), // भ (Bha, 309) - 310 => b"devanagari_ma".to_vec(), // म (Ma, 310) - 311 => b"devanagari_ya".to_vec(), // य (Ya, 311) - 312 => b"devanagari_ra".to_vec(), // र (Ra, 312) - 313 => b"devanagari_la".to_vec(), // ल (La, 313) - 314 => b"devanagari_va".to_vec(), // व (Va, 314) - 315 => b"devanagari_sha".to_vec(), // श (Sha, 315) - 316 => b"devanagari_ssa".to_vec(), // ष (Ssa, 316) - 317 => b"devanagari_sa".to_vec(), // स (Sa, 317) - 318 => b"devanagari_ha".to_vec(), // ह (Ha, 318) - 319 => b"katakana_a".to_vec(), // ア (A, 319) - 320 => b"kana_i".to_vec(), - 321 => b"kana_u".to_vec(), - 322 => b"kana_e".to_vec(), - 323 => b"kana_o".to_vec(), - 324 => b"kana_a".to_vec(), - 325 => b"kana_ki".to_vec(), - 326 => b"kana_ku".to_vec(), - 327 => b"kana_ke".to_vec(), - 328 => b"kana_ko".to_vec(), - 329 => b"kana_sa".to_vec(), - 330 => b"kana_shi".to_vec(), - 331 => b"kana_su".to_vec(), - 332 => b"kana_se".to_vec(), - 333 => b"kana_so".to_vec(), - 334 => b"kana_ta".to_vec(), - 335 => b"kana_chi".to_vec(), - 336 => b"kana_tsu".to_vec(), - 337 => b"kana_te".to_vec(), - 338 => b"kana_to".to_vec(), - 339 => b"kana_na".to_vec(), - 340 => b"kana_ni".to_vec(), - 341 => b"kana_nu".to_vec(), - 342 => b"kana_ne".to_vec(), - 343 => b"kana_no".to_vec(), - 344 => b"kana_ha".to_vec(), - 345 => b"kana_hi".to_vec(), - 346 => b"kana_fu".to_vec(), - 347 => b"kana_he".to_vec(), - 348 => b"kana_ho".to_vec(), - 349 => b"kana_ma".to_vec(), - 350 => b"kana_mi".to_vec(), - 351 => b"kana_mu".to_vec(), - 352 => b"kana_me".to_vec(), - 353 => b"kana_mo".to_vec(), - 354 => b"kana_ya".to_vec(), - 355 => b"kana_yu".to_vec(), - 356 => b"kana_yo".to_vec(), - 357 => b"kana_ra".to_vec(), - 358 => b"kana_ri".to_vec(), - 359 => b"kana_ru".to_vec(), - 360 => b"kana_re".to_vec(), - 361 => b"kana_ro".to_vec(), - 362 => b"kana_wa".to_vec(), - 363 => b"kana_wo".to_vec(), - 364 => b"kana_n".to_vec(), - 365 => b"ya".to_vec(), - 366 => b"yab".to_vec(), - 367 => b"yabh".to_vec(), - 368 => b"yag".to_vec(), - 369 => b"yagh".to_vec(), - 370 => b"yaj".to_vec(), - 371 => b"yach".to_vec(), - 372 => b"yad".to_vec(), - 373 => b"yadh".to_vec(), - 374 => b"yadhe".to_vec(), - 375 => b"yaz".to_vec(), - 376 => b"yazh".to_vec(), - 377 => b"yaf".to_vec(), - 378 => b"yak".to_vec(), - 379 => b"yakv".to_vec(), - 380 => b"yaq".to_vec(), - 381 => b"yah".to_vec(), - 382 => b"yahh".to_vec(), - 383 => b"yahl".to_vec(), - 384 => b"yahm".to_vec(), - 385 => b"yayn".to_vec(), - 386 => b"yakh".to_vec(), - 387 => b"yakl".to_vec(), - 388 => b"yahq".to_vec(), - 389 => b"yash".to_vec(), - 390 => b"yi".to_vec(), - 391 => b"yij".to_vec(), - 392 => b"yizh".to_vec(), - 393 => b"yink".to_vec(), - 394 => b"yal".to_vec(), - 395 => b"yam".to_vec(), - 396 => b"yan".to_vec(), - 397 => b"yang".to_vec(), - 398 => b"yany".to_vec(), - 399 => b"yap".to_vec(), - 400 => b"yu".to_vec(), - 401 => b"a".to_vec(), - 402 => b"aa".to_vec(), - 403 => b"i".to_vec(), - 404 => b"ii".to_vec(), - 405 => b"u".to_vec(), - 406 => b"uu".to_vec(), - 407 => b"r".to_vec(), - 408 => b"rr".to_vec(), - 409 => b"l".to_vec(), - 410 => b"ll".to_vec(), - 411 => b"e".to_vec(), - 412 => b"ee".to_vec(), - 413 => b"ai".to_vec(), - 414 => b"o".to_vec(), - 415 => b"oo".to_vec(), - 416 => b"au".to_vec(), - 417 => b"ka".to_vec(), - 418 => b"kha".to_vec(), - 419 => b"ga".to_vec(), - 420 => b"gha".to_vec(), - 421 => b"nga".to_vec(), - 422 => b"cha".to_vec(), - 423 => b"chha".to_vec(), - 424 => b"ja".to_vec(), - 425 => b"jha".to_vec(), - 426 => b"nya".to_vec(), - 427 => b"ta".to_vec(), - 428 => b"tha".to_vec(), - 429 => b"da".to_vec(), - 430 => b"dha".to_vec(), - 431 => b"na".to_vec(), - 432 => b"pa".to_vec(), - 433 => b"pha".to_vec(), - 434 => b"ba".to_vec(), - 435 => b"bha".to_vec(), - 436 => b"ma".to_vec(), - 437 => b"ya".to_vec(), - 438 => b"ra".to_vec(), - _ => b"unknown".to_vec(), - } - // match netuid { - // // Greek Alphabet (Lowercase) - // 0 => b"root".to_vec(), // Τ (Upper case Tau) - // 1 => b"apex".to_vec(), // α (Alpha) - // 2 => b"omron".to_vec(), // β (Beta) - // 3 => b"templar".to_vec(), // γ (Gamma) - // 4 => b"targon".to_vec(), // δ (Delta) - // 5 => b"kaito".to_vec(), // ε (Epsilon) - // 6 => b"infinite".to_vec(), // ζ (Zeta) - // 7 => b"subvortex".to_vec(), // η (Eta) - // 8 => b"ptn".to_vec(), // θ (Theta) - // 9 => b"pretrain".to_vec(), // ι (Iota) - // 10 => b"sturdy".to_vec(), // κ (Kappa) - // 11 => b"dippy".to_vec(), // λ (Lambda) - // 12 => b"horde".to_vec(), // μ (Mu) - // 13 => b"dataverse".to_vec(), // ν (Nu) - // 14 => b"palaidn".to_vec(), // ξ (Xi) - // 15 => b"deval".to_vec(), // ο (Omicron) - // 16 => b"bitads".to_vec(), // π (Pi) - // 17 => b"3gen".to_vec(), // ρ (Rho) - // 18 => b"cortex".to_vec(), // σ (Sigma) - // 19 => b"inference".to_vec(), // t (Tau) - // 20 => b"bitagent".to_vec(), // υ (Upsilon) - // 21 => b"any-any".to_vec(), // φ (Phi) - // 22 => b"meta".to_vec(), // χ (Chi) - // 23 => b"social".to_vec(), // ψ (Psi) - // 24 => b"omega".to_vec(), // ω (Omega) - // 25 => b"protein".to_vec(), // א (Aleph) - // 26 => b"alchemy".to_vec(), // ב (Bet) - // 27 => b"compute".to_vec(), // ג (Gimel) - // 28 => b"oracle".to_vec(), // ד (Dalet) - // 29 => b"coldint".to_vec(), // ה (He) - // 30 => b"bet".to_vec(), // ו (Vav) - // 31 => b"naschain".to_vec(), // ז (Zayin) - // 32 => b"itsai".to_vec(), // ח (Het) - // 33 => b"ready".to_vec(), // ט (Tet) - // 34 => b"mind".to_vec(), // י (Yod) - // 35 => b"logic".to_vec(), // ך (Final Kaf) - // 36 => b"automata".to_vec(), // כ (Kaf) - // 37 => b"tuning".to_vec(), // ל (Lamed) - // 38 => b"distributed".to_vec(), // ם (Final Mem) - // 39 => b"edge".to_vec(), // מ (Mem) - // 40 => b"chunk".to_vec(), // ן (Final Nun) - // 41 => b"sportsensor".to_vec(), // נ (Nun) - // 42 => b"masa".to_vec(), // ס (Samekh) - // 43 => b"graphite".to_vec(), // ע (Ayin) - // 44 => b"score".to_vec(), // ף (Final Pe) - // 45 => b"gen42".to_vec(), // פ (Pe) - // 46 => b"neural".to_vec(), // ץ (Final Tsadi) - // 47 => b"condense".to_vec(), // צ (Tsadi) - // 48 => b"nextplace".to_vec(), // ק (Qof) - // 49 => b"automl".to_vec(), // ר (Resh) - // 50 => b"audio".to_vec(), // ש (Shin) - // 51 => b"celium".to_vec(), // ת (Tav) - // 52 => b"dojo".to_vec(), // ا (Alif) - // 53 => b"frontier".to_vec(), // ب (Ba) - // 54 => b"safescan".to_vec(), // ت (Ta) - // 55 => b"unknown".to_vec(), // ث (Tha) - // 56 => b"gradients".to_vec(), // ج (Jim) - // 57 => b"gaia".to_vec(), // ح (Ha) - // 58 => b"dippy-speach".to_vec(), // خ (Kha) - // 59 => b"agent-arena".to_vec(), // د (Dal) - // 60 => b"unknown".to_vec(), // ذ (Dhal) - // 61 => b"red team".to_vec(), // ر (Ra) - // 62 => b"agentao".to_vec(), // ز (Zay) - // 63 => b"lean-in".to_vec(), // س (Sin) - // 64 => b"chutes".to_vec(), // ش (Shin) - // // Default case - // _ => b"unknown".to_vec(), // unknown subnet. - // } + 0 => b"root".to_vec(), // Τ (Upper case Tau) + 1 => b"apex".to_vec(), // α (Alpha) + 2 => b"omron".to_vec(), // β (Beta) + 3 => b"templar".to_vec(), // γ (Gamma) + 4 => b"targon".to_vec(), // δ (Delta) + 5 => b"kaito".to_vec(), // ε (Epsilon) + 6 => b"infinite".to_vec(), // ζ (Zeta) + 7 => b"subvortex".to_vec(), // η (Eta) + 8 => b"ptn".to_vec(), // θ (Theta) + 9 => b"pretrain".to_vec(), // ι (Iota) + 10 => b"sturdy".to_vec(), // κ (Kappa) + 11 => b"dippy".to_vec(), // λ (Lambda) + 12 => b"horde".to_vec(), // μ (Mu) + 13 => b"dataverse".to_vec(), // ν (Nu) + 14 => b"palaidn".to_vec(), // ξ (Xi) + 15 => b"deval".to_vec(), // ο (Omicron) + 16 => b"bitads".to_vec(), // π (Pi) + 17 => b"3gen".to_vec(), // ρ (Rho) + 18 => b"cortex".to_vec(), // σ (Sigma) + 19 => b"inference".to_vec(), // t (Tau) + 20 => b"bitagent".to_vec(), // υ (Upsilon) + 21 => b"any-any".to_vec(), // φ (Phi) + 22 => b"meta".to_vec(), // χ (Chi) + 23 => b"social".to_vec(), // ψ (Psi) + 24 => b"omega".to_vec(), // ω (Omega) + 25 => b"protein".to_vec(), // א (Aleph) + 26 => b"alchemy".to_vec(), // ב (Bet) + 27 => b"compute".to_vec(), // ג (Gimel) + 28 => b"oracle".to_vec(), // ד (Dalet) + 29 => b"coldint".to_vec(), // ה (He) + 30 => b"bet".to_vec(), // ו (Vav) + 31 => b"naschain".to_vec(), // ז (Zayin) + 32 => b"itsai".to_vec(), // ח (Het) + 33 => b"ready".to_vec(), // ט (Tet) + 34 => b"mind".to_vec(), // י (Yod) + 35 => b"logic".to_vec(), // ך (Final Kaf) + 36 => b"automata".to_vec(), // כ (Kaf) + 37 => b"tuning".to_vec(), // ל (Lamed) + 38 => b"distributed".to_vec(), // ם (Final Mem) + 39 => b"edge".to_vec(), // מ (Mem) + 40 => b"chunk".to_vec(), // ן (Final Nun) + 41 => b"sportsensor".to_vec(), // נ (Nun) + 42 => b"masa".to_vec(), // ס (Samekh) + 43 => b"graphite".to_vec(), // ע (Ayin) + 44 => b"score".to_vec(), // ף (Final Pe) + 45 => b"gen42".to_vec(), // פ (Pe) + 46 => b"neural".to_vec(), // ץ (Final Tsadi) + 47 => b"condense".to_vec(), // צ (Tsadi) + 48 => b"nextplace".to_vec(), // ק (Qof) + 49 => b"automl".to_vec(), // ר (Resh) + 50 => b"audio".to_vec(), // ש (Shin) + 51 => b"celium".to_vec(), // ת (Tav) + 52 => b"dojo".to_vec(), // ا (Alif) + 53 => b"frontier".to_vec(), // ب (Ba) + 54 => b"safescan".to_vec(), // ت (Ta) + 55 => b"unknown".to_vec(), // ث (Tha) + 56 => b"gradients".to_vec(), // ج (Jim) + 57 => b"gaia".to_vec(), // ح (Ha) + 58 => b"dippy-speach".to_vec(), // خ (Kha) + 59 => b"agent-arena".to_vec(), // د (Dal) + 60 => b"unknown".to_vec(), // ذ (Dhal) + 61 => b"red team".to_vec(), // ر (Ra) + 62 => b"agentao".to_vec(), // ز (Zay) + 63 => b"lean-in".to_vec(), // س (Sin) + 64 => b"chutes".to_vec(), // ش (Shin) + 65 => b"sad".to_vec(), + 66 => b"dad".to_vec(), + 67 => b"ta".to_vec(), + 68 => b"dha".to_vec(), + 69 => b"ain".to_vec(), + 70 => b"ghayn".to_vec(), + 71 => b"fa".to_vec(), + 72 => b"qaf".to_vec(), + 73 => b"kaf".to_vec(), + 74 => b"lam".to_vec(), + 75 => b"mim".to_vec(), + 76 => b"nun".to_vec(), + 77 => b"ha".to_vec(), + 78 => b"waw".to_vec(), + 79 => b"ya".to_vec(), + 80 => b"alef".to_vec(), + 81 => b"fehu".to_vec(), + 82 => b"uruz".to_vec(), + 83 => b"thurisaz".to_vec(), + 84 => b"ansuz".to_vec(), + 85 => b"raidho".to_vec(), + 86 => b"kaunan".to_vec(), + 87 => b"cyr_yeru".to_vec(), + 88 => b"algiz".to_vec(), + 89 => b"berkanan".to_vec(), + 90 => b"ogham".to_vec(), + 91 => b"beith".to_vec(), + 92 => b"luis".to_vec(), + 93 => b"fearn".to_vec(), + 94 => b"sail".to_vec(), + 95 => b"nion".to_vec(), + 96 => b"forfeda".to_vec(), + 97 => b"ani".to_vec(), + 98 => b"bani".to_vec(), + 99 => b"gani".to_vec(), + 100 => b"doni".to_vec(), + 101 => b"eni".to_vec(), + 102 => b"vini".to_vec(), + 103 => b"ayp".to_vec(), + 104 => b"ben".to_vec(), + 105 => b"gim".to_vec(), + 106 => b"da".to_vec(), + 107 => b"ech".to_vec(), + 108 => b"za".to_vec(), + 109 => b"armeni".to_vec(), + 110 => b"grave".to_vec(), + 111 => b"io".to_vec(), + 112 => b"dje".to_vec(), + 113 => b"gje".to_vec(), + 114 => b"ie".to_vec(), + 115 => b"dze".to_vec(), + 116 => b"hard_sign".to_vec(), + 117 => b"alfa".to_vec(), + 118 => b"alfas".to_vec(), + 119 => b"vida".to_vec(), // Ⲃ (Vida, 119) + 120 => b"vida_small".to_vec(), // ⲃ (Small Vida, 120) + 121 => b"gamma".to_vec(), // Ⲅ (Gamma, 121) + 122 => b"gamma_small".to_vec(), // ⲅ (Small Gamma, 122) + 123 => b"brahmi_a".to_vec(), // 𑀀 (A, 123) + 124 => b"brahmi_aa".to_vec(), // 𑀁 (Aa, 124) + 125 => b"brahmi_i".to_vec(), // 𑀂 (I, 125) + 126 => b"brahmi_ii".to_vec(), // 𑀃 (Ii, 126) + 127 => b"brahmi_u".to_vec(), // 𑀅 (U, 127) + 128 => b"la".to_vec(), + 129 => b"va".to_vec(), + 130 => b"sha".to_vec(), + 131 => b"ssa".to_vec(), + 132 => b"sa".to_vec(), + 133 => b"ha".to_vec(), + 134 => b"glagolitic_az".to_vec(), // Ⰰ (Az, 134) + 135 => b"glagolitic_buky".to_vec(), // Ⰱ (Buky, 135) + 136 => b"glagolitic_vede".to_vec(), // Ⰲ (Vede, 136) + 137 => b"glagolitic_glagoli".to_vec(), // Ⰳ (Glagoli, 137) + 138 => b"glagolitic_dobro".to_vec(), // Ⰴ (Dobro, 138) + 139 => b"glagolitic_yest".to_vec(), // Ⰵ (Yest, 139) + 140 => b"glagolitic_zhivete".to_vec(), // Ⰶ (Zhivete, 140) + 141 => b"glagolitic_zemlja".to_vec(), // Ⰷ (Zemlja, 141) + 142 => b"glagolitic_izhe".to_vec(), // Ⰸ (Izhe, 142) + 143 => b"glagolitic_initial_izhe".to_vec(), // Ⰹ (Initial Izhe, 143) + 144 => b"glagolitic_i".to_vec(), // Ⰺ (I, 144) + 145 => b"glagolitic_djerv".to_vec(), // Ⰻ (Djerv, 145) + 146 => b"glagolitic_kako".to_vec(), // Ⰼ (Kako, 146) + 147 => b"glagolitic_ljudije".to_vec(), // Ⰽ (Ljudije, 147) + 148 => b"glagolitic_myse".to_vec(), // Ⰾ (Myse, 148) + 149 => b"glagolitic_nash".to_vec(), // Ⰿ (Nash, 149) + 150 => b"glagolitic_on".to_vec(), // Ⱀ (On, 150) + 151 => b"glagolitic_pokoj".to_vec(), // Ⱁ (Pokoj, 151) + 152 => b"glagolitic_rtsy".to_vec(), // Ⱂ (Rtsy, 152) + 153 => b"glagolitic_slovo".to_vec(), // Ⱃ (Slovo, 153) + 154 => b"glagolitic_tvrido".to_vec(), // Ⱄ (Tvrido, 154) + 155 => b"glagolitic_uku".to_vec(), // Ⱅ (Uku, 155) + 156 => b"glagolitic_fert".to_vec(), // Ⱆ (Fert, 156) + 157 => b"glagolitic_xrivi".to_vec(), // Ⱇ (Xrivi, 157) + 158 => b"glagolitic_ot".to_vec(), // Ⱈ (Ot, 158) + 159 => b"glagolitic_cy".to_vec(), // Ⱉ (Cy, 159) + 160 => b"glagolitic_shcha".to_vec(), // Ⱊ (Shcha, 160) + 161 => b"glagolitic_er".to_vec(), // Ⱋ (Er, 161) + 162 => b"glagolitic_yeru".to_vec(), // Ⱌ (Yeru, 162) + 163 => b"glagolitic_small_yer".to_vec(), // Ⱍ (Small Yer, 163) + 164 => b"glagolitic_yo".to_vec(), // Ⱎ (Yo, 164) + 165 => b"glagolitic_yu".to_vec(), // Ⱏ (Yu, 165) + 166 => b"glagolitic_ja".to_vec(), // Ⱐ (Ja, 166) + 167 => b"thai_ko_kai".to_vec(), // ก (Ko Kai, 167) + 168 => b"thai_kho_khai".to_vec(), // ข (Kho Khai, 168) + 169 => b"thai_kho_khuat".to_vec(), // ฃ (Kho Khuat, 169) + 170 => b"thai_kho_khon".to_vec(), // ค (Kho Khon, 170) + 171 => b"thai_kho_rakhang".to_vec(), // ฅ (Kho Rakhang, 171) + 172 => b"thai_kho_khwai".to_vec(), // ฆ (Kho Khwai, 172) + 173 => b"thai_ngo_ngu".to_vec(), // ง (Ngo Ngu, 173) + 174 => b"thai_cho_chan".to_vec(), // จ (Cho Chan, 174) + 175 => b"thai_cho_ching".to_vec(), // ฉ (Cho Ching, 175) + 176 => b"thai_cho_chang".to_vec(), // ช (Cho Chang, 176) + 177 => b"thai_so_so".to_vec(), // ซ (So So, 177) + 178 => b"thai_cho_choe".to_vec(), // ฌ (Cho Choe, 178) + 179 => b"thai_yo_ying".to_vec(), // ญ (Yo Ying, 179) + 180 => b"thai_do_chada".to_vec(), // ฎ (Do Chada, 180) + 181 => b"thai_to_patak".to_vec(), // ฏ (To Patak, 181) + 182 => b"thai_tho_than".to_vec(), // ฐ (Tho Than, 182) + 183 => b"thai_tho_nangmontho".to_vec(), // ฑ (Tho Nangmontho, 183) + 184 => b"thai_tho_phuthao".to_vec(), // ฒ (Tho Phuthao, 184) + 185 => b"thai_no_nen".to_vec(), // ณ (No Nen, 185) + 186 => b"thai_do_dek".to_vec(), // ด (Do Dek, 186) + 187 => b"thai_to_tao".to_vec(), // ต (To Tao, 187) + 188 => b"thai_tho_thung".to_vec(), // ถ (Tho Thung, 188) + 189 => b"thai_tho_thahan".to_vec(), // ท (Tho Thahan, 189) + 190 => b"thai_tho_thong".to_vec(), // ธ (Tho Thong, 190) + 191 => b"thai_no_nu".to_vec(), // น (No Nu, 191) + 192 => b"thai_bo_baimai".to_vec(), // บ (Bo Baimai, 192) + 193 => b"thai_po_pla".to_vec(), // ป (Po Pla, 193) + 194 => b"thai_pho_phung".to_vec(), // ผ (Pho Phung, 194) + 195 => b"thai_fo_fa".to_vec(), // ฝ (Fo Fa, 195) + 196 => b"thai_pho_phan".to_vec(), // พ (Pho Phan, 196) + 197 => b"thai_fo_fan".to_vec(), // ฟ (Fo Fan, 197) + 198 => b"thai_pho_samphao".to_vec(), // ภ (Pho Samphao, 198) + 199 => b"thai_mo_ma".to_vec(), // ม (Mo Ma, 199) + 200 => b"thai_yo_yak".to_vec(), // ย (Yo Yak, 200) + 201 => b"thai_ro_rua".to_vec(), // ร (Ro Rua, 201) + 202 => b"thai_lo_ling".to_vec(), // ล (Lo Ling, 202) + 203 => b"thai_wo_waen".to_vec(), // ว (Wo Waen, 203) + 204 => b"thai_so_sala".to_vec(), // ศ (So Sala, 204) + 205 => b"thai_so_rusi".to_vec(), // ษ (So Rusi, 205) + 206 => b"thai_so_sua".to_vec(), // ส (So Sua, 206) + 207 => b"thai_ho_hip".to_vec(), // ห (Ho Hip, 207) + 208 => b"thai_lo_chula".to_vec(), // ฬ (Lo Chula, 208) + 209 => b"thai_o_ang".to_vec(), // อ (O Ang, 209) + 210 => b"thai_ho_nokhuk".to_vec(), // ฮ (Ho Nokhuk, 210) + 211 => b"hangul_giyeok".to_vec(), // ㄱ (Giyeok, 211) + 212 => b"hangul_nieun".to_vec(), // ㄴ (Nieun, 212) + 213 => b"hangul_digeut".to_vec(), // ㄷ (Digeut, 213) + 214 => b"hangul_rieul".to_vec(), // ㄹ (Rieul, 214) + 215 => b"hangul_mieum".to_vec(), // ㅁ (Mieum, 215) + 216 => b"hangul_bieup".to_vec(), // ㅂ (Bieup, 216) + 217 => b"hangul_siot".to_vec(), // ㅅ (Siot, 217) + 218 => b"hangul_ieung".to_vec(), // ㅇ (Ieung, 218) + 219 => b"hangul_jieut".to_vec(), // ㅈ (Jieut, 219) + 220 => b"hangul_chieut".to_vec(), // ㅊ (Chieut, 220) + 221 => b"hangul_kieuk".to_vec(), // ㅋ (Kieuk, 221) + 222 => b"hangul_tieut".to_vec(), // ㅌ (Tieut, 222) + 223 => b"hangul_pieup".to_vec(), // ㅍ (Pieup, 223) + 224 => b"hangul_hieut".to_vec(), // ㅎ (Hieut, 224) + 225 => b"hangul_a".to_vec(), // ㅏ (A, 225) + 226 => b"hangul_ae".to_vec(), // ㅐ (Ae, 226) + 227 => b"hangul_ya".to_vec(), // ㅑ (Ya, 227) + 228 => b"hangul_yae".to_vec(), // ㅒ (Yae, 228) + 229 => b"hangul_eo".to_vec(), // ㅓ (Eo, 229) + 230 => b"hangul_e".to_vec(), // ㅔ (E, 230) + 231 => b"hangul_yeo".to_vec(), // ㅕ (Yeo, 231) + 232 => b"hangul_ye".to_vec(), // ㅖ (Ye, 232) + 233 => b"hangul_o".to_vec(), // ㅗ (O, 233) + 234 => b"hangul_wa".to_vec(), // ㅘ (Wa, 234) + 235 => b"hangul_wae".to_vec(), // ㅙ (Wae, 235) + 236 => b"hangul_oe".to_vec(), // ㅚ (Oe, 236) + 237 => b"hangul_yo".to_vec(), // ㅛ (Yo, 237) + 238 => b"hangul_u".to_vec(), // ㅜ (U, 238) + 239 => b"hangul_weo".to_vec(), // ㅝ (Weo, 239) + 240 => b"hangul_we".to_vec(), // ㅞ (We, 240) + 241 => b"hangul_wi".to_vec(), // ㅟ (Wi, 241) + 242 => b"hangul_yu".to_vec(), // ㅠ (Yu, 242) + 243 => b"hangul_eu".to_vec(), // ㅡ (Eu, 243) + 244 => b"hangul_ui".to_vec(), // ㅢ (Ui, 244) + 245 => b"hangul_i".to_vec(), // ㅣ (I, 245) + 246 => b"ethiopic_glottal_a".to_vec(), // አ (Glottal A, 246) + 247 => b"ethiopic_glottal_u".to_vec(), // ኡ (Glottal U, 247) + 248 => b"ethiopic_glottal_i".to_vec(), // ኢ (Glottal I, 248) + 249 => b"ethiopic_glottal_aa".to_vec(), // ኣ (Glottal Aa, 249) + 250 => b"ethiopic_glottal_e".to_vec(), // ኤ (Glottal E, 250) + 251 => b"ethiopic_glottal_ie".to_vec(), // እ (Glottal Ie, 251) + 252 => b"ethiopic_glottal_o".to_vec(), // ኦ (Glottal O, 252) + 253 => b"ethiopic_glottal_wa".to_vec(), // ኧ (Glottal Wa, 253) + 254 => b"ethiopic_wa".to_vec(), // ወ (Wa, 254) + 255 => b"ethiopic_wu".to_vec(), // ዉ (Wu, 255) + 256 => b"ethiopic_wi".to_vec(), // ዊ (Wi, 256) + 257 => b"ethiopic_waa".to_vec(), // ዋ (Waa, 257) + 258 => b"ethiopic_we".to_vec(), // ዌ (We, 258) + 259 => b"ethiopic_wye".to_vec(), // ው (Wye, 259) + 260 => b"ethiopic_wo".to_vec(), // ዎ (Wo, 260) + 261 => b"ethiopic_ko".to_vec(), // ኰ (Ko, 261) + 262 => b"ethiopic_ku".to_vec(), // ኱ (Ku, 262) + 263 => b"ethiopic_ki".to_vec(), // ኲ (Ki, 263) + 264 => b"ethiopic_kua".to_vec(), // ኳ (Kua, 264) + 265 => b"ethiopic_ke".to_vec(), // ኴ (Ke, 265) + 266 => b"ethiopic_kwe".to_vec(), // ኵ (Kwe, 266) + 267 => b"ethiopic_ko_alt".to_vec(), // ኶ (Ko, 267) + 268 => b"ethiopic_go".to_vec(), // ጐ (Go, 268) + 269 => b"ethiopic_gu".to_vec(), // ጑ (Gu, 269) + 270 => b"ethiopic_gi".to_vec(), // ጒ (Gi, 270) + 271 => b"ethiopic_gua".to_vec(), // መ (Gua, 271) + 272 => b"ethiopic_ge".to_vec(), // ጔ (Ge, 272) + 273 => b"ethiopic_gwe".to_vec(), // ጕ (Gwe, 273) + 274 => b"ethiopic_go_alt".to_vec(), // ጖ (Go, 274) + 275 => b"devanagari_a".to_vec(), // अ (A, 275) + 276 => b"devanagari_aa".to_vec(), // आ (Aa, 276) + 277 => b"devanagari_i".to_vec(), // इ (I, 277) + 278 => b"devanagari_ii".to_vec(), // ई (Ii, 278) + 279 => b"devanagari_u".to_vec(), // उ (U, 279) + 280 => b"devanagari_uu".to_vec(), // ऊ (Uu, 280) + 281 => b"devanagari_r".to_vec(), // ऋ (R, 281) + 282 => b"devanagari_e".to_vec(), // ए (E, 282) + 283 => b"devanagari_ai".to_vec(), // ऐ (Ai, 283) + 284 => b"devanagari_o".to_vec(), // ओ (O, 284) + 285 => b"devanagari_au".to_vec(), // औ (Au, 285) + 286 => b"devanagari_ka".to_vec(), // क (Ka, 286) + 287 => b"devanagari_kha".to_vec(), // ख (Kha, 287) + 288 => b"devanagari_ga".to_vec(), // ग (Ga, 288) + 289 => b"devanagari_gha".to_vec(), // घ (Gha, 289) + 290 => b"devanagari_nga".to_vec(), // ङ (Nga, 290) + 291 => b"devanagari_cha".to_vec(), // च (Cha, 291) + 292 => b"devanagari_chha".to_vec(), // छ (Chha, 292) + 293 => b"devanagari_ja".to_vec(), // ज (Ja, 293) + 294 => b"devanagari_jha".to_vec(), // झ (Jha, 294) + 295 => b"devanagari_nya".to_vec(), // ञ (Nya, 295) + 296 => b"devanagari_ta".to_vec(), // ट (Ta, 296) + 297 => b"devanagari_tha".to_vec(), // ठ (Tha, 297) + 298 => b"devanagari_da".to_vec(), // ड (Da, 298) + 299 => b"devanagari_dha".to_vec(), // ढ (Dha, 299) + 300 => b"devanagari_na".to_vec(), // ण (Na, 300) + 301 => b"devanagari_ta_alt".to_vec(), // त (Ta, 301) + 302 => b"devanagari_tha_alt".to_vec(), // थ (Tha, 302) + 303 => b"devanagari_da_alt".to_vec(), // द (Da, 303) + 304 => b"devanagari_dha_alt".to_vec(), // ध (Dha, 304) + 305 => b"devanagari_na_alt".to_vec(), // न (Na, 305) + 306 => b"devanagari_pa".to_vec(), // प (Pa, 306) + 307 => b"devanagari_pha".to_vec(), // फ (Pha, 307) + 308 => b"devanagari_ba".to_vec(), // ब (Ba, 308) + 309 => b"devanagari_bha".to_vec(), // भ (Bha, 309) + 310 => b"devanagari_ma".to_vec(), // म (Ma, 310) + 311 => b"devanagari_ya".to_vec(), // य (Ya, 311) + 312 => b"devanagari_ra".to_vec(), // र (Ra, 312) + 313 => b"devanagari_la".to_vec(), // ल (La, 313) + 314 => b"devanagari_va".to_vec(), // व (Va, 314) + 315 => b"devanagari_sha".to_vec(), // श (Sha, 315) + 316 => b"devanagari_ssa".to_vec(), // ष (Ssa, 316) + 317 => b"devanagari_sa".to_vec(), // स (Sa, 317) + 318 => b"devanagari_ha".to_vec(), // ह (Ha, 318) + 319 => b"katakana_a".to_vec(), // ア (A, 319) + 320 => b"kana_i".to_vec(), + 321 => b"kana_u".to_vec(), + 322 => b"kana_e".to_vec(), + 323 => b"kana_o".to_vec(), + 324 => b"kana_a".to_vec(), + 325 => b"kana_ki".to_vec(), + 326 => b"kana_ku".to_vec(), + 327 => b"kana_ke".to_vec(), + 328 => b"kana_ko".to_vec(), + 329 => b"kana_sa".to_vec(), + 330 => b"kana_shi".to_vec(), + 331 => b"kana_su".to_vec(), + 332 => b"kana_se".to_vec(), + 333 => b"kana_so".to_vec(), + 334 => b"kana_ta".to_vec(), + 335 => b"kana_chi".to_vec(), + 336 => b"kana_tsu".to_vec(), + 337 => b"kana_te".to_vec(), + 338 => b"kana_to".to_vec(), + 339 => b"kana_na".to_vec(), + 340 => b"kana_ni".to_vec(), + 341 => b"kana_nu".to_vec(), + 342 => b"kana_ne".to_vec(), + 343 => b"kana_no".to_vec(), + 344 => b"kana_ha".to_vec(), + 345 => b"kana_hi".to_vec(), + 346 => b"kana_fu".to_vec(), + 347 => b"kana_he".to_vec(), + 348 => b"kana_ho".to_vec(), + 349 => b"kana_ma".to_vec(), + 350 => b"kana_mi".to_vec(), + 351 => b"kana_mu".to_vec(), + 352 => b"kana_me".to_vec(), + 353 => b"kana_mo".to_vec(), + 354 => b"kana_ya".to_vec(), + 355 => b"kana_yu".to_vec(), + 356 => b"kana_yo".to_vec(), + 357 => b"kana_ra".to_vec(), + 358 => b"kana_ri".to_vec(), + 359 => b"kana_ru".to_vec(), + 360 => b"kana_re".to_vec(), + 361 => b"kana_ro".to_vec(), + 362 => b"kana_wa".to_vec(), + 363 => b"kana_wo".to_vec(), + 364 => b"kana_n".to_vec(), + 365 => b"ya".to_vec(), + 366 => b"yab".to_vec(), + 367 => b"yabh".to_vec(), + 368 => b"yag".to_vec(), + 369 => b"yagh".to_vec(), + 370 => b"yaj".to_vec(), + 371 => b"yach".to_vec(), + 372 => b"yad".to_vec(), + 373 => b"yadh".to_vec(), + 374 => b"yadhe".to_vec(), + 375 => b"yaz".to_vec(), + 376 => b"yazh".to_vec(), + 377 => b"yaf".to_vec(), + 378 => b"yak".to_vec(), + 379 => b"yakv".to_vec(), + 380 => b"yaq".to_vec(), + 381 => b"yah".to_vec(), + 382 => b"yahh".to_vec(), + 383 => b"yahl".to_vec(), + 384 => b"yahm".to_vec(), + 385 => b"yayn".to_vec(), + 386 => b"yakh".to_vec(), + 387 => b"yakl".to_vec(), + 388 => b"yahq".to_vec(), + 389 => b"yash".to_vec(), + 390 => b"yi".to_vec(), + 391 => b"yij".to_vec(), + 392 => b"yizh".to_vec(), + 393 => b"yink".to_vec(), + 394 => b"yal".to_vec(), + 395 => b"yam".to_vec(), + 396 => b"yan".to_vec(), + 397 => b"yang".to_vec(), + 398 => b"yany".to_vec(), + 399 => b"yap".to_vec(), + 400 => b"yu".to_vec(), + 401 => b"a".to_vec(), + 402 => b"aa".to_vec(), + 403 => b"i".to_vec(), + 404 => b"ii".to_vec(), + 405 => b"u".to_vec(), + 406 => b"uu".to_vec(), + 407 => b"r".to_vec(), + 408 => b"rr".to_vec(), + 409 => b"l".to_vec(), + 410 => b"ll".to_vec(), + 411 => b"e".to_vec(), + 412 => b"ee".to_vec(), + 413 => b"ai".to_vec(), + 414 => b"o".to_vec(), + 415 => b"oo".to_vec(), + 416 => b"au".to_vec(), + 417 => b"ka".to_vec(), + 418 => b"kha".to_vec(), + 419 => b"ga".to_vec(), + 420 => b"gha".to_vec(), + 421 => b"nga".to_vec(), + 422 => b"cha".to_vec(), + 423 => b"chha".to_vec(), + 424 => b"ja".to_vec(), + 425 => b"jha".to_vec(), + 426 => b"nya".to_vec(), + 427 => b"ta".to_vec(), + 428 => b"tha".to_vec(), + 429 => b"da".to_vec(), + 430 => b"dha".to_vec(), + 431 => b"na".to_vec(), + 432 => b"pa".to_vec(), + 433 => b"pha".to_vec(), + 434 => b"ba".to_vec(), + 435 => b"bha".to_vec(), + 436 => b"ma".to_vec(), + 437 => b"ya".to_vec(), + 438 => b"ra".to_vec(), + _ => b"unknown".to_vec(), + } + // match netuid { + // // Greek Alphabet (Lowercase) + // 0 => b"root".to_vec(), // Τ (Upper case Tau) + // 1 => b"apex".to_vec(), // α (Alpha) + // 2 => b"omron".to_vec(), // β (Beta) + // 3 => b"templar".to_vec(), // γ (Gamma) + // 4 => b"targon".to_vec(), // δ (Delta) + // 5 => b"kaito".to_vec(), // ε (Epsilon) + // 6 => b"infinite".to_vec(), // ζ (Zeta) + // 7 => b"subvortex".to_vec(), // η (Eta) + // 8 => b"ptn".to_vec(), // θ (Theta) + // 9 => b"pretrain".to_vec(), // ι (Iota) + // 10 => b"sturdy".to_vec(), // κ (Kappa) + // 11 => b"dippy".to_vec(), // λ (Lambda) + // 12 => b"horde".to_vec(), // μ (Mu) + // 13 => b"dataverse".to_vec(), // ν (Nu) + // 14 => b"palaidn".to_vec(), // ξ (Xi) + // 15 => b"deval".to_vec(), // ο (Omicron) + // 16 => b"bitads".to_vec(), // π (Pi) + // 17 => b"3gen".to_vec(), // ρ (Rho) + // 18 => b"cortex".to_vec(), // σ (Sigma) + // 19 => b"inference".to_vec(), // t (Tau) + // 20 => b"bitagent".to_vec(), // υ (Upsilon) + // 21 => b"any-any".to_vec(), // φ (Phi) + // 22 => b"meta".to_vec(), // χ (Chi) + // 23 => b"social".to_vec(), // ψ (Psi) + // 24 => b"omega".to_vec(), // ω (Omega) + // 25 => b"protein".to_vec(), // א (Aleph) + // 26 => b"alchemy".to_vec(), // ב (Bet) + // 27 => b"compute".to_vec(), // ג (Gimel) + // 28 => b"oracle".to_vec(), // ד (Dalet) + // 29 => b"coldint".to_vec(), // ה (He) + // 30 => b"bet".to_vec(), // ו (Vav) + // 31 => b"naschain".to_vec(), // ז (Zayin) + // 32 => b"itsai".to_vec(), // ח (Het) + // 33 => b"ready".to_vec(), // ט (Tet) + // 34 => b"mind".to_vec(), // י (Yod) + // 35 => b"logic".to_vec(), // ך (Final Kaf) + // 36 => b"automata".to_vec(), // כ (Kaf) + // 37 => b"tuning".to_vec(), // ל (Lamed) + // 38 => b"distributed".to_vec(), // ם (Final Mem) + // 39 => b"edge".to_vec(), // מ (Mem) + // 40 => b"chunk".to_vec(), // ן (Final Nun) + // 41 => b"sportsensor".to_vec(), // נ (Nun) + // 42 => b"masa".to_vec(), // ס (Samekh) + // 43 => b"graphite".to_vec(), // ע (Ayin) + // 44 => b"score".to_vec(), // ף (Final Pe) + // 45 => b"gen42".to_vec(), // פ (Pe) + // 46 => b"neural".to_vec(), // ץ (Final Tsadi) + // 47 => b"condense".to_vec(), // צ (Tsadi) + // 48 => b"nextplace".to_vec(), // ק (Qof) + // 49 => b"automl".to_vec(), // ר (Resh) + // 50 => b"audio".to_vec(), // ש (Shin) + // 51 => b"celium".to_vec(), // ת (Tav) + // 52 => b"dojo".to_vec(), // ا (Alif) + // 53 => b"frontier".to_vec(), // ب (Ba) + // 54 => b"safescan".to_vec(), // ت (Ta) + // 55 => b"unknown".to_vec(), // ث (Tha) + // 56 => b"gradients".to_vec(), // ج (Jim) + // 57 => b"gaia".to_vec(), // ح (Ha) + // 58 => b"dippy-speach".to_vec(), // خ (Kha) + // 59 => b"agent-arena".to_vec(), // د (Dal) + // 60 => b"unknown".to_vec(), // ذ (Dhal) + // 61 => b"red team".to_vec(), // ر (Ra) + // 62 => b"agentao".to_vec(), // ز (Zay) + // 63 => b"lean-in".to_vec(), // س (Sin) + // 64 => b"chutes".to_vec(), // ش (Shin) + // // Default case + // _ => b"unknown".to_vec(), // unknown subnet. + // } }) } From e906b327242e4fee21a820f0ac58643c7aa5dd4d Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Thu, 1 May 2025 17:11:06 +0200 Subject: [PATCH 105/226] bump spec_version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a7a89608c9..88dabca33c 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 264, + spec_version: 265, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 14a86cd47e6999477ecbf0f884c1823842d7a099 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 30 Apr 2025 19:17:11 +0400 Subject: [PATCH 106/226] Update get_max_amount_* methods. - update tests and benchmarks --- pallets/subtensor/src/benchmarks.rs | 172 ++++++------- pallets/subtensor/src/lib.rs | 18 +- pallets/subtensor/src/staking/move_stake.rs | 2 +- pallets/subtensor/src/staking/remove_stake.rs | 26 +- pallets/subtensor/src/tests/staking.rs | 240 ++++++++++++------ 5 files changed, 274 insertions(+), 184 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index faa0b46a6d..3c9d94a944 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -162,7 +162,48 @@ benchmarks! { assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); }: add_stake_aggregate(RawOrigin::Signed( coldkey.clone() ), hotkey, netuid, amount) - benchmark_remove_stake_limit_aggregate{ + benchmark_remove_stake_limit { + let caller: T::AccountId = whitelisted_caller::>(); + let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); + let netuid: u16 = 1; + let tempo: u16 = 1; + let modality: u16 = 0; + let seed : u32 = 1; + + // Set our total stake to 1000 TAO + Subtensor::::increase_total_stake(1_000_000_000_000); + + Subtensor::::init_new_network(netuid, tempo); + Subtensor::::set_network_registration_allowed( netuid, true ); + SubtokenEnabled::::insert(netuid, true); + + Subtensor::::set_max_allowed_uids( netuid, 4096 ); + assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); + + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + Subtensor::::set_burn(netuid, 1); + + let limit: u64 = 1_000_000_000; + let tao_reserve = 150_000_000_000_u64; + let alpha_in = 100_000_000_000_u64; + SubnetTAO::::insert(netuid, tao_reserve); + SubnetAlphaIn::::insert(netuid, alpha_in); + + let wallet_bal = 1000000u32.into(); + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), wallet_bal); + + assert_ok!(Subtensor::::do_burned_registration(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone())); + + let u64_staked_amt = 100_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), u64_staked_amt); + + assert_ok!(Subtensor::::add_stake(RawOrigin::Signed( coldkey.clone() ).into() , hotkey.clone(), netuid, u64_staked_amt)); + + let amount_unstaked: u64 = 30_000_000_000; + }: remove_stake_limit(RawOrigin::Signed( coldkey.clone() ), hotkey.clone(), netuid, amount_unstaked, limit, false) + +benchmark_remove_stake_limit_aggregate{ let caller: T::AccountId = whitelisted_caller::>(); let caller_origin = ::RuntimeOrigin::from(RawOrigin::Signed(caller.clone())); let netuid: u16 = 1; @@ -895,103 +936,62 @@ benchmark_move_stake { Subtensor::::create_account_if_non_existent(&coldkey, &destination); }: move_stake(RawOrigin::Signed(coldkey.clone()),origin.clone(),destination.clone(),netuid,netuid,alpha_to_move) -benchmark_remove_stake_limit { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hotkey: T::AccountId = account("Alice", 0, 1); - let netuid: u16 = 1; +benchmark_swap_stake_limit { + let coldkey: T::AccountId = whitelisted_caller::>(); + let hot: T::AccountId = account("A", 0, 1); + let netuid1: u16 = 1; + let netuid2: u16 = 2; + let allow: bool = true; - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); + SubtokenEnabled::::insert(netuid1, true); + Subtensor::::init_new_network(netuid1, 1); + SubtokenEnabled::::insert(netuid2, true); + Subtensor::::init_new_network(netuid2, 1); - let bond = Subtensor::::get_burn_as_u64(netuid); - let fee = DefaultStakingFee::::get(); - let amount: u64 = 1_000_000; - let deposit = (amount + bond + fee).saturating_mul(10); + let tao_reserve = 150_000_000_000_u64; + let alpha_in = 100_000_000_000_u64; + SubnetTAO::::insert(netuid1, tao_reserve); + SubnetAlphaIn::::insert(netuid1, alpha_in); + SubnetTAO::::insert(netuid2, tao_reserve); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone(), - ) - ); + Subtensor::::increase_total_stake(1_000_000_000_000); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - SubnetAlphaOut::::insert(netuid, deposit); - TotalStake::::set(deposit); + let limit: u64 = 1_000_000_000; + let amount = 900_000_000_000; + let limit_stake: u64 = 6_000_000_000; + let limit_swap: u64 = 1_000_000_000; + let amount_to_be_staked = 440_000_000_000; + let amount_swapped: u64 = 30_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount); - assert_ok!( - Subtensor::::add_stake_limit( + assert_ok!( + Subtensor::::burned_register( RawOrigin::Signed(coldkey.clone()).into(), - hotkey.clone(), - netuid, - amount, - u64::MAX, - false, - ) - ); - - let alpha: u64 = Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey, &coldkey, netuid - ); + netuid1, + hot.clone() + ) + ); - assert_ok!( - Subtensor::::remove_stake_limit( + assert_ok!( + Subtensor::::burned_register( RawOrigin::Signed(coldkey.clone()).into(), - hotkey.clone(), - netuid, - alpha, - u64::MAX, - true, - ) - ); -}: remove_stake_limit(RawOrigin::Signed(coldkey.clone()),hotkey.clone(),netuid,alpha,u64::MAX,true) - -benchmark_swap_stake_limit { - let coldkey: T::AccountId = whitelisted_caller::>(); - let hot: T::AccountId = account("A", 0, 1); - let netuid: u16 = 1; - let allow: bool = true; - - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); - - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - let stake_tao = 1_000_000; - let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - - assert_ok!( - Subtensor::::burned_register( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hot.clone() - ) - ); - - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); + netuid2, + hot.clone() + ) + ); - assert_ok!( - Subtensor::::add_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hot.clone(), - netuid, - stake_tao, - u64::MAX, - allow + assert_ok!( + Subtensor::::add_stake_limit( + RawOrigin::Signed(coldkey.clone()).into(), + hot.clone(), + netuid1, + amount_to_be_staked, + limit_stake, + allow ) ); - let alpha_to_swap: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet( - &hot, &coldkey, netuid - ); -}: swap_stake_limit(RawOrigin::Signed(coldkey.clone()),hot.clone(),netuid,netuid,alpha_to_swap,u64::MAX,allow) +}: swap_stake_limit(RawOrigin::Signed(coldkey.clone()),hot.clone(),netuid1,netuid2,amount_swapped,limit_swap,allow) benchmark_transfer_stake { let coldkey: T::AccountId = whitelisted_caller::>(); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index b782d37723..753bedd0a1 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2123,8 +2123,14 @@ where limit_price, allow_partial, }) => { - // Calcaulate the maximum amount that can be executed with price limit - let max_amount = Pallet::::get_max_amount_remove(*netuid, *limit_price); + // Calculate the maximum amount that can be executed with price limit + let Ok(max_amount) = Pallet::::get_max_amount_remove(*netuid, *limit_price) + else { + return InvalidTransaction::Custom( + CustomTransactionError::ZeroMaxAmount.into(), + ) + .into(); + }; // Fully validate the user input Self::result_to_validity( @@ -2224,7 +2230,13 @@ where allow_partial, }) => { // Calculate the maximum amount that can be executed with price limit - let max_amount = Pallet::::get_max_amount_remove(*netuid, *limit_price); + let Ok(max_amount) = Pallet::::get_max_amount_remove(*netuid, *limit_price) + else { + return InvalidTransaction::Custom( + CustomTransactionError::ZeroMaxAmount.into(), + ) + .into(); + }; // Fully validate the user input Self::result_to_validity( diff --git a/pallets/subtensor/src/staking/move_stake.rs b/pallets/subtensor/src/staking/move_stake.rs index 75b84b205e..ef576f3607 100644 --- a/pallets/subtensor/src/staking/move_stake.rs +++ b/pallets/subtensor/src/staking/move_stake.rs @@ -443,7 +443,7 @@ impl Pallet { || (SubnetMechanism::::get(destination_netuid)) == 0) && ((SubnetMechanism::::get(origin_netuid)) == 1) { - return Ok(Self::get_max_amount_remove(origin_netuid, limit_price)); + return Self::get_max_amount_remove(origin_netuid, limit_price); } // Corner case: SubnetTAO for any of two subnets is zero diff --git a/pallets/subtensor/src/staking/remove_stake.rs b/pallets/subtensor/src/staking/remove_stake.rs index 3930a923a8..372b4f6e61 100644 --- a/pallets/subtensor/src/staking/remove_stake.rs +++ b/pallets/subtensor/src/staking/remove_stake.rs @@ -484,8 +484,8 @@ impl Pallet { alpha_unstaked ); - // 2. Calcaulate the maximum amount that can be executed with price limit - let max_amount = Self::get_max_amount_remove(netuid, limit_price); + // 2. Calculate the maximum amount that can be executed with price limit + let max_amount = Self::get_max_amount_remove(netuid, limit_price)?; let mut possible_alpha = alpha_unstaked; if possible_alpha > max_amount { possible_alpha = max_amount; @@ -614,36 +614,36 @@ impl Pallet { } // Returns the maximum amount of RAO that can be executed with price limit - pub fn get_max_amount_remove(netuid: u16, limit_price: u64) -> u64 { + pub fn get_max_amount_remove(netuid: u16, limit_price: u64) -> Result> { // Corner case: root and stao // There's no slippage for root or stable subnets, so if limit price is 1e9 rao or // higher, then max_amount equals u64::MAX, otherwise it is 0. if (netuid == Self::get_root_netuid()) || (SubnetMechanism::::get(netuid)) == 0 { if limit_price <= 1_000_000_000 { - return u64::MAX; + return Ok(u64::MAX); } else { - return 0; + return Err(Error::ZeroMaxStakeAmount); } } // Corner case: SubnetAlphaIn is zero. Staking can't happen, so max amount is zero. let alpha_in = SubnetAlphaIn::::get(netuid); if alpha_in == 0 { - return 0; + return Err(Error::ZeroMaxStakeAmount); } let alpha_in_u128 = alpha_in as u128; // Corner case: SubnetTAO is zero. Staking can't happen, so max amount is zero. let tao_reserve = SubnetTAO::::get(netuid); if tao_reserve == 0 { - return 0; + return Err(Error::ZeroMaxStakeAmount); } let tao_reserve_u128 = tao_reserve as u128; // Corner case: limit_price == 0 (because there's division by limit price) // => can sell all if limit_price == 0 { - return u64::MAX; + return Ok(u64::MAX); } // Corner case: limit_price >= current_price (price cannot increase with unstaking) @@ -657,7 +657,7 @@ impl Pallet { .checked_div(alpha_in_u128) .unwrap_or(0) { - return 0; + return Err(Error::ZeroMaxStakeAmount); } // Main case: SubnetTAO / limit_price - SubnetAlphaIn @@ -670,9 +670,13 @@ impl Pallet { .saturating_sub(alpha_in_u128); if result < u64::MAX as u128 { - result as u64 + if result == 0 { + return Err(Error::ZeroMaxStakeAmount); + } + + Ok(result as u64) } else { - u64::MAX + Ok(u64::MAX) } } } diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index a2c3517ca7..8e9bf6fe09 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -223,7 +223,10 @@ fn test_verify_aggregated_stake_order() { new_test_ext(1).execute_with(|| { let hotkey_account_id = U256::from(533453); let coldkey_account_id = U256::from(55453); - let amount = 900_000_000_000; // over the maximum + let amount = 1_000_000_000_000u64; + let limit_price = 6_000_000_000u64; + let unstake_amount = 150_000_000_000u64; + let limit_price2 = 1_350_000_000; // add network let netuid1: u16 = add_dynamic_network(&hotkey_account_id, &coldkey_account_id); @@ -233,8 +236,8 @@ fn test_verify_aggregated_stake_order() { let netuid5: u16 = add_dynamic_network(&hotkey_account_id, &coldkey_account_id); let netuid6: u16 = add_dynamic_network(&hotkey_account_id, &coldkey_account_id); - let tao_reserve: U96F32 = U96F32::from_num(150_000_000_000_u64); - let alpha_in: U96F32 = U96F32::from_num(100_000_000_000_u64); + let tao_reserve: U96F32 = U96F32::from_num(1_500_000_000_000_u64); + let alpha_in: U96F32 = U96F32::from_num(1_000_000_000_000_u64); for netuid in [netuid1, netuid3, netuid3, netuid4, netuid5, netuid6] { SubnetTAO::::insert(netuid, tao_reserve.to_num::()); @@ -257,8 +260,6 @@ fn test_verify_aggregated_stake_order() { amount, ); - let limit_price = 6_000_000_000u64; - // Add stake with slippage safety and check if the result is ok assert_ok!(SubtensorModule::remove_stake_aggregate( RuntimeOrigin::signed(coldkey_account_id), @@ -271,8 +272,8 @@ fn test_verify_aggregated_stake_order() { RuntimeOrigin::signed(coldkey_account_id), hotkey_account_id, netuid4, - amount, - limit_price, + unstake_amount, + limit_price2, true )); @@ -401,8 +402,10 @@ fn test_verify_aggregated_stake_order() { #[allow(clippy::indexing_slicing)] fn test_verify_aggregated_stake_order_reversed() { new_test_ext(1).execute_with(|| { - let amount = 900_000_000_000; // over the maximum + let amount = 1_000_000_000_000u64; let limit_price = 6_000_000_000u64; + let unstake_amount = 150_000_000_000u64; + let limit_price2 = 1_350_000_000; // Coldkeys and hotkeys let coldkeys = vec![ @@ -422,8 +425,8 @@ fn test_verify_aggregated_stake_order_reversed() { .map(|(h, c)| add_dynamic_network(h, c)) .collect(); - let tao_reserve = U96F32::from_num(150_000_000_000u64); - let alpha_in = U96F32::from_num(100_000_000_000u64); + let tao_reserve = U96F32::from_num(1_500_000_000_000u64); + let alpha_in = U96F32::from_num(1_000_000_000_000u64); for netuid in &netuids { SubnetTAO::::insert(*netuid, tao_reserve.to_num::()); @@ -452,8 +455,8 @@ fn test_verify_aggregated_stake_order_reversed() { RuntimeOrigin::signed(coldkeys[3]), hotkeys[3], netuids[3], - amount, - limit_price, + unstake_amount, + limit_price2, true )); @@ -589,8 +592,10 @@ fn test_verify_aggregated_stake_order_reversed() { #[allow(clippy::indexing_slicing)] fn test_verify_all_job_type_sort_by_coldkey() { new_test_ext(1).execute_with(|| { - let amount = 1_000_000_000_000; + let amount = 1_000_000_000_000u64; let limit_price = 6_000_000_000u64; + let unstake_amount = 150_000_000_000u64; + let limit_price2 = 1_350_000_000; // Coldkeys and hotkeys let coldkeys = vec![ @@ -616,8 +621,8 @@ fn test_verify_all_job_type_sort_by_coldkey() { .map(|(h, c)| add_dynamic_network(h, c)) .collect(); - let tao_reserve = U96F32::from_num(150_000_000_000u64); - let alpha_in = U96F32::from_num(100_000_000_000u64); + let tao_reserve = U96F32::from_num(1_500_000_000_000u64); + let alpha_in = U96F32::from_num(1_000_000_000_000u64); for netuid in &netuids { SubnetTAO::::insert(*netuid, tao_reserve.to_num::()); @@ -683,16 +688,16 @@ fn test_verify_all_job_type_sort_by_coldkey() { RuntimeOrigin::signed(coldkeys[6]), hotkeys[6], netuids[6], - amount, - limit_price, + unstake_amount, + limit_price2, true )); assert_ok!(SubtensorModule::remove_stake_limit_aggregate( RuntimeOrigin::signed(coldkeys[7]), hotkeys[7], netuids[7], - amount, - limit_price, + unstake_amount, + limit_price2, true )); @@ -769,8 +774,10 @@ fn test_verify_all_job_type_sort_by_coldkey() { #[allow(clippy::indexing_slicing)] fn test_verify_all_job_type_sort_by_coldkey_reverse_order() { new_test_ext(1).execute_with(|| { - let amount = 1_000_000_000_000; + let amount = 1_000_000_000_000u64; let limit_price = 6_000_000_000u64; + let unstake_amount = 150_000_000_000u64; + let limit_price2 = 1_350_000_000; // Coldkeys and hotkeys let coldkeys = vec![ @@ -796,8 +803,8 @@ fn test_verify_all_job_type_sort_by_coldkey_reverse_order() { .map(|(h, c)| add_dynamic_network(h, c)) .collect(); - let tao_reserve = U96F32::from_num(150_000_000_000u64); - let alpha_in = U96F32::from_num(100_000_000_000u64); + let tao_reserve = U96F32::from_num(1_500_000_000_000u64); + let alpha_in = U96F32::from_num(1_000_000_000_000u64); for netuid in &netuids { SubnetTAO::::insert(*netuid, tao_reserve.to_num::()); @@ -863,16 +870,16 @@ fn test_verify_all_job_type_sort_by_coldkey_reverse_order() { RuntimeOrigin::signed(coldkeys[6]), hotkeys[6], netuids[6], - amount, - limit_price, + unstake_amount, + limit_price2, true )); assert_ok!(SubtensorModule::remove_stake_limit_aggregate( RuntimeOrigin::signed(coldkeys[7]), hotkeys[7], netuids[7], - amount, - limit_price, + unstake_amount, + limit_price2, true )); @@ -4076,31 +4083,37 @@ fn test_max_amount_add_dynamic() { fn test_max_amount_remove_root() { new_test_ext(0).execute_with(|| { // 0 price on root => max is u64::MAX - assert_eq!(SubtensorModule::get_max_amount_remove(0, 0), u64::MAX); + assert_eq!(SubtensorModule::get_max_amount_remove(0, 0), Ok(u64::MAX)); // 0.5 price on root => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_remove(0, 500_000_000), - u64::MAX + Ok(u64::MAX) ); // 0.999999... price on root => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_remove(0, 999_999_999), - u64::MAX + Ok(u64::MAX) ); // 1.0 price on root => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_remove(0, 1_000_000_000), - u64::MAX + Ok(u64::MAX) ); // 1.000...001 price on root => max is 0 - assert_eq!(SubtensorModule::get_max_amount_remove(0, 1_000_000_001), 0); + assert_eq!( + SubtensorModule::get_max_amount_remove(0, 1_000_000_001), + Err(Error::::ZeroMaxStakeAmount) + ); // 2.0 price on root => max is 0 - assert_eq!(SubtensorModule::get_max_amount_remove(0, 2_000_000_000), 0); + assert_eq!( + SubtensorModule::get_max_amount_remove(0, 2_000_000_000), + Err(Error::::ZeroMaxStakeAmount) + ); }); } @@ -4111,30 +4124,33 @@ fn test_max_amount_remove_stable() { add_network(netuid, 1, 0); // 0 price => max is u64::MAX - assert_eq!(SubtensorModule::get_max_amount_remove(netuid, 0), u64::MAX); + assert_eq!( + SubtensorModule::get_max_amount_remove(netuid, 0), + Ok(u64::MAX) + ); // 0.999999... price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_remove(netuid, 999_999_999), - u64::MAX + Ok(u64::MAX) ); // 1.0 price => max is u64::MAX assert_eq!( SubtensorModule::get_max_amount_remove(netuid, 1_000_000_000), - u64::MAX + Ok(u64::MAX) ); // 1.000...001 price => max is 0 assert_eq!( SubtensorModule::get_max_amount_remove(netuid, 1_000_000_001), - 0 + Err(Error::::ZeroMaxStakeAmount) ); // 2.0 price => max is 0 assert_eq!( SubtensorModule::get_max_amount_remove(netuid, 2_000_000_000), - 0 + Err(Error::::ZeroMaxStakeAmount) ); }); } @@ -4159,85 +4175,142 @@ fn test_max_amount_remove_dynamic() { // tao_in, alpha_in, limit_price, expected_max_swappable [ // Zero handling (no panics) - (0, 1_000_000_000, 100, 0), - (1_000_000_000, 0, 100, 0), - (1_000_000_000, 1_000_000_000, 0, u64::MAX), + ( + 0, + 1_000_000_000, + 100, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000_000, + 0, + 100, + Err(Error::::ZeroMaxStakeAmount), + ), + (1_000_000_000, 1_000_000_000, 0, Ok(u64::MAX)), // Low bounds - (1, 1, 0, u64::MAX), - (1, 1, 1, 999_999_999), - (1, 1, 2, 499_999_999), - (1, 1, 250_000_000, 3), + (1, 1, 0, Ok(u64::MAX)), + (1, 1, 1, Ok(999_999_999)), + (1, 1, 2, Ok(499_999_999)), + (1, 1, 250_000_000, Ok(3)), // Basic math - (1_000, 1_000, 250_000_000, 3_000), - (1_000, 1_000, 62_500_000, 15_000), + (1_000, 1_000, 250_000_000, Ok(3_000)), + (1_000, 1_000, 62_500_000, Ok(15_000)), ( 1_000_000_000_000, 1_000_000_000_000, 62_500_000, - 15_000_000_000_000, + Ok(15_000_000_000_000), ), // Normal range values with edge cases - (200_000_000_000, 100_000_000_000, 0, u64::MAX), + (200_000_000_000, 100_000_000_000, 0, Ok(u64::MAX)), ( 200_000_000_000, 100_000_000_000, 1_000_000_000, - 100_000_000_000, + Ok(100_000_000_000), ), ( 200_000_000_000, 100_000_000_000, 500_000_000, - 300_000_000_000, + Ok(300_000_000_000), + ), + ( + 200_000_000_000, + 100_000_000_000, + 2_000_000_000, + Err(Error::::ZeroMaxStakeAmount), ), - (200_000_000_000, 100_000_000_000, 2_000_000_000, 0), - (200_000_000_000, 100_000_000_000, 2_000_000_001, 0), - (200_000_000_000, 100_000_000_000, 1_999_999_999, 50), - (200_000_000_000, 100_000_000_000, 1_999_999_990, 500), + ( + 200_000_000_000, + 100_000_000_000, + 2_000_000_001, + Err(Error::::ZeroMaxStakeAmount), + ), + (200_000_000_000, 100_000_000_000, 1_999_999_999, Ok(50)), + (200_000_000_000, 100_000_000_000, 1_999_999_990, Ok(500)), // Miscellaneous overflows and underflows - (2_000_000_000_000, 100_000_000_000, u64::MAX, 0), - (200_000_000_000, 100_000_000_000, u64::MAX / 2, 0), - (1_000_000, 1_000_000_000_000_000_000_u64, 1, 0), - (1_000_000, 1_000_000_000_000_000_000_u64, 10, 0), - (1_000_000, 1_000_000_000_000_000_000_u64, 100, 0), - (1_000_000, 1_000_000_000_000_000_000_u64, 1_000, 0), - (1_000_000, 1_000_000_000_000_000_000_u64, u64::MAX, 0), + ( + 2_000_000_000_000, + 100_000_000_000, + u64::MAX, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 200_000_000_000, + 100_000_000_000, + u64::MAX / 2, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000, + 1_000_000_000_000_000_000_u64, + 1, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000, + 1_000_000_000_000_000_000_u64, + 10, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000, + 1_000_000_000_000_000_000_u64, + 100, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000, + 1_000_000_000_000_000_000_u64, + 1_000, + Err(Error::::ZeroMaxStakeAmount), + ), + ( + 1_000_000, + 1_000_000_000_000_000_000_u64, + u64::MAX, + Err(Error::::ZeroMaxStakeAmount), + ), ( 21_000_000_000_000_000, 1_000_000, 21_000_000_000_000_000, - 999_000_000, + Ok(999_000_000), ), - (21_000_000_000_000_000, 1_000_000, u64::MAX, 138_412), + (21_000_000_000_000_000, 1_000_000, u64::MAX, Ok(138_412)), ( 21_000_000_000_000_000, 1_000_000_000_000_000_000_u64, u64::MAX, - 0, + Err(Error::::ZeroMaxStakeAmount), ), ( 21_000_000_000_000_000, 1_000_000_000_000_000_000_u64, 20_000_000, - 50_000_000_000_000_000, + Ok(50_000_000_000_000_000), ), ] .iter() - .for_each(|&(tao_in, alpha_in, limit_price, expected_max_swappable)| { - // Forse-set alpha in and tao reserve to achieve relative price of subnets - SubnetTAO::::insert(netuid, tao_in); - SubnetAlphaIn::::insert(netuid, alpha_in); - - if alpha_in != 0 { - let expected_price = I96F32::from_num(tao_in) / I96F32::from_num(alpha_in); - assert_eq!(SubtensorModule::get_alpha_price(netuid), expected_price); - } + .for_each( + |&(tao_in, alpha_in, limit_price, ref expected_max_swappable)| { + // Forse-set alpha in and tao reserve to achieve relative price of subnets + SubnetTAO::::insert(netuid, tao_in); + SubnetAlphaIn::::insert(netuid, alpha_in); - assert_eq!( - SubtensorModule::get_max_amount_remove(netuid, limit_price), - expected_max_swappable, - ); - }); + if alpha_in != 0 { + let expected_price = I96F32::from_num(tao_in) / I96F32::from_num(alpha_in); + assert_eq!(SubtensorModule::get_alpha_price(netuid), expected_price); + } + + assert_eq!( + SubtensorModule::get_max_amount_remove(netuid, limit_price), + *expected_max_swappable, + ); + }, + ); }); } @@ -4449,7 +4522,7 @@ fn test_max_amount_move_dynamic_stable() { // 1.5 price => max is 0 because of non-zero slippage assert_abs_diff_eq!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, 1_500_000_000) - .unwrap(), + .unwrap_or(0), 0, epsilon = 10_000 ); @@ -4472,17 +4545,18 @@ fn test_max_amount_move_dynamic_stable() { // Max price doesn't panic and returns something meaningful assert!( - SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX).unwrap() + SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX) + .unwrap_or(0) < 21_000_000_000_000_000 ); assert!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX - 1) - .unwrap() + .unwrap_or(0) < 21_000_000_000_000_000 ); assert!( SubtensorModule::get_max_amount_move(dynamic_netuid, stable_netuid, u64::MAX / 2) - .unwrap() + .unwrap_or(0) < 21_000_000_000_000_000 ); }); From a6e7de80e36f429e31b0bc032bb00f1077ec64e6 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 2 May 2025 00:15:14 +0900 Subject: [PATCH 107/226] Compare bytes --- evm-tests/test/uid.precompile.lookup.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index ed82b72a6b..9766135454 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -69,7 +69,7 @@ describe("Test the UID Lookup precompile", () => { const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) assert.notEqual(storedEvmKey, undefined, "storedEvmKey should be defined") if (storedEvmKey !== undefined) { - assert.equal(storedEvmKey[0], convertToFixedSizeBinary(evmWallet.address, 20)) + assert.equal(storedEvmKey[0].asBytes(), convertToFixedSizeBinary(evmWallet.address, 20).asBytes()) blockNumberAssociated = storedEvmKey[1] } }) From aa4ac19ef37b806ca0e73ea2adfd16b7f4cf16ae Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 09:50:17 -0700 Subject: [PATCH 108/226] update weights --- pallets/subtensor/src/macros/dispatches.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 98b83791e8..77617155a9 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1780,9 +1780,9 @@ mod dispatches { /// - Errors stemming from transaction pallet. /// #[pallet::call_index(88)] - #[pallet::weight((Weight::from_parts(91_010_000, 0) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(6)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(159_200_000, 0) + .saturating_add(T::DbWeight::get().reads(13)) + .saturating_add(T::DbWeight::get().writes(10)), DispatchClass::Normal, Pays::No))] pub fn add_stake_limit( origin: OriginFor, hotkey: T::AccountId, @@ -1844,9 +1844,9 @@ mod dispatches { /// - Thrown if there is not enough stake on the hotkey to withdwraw this amount. /// #[pallet::call_index(89)] - #[pallet::weight((Weight::from_parts(172_100_000, 0) - .saturating_add(T::DbWeight::get().reads(17)) - .saturating_add(T::DbWeight::get().writes(9)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(192_600_000, 0) + .saturating_add(T::DbWeight::get().reads(18)) + .saturating_add(T::DbWeight::get().writes(10)), DispatchClass::Normal, Pays::No))] pub fn remove_stake_limit( origin: OriginFor, hotkey: T::AccountId, @@ -1888,9 +1888,9 @@ mod dispatches { /// May emit a `StakeSwapped` event on success. #[pallet::call_index(90)] #[pallet::weight(( - Weight::from_parts(162_400_000, 0) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(9)), + Weight::from_parts(232_000_000, 0) + .saturating_add(T::DbWeight::get().reads(25)) + .saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::No ))] From b119199fcd9946a6b2071a1d790a8bd101ab8197 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 1 May 2025 12:50:43 -0400 Subject: [PATCH 109/226] remove migration --- pallets/subtensor/src/macros/hooks.rs | 4 +- .../migrate_remove_subnet_name_map.rs | 61 ------------------- pallets/subtensor/src/migrations/mod.rs | 1 - 3 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 6202fd2403..4d26994f05 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -110,9 +110,7 @@ mod hooks { // Reset bonds moving average .saturating_add(migrations::migrate_reset_bonds_moving_average::migrate_reset_bonds_moving_average::()) // Reset max burn - .saturating_add(migrations::migrate_reset_max_burn::migrate_reset_max_burn::()) - // Wipe unused SubnetName map - .saturating_add(migrations::migrate_remove_subnet_name_map::migrate_remove_subnet_name_map::()); + .saturating_add(migrations::migrate_reset_max_burn::migrate_reset_max_burn::()); weight } diff --git a/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs b/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs deleted file mode 100644 index 450929ff90..0000000000 --- a/pallets/subtensor/src/migrations/migrate_remove_subnet_name_map.rs +++ /dev/null @@ -1,61 +0,0 @@ -use super::*; -use crate::HasMigrationRun; -use frame_support::{traits::Get, weights::Weight}; -use scale_info::prelude::string::String; -use sp_io::{KillStorageResult, hashing::twox_128, storage::clear_prefix}; - -fn remove_prefix(old_map: &str, weight: &mut Weight) { - let mut prefix = Vec::new(); - prefix.extend_from_slice(&twox_128("SubtensorModule".as_bytes())); - prefix.extend_from_slice(&twox_128(old_map.as_bytes())); - - let removal_results = clear_prefix(&prefix, Some(u32::MAX)); - - let removed_entries_count = match removal_results { - KillStorageResult::AllRemoved(removed) => removed as u64, - KillStorageResult::SomeRemaining(removed) => { - log::info!("Failed To Remove Some Items During migration"); - removed as u64 - } - }; - - log::info!( - "Removed {:?} entries from {:?} map.", - removed_entries_count, - old_map - ); - - *weight = (*weight).saturating_add(T::DbWeight::get().writes(removed_entries_count)); -} - -pub fn migrate_remove_subnet_name_map() -> Weight { - let migration_name = b"migrate_remove_subnet_name_map".to_vec(); - let mut weight = T::DbWeight::get().reads(1); - - if HasMigrationRun::::get(&migration_name) { - log::info!( - "Migration '{:?}' has already run. Skipping.", - migration_name - ); - return weight; - } - - log::info!( - "Running migration '{}'", - String::from_utf8_lossy(&migration_name) - ); - - // Remove SubnetName - remove_prefix::("SubnetName", &mut weight); - - // Mark Migration as Completed - HasMigrationRun::::insert(&migration_name, true); - weight = weight.saturating_add(T::DbWeight::get().writes(1)); - - log::info!( - "Migration '{:?}' completed successfully.", - String::from_utf8_lossy(&migration_name) - ); - - weight -} diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index 30a2a1ce7d..824d8d4706 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -15,7 +15,6 @@ pub mod migrate_orphaned_storage_items; pub mod migrate_populate_owned_hotkeys; pub mod migrate_rao; pub mod migrate_remove_stake_map; -pub mod migrate_remove_subnet_name_map; pub mod migrate_remove_total_hotkey_coldkey_stakes_this_interval; pub mod migrate_remove_unused_maps_and_values; pub mod migrate_remove_zero_total_hotkey_alpha; From 63b72bba41bd699270c72140efa8b9f20ed068f8 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 1 May 2025 12:51:25 -0400 Subject: [PATCH 110/226] remove comment --- pallets/subtensor/src/subnets/symbols.rs | 70 ------------------------ 1 file changed, 70 deletions(-) diff --git a/pallets/subtensor/src/subnets/symbols.rs b/pallets/subtensor/src/subnets/symbols.rs index 7d224e208c..1aae9c3a0c 100644 --- a/pallets/subtensor/src/subnets/symbols.rs +++ b/pallets/subtensor/src/subnets/symbols.rs @@ -454,76 +454,6 @@ impl Pallet { 438 => b"ra".to_vec(), _ => b"unknown".to_vec(), } - // match netuid { - // // Greek Alphabet (Lowercase) - // 0 => b"root".to_vec(), // Τ (Upper case Tau) - // 1 => b"apex".to_vec(), // α (Alpha) - // 2 => b"omron".to_vec(), // β (Beta) - // 3 => b"templar".to_vec(), // γ (Gamma) - // 4 => b"targon".to_vec(), // δ (Delta) - // 5 => b"kaito".to_vec(), // ε (Epsilon) - // 6 => b"infinite".to_vec(), // ζ (Zeta) - // 7 => b"subvortex".to_vec(), // η (Eta) - // 8 => b"ptn".to_vec(), // θ (Theta) - // 9 => b"pretrain".to_vec(), // ι (Iota) - // 10 => b"sturdy".to_vec(), // κ (Kappa) - // 11 => b"dippy".to_vec(), // λ (Lambda) - // 12 => b"horde".to_vec(), // μ (Mu) - // 13 => b"dataverse".to_vec(), // ν (Nu) - // 14 => b"palaidn".to_vec(), // ξ (Xi) - // 15 => b"deval".to_vec(), // ο (Omicron) - // 16 => b"bitads".to_vec(), // π (Pi) - // 17 => b"3gen".to_vec(), // ρ (Rho) - // 18 => b"cortex".to_vec(), // σ (Sigma) - // 19 => b"inference".to_vec(), // t (Tau) - // 20 => b"bitagent".to_vec(), // υ (Upsilon) - // 21 => b"any-any".to_vec(), // φ (Phi) - // 22 => b"meta".to_vec(), // χ (Chi) - // 23 => b"social".to_vec(), // ψ (Psi) - // 24 => b"omega".to_vec(), // ω (Omega) - // 25 => b"protein".to_vec(), // א (Aleph) - // 26 => b"alchemy".to_vec(), // ב (Bet) - // 27 => b"compute".to_vec(), // ג (Gimel) - // 28 => b"oracle".to_vec(), // ד (Dalet) - // 29 => b"coldint".to_vec(), // ה (He) - // 30 => b"bet".to_vec(), // ו (Vav) - // 31 => b"naschain".to_vec(), // ז (Zayin) - // 32 => b"itsai".to_vec(), // ח (Het) - // 33 => b"ready".to_vec(), // ט (Tet) - // 34 => b"mind".to_vec(), // י (Yod) - // 35 => b"logic".to_vec(), // ך (Final Kaf) - // 36 => b"automata".to_vec(), // כ (Kaf) - // 37 => b"tuning".to_vec(), // ל (Lamed) - // 38 => b"distributed".to_vec(), // ם (Final Mem) - // 39 => b"edge".to_vec(), // מ (Mem) - // 40 => b"chunk".to_vec(), // ן (Final Nun) - // 41 => b"sportsensor".to_vec(), // נ (Nun) - // 42 => b"masa".to_vec(), // ס (Samekh) - // 43 => b"graphite".to_vec(), // ע (Ayin) - // 44 => b"score".to_vec(), // ף (Final Pe) - // 45 => b"gen42".to_vec(), // פ (Pe) - // 46 => b"neural".to_vec(), // ץ (Final Tsadi) - // 47 => b"condense".to_vec(), // צ (Tsadi) - // 48 => b"nextplace".to_vec(), // ק (Qof) - // 49 => b"automl".to_vec(), // ר (Resh) - // 50 => b"audio".to_vec(), // ש (Shin) - // 51 => b"celium".to_vec(), // ת (Tav) - // 52 => b"dojo".to_vec(), // ا (Alif) - // 53 => b"frontier".to_vec(), // ب (Ba) - // 54 => b"safescan".to_vec(), // ت (Ta) - // 55 => b"unknown".to_vec(), // ث (Tha) - // 56 => b"gradients".to_vec(), // ج (Jim) - // 57 => b"gaia".to_vec(), // ح (Ha) - // 58 => b"dippy-speach".to_vec(), // خ (Kha) - // 59 => b"agent-arena".to_vec(), // د (Dal) - // 60 => b"unknown".to_vec(), // ذ (Dhal) - // 61 => b"red team".to_vec(), // ر (Ra) - // 62 => b"agentao".to_vec(), // ز (Zay) - // 63 => b"lean-in".to_vec(), // س (Sin) - // 64 => b"chutes".to_vec(), // ش (Shin) - // // Default case - // _ => b"unknown".to_vec(), // unknown subnet. - // } }) } From 153e3dacdba5a6a7a266cb1f5e57f3eac797f67f Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 1 May 2025 17:05:27 -0400 Subject: [PATCH 111/226] add event for yuma3 toggle --- pallets/admin-utils/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index a0a3c74abe..c81a600e52 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -83,6 +83,13 @@ pub mod pallet { /// Indicates if the precompile operation is enabled or not. enabled: bool, }, + /// Event emitted when the Yuma3 enable is toggled. + Yuma3EnableToggled { + /// The network identifier. + netuid: u16, + /// Indicates if the Yuma3 enable was enabled or disabled. + enabled: bool, + }, } // Errors inform users that something went wrong. @@ -1533,13 +1540,15 @@ pub mod pallet { ) -> DispatchResult { pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin, netuid)?; pallet_subtensor::Pallet::::set_yuma3_enabled(netuid, enabled); + + Self::deposit_event(Event::Yuma3EnableToggled { netuid, enabled }); log::debug!( "Yuma3EnableToggled( netuid: {:?}, Enabled: {:?} ) ", netuid, enabled ); Ok(()) - } + } /// Sets or updates the hotkey account associated with the owner of a specific subnet. /// From 9f91dad68d58ea06cc81e2fae3558f62ffabe939 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 2 May 2025 12:14:23 +0800 Subject: [PATCH 112/226] Debug --- evm-tests/test/uid.precompile.lookup.test.ts | 5 ++++ pallets/subtensor/src/utils/evm.rs | 30 ++++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 9766135454..fa06ee92fb 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -49,11 +49,16 @@ describe("Test the UID Lookup precompile", () => { // Associate EVM key blockNumber = await api.query.System.Number.getValue(); + console.info(blockNumber) const blockNumberBytes = u64.enc(BigInt(blockNumber)); const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); + console.info(hotkey.publicKey) + console.info(concatenatedArray) const concatenatedHash = keccak256(concatenatedArray); + console.info(concatenatedHash) const signature = await evmWallet.signMessage(concatenatedHash); + console.info(signature) const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, hotkey: convertPublicKeyToSs58(hotkey.publicKey), diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index bed21ab38d..3b31c86fe7 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -42,22 +42,22 @@ impl Pallet { let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; - // let mut message = [0u8; 64]; - // let block_hash = keccak_256(block_number.encode().as_ref()); - // message[..32].copy_from_slice(&hotkey.encode()[..]); - // message[32..].copy_from_slice(block_hash.as_ref()); - // let public = signature - // .recover_prehashed(&keccak_256(message.as_ref())) - // .ok_or(Error::::UnableToRecoverPublicKey)?; - // let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) - // .map_err(|_| Error::::UnableToRecoverPublicKey)?; - // let uncompressed = secp_pubkey.serialize(); - // let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); + let mut message = [0u8; 64]; + let block_hash = keccak_256(block_number.encode().as_ref()); + message[..32].copy_from_slice(&hotkey.encode()[..]); + message[32..].copy_from_slice(block_hash.as_ref()); + let public = signature + .recover_prehashed(&keccak_256(message.as_ref())) + .ok_or(Error::::UnableToRecoverPublicKey)?; + let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) + .map_err(|_| Error::::UnableToRecoverPublicKey)?; + let uncompressed = secp_pubkey.serialize(); + let hashed_evm_key = H160::from_slice(&keccak_256(&uncompressed[1..])[12..]); - // ensure!( - // evm_key == hashed_evm_key, - // Error::::InvalidRecoveredPublicKey - // ); + ensure!( + evm_key == hashed_evm_key, + Error::::InvalidRecoveredPublicKey + ); let current_block_number = Self::get_current_block_as_u64(); From cb46c82d2a86cd0365bc8c78eced2d02323c9062 Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 2 May 2025 13:12:51 +0800 Subject: [PATCH 113/226] Ensure signature is in EIP191 format --- evm-tests/test/uid.precompile.lookup.test.ts | 8 +------- pallets/subtensor/src/tests/evm.rs | 4 +++- pallets/subtensor/src/utils/evm.rs | 9 ++++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index fa06ee92fb..2188897fb8 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -49,16 +49,10 @@ describe("Test the UID Lookup precompile", () => { // Associate EVM key blockNumber = await api.query.System.Number.getValue(); - console.info(blockNumber) const blockNumberBytes = u64.enc(BigInt(blockNumber)); const blockNumberHash = hexToU8a(keccak256(blockNumberBytes)); const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]); - console.info(hotkey.publicKey) - console.info(concatenatedArray) - const concatenatedHash = keccak256(concatenatedArray); - console.info(concatenatedHash) - const signature = await evmWallet.signMessage(concatenatedHash); - console.info(signature) + const signature = await evmWallet.signMessage(concatenatedArray); const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, hotkey: convertPublicKeyToSs58(hotkey.publicKey), diff --git a/pallets/subtensor/src/tests/evm.rs b/pallets/subtensor/src/tests/evm.rs index bdd55c1961..a970470853 100644 --- a/pallets/subtensor/src/tests/evm.rs +++ b/pallets/subtensor/src/tests/evm.rs @@ -8,6 +8,8 @@ use super::mock::*; use crate::*; use frame_support::testing_prelude::*; use sp_core::{H160, Pair, U256, blake2_256, ecdsa, keccak_256}; +use sp_core::crypto::Ss58Codec; +use sp_runtime::AccountId32; fn public_to_evm_key(pubkey: &ecdsa::Public) -> H160 { use libsecp256k1::PublicKey; @@ -47,7 +49,7 @@ fn test_associate_evm_key_success() { let mut message = [0u8; 64]; message[..32].copy_from_slice(hotkey_bytes.as_ref()); message[32..].copy_from_slice(hashed_block_number.as_ref()); - let hashed_message = keccak_256(message.as_ref()); + let hashed_message = SubtensorModule::hash_message_eip191(dbg!(message).as_ref()); let signature = pair.sign_prehashed(&hashed_message); assert_ok!(SubtensorModule::associate_evm_key( diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 3b31c86fe7..66efeef1ee 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -5,7 +5,14 @@ use frame_system::ensure_signed; use sp_core::{H160, ecdsa::Signature, hashing::keccak_256}; use sp_std::vec::Vec; +const MESSAGE_PREFIX: &str = "\x19Ethereum Signed Message:\n"; + impl Pallet { + pub(crate) fn hash_message_eip191>(message: M) -> [u8; 32] { + let msg_len = message.as_ref().len().to_string(); + keccak_256(&[MESSAGE_PREFIX.as_bytes(), msg_len.as_bytes(), message.as_ref()].concat()) + } + /// Associate an EVM key with a hotkey. /// /// This function accepts a Signature, which is a signed message containing the hotkey concatenated with @@ -47,7 +54,7 @@ impl Pallet { message[..32].copy_from_slice(&hotkey.encode()[..]); message[32..].copy_from_slice(block_hash.as_ref()); let public = signature - .recover_prehashed(&keccak_256(message.as_ref())) + .recover_prehashed(&Self::hash_message_eip191(message.as_ref())) .ok_or(Error::::UnableToRecoverPublicKey)?; let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) .map_err(|_| Error::::UnableToRecoverPublicKey)?; From 4e6c6b65f94267896114edb462b4295f2cbf821e Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 2 May 2025 13:13:27 +0800 Subject: [PATCH 114/226] Remove unused imports --- evm-tests/package-lock.json | 6 +++++- evm-tests/package.json | 1 + pallets/subtensor/src/tests/evm.rs | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/evm-tests/package-lock.json b/evm-tests/package-lock.json index ce2766fb4e..68fae940bf 100644 --- a/evm-tests/package-lock.json +++ b/evm-tests/package-lock.json @@ -6,6 +6,7 @@ "": { "license": "ISC", "dependencies": { + "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", @@ -32,7 +33,6 @@ ".papi/descriptors": { "name": "@polkadot-api/descriptors", "version": "0.1.0-autogenerated.7914363913476982777", - "extraneous": true, "peerDependencies": { "polkadot-api": "*" } @@ -731,6 +731,10 @@ "@polkadot-api/utils": "0.1.2" } }, + "node_modules/@polkadot-api/descriptors": { + "resolved": ".papi/descriptors", + "link": true + }, "node_modules/@polkadot-api/ink-contracts": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/@polkadot-api/ink-contracts/-/ink-contracts-0.2.6.tgz", diff --git a/evm-tests/package.json b/evm-tests/package.json index 0e90cdb976..ca35fe2d1b 100644 --- a/evm-tests/package.json +++ b/evm-tests/package.json @@ -6,6 +6,7 @@ "author": "", "license": "ISC", "dependencies": { + "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", diff --git a/pallets/subtensor/src/tests/evm.rs b/pallets/subtensor/src/tests/evm.rs index a970470853..f6a782a587 100644 --- a/pallets/subtensor/src/tests/evm.rs +++ b/pallets/subtensor/src/tests/evm.rs @@ -8,8 +8,6 @@ use super::mock::*; use crate::*; use frame_support::testing_prelude::*; use sp_core::{H160, Pair, U256, blake2_256, ecdsa, keccak_256}; -use sp_core::crypto::Ss58Codec; -use sp_runtime::AccountId32; fn public_to_evm_key(pubkey: &ecdsa::Public) -> H160 { use libsecp256k1::PublicKey; From a4794f9b3f178e9af829a5cd38754d4819f86265 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 2 May 2025 14:09:03 +0400 Subject: [PATCH 115/226] Update benchmarks to V2 after merge. --- pallets/subtensor/src/benchmarks.rs | 156 +++++++++++++++------------- 1 file changed, 86 insertions(+), 70 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 9201a73fc5..2d8db04620 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -859,39 +859,43 @@ mod pallet_benchmarks { #[benchmark] fn add_stake_limit() { - let coldkey: T::AccountId = whitelisted_caller(); - let hotkey: T::AccountId = account("Alice", 0, 1); let netuid: u16 = 1; - let amount: u64 = 1_000_000; - let limit: u64 = 1_000_000; - let allow: bool = true; + let tempo: u16 = 1; + let seed: u32 = 1; - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::init_new_network(netuid, tempo); SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_burn(netuid, 1); + Subtensor::::set_network_registration_allowed(netuid, true); + Subtensor::::set_max_allowed_uids(netuid, 4096); - let bond = Subtensor::::get_burn_as_u64(netuid); - let deposit = (amount + bond + DefaultStakingFee::::get()) * 10; - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); - assert_ok!(Subtensor::::burned_register( + let amount = 900_000_000_000; + let limit: u64 = 6_000_000_000; + let amount_to_be_staked = 440_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount); + + let tao_reserve = 150_000_000_000_u64; + let alpha_in = 100_000_000_000_u64; + SubnetTAO::::insert(netuid, tao_reserve); + SubnetAlphaIn::::insert(netuid, alpha_in); + + assert_ok!(Subtensor::::do_burned_registration( RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone() )); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); - #[extrinsic_call] _( RawOrigin::Signed(coldkey.clone()), - hotkey.clone(), + hotkey, netuid, - amount, + amount_to_be_staked, limit, - allow, + false, ); } @@ -947,107 +951,119 @@ mod pallet_benchmarks { #[benchmark] fn remove_stake_limit() { - let coldkey: T::AccountId = whitelisted_caller(); - let hotkey: T::AccountId = account("Alice", 0, 1); let netuid: u16 = 1; + let tempo: u16 = 1; + let seed: u32 = 1; - Subtensor::::init_new_network(netuid, 1); + // Set our total stake to 1000 TAO + Subtensor::::increase_total_stake(1_000_000_000_000); + + Subtensor::::init_new_network(netuid, tempo); Subtensor::::set_network_registration_allowed(netuid, true); SubtokenEnabled::::insert(netuid, true); - let bond = Subtensor::::get_burn_as_u64(netuid); - let fee = DefaultStakingFee::::get(); - let amount: u64 = 1_000_000; - let deposit = (amount + bond + fee).saturating_mul(10); + Subtensor::::set_max_allowed_uids(netuid, 4096); + assert_eq!(Subtensor::::get_max_allowed_uids(netuid), 4096); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); - assert_ok!(Subtensor::::burned_register( + let coldkey: T::AccountId = account("Test", 0, seed); + let hotkey: T::AccountId = account("Alice", 0, seed); + Subtensor::::set_burn(netuid, 1); + + let limit: u64 = 1_000_000_000; + let tao_reserve = 150_000_000_000_u64; + let alpha_in = 100_000_000_000_u64; + SubnetTAO::::insert(netuid, tao_reserve); + SubnetAlphaIn::::insert(netuid, alpha_in); + + let wallet_bal = 1000000u32.into(); + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), wallet_bal); + + assert_ok!(Subtensor::::do_burned_registration( RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone() )); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - SubnetAlphaOut::::insert(netuid, deposit); - TotalStake::::set(deposit); + let u64_staked_amt = 100_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), u64_staked_amt); - assert_ok!(Subtensor::::add_stake_limit( + assert_ok!(Subtensor::::add_stake( RawOrigin::Signed(coldkey.clone()).into(), hotkey.clone(), netuid, - amount, - u64::MAX, - false + u64_staked_amt )); - let alpha: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); - assert_ok!(Subtensor::::remove_stake_limit( - RawOrigin::Signed(coldkey.clone()).into(), - hotkey.clone(), - netuid, - alpha, - u64::MAX, - true - )); + let amount_unstaked: u64 = 30_000_000_000; #[extrinsic_call] _( RawOrigin::Signed(coldkey.clone()), hotkey.clone(), netuid, - alpha, - u64::MAX, - true, + amount_unstaked, + limit, + false, ); } #[benchmark] fn swap_stake_limit() { - let coldkey: T::AccountId = whitelisted_caller(); + let coldkey: T::AccountId = whitelisted_caller::>(); let hot: T::AccountId = account("A", 0, 1); - let netuid: u16 = 1; + let netuid1: u16 = 1; + let netuid2: u16 = 2; let allow: bool = true; - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid1, true); + Subtensor::::init_new_network(netuid1, 1); + SubtokenEnabled::::insert(netuid2, true); + Subtensor::::init_new_network(netuid2, 1); - let reg_fee = Subtensor::::get_burn_as_u64(netuid); - let stake_tao: u64 = 1_000_000; - let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); - Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); + let tao_reserve = 150_000_000_000_u64; + let alpha_in = 100_000_000_000_u64; + SubnetTAO::::insert(netuid1, tao_reserve); + SubnetAlphaIn::::insert(netuid1, alpha_in); + SubnetTAO::::insert(netuid2, tao_reserve); + + Subtensor::::increase_total_stake(1_000_000_000_000); + + let amount = 900_000_000_000; + let limit_stake: u64 = 6_000_000_000; + let limit_swap: u64 = 1_000_000_000; + let amount_to_be_staked = 440_000_000_000; + let amount_swapped: u64 = 30_000_000_000; + Subtensor::::add_balance_to_coldkey_account(&coldkey.clone(), amount); assert_ok!(Subtensor::::burned_register( RawOrigin::Signed(coldkey.clone()).into(), - netuid, + netuid1, hot.clone() )); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); - TotalStake::::set(deposit); + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(coldkey.clone()).into(), + netuid2, + hot.clone() + )); assert_ok!(Subtensor::::add_stake_limit( RawOrigin::Signed(coldkey.clone()).into(), hot.clone(), - netuid, - stake_tao, - u64::MAX, + netuid1, + amount_to_be_staked, + limit_stake, allow )); - let alpha_to_swap: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hot, &coldkey, netuid); - #[extrinsic_call] _( RawOrigin::Signed(coldkey.clone()), hot.clone(), - netuid, - netuid, - alpha_to_swap, - u64::MAX, + netuid1, + netuid2, + amount_swapped, + limit_swap, allow, ); } From e6d17caab435ce29a409ce67f3e017ad2b2421c2 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 2 May 2025 16:38:56 +0400 Subject: [PATCH 116/226] Introduce SameSubnetId error for move and swap stake extrinsics. --- pallets/subtensor/src/benchmarks.rs | 27 ++++--- pallets/subtensor/src/macros/errors.rs | 4 +- pallets/subtensor/src/staking/stake_utils.rs | 10 ++- pallets/subtensor/src/tests/move_stake.rs | 74 ++++++++++---------- 4 files changed, 66 insertions(+), 49 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 2d8db04620..717722c479 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -1122,44 +1122,49 @@ mod pallet_benchmarks { fn swap_stake() { let coldkey: T::AccountId = whitelisted_caller(); let hot: T::AccountId = account("A", 0, 9); - let netuid: u16 = 1; + let netuid1: u16 = 1; + let netuid2: u16 = 2; - SubtokenEnabled::::insert(netuid, true); - Subtensor::::init_new_network(netuid, 1); + SubtokenEnabled::::insert(netuid1, true); + Subtensor::::init_new_network(netuid1, 1); + SubtokenEnabled::::insert(netuid2, true); + Subtensor::::init_new_network(netuid2, 1); - let reg_fee = Subtensor::::get_burn_as_u64(netuid); + let reg_fee = Subtensor::::get_burn_as_u64(netuid1); let stake_tao: u64 = 1_000_000; let deposit = reg_fee.saturating_mul(2).saturating_add(stake_tao); Subtensor::::add_balance_to_coldkey_account(&coldkey, deposit); assert_ok!(Subtensor::::burned_register( RawOrigin::Signed(coldkey.clone()).into(), - netuid, + netuid1, hot.clone() )); - SubnetTAO::::insert(netuid, deposit); - SubnetAlphaIn::::insert(netuid, deposit); + SubnetTAO::::insert(netuid1, deposit); + SubnetAlphaIn::::insert(netuid1, deposit); + SubnetTAO::::insert(netuid2, deposit); + SubnetAlphaIn::::insert(netuid2, deposit); TotalStake::::set(deposit); assert_ok!(Subtensor::::add_stake_limit( RawOrigin::Signed(coldkey.clone()).into(), hot.clone(), - netuid, + netuid1, stake_tao, u64::MAX, false )); let alpha_to_swap: u64 = - Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hot, &coldkey, netuid); + Subtensor::::get_stake_for_hotkey_and_coldkey_on_subnet(&hot, &coldkey, netuid1); #[extrinsic_call] _( RawOrigin::Signed(coldkey.clone()), hot.clone(), - netuid, - netuid, + netuid1, + netuid2, alpha_to_swap, ); } diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index 8ace006010..a5bf028831 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -210,7 +210,9 @@ mod errors { InvalidRecoveredPublicKey, /// SubToken disabled now SubtokenDisabled, - /// Zero max stake amout + /// Zero max stake amount ZeroMaxStakeAmount, + /// Invalid netuid duplication + SameSubnetId, } } diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index a928c53e31..6c5647e032 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -999,7 +999,7 @@ impl Pallet { /// pub fn validate_stake_transition( origin_coldkey: &T::AccountId, - _destination_coldkey: &T::AccountId, + destination_coldkey: &T::AccountId, origin_hotkey: &T::AccountId, destination_hotkey: &T::AccountId, origin_netuid: u16, @@ -1009,6 +1009,14 @@ impl Pallet { maybe_allow_partial: Option, check_transfer_toggle: bool, ) -> Result<(), Error> { + // Ensure stake transition is actually happening + if origin_coldkey == destination_coldkey && origin_hotkey == destination_hotkey { + ensure!( + origin_netuid != destination_netuid, + Error::::SameSubnetId + ); + } + // Ensure that both subnets exist. ensure!( Self::if_subnet_exist(origin_netuid), diff --git a/pallets/subtensor/src/tests/move_stake.rs b/pallets/subtensor/src/tests/move_stake.rs index 0b7584a4f0..0590fb9a1c 100644 --- a/pallets/subtensor/src/tests/move_stake.rs +++ b/pallets/subtensor/src/tests/move_stake.rs @@ -566,11 +566,11 @@ fn test_do_move_wrong_origin() { }); } -// 14. test_do_move_same_hotkey -// Description: Attempt to move stake to the same hotkey, which should fail or have no effect -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test move -- test_do_move_same_hotkey --exact --nocapture +// 14. test_do_move_same_hotkey_fails +// Description: Attempt to move stake to the same hotkey, which should fail +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test move -- test_do_move_same_hotkey_fails --exact --nocapture #[test] -fn test_do_move_same_hotkey() { +fn test_do_move_same_hotkey_fails() { new_test_ext(1).execute_with(|| { let subnet_owner_coldkey = U256::from(1001); let subnet_owner_hotkey = U256::from(1002); @@ -587,20 +587,22 @@ fn test_do_move_same_hotkey() { SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); // Attempt to move stake to the same hotkey - assert_ok!(SubtensorModule::do_move_stake( - RuntimeOrigin::signed(coldkey), - hotkey, - hotkey, - netuid, - netuid, - alpha, - )); + assert_eq!( + SubtensorModule::do_move_stake( + RuntimeOrigin::signed(coldkey), + hotkey, + hotkey, + netuid, + netuid, + alpha, + ), + Err(Error::::SameSubnetId.into()) + ); // Check that stake remains unchanged - assert_abs_diff_eq!( + assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid), - alpha - fee, - epsilon = alpha / 1000 + alpha, ); }); } @@ -1151,7 +1153,8 @@ fn test_do_swap_nonexistent_subnet() { new_test_ext(1).execute_with(|| { let coldkey = U256::from(1); let hotkey = U256::from(2); - let nonexistent_netuid: u16 = 9999; + let nonexistent_netuid1: u16 = 9998; + let nonexistent_netuid2: u16 = 9999; let stake_amount = 1_000_000; SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey); @@ -1160,8 +1163,8 @@ fn test_do_swap_nonexistent_subnet() { SubtensorModule::do_swap_stake( RuntimeOrigin::signed(coldkey), hotkey, - nonexistent_netuid, - nonexistent_netuid, + nonexistent_netuid1, + nonexistent_netuid2, stake_amount ), Error::::SubnetNotExists @@ -1257,7 +1260,8 @@ fn test_do_swap_minimum_stake_check() { new_test_ext(1).execute_with(|| { let subnet_owner_coldkey = U256::from(1001); let subnet_owner_hotkey = U256::from(1002); - let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let netuid1 = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let netuid2 = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); let coldkey = U256::from(1); let hotkey = U256::from(3); @@ -1265,14 +1269,14 @@ fn test_do_swap_minimum_stake_check() { let swap_amount = 1; SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey); - SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid, total_stake, 0); + SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid1, total_stake, 0); assert_err!( SubtensorModule::do_swap_stake( RuntimeOrigin::signed(coldkey), hotkey, - netuid, - netuid, + netuid1, + netuid2, swap_amount ), Error::::AmountTooLow @@ -1290,30 +1294,28 @@ fn test_do_swap_same_subnet() { let coldkey = U256::from(1); let hotkey = U256::from(2); let stake_amount = DefaultMinStake::::get() * 10; - let fee = DefaultStakingFee::::get(); SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey); SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid, stake_amount, 0); let alpha_before = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); - let fee_as_alpha = SubtensorModule::swap_tao_for_alpha(netuid, fee); - assert_ok!(SubtensorModule::do_swap_stake( - RuntimeOrigin::signed(coldkey), - hotkey, - netuid, - netuid, - alpha_before - )); + assert_eq!( + SubtensorModule::do_swap_stake( + RuntimeOrigin::signed(coldkey), + hotkey, + netuid, + netuid, + alpha_before + ), + Err(Error::::SameSubnetId.into()) + ); let alpha_after = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); - assert_abs_diff_eq!( - alpha_after, - alpha_before - fee_as_alpha, - epsilon = alpha_after / 10000 - ); + + assert_eq!(alpha_after, alpha_before,); }); } From 76d6c360a76ab6f12ef3add8452a13657d183d56 Mon Sep 17 00:00:00 2001 From: Keith Date: Sat, 3 May 2025 00:01:20 +0800 Subject: [PATCH 117/226] Ensure recovery ID of signature is normalized to 0 or 1 --- evm-tests/src/substrate.ts | 3 ++ evm-tests/test/uid.precompile.lookup.test.ts | 4 +-- pallets/subtensor/src/tests/evm.rs | 36 +++++++++----------- pallets/subtensor/src/utils/evm.rs | 16 +++++---- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/evm-tests/src/substrate.ts b/evm-tests/src/substrate.ts index d86479450f..bd6d725d48 100644 --- a/evm-tests/src/substrate.ts +++ b/evm-tests/src/substrate.ts @@ -173,6 +173,9 @@ export async function getTransactionWatchPromise(tx: Transaction<{}, string, str if (value.type === "finalized") { console.log("Transaction is finalized in block:", value.txHash); subscription.unsubscribe(); + if (!value.ok) { + console.log("Transaction threw an error:", value.dispatchError) + } // Resolve the promise when the transaction is finalized resolve(); diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 2188897fb8..6e702d612e 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -68,7 +68,7 @@ describe("Test the UID Lookup precompile", () => { const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid) assert.notEqual(storedEvmKey, undefined, "storedEvmKey should be defined") if (storedEvmKey !== undefined) { - assert.equal(storedEvmKey[0].asBytes(), convertToFixedSizeBinary(evmWallet.address, 20).asBytes()) + assert.equal(storedEvmKey[0].asHex(), convertToFixedSizeBinary(evmWallet.address, 20).asHex()) blockNumberAssociated = storedEvmKey[1] } }) @@ -85,6 +85,6 @@ describe("Test the UID Lookup precompile", () => { assert.notEqual(uidArray, undefined, "UID should be defined") assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`) assert.ok(uidArray.length > 0, "UID array should not be empty") - assert.equal(uidArray[0], [uid, blockNumberAssociated]) + assert.deepStrictEqual(uidArray[0], { uid: uid, block_associated: blockNumberAssociated }) }) }); diff --git a/pallets/subtensor/src/tests/evm.rs b/pallets/subtensor/src/tests/evm.rs index f6a782a587..fd0ea51061 100644 --- a/pallets/subtensor/src/tests/evm.rs +++ b/pallets/subtensor/src/tests/evm.rs @@ -21,6 +21,14 @@ fn public_to_evm_key(pubkey: &ecdsa::Public) -> H160 { H160::from(address) } +fn sign_evm_message>(pair: &ecdsa::Pair, message: M) -> ecdsa::Signature { + let hash = SubtensorModule::hash_message_eip191(message); + let mut sig = pair.sign_prehashed(&hash); + // Adjust the v value to either 27 or 28 + sig.0[64] += 27; + sig +} + #[test] fn test_associate_evm_key_success() { new_test_ext(1).execute_with(|| { @@ -47,8 +55,7 @@ fn test_associate_evm_key_success() { let mut message = [0u8; 64]; message[..32].copy_from_slice(hotkey_bytes.as_ref()); message[32..].copy_from_slice(hashed_block_number.as_ref()); - let hashed_message = SubtensorModule::hash_message_eip191(dbg!(message).as_ref()); - let signature = pair.sign_prehashed(&hashed_message); + let signature = sign_evm_message(&pair, message); assert_ok!(SubtensorModule::associate_evm_key( RuntimeOrigin::signed(coldkey), @@ -94,11 +101,8 @@ fn test_associate_evm_key_different_block_number_success() { let hashed_block_number = keccak_256(block_number.encode().as_ref()); let hotkey_bytes = hotkey.encode(); - let mut message = [0u8; 64]; - message[..32].copy_from_slice(hotkey_bytes.as_ref()); - message[32..].copy_from_slice(hashed_block_number.as_ref()); - let hashed_message = keccak_256(message.as_ref()); - let signature = pair.sign_prehashed(&hashed_message); + let message = [hotkey_bytes.as_ref(), hashed_block_number.as_ref()].concat(); + let signature = sign_evm_message(&pair, message); assert_ok!(SubtensorModule::associate_evm_key( RuntimeOrigin::signed(coldkey), @@ -141,11 +145,8 @@ fn test_associate_evm_key_coldkey_does_not_own_hotkey() { let hashed_block_number = keccak_256(block_number.encode().as_ref()); let hotkey_bytes = hotkey.encode(); - let mut message = [0u8; 64]; - message[..32].copy_from_slice(hotkey_bytes.as_ref()); - message[32..].copy_from_slice(hashed_block_number.as_ref()); - let hashed_message = keccak_256(message.as_ref()); - let signature = pair.sign_prehashed(&hashed_message); + let message = [hotkey_bytes.as_ref(), hashed_block_number.as_ref()].concat(); + let signature = sign_evm_message(&pair, message); assert_err!( SubtensorModule::associate_evm_key( @@ -182,11 +183,8 @@ fn test_associate_evm_key_hotkey_not_registered_in_subnet() { let hashed_block_number = keccak_256(block_number.encode().as_ref()); let hotkey_bytes = hotkey.encode(); - let mut message = [0u8; 64]; - message[..32].copy_from_slice(hotkey_bytes.as_ref()); - message[32..].copy_from_slice(hashed_block_number.as_ref()); - let hashed_message = keccak_256(message.as_ref()); - let signature = pair.sign_prehashed(&hashed_message); + let message = [hotkey_bytes.as_ref(), hashed_block_number.as_ref()].concat(); + let signature = sign_evm_message(&pair, message); assert_err!( SubtensorModule::associate_evm_key( @@ -225,9 +223,7 @@ fn test_associate_evm_key_using_wrong_hash_function() { let hashed_block_number = keccak_256(block_number.encode().as_ref()); let hotkey_bytes = hotkey.encode(); - let mut message = [0u8; 64]; - message[..32].copy_from_slice(hotkey_bytes.as_ref()); - message[32..].copy_from_slice(hashed_block_number.as_ref()); + let message = [hotkey_bytes.as_ref(), hashed_block_number.as_ref()].concat(); let hashed_message = blake2_256(message.as_ref()); let signature = pair.sign_prehashed(&hashed_message); diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 66efeef1ee..bec5a0ec58 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -1,5 +1,6 @@ use super::*; +use alloc::string::ToString; use frame_support::ensure; use frame_system::ensure_signed; use sp_core::{H160, ecdsa::Signature, hashing::keccak_256}; @@ -38,7 +39,7 @@ impl Pallet { hotkey: T::AccountId, evm_key: H160, block_number: u64, - signature: Signature, + mut signature: Signature, ) -> dispatch::DispatchResult { let coldkey = ensure_signed(origin)?; @@ -47,15 +48,18 @@ impl Pallet { Error::::NonAssociatedColdKey ); + // Normalize the v value to 0 or 1 + if signature.0[64] >= 27 { + signature.0[64] -= 27; + } + let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; - let mut message = [0u8; 64]; let block_hash = keccak_256(block_number.encode().as_ref()); - message[..32].copy_from_slice(&hotkey.encode()[..]); - message[32..].copy_from_slice(block_hash.as_ref()); + let message = [hotkey.encode().as_ref(), block_hash.as_ref()].concat(); let public = signature - .recover_prehashed(&Self::hash_message_eip191(message.as_ref())) - .ok_or(Error::::UnableToRecoverPublicKey)?; + .recover_prehashed(&Self::hash_message_eip191(message)) + .ok_or(Error::::InvalidIdentity)?; let secp_pubkey = libsecp256k1::PublicKey::parse_compressed(&public.0) .map_err(|_| Error::::UnableToRecoverPublicKey)?; let uncompressed = secp_pubkey.serialize(); From ef5ce60b9ed4005e484ed6034f603243a4c893c5 Mon Sep 17 00:00:00 2001 From: Keith Date: Sat, 3 May 2025 00:08:49 +0800 Subject: [PATCH 118/226] Satisfy linters --- pallets/subtensor/src/utils/evm.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index bec5a0ec58..6877739f69 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -11,7 +11,14 @@ const MESSAGE_PREFIX: &str = "\x19Ethereum Signed Message:\n"; impl Pallet { pub(crate) fn hash_message_eip191>(message: M) -> [u8; 32] { let msg_len = message.as_ref().len().to_string(); - keccak_256(&[MESSAGE_PREFIX.as_bytes(), msg_len.as_bytes(), message.as_ref()].concat()) + keccak_256( + &[ + MESSAGE_PREFIX.as_bytes(), + msg_len.as_bytes(), + message.as_ref(), + ] + .concat(), + ) } /// Associate an EVM key with a hotkey. @@ -50,7 +57,7 @@ impl Pallet { // Normalize the v value to 0 or 1 if signature.0[64] >= 27 { - signature.0[64] -= 27; + signature.0[64] = signature.0[64].saturating_sub(27); } let uid = Self::get_uid_for_net_and_hotkey(netuid, &hotkey)?; From 8295710c2cd4844752ca8e15d5597fede0816d0e Mon Sep 17 00:00:00 2001 From: Keith Date: Sat, 3 May 2025 00:18:30 +0800 Subject: [PATCH 119/226] Restore package.json --- evm-tests/package-lock.json | 6 +----- evm-tests/package.json | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/evm-tests/package-lock.json b/evm-tests/package-lock.json index 68fae940bf..ce2766fb4e 100644 --- a/evm-tests/package-lock.json +++ b/evm-tests/package-lock.json @@ -6,7 +6,6 @@ "": { "license": "ISC", "dependencies": { - "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", @@ -33,6 +32,7 @@ ".papi/descriptors": { "name": "@polkadot-api/descriptors", "version": "0.1.0-autogenerated.7914363913476982777", + "extraneous": true, "peerDependencies": { "polkadot-api": "*" } @@ -731,10 +731,6 @@ "@polkadot-api/utils": "0.1.2" } }, - "node_modules/@polkadot-api/descriptors": { - "resolved": ".papi/descriptors", - "link": true - }, "node_modules/@polkadot-api/ink-contracts": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/@polkadot-api/ink-contracts/-/ink-contracts-0.2.6.tgz", diff --git a/evm-tests/package.json b/evm-tests/package.json index ca35fe2d1b..0e90cdb976 100644 --- a/evm-tests/package.json +++ b/evm-tests/package.json @@ -6,7 +6,6 @@ "author": "", "license": "ISC", "dependencies": { - "@polkadot-api/descriptors": "file:.papi/descriptors", "@polkadot-labs/hdkd": "^0.0.10", "@polkadot-labs/hdkd-helpers": "^0.0.11", "@polkadot/api": "15.1.1", From 4f192d5ef0f66a263b259e8f67236ad646e0f189 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 07:34:19 -0700 Subject: [PATCH 120/226] script benchmarks all pallets --- scripts/benchmark_action.sh | 238 +++++++++++++++++++----------------- 1 file changed, 129 insertions(+), 109 deletions(-) diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index 1d529f2eb0..d088ffdc82 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -1,44 +1,45 @@ #!/usr/bin/env bash set -euo pipefail +# A list of pallets we wish to benchmark +PALLETS=(subtensor admin_utils commitments drand crowdloan) + +# Map of pallet -> dispatch path (relative to this script's directory) +declare -A DISPATCH_PATHS=( + [subtensor]="../pallets/subtensor/src/macros/dispatches.rs" + [admin_utils]="../pallets/admin-utils/src/lib.rs" + [commitments]="../pallets/commitments/src/lib.rs" + [drand]="../pallets/drand/src/lib.rs" + [crowdloan]="../pallets/crowdloan/src/lib.rs" +) + # Max allowed drift (%) THRESHOLD=10 +MAX_RETRIES=3 -# Resolve script paths +# We'll build once for runtime-benchmarks SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -DISPATCH="$SCRIPT_DIR/../pallets/subtensor/src/macros/dispatches.rs" -RUNTIME_WASM="./target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm" - -# Sanity check -if [[ ! -f "$DISPATCH" ]]; then - echo "❌ ERROR: dispatches.rs not found at $DISPATCH" - exit 1 -fi +RUNTIME_WASM="$SCRIPT_DIR/../target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm" echo "Building runtime-benchmarks…" cargo build --profile production -p node-subtensor --features runtime-benchmarks echo echo "──────────────────────────────────────────" -echo " Running pallet_subtensor benchmarks…" +echo " Will benchmark pallets: ${PALLETS[*]}" echo "──────────────────────────────────────────" -MAX_RETRIES=3 -attempt=1 - ################################################################################ -# Helper function to "finalize" an extrinsic. We look up the code-side -# reads/writes/weight in dispatches.rs, then compare to measured values. +# Helper to "finalize" an extrinsic. We look up code-side reads/writes/weight +# in the dispatch file, then compare them to measured values. ################################################################################ -summary_lines=() -failures=() -fail=0 function process_extr() { local e="$1" local us="$2" local rd="$3" local wr="$4" + local dispatch_file="$5" # If any piece is empty, skip if [[ -z "$e" || -z "$us" || -z "$rd" || -z "$wr" ]]; then @@ -50,11 +51,8 @@ function process_extr() { meas_ps=$(awk -v x="$us" 'BEGIN{printf("%.0f", x * 1000000)}') # --------------------------------------------------------------------------- - # Code-side lookup from $DISPATCH + # Code-side lookup from dispatch_file # --------------------------------------------------------------------------- - # We find the matching "pub fn (" line in dispatches.rs, - # then parse the preceding Weight::from_parts, .reads, .writes lines. - local code_record code_record=$(awk -v extr="$e" ' /^\s*#\[pallet::call_index\(/ { next } @@ -100,9 +98,8 @@ function process_extr() { print w, r, wri exit } - ' "$DISPATCH") + ' "$dispatch_file") - # separate into variables local code_w code_reads code_writes read code_w code_reads code_writes <<<"$code_record" @@ -163,107 +160,130 @@ function process_extr() { } ################################################################################ +# We'll do the standard "attempt" logic for each pallet +################################################################################ + +for pallet_name in "${PALLETS[@]}"; do + # ensure the dispatch path is defined + if [[ -z "${DISPATCH_PATHS[$pallet_name]:-}" ]]; then + echo "❌ ERROR: dispatch path not defined for pallet '$pallet_name'" + exit 1 + fi + + # Prepend $SCRIPT_DIR to the path + DISPATCH="$SCRIPT_DIR/${DISPATCH_PATHS[$pallet_name]}" + if [[ ! -f "$DISPATCH" ]]; then + echo "❌ ERROR: dispatch file not found at $DISPATCH" + exit 1 + fi + + attempt=1 + pallet_success=0 + + while (( attempt <= MAX_RETRIES )); do + echo + echo "══════════════════════════════════════" + echo "Benchmarking pallet: $pallet_name (attempt #$attempt)" + echo "Dispatch file: $DISPATCH" + echo "══════════════════════════════════════" + + TMP="$(mktemp)" + trap "rm -f \"$TMP\"" EXIT + + # Run benchmark for just this pallet + ./target/production/node-subtensor benchmark pallet \ + --runtime "$RUNTIME_WASM" \ + --genesis-builder=runtime \ + --genesis-builder-preset=benchmark \ + --wasm-execution=compiled \ + --pallet "pallet_${pallet_name}" \ + --extrinsic "*" \ + --steps 50 \ + --repeat 5 \ + | tee "$TMP" + + # now parse results + summary_lines=() + failures=() + fail=0 -while (( attempt <= MAX_RETRIES )); do - echo - echo "Attempt #$attempt" - echo "──────────────────────────────────────────" - - # run benchmarks and capture output - TMP="$(mktemp)" - trap "rm -f \"$TMP\"" EXIT - - ./target/production/node-subtensor benchmark pallet \ - --runtime "$RUNTIME_WASM" \ - --genesis-builder=runtime \ - --genesis-builder-preset=benchmark \ - --wasm-execution=compiled \ - --pallet pallet_subtensor \ - --extrinsic "*" \ - --steps 50 \ - --repeat 5 \ - | tee "$TMP" - - # reset arrays - summary_lines=() - failures=() - fail=0 - - # Current extrinsic data - extr="" - meas_us="" - meas_reads="" - meas_writes="" - - # We'll finalize an extrinsic each time we see a new "Extrinsic: " - # or at the end of parsing. - function finalize_extr() { - process_extr "$extr" "$meas_us" "$meas_reads" "$meas_writes" - # reset extr="" meas_us="" meas_reads="" meas_writes="" - } - - # parse the file line-by-line - while IFS= read -r line; do - # match new extrinsic name - if [[ $line =~ Extrinsic:\ \"([[:alnum:]_]+)\" ]]; then - # finalize the old extrinsic if any - finalize_extr - extr="${BASH_REMATCH[1]}" - continue - fi - # match "Time ~= ..." - if [[ $line =~ Time\ ~=\ *([0-9]+(\.[0-9]+)?) ]]; then - meas_us="${BASH_REMATCH[1]}" - continue - fi + function finalize_extr() { + process_extr "$extr" "$meas_us" "$meas_reads" "$meas_writes" "$DISPATCH" + extr="" + meas_us="" + meas_reads="" + meas_writes="" + } - # match "Reads = n" - if [[ $line =~ Reads[[:space:]]*=[[:space:]]*([0-9]+) ]]; then - meas_reads="${BASH_REMATCH[1]}" - continue - fi + while IFS= read -r line; do + if [[ $line =~ Extrinsic:\ \"([[:alnum:]_]+)\" ]]; then + finalize_extr + extr="${BASH_REMATCH[1]}" + continue + fi - # match "Writes = n" - if [[ $line =~ Writes[[:space:]]*=[[:space:]]*([0-9]+) ]]; then - meas_writes="${BASH_REMATCH[1]}" - continue - fi - done < "$TMP" + if [[ $line =~ Time\ ~=\ *([0-9]+(\.[0-9]+)?) ]]; then + meas_us="${BASH_REMATCH[1]}" + continue + fi - # finalize the last extrinsic if we have one - finalize_extr + if [[ $line =~ Reads[[:space:]]*=[[:space:]]*([0-9]+) ]]; then + meas_reads="${BASH_REMATCH[1]}" + continue + fi - # summary output - echo - echo "Benchmark Summary for attempt #$attempt:" - for l in "${summary_lines[@]}"; do - echo " $l" - done + if [[ $line =~ Writes[[:space:]]*=[[:space:]]*([0-9]+) ]]; then + meas_writes="${BASH_REMATCH[1]}" + continue + fi + done < "$TMP" + + finalize_extr - if (( fail )); then echo - echo "❌ Issues detected on attempt #$attempt:" - for e in "${failures[@]}"; do - echo " • $e" + echo "Benchmark Summary for pallet '$pallet_name' (attempt #$attempt):" + for l in "${summary_lines[@]}"; do + echo " $l" done - if (( attempt < MAX_RETRIES )); then - echo "→ Retrying…" - (( attempt++ )) - continue + if (( fail )); then + echo + echo "❌ Issues detected on attempt #$attempt (pallet '$pallet_name'):" + for e in "${failures[@]}"; do + echo " • $e" + done + + if (( attempt < MAX_RETRIES )); then + echo "→ Retrying…" + (( attempt++ )) + continue + else + echo + echo "❌ Benchmarks for pallet '$pallet_name' failed after $MAX_RETRIES attempts." + exit 1 + fi else echo - echo "❌ Benchmarks failed after $MAX_RETRIES attempts." - exit 1 + echo "✅ Pallet '$pallet_name' benchmarks all good within ±${THRESHOLD}% drift." + pallet_success=1 + break fi - else - echo - echo "✅ All benchmarks within ±${THRESHOLD}% drift." - exit 0 + done + + # If we never succeeded for this pallet, exit + if (( pallet_success == 0 )); then + echo "❌ Could not benchmark pallet '$pallet_name' successfully." + exit 1 fi done + +echo +echo "══════════════════════════════════════" +echo "All requested pallets benchmarked successfully!" +echo "══════════════════════════════════════" +exit 0 From 70866642787b60fcd421ecd801db84761a7f4f78 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 29 Apr 2025 14:57:20 -0700 Subject: [PATCH 121/226] update dispatch weights for admin-utils --- pallets/admin-utils/src/lib.rs | 118 +++- pallets/admin-utils/src/tests/mock.rs | 1 - pallets/admin-utils/src/weights.rs | 854 -------------------------- runtime/src/lib.rs | 1 - 4 files changed, 84 insertions(+), 890 deletions(-) delete mode 100644 pallets/admin-utils/src/weights.rs diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 419e5bf06b..30361a4d6e 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -3,9 +3,6 @@ // extern crate alloc; pub use pallet::*; -pub mod weights; -pub use weights::WeightInfo; - use frame_system::pallet_prelude::BlockNumberFor; // - we could replace it with Vec<(AuthorityId, u64)>, but we would need // `sp_consensus_grandpa` for `AuthorityId` anyway @@ -66,9 +63,6 @@ pub mod pallet { /// The maximum number of authorities that the pallet can hold. type MaxAuthorities: Get; - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; - /// Unit of assets type Balance: Balance; } @@ -136,7 +130,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Aura pallet to change the authorities. #[pallet::call_index(0)] - #[pallet::weight(::WeightInfo::swap_authorities(new_authorities.len() as u32))] + #[pallet::weight(Weight::from_parts(20_410_228, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)))] pub fn swap_authorities( origin: OriginFor, new_authorities: BoundedVec<::AuthorityId, T::MaxAuthorities>, @@ -155,7 +151,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the default take. #[pallet::call_index(1)] - #[pallet::weight(::WeightInfo::sudo_set_default_take())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_default_take(origin: OriginFor, default_take: u16) -> DispatchResult { ensure_root(origin)?; pallet_subtensor::Pallet::::set_max_delegate_take(default_take); @@ -179,7 +177,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the serving rate limit. #[pallet::call_index(3)] - #[pallet::weight(::WeightInfo::sudo_set_serving_rate_limit())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_serving_rate_limit( origin: OriginFor, netuid: u16, @@ -199,7 +199,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the minimum difficulty. #[pallet::call_index(4)] - #[pallet::weight(::WeightInfo::sudo_set_min_difficulty())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_difficulty( origin: OriginFor, netuid: u16, @@ -224,7 +226,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the maximum difficulty. #[pallet::call_index(5)] - #[pallet::weight(::WeightInfo::sudo_set_max_difficulty())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_difficulty( origin: OriginFor, netuid: u16, @@ -249,7 +253,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the weights version key. #[pallet::call_index(6)] - #[pallet::weight(::WeightInfo::sudo_set_weights_version_key())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_weights_version_key( origin: OriginFor, netuid: u16, @@ -297,7 +303,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the weights set rate limit. #[pallet::call_index(7)] - #[pallet::weight(::WeightInfo::sudo_set_weights_set_rate_limit())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_weights_set_rate_limit( origin: OriginFor, netuid: u16, @@ -325,7 +333,9 @@ pub mod pallet { /// It is only callable by the root account, not changeable by the subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment interval. #[pallet::call_index(8)] - #[pallet::weight(::WeightInfo::sudo_set_adjustment_interval())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_adjustment_interval( origin: OriginFor, netuid: u16, @@ -380,7 +390,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment beta. #[pallet::call_index(12)] - #[pallet::weight(::WeightInfo::sudo_set_max_weight_limit())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_weight_limit( origin: OriginFor, netuid: u16, @@ -405,7 +417,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the immunity period. #[pallet::call_index(13)] - #[pallet::weight(::WeightInfo::sudo_set_immunity_period())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_immunity_period( origin: OriginFor, netuid: u16, @@ -430,7 +444,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the minimum allowed weights. #[pallet::call_index(14)] - #[pallet::weight(::WeightInfo::sudo_set_min_allowed_weights())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_allowed_weights( origin: OriginFor, netuid: u16, @@ -455,7 +471,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the maximum allowed UIDs for a subnet. #[pallet::call_index(15)] - #[pallet::weight(::WeightInfo::sudo_set_max_allowed_uids())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_allowed_uids( origin: OriginFor, netuid: u16, @@ -483,7 +501,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the kappa. #[pallet::call_index(16)] - #[pallet::weight(::WeightInfo::sudo_set_kappa())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_kappa(origin: OriginFor, netuid: u16, kappa: u16) -> DispatchResult { pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin, netuid)?; @@ -500,7 +520,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the rho. #[pallet::call_index(17)] - #[pallet::weight(::WeightInfo::sudo_set_rho())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_rho(origin: OriginFor, netuid: u16, rho: u16) -> DispatchResult { pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin, netuid)?; @@ -517,7 +539,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the activity cutoff. #[pallet::call_index(18)] - #[pallet::weight(::WeightInfo::sudo_set_activity_cutoff())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_activity_cutoff( origin: OriginFor, netuid: u16, @@ -605,7 +629,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the target registrations per interval. #[pallet::call_index(21)] - #[pallet::weight(::WeightInfo::sudo_set_target_registrations_per_interval())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_target_registrations_per_interval( origin: OriginFor, netuid: u16, @@ -633,7 +659,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the minimum burn. #[pallet::call_index(22)] - #[pallet::weight(::WeightInfo::sudo_set_min_burn())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_burn( origin: OriginFor, netuid: u16, @@ -658,7 +686,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the maximum burn. #[pallet::call_index(23)] - #[pallet::weight(::WeightInfo::sudo_set_max_burn())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_burn( origin: OriginFor, netuid: u16, @@ -683,7 +713,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the difficulty. #[pallet::call_index(24)] - #[pallet::weight(::WeightInfo::sudo_set_difficulty())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_difficulty( origin: OriginFor, netuid: u16, @@ -707,7 +739,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the maximum allowed validators. #[pallet::call_index(25)] - #[pallet::weight(::WeightInfo::sudo_set_max_allowed_validators())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_allowed_validators( origin: OriginFor, netuid: u16, @@ -740,7 +774,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the bonds moving average. #[pallet::call_index(26)] - #[pallet::weight(::WeightInfo::sudo_set_bonds_moving_average())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_bonds_moving_average( origin: OriginFor, netuid: u16, @@ -772,7 +808,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the bonds penalty. #[pallet::call_index(60)] - #[pallet::weight(::WeightInfo::sudo_set_bonds_penalty())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_bonds_penalty( origin: OriginFor, netuid: u16, @@ -797,7 +835,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the maximum registrations per block. #[pallet::call_index(27)] - #[pallet::weight(::WeightInfo::sudo_set_max_registrations_per_block())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_registrations_per_block( origin: OriginFor, netuid: u16, @@ -868,7 +908,9 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the tempo. #[pallet::call_index(30)] - #[pallet::weight(::WeightInfo::sudo_set_tempo())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_tempo(origin: OriginFor, netuid: u16, tempo: u16) -> DispatchResult { ensure_root(origin)?; ensure!( @@ -1086,7 +1128,9 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the value. #[pallet::call_index(49)] - #[pallet::weight(::WeightInfo::sudo_set_commit_reveal_weights_enabled())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_commit_reveal_weights_enabled( origin: OriginFor, netuid: u16, @@ -1285,7 +1329,9 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(57)] - #[pallet::weight(::WeightInfo::sudo_set_commit_reveal_weights_interval())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_commit_reveal_weights_interval( origin: OriginFor, netuid: u16, @@ -1319,7 +1365,9 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(58)] - #[pallet::weight(::WeightInfo::sudo_set_evm_chain_id())] + #[pallet::weight(Weight::from_parts(27_199_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_evm_chain_id(origin: OriginFor, chain_id: u64) -> DispatchResult { // Ensure the call is made by the root account ensure_root(origin)?; @@ -1344,7 +1392,9 @@ pub mod pallet { /// No change should be signaled while any change is pending. Returns an error if a change /// is already pending. #[pallet::call_index(59)] - #[pallet::weight(::WeightInfo::swap_authorities(next_authorities.len() as u32))] + #[pallet::weight(Weight::from_parts(20_410_228, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)))] pub fn schedule_grandpa_change( origin: OriginFor, // grandpa ID is always the same type, so we don't need to parametrize it via `Config` diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 99c11b7165..77ccdfbf5d 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -285,7 +285,6 @@ impl crate::Config for Test { type Aura = (); type Grandpa = GrandpaInterfaceImpl; type Balance = Balance; - type WeightInfo = (); } parameter_types! { diff --git a/pallets/admin-utils/src/weights.rs b/pallets/admin-utils/src/weights.rs deleted file mode 100644 index 6ef9523546..0000000000 --- a/pallets/admin-utils/src/weights.rs +++ /dev/null @@ -1,854 +0,0 @@ - -//! Autogenerated weights for `pallet_admin_utils` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `morpheus`, CPU: `AMD EPYC 7513 32-Core Processor` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: `1024` - -// Executed Command: -// ./target/release/node-subtensor -// benchmark -// pallet -// --chain=local -// --execution=wasm -// --wasm-execution=compiled -// --pallet=pallet_admin_utils -// --extrinsic=* -// --steps -// 50 -// --repeat -// 20 -// --output=pallets/admin-utils/src/weights.rs -// --template=./.maintain/frame-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use core::marker::PhantomData; - -/// Weight functions needed for `pallet_admin_utils`. -pub trait WeightInfo { - fn swap_authorities(a: u32, ) -> Weight; - fn sudo_set_min_delegate_take() -> Weight; - fn sudo_set_default_take() -> Weight; - fn sudo_set_serving_rate_limit() -> Weight; - fn sudo_set_max_difficulty() -> Weight; - fn sudo_set_min_difficulty() -> Weight; - fn sudo_set_weights_set_rate_limit() -> Weight; - fn sudo_set_weights_version_key() -> Weight; - fn sudo_set_bonds_moving_average() -> Weight; - fn sudo_set_bonds_penalty() -> Weight; - fn sudo_set_max_allowed_validators() -> Weight; - fn sudo_set_difficulty() -> Weight; - fn sudo_set_adjustment_interval() -> Weight; - fn sudo_set_target_registrations_per_interval() -> Weight; - fn sudo_set_activity_cutoff() -> Weight; - fn sudo_set_rho() -> Weight; - fn sudo_set_kappa() -> Weight; - fn sudo_set_max_allowed_uids() -> Weight; - fn sudo_set_min_allowed_weights() -> Weight; - fn sudo_set_validator_prune_len() -> Weight; - fn sudo_set_scaling_law_power() -> Weight; - fn sudo_set_immunity_period() -> Weight; - fn sudo_set_max_weight_limit() -> Weight; - fn sudo_set_max_registrations_per_block() -> Weight; - fn sudo_set_max_burn() -> Weight; - fn sudo_set_min_burn() -> Weight; - fn sudo_set_network_registration_allowed() -> Weight; - fn sudo_set_tempo() -> Weight; - fn sudo_set_commit_reveal_weights_interval() -> Weight; - fn sudo_set_commit_reveal_weights_enabled() -> Weight; - fn sudo_set_evm_chain_id() -> Weight; - fn schedule_grandpa_change(a: u32) -> Weight; -} - -/// Weights for `pallet_admin_utils` using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: System Digest (r:1 w:1) - /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Aura Authorities (r:0 w:1) - /// Proof: Aura Authorities (max_values: Some(1), max_size: Some(1025), added: 1520, mode: MaxEncodedLen) - /// The range of component `a` is `[0, 32]`. - fn swap_authorities(a: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `632` - // Estimated: `1127` - // Minimum execution time: 11_490_000 picoseconds. - Weight::from_parts(20_410_228, 1127) - // Standard Error: 8_309 - .saturating_add(Weight::from_parts(199_399, 0).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: SubtensorModule DefaultTake (r:0 w:1) - /// Proof Skipped: SubtensorModule DefaultTake (max_values: Some(1), max_size: None, mode: Measured) - fn sudo_set_default_take() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 26_770_000 picoseconds. - Weight::from_parts(27_199_000, 655) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule DefaultTake (r:0 w:1) - /// Proof Skipped: SubtensorModule DefaultTake (max_values: Some(1), max_size: None, mode: Measured) - fn sudo_set_min_delegate_take() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 26_770_000 picoseconds. - Weight::from_parts(27_199_000, 655) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule ServingRateLimit (r:0 w:1) - /// Proof Skipped: SubtensorModule ServingRateLimit (max_values: None, max_size: None, mode: Measured) - fn sudo_set_serving_rate_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 27_700_000 picoseconds. - Weight::from_parts(28_290_000, 655) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxDifficulty (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxDifficulty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_difficulty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_450_000 picoseconds. - Weight::from_parts(47_279_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MinDifficulty (r:0 w:1) - /// Proof Skipped: SubtensorModule MinDifficulty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_min_difficulty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_110_000 picoseconds. - Weight::from_parts(46_909_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule WeightsSetRateLimit (r:0 w:1) - /// Proof Skipped: SubtensorModule WeightsSetRateLimit (max_values: None, max_size: None, mode: Measured) - fn sudo_set_weights_set_rate_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_349_000 picoseconds. - Weight::from_parts(46_970_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule WeightsVersionKey (r:0 w:1) - /// Proof Skipped: SubtensorModule WeightsVersionKey (max_values: None, max_size: None, mode: Measured) - fn sudo_set_weights_version_key() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_940_000 picoseconds. - Weight::from_parts(47_460_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule BondsMovingAverage (r:0 w:1) - /// Proof Skipped: SubtensorModule BondsMovingAverage (max_values: None, max_size: None, mode: Measured) - fn sudo_set_bonds_moving_average() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_099_000 picoseconds. - Weight::from_parts(47_510_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule BondsPenalty (r:0 w:1) - /// Proof Skipped: SubtensorModule BondsPenalty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_bonds_penalty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_099_000 picoseconds. - Weight::from_parts(47_510_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxAllowedUids (r:1 w:0) - /// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxAllowedValidators (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxAllowedValidators (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_allowed_validators() -> Weight { - // Proof Size summary in bytes: - // Measured: `1154` - // Estimated: `8412` - // Minimum execution time: 52_599_000 picoseconds. - Weight::from_parts(53_640_000, 8412) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Difficulty (r:0 w:1) - /// Proof Skipped: SubtensorModule Difficulty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_difficulty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_240_000 picoseconds. - Weight::from_parts(47_130_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule AdjustmentInterval (r:0 w:1) - /// Proof Skipped: SubtensorModule AdjustmentInterval (max_values: None, max_size: None, mode: Measured) - fn sudo_set_adjustment_interval() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_430_000 picoseconds. - Weight::from_parts(46_790_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule TargetRegistrationsPerInterval (r:0 w:1) - /// Proof Skipped: SubtensorModule TargetRegistrationsPerInterval (max_values: None, max_size: None, mode: Measured) - fn sudo_set_target_registrations_per_interval() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_899_000 picoseconds. - Weight::from_parts(47_099_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ActivityCutoff (r:0 w:1) - /// Proof Skipped: SubtensorModule ActivityCutoff (max_values: None, max_size: None, mode: Measured) - fn sudo_set_activity_cutoff() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_029_000 picoseconds. - Weight::from_parts(46_759_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Rho (r:0 w:1) - /// Proof Skipped: SubtensorModule Rho (max_values: None, max_size: None, mode: Measured) - fn sudo_set_rho() -> Weight { - // Proof Size summary in bytes: - // Measured: `903` - // Estimated: `4281` - // Minimum execution time: 30_980_000 picoseconds. - Weight::from_parts(31_820_000, 4281) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Kappa (r:0 w:1) - /// Proof Skipped: SubtensorModule Kappa (max_values: None, max_size: None, mode: Measured) - fn sudo_set_kappa() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_620_000 picoseconds. - Weight::from_parts(46_440_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule SubnetworkN (r:1 w:0) - /// Proof Skipped: SubtensorModule SubnetworkN (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxAllowedUids (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_allowed_uids() -> Weight { - // Proof Size summary in bytes: - // Measured: `1117` - // Estimated: `8301` - // Minimum execution time: 50_270_000 picoseconds. - Weight::from_parts(51_149_000, 8301) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MinAllowedWeights (r:0 w:1) - /// Proof Skipped: SubtensorModule MinAllowedWeights (max_values: None, max_size: None, mode: Measured) - fn sudo_set_min_allowed_weights() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_990_000 picoseconds. - Weight::from_parts(47_390_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ValidatorPruneLen (r:0 w:1) - /// Proof Skipped: SubtensorModule ValidatorPruneLen (max_values: None, max_size: None, mode: Measured) - fn sudo_set_validator_prune_len() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_939_000 picoseconds. - Weight::from_parts(46_960_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ScalingLawPower (r:0 w:1) - /// Proof Skipped: SubtensorModule ScalingLawPower (max_values: None, max_size: None, mode: Measured) - fn sudo_set_scaling_law_power() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_480_000 picoseconds. - Weight::from_parts(46_590_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ImmunityPeriod (r:0 w:1) - /// Proof Skipped: SubtensorModule ImmunityPeriod (max_values: None, max_size: None, mode: Measured) - fn sudo_set_immunity_period() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_289_000 picoseconds. - Weight::from_parts(46_679_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxWeightsLimit (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxWeightsLimit (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_weight_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_850_000 picoseconds. - Weight::from_parts(46_589_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxRegistrationsPerBlock (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxRegistrationsPerBlock (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_registrations_per_block() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_330_000 picoseconds. - Weight::from_parts(46_490_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxBurn (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxBurn (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_burn() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_390_000 picoseconds. - Weight::from_parts(46_339_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MinBurn (r:0 w:1) - /// Proof Skipped: SubtensorModule MinBurn (max_values: None, max_size: None, mode: Measured) - fn sudo_set_min_burn() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_189_000 picoseconds. - Weight::from_parts(46_109_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworkPowRegistrationAllowed (r:0 w:1) - /// Proof Skipped: SubtensorModule NetworkPowRegistrationAllowed (max_values: None, max_size: None, mode: Measured) - fn sudo_set_network_registration_allowed() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 33_600_000 picoseconds. - Weight::from_parts(34_599_000, 655) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Tempo (r:0 w:1) - /// Proof Skipped: SubtensorModule Tempo (max_values: None, max_size: None, mode: Measured) - fn sudo_set_tempo() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 44_739_000 picoseconds. - Weight::from_parts(45_489_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - fn sudo_set_commit_reveal_weights_interval() -> Weight { - // Proof Size summary in bytes: - // Measured: `456` - // Estimated: `3921` - // Minimum execution time: 19_070_000 picoseconds. - Weight::from_parts(19_380_000, 456) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - fn sudo_set_commit_reveal_weights_enabled() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_450_000 picoseconds. - Weight::from_parts(47_279_000, 4697) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - fn sudo_set_evm_chain_id() -> Weight { - Weight::from_parts(20_200_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - - fn schedule_grandpa_change(_a: u32) -> Weight { - // TODO should be replaced by benchmarked weights - Weight::default() - } -} - -// For backwards compatibility and tests. -impl WeightInfo for () { - /// Storage: System Digest (r:1 w:1) - /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Aura Authorities (r:0 w:1) - /// Proof: Aura Authorities (max_values: Some(1), max_size: Some(1025), added: 1520, mode: MaxEncodedLen) - /// The range of component `a` is `[0, 32]`. - fn swap_authorities(a: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `632` - // Estimated: `1127` - // Minimum execution time: 11_490_000 picoseconds. - Weight::from_parts(20_410_228, 1127) - // Standard Error: 8_309 - .saturating_add(Weight::from_parts(199_399, 0).saturating_mul(a.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: SubtensorModule DefaultTake (r:0 w:1) - /// Proof Skipped: SubtensorModule DefaultTake (max_values: Some(1), max_size: None, mode: Measured) - fn sudo_set_default_take() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 26_770_000 picoseconds. - Weight::from_parts(27_199_000, 655) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule DefaultTake (r:0 w:1) - /// Proof Skipped: SubtensorModule DefaultTake (max_values: Some(1), max_size: None, mode: Measured) - fn sudo_set_min_delegate_take() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 26_770_000 picoseconds. - Weight::from_parts(27_199_000, 655) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule ServingRateLimit (r:0 w:1) - /// Proof Skipped: SubtensorModule ServingRateLimit (max_values: None, max_size: None, mode: Measured) - fn sudo_set_serving_rate_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 27_700_000 picoseconds. - Weight::from_parts(28_290_000, 655) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxDifficulty (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxDifficulty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_difficulty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_450_000 picoseconds. - Weight::from_parts(47_279_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MinDifficulty (r:0 w:1) - /// Proof Skipped: SubtensorModule MinDifficulty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_min_difficulty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_110_000 picoseconds. - Weight::from_parts(46_909_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule WeightsSetRateLimit (r:0 w:1) - /// Proof Skipped: SubtensorModule WeightsSetRateLimit (max_values: None, max_size: None, mode: Measured) - fn sudo_set_weights_set_rate_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_349_000 picoseconds. - Weight::from_parts(46_970_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule WeightsVersionKey (r:0 w:1) - /// Proof Skipped: SubtensorModule WeightsVersionKey (max_values: None, max_size: None, mode: Measured) - fn sudo_set_weights_version_key() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_940_000 picoseconds. - Weight::from_parts(47_460_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule BondsMovingAverage (r:0 w:1) - /// Proof Skipped: SubtensorModule BondsMovingAverage (max_values: None, max_size: None, mode: Measured) - fn sudo_set_bonds_moving_average() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_099_000 picoseconds. - Weight::from_parts(47_510_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule BondsPenalty (r:0 w:1) - /// Proof Skipped: SubtensorModule BondsPenalty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_bonds_penalty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_099_000 picoseconds. - Weight::from_parts(47_510_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxAllowedUids (r:1 w:0) - /// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxAllowedValidators (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxAllowedValidators (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_allowed_validators() -> Weight { - // Proof Size summary in bytes: - // Measured: `1154` - // Estimated: `8412` - // Minimum execution time: 52_599_000 picoseconds. - Weight::from_parts(53_640_000, 8412) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Difficulty (r:0 w:1) - /// Proof Skipped: SubtensorModule Difficulty (max_values: None, max_size: None, mode: Measured) - fn sudo_set_difficulty() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_240_000 picoseconds. - Weight::from_parts(47_130_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule AdjustmentInterval (r:0 w:1) - /// Proof Skipped: SubtensorModule AdjustmentInterval (max_values: None, max_size: None, mode: Measured) - fn sudo_set_adjustment_interval() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_430_000 picoseconds. - Weight::from_parts(46_790_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule TargetRegistrationsPerInterval (r:0 w:1) - /// Proof Skipped: SubtensorModule TargetRegistrationsPerInterval (max_values: None, max_size: None, mode: Measured) - fn sudo_set_target_registrations_per_interval() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_899_000 picoseconds. - Weight::from_parts(47_099_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ActivityCutoff (r:0 w:1) - /// Proof Skipped: SubtensorModule ActivityCutoff (max_values: None, max_size: None, mode: Measured) - fn sudo_set_activity_cutoff() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 46_029_000 picoseconds. - Weight::from_parts(46_759_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Rho (r:0 w:1) - /// Proof Skipped: SubtensorModule Rho (max_values: None, max_size: None, mode: Measured) - fn sudo_set_rho() -> Weight { - // Proof Size summary in bytes: - // Measured: `903` - // Estimated: `4281` - // Minimum execution time: 30_980_000 picoseconds. - Weight::from_parts(31_820_000, 4281) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Kappa (r:0 w:1) - /// Proof Skipped: SubtensorModule Kappa (max_values: None, max_size: None, mode: Measured) - fn sudo_set_kappa() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_620_000 picoseconds. - Weight::from_parts(46_440_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule SubnetworkN (r:1 w:0) - /// Proof Skipped: SubtensorModule SubnetworkN (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxAllowedUids (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_allowed_uids() -> Weight { - // Proof Size summary in bytes: - // Measured: `1117` - // Estimated: `8301` - // Minimum execution time: 50_270_000 picoseconds. - Weight::from_parts(51_149_000, 8301) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MinAllowedWeights (r:0 w:1) - /// Proof Skipped: SubtensorModule MinAllowedWeights (max_values: None, max_size: None, mode: Measured) - fn sudo_set_min_allowed_weights() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_990_000 picoseconds. - Weight::from_parts(47_390_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ValidatorPruneLen (r:0 w:1) - /// Proof Skipped: SubtensorModule ValidatorPruneLen (max_values: None, max_size: None, mode: Measured) - fn sudo_set_validator_prune_len() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_939_000 picoseconds. - Weight::from_parts(46_960_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ScalingLawPower (r:0 w:1) - /// Proof Skipped: SubtensorModule ScalingLawPower (max_values: None, max_size: None, mode: Measured) - fn sudo_set_scaling_law_power() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_480_000 picoseconds. - Weight::from_parts(46_590_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule ImmunityPeriod (r:0 w:1) - /// Proof Skipped: SubtensorModule ImmunityPeriod (max_values: None, max_size: None, mode: Measured) - fn sudo_set_immunity_period() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_289_000 picoseconds. - Weight::from_parts(46_679_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxWeightsLimit (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxWeightsLimit (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_weight_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_850_000 picoseconds. - Weight::from_parts(46_589_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxRegistrationsPerBlock (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxRegistrationsPerBlock (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_registrations_per_block() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_330_000 picoseconds. - Weight::from_parts(46_490_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MaxBurn (r:0 w:1) - /// Proof Skipped: SubtensorModule MaxBurn (max_values: None, max_size: None, mode: Measured) - fn sudo_set_max_burn() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_390_000 picoseconds. - Weight::from_parts(46_339_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule MinBurn (r:0 w:1) - /// Proof Skipped: SubtensorModule MinBurn (max_values: None, max_size: None, mode: Measured) - fn sudo_set_min_burn() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 45_189_000 picoseconds. - Weight::from_parts(46_109_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworkPowRegistrationAllowed (r:0 w:1) - /// Proof Skipped: SubtensorModule NetworkPowRegistrationAllowed (max_values: None, max_size: None, mode: Measured) - fn sudo_set_network_registration_allowed() -> Weight { - // Proof Size summary in bytes: - // Measured: `655` - // Estimated: `655` - // Minimum execution time: 33_600_000 picoseconds. - Weight::from_parts(34_599_000, 655) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: SubtensorModule NetworksAdded (r:1 w:0) - /// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured) - /// Storage: SubtensorModule Tempo (r:0 w:1) - /// Proof Skipped: SubtensorModule Tempo (max_values: None, max_size: None, mode: Measured) - fn sudo_set_tempo() -> Weight { - // Proof Size summary in bytes: - // Measured: `1111` - // Estimated: `4697` - // Minimum execution time: 44_739_000 picoseconds. - Weight::from_parts(45_489_000, 4697) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - fn sudo_set_commit_reveal_weights_interval() -> Weight { - // -- Extrinsic Time -- - // Model: - // Time ~= 19.38 - // µs - // Reads = 1 - // Writes = 1 - // Recorded proof Size = 456 - Weight::from_parts(19_380_000, 456) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - fn sudo_set_commit_reveal_weights_enabled() -> Weight { - // -- Extrinsic Time -- - // Model: - // Time ~= 19.78 - // µs - // Reads = 1 - // Writes = 1 - // Recorded proof Size = 456 - Weight::from_parts(19_780_000, 456) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - fn sudo_set_evm_chain_id() -> Weight { - Weight::from_parts(20_200_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - fn schedule_grandpa_change(_a: u32) -> Weight { - // TODO should be replaced by benchmarked weights - Weight::default() - } -} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 88dabca33c..64d91e2e73 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1176,7 +1176,6 @@ impl pallet_admin_utils::Config for Runtime { type Aura = AuraPalletIntrf; type Grandpa = GrandpaInterfaceImpl; type Balance = Balance; - type WeightInfo = pallet_admin_utils::weights::SubstrateWeight; } /// Define the ChainId From aba5d9fdc48f10104868b3087a259c8bc7d0ebbb Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 08:24:02 -0700 Subject: [PATCH 122/226] update admin-utils weights --- pallets/admin-utils/src/lib.rs | 70 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 30361a4d6e..6dd6a626de 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -2,8 +2,8 @@ // extern crate alloc; -pub use pallet::*; use frame_system::pallet_prelude::BlockNumberFor; +pub use pallet::*; // - we could replace it with Vec<(AuthorityId, u64)>, but we would need // `sp_consensus_grandpa` for `AuthorityId` anyway // - we could use a type parameter for `AuthorityId`, but there is @@ -130,7 +130,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Aura pallet to change the authorities. #[pallet::call_index(0)] - #[pallet::weight(Weight::from_parts(20_410_228, 0) + #[pallet::weight(Weight::from_parts(6_265_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)))] pub fn swap_authorities( @@ -151,8 +151,8 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the default take. #[pallet::call_index(1)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) + #[pallet::weight(Weight::from_parts(6_942_000, 0) + .saturating_add(T::DbWeight::get().reads(0_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_default_take(origin: OriginFor, default_take: u16) -> DispatchResult { ensure_root(origin)?; @@ -177,8 +177,8 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the serving rate limit. #[pallet::call_index(3)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) + #[pallet::weight(Weight::from_parts(7_815_000, 0) + .saturating_add(T::DbWeight::get().reads(0_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_serving_rate_limit( origin: OriginFor, @@ -199,7 +199,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the minimum difficulty. #[pallet::call_index(4)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_780_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_difficulty( @@ -226,7 +226,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the maximum difficulty. #[pallet::call_index(5)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_050_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_difficulty( @@ -253,7 +253,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the weights version key. #[pallet::call_index(6)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_990_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_weights_version_key( @@ -303,7 +303,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the weights set rate limit. #[pallet::call_index(7)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_050_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_weights_set_rate_limit( @@ -333,7 +333,7 @@ pub mod pallet { /// It is only callable by the root account, not changeable by the subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment interval. #[pallet::call_index(8)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_010_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_adjustment_interval( @@ -390,7 +390,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment beta. #[pallet::call_index(12)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_240_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_weight_limit( @@ -417,7 +417,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the immunity period. #[pallet::call_index(13)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_380_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_immunity_period( @@ -471,8 +471,8 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the maximum allowed UIDs for a subnet. #[pallet::call_index(15)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) + #[pallet::weight(Weight::from_parts(23_820_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_allowed_uids( origin: OriginFor, @@ -501,7 +501,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the kappa. #[pallet::call_index(16)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_590_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_kappa(origin: OriginFor, netuid: u16, kappa: u16) -> DispatchResult { @@ -520,7 +520,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the rho. #[pallet::call_index(17)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(16_420_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_rho(origin: OriginFor, netuid: u16, rho: u16) -> DispatchResult { @@ -539,8 +539,8 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the activity cutoff. #[pallet::call_index(18)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) + #[pallet::weight(Weight::from_parts(22_600_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_activity_cutoff( origin: OriginFor, @@ -573,8 +573,8 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the network registration allowed. #[pallet::call_index(19)] #[pallet::weight(( - Weight::from_parts(4_000_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + Weight::from_parts(8_696_000, 0) + .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No @@ -629,7 +629,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the target registrations per interval. #[pallet::call_index(21)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_830_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_target_registrations_per_interval( @@ -659,7 +659,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the minimum burn. #[pallet::call_index(22)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_840_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_burn( @@ -686,7 +686,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the maximum burn. #[pallet::call_index(23)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_740_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_burn( @@ -713,7 +713,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the difficulty. #[pallet::call_index(24)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_280_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_difficulty( @@ -739,8 +739,8 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the maximum allowed validators. #[pallet::call_index(25)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) + #[pallet::weight(Weight::from_parts(25_210_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_allowed_validators( origin: OriginFor, @@ -774,7 +774,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the bonds moving average. #[pallet::call_index(26)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_270_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_bonds_moving_average( @@ -808,7 +808,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the bonds penalty. #[pallet::call_index(60)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_030_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_bonds_penalty( @@ -835,7 +835,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the maximum registrations per block. #[pallet::call_index(27)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_680_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_registrations_per_block( @@ -908,7 +908,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the tempo. #[pallet::call_index(30)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_900_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_tempo(origin: OriginFor, netuid: u16, tempo: u16) -> DispatchResult { @@ -1128,7 +1128,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the value. #[pallet::call_index(49)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_480_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_commit_reveal_weights_enabled( @@ -1329,7 +1329,7 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(57)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(20_490_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_commit_reveal_weights_interval( @@ -1392,9 +1392,9 @@ pub mod pallet { /// No change should be signaled while any change is pending. Returns an error if a change /// is already pending. #[pallet::call_index(59)] - #[pallet::weight(Weight::from_parts(20_410_228, 0) + #[pallet::weight(Weight::from_parts(11_550_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)))] + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn schedule_grandpa_change( origin: OriginFor, // grandpa ID is always the same type, so we don't need to parametrize it via `Config` From c2830ecefa597558452dc43c25c5bcae83835c55 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 08:56:12 -0700 Subject: [PATCH 123/226] update weight --- pallets/admin-utils/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 6dd6a626de..99d228d5e3 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -444,7 +444,7 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the minimum allowed weights. #[pallet::call_index(14)] - #[pallet::weight(Weight::from_parts(27_199_000, 0) + #[pallet::weight(Weight::from_parts(19_770_000, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_allowed_weights( From 91134bf7301adde2f425ef279f4b50a65b62277a Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 10:29:26 -0700 Subject: [PATCH 124/226] add commitments benchmarks --- pallets/commitments/src/benchmarking.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pallets/commitments/src/benchmarking.rs b/pallets/commitments/src/benchmarking.rs index 54247bb9d6..fc1f5f92a4 100644 --- a/pallets/commitments/src/benchmarking.rs +++ b/pallets/commitments/src/benchmarking.rs @@ -35,7 +35,6 @@ mod benchmarks { #[benchmark] fn set_commitment() { - // The target user let netuid = 1; let caller: T::AccountId = whitelisted_caller(); let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); @@ -56,5 +55,25 @@ mod benchmarks { ); } + #[benchmark] + fn set_rate_limit() { + let new_limit: u32 = 42; + + #[extrinsic_call] + _(RawOrigin::Root, new_limit); + + assert_eq!(RateLimit::::get(), new_limit.into()); + } + + #[benchmark] + fn set_max_space() { + let new_space: u32 = 1_000; + + #[extrinsic_call] + _(RawOrigin::Root, new_space); + + assert_eq!(MaxSpace::::get(), new_space); + } + //impl_benchmark_test_suite!(Commitments, crate::tests::new_test_ext(), crate::tests::Test); } From 3e08bafff91c6c634f497b7dc26775e33a82012b Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 10:29:38 -0700 Subject: [PATCH 125/226] add commitments weights --- pallets/commitments/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 11e1ae76ee..e223d4eed4 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -198,7 +198,9 @@ pub mod pallet { /// Set the commitment for a given netuid #[pallet::call_index(0)] #[pallet::weight(( - ::WeightInfo::set_commitment(), + Weight::from_parts(28_000_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Operational, Pays::No ))] @@ -309,7 +311,9 @@ pub mod pallet { /// Sudo-set the commitment rate limit #[pallet::call_index(1)] #[pallet::weight(( - ::WeightInfo::set_rate_limit(), + Weight::from_parts(10_000_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Operational, Pays::No ))] @@ -322,7 +326,9 @@ pub mod pallet { /// Sudo-set MaxSpace #[pallet::call_index(2)] #[pallet::weight(( - ::WeightInfo::set_rate_limit(), + Weight::from_parts(10_000_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Operational, Pays::No ))] From 42bf08bbadc1d05d68c782f0aaa6ced9009ff65f Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 11:21:13 -0700 Subject: [PATCH 126/226] update commitments weights again --- pallets/commitments/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index e223d4eed4..519d361e66 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -198,9 +198,9 @@ pub mod pallet { /// Set the commitment for a given netuid #[pallet::call_index(0)] #[pallet::weight(( - Weight::from_parts(28_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)), + Weight::from_parts(38_000_000, 0) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)), DispatchClass::Operational, Pays::No ))] @@ -311,9 +311,9 @@ pub mod pallet { /// Sudo-set the commitment rate limit #[pallet::call_index(1)] #[pallet::weight(( - Weight::from_parts(10_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)), + Weight::from_parts(3_596_000, 0) + .saturating_add(T::DbWeight::get().reads(0_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::No ))] @@ -326,9 +326,9 @@ pub mod pallet { /// Sudo-set MaxSpace #[pallet::call_index(2)] #[pallet::weight(( - Weight::from_parts(10_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)), + Weight::from_parts(3_556_000, 0) + .saturating_add(T::DbWeight::get().reads(0_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::No ))] From 888ea8e10e7b8a4509a28d1f630de21ad64dbe31 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 11:36:25 -0700 Subject: [PATCH 127/226] raise tolerance threshold 10% => 15% --- scripts/benchmark_action.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index d088ffdc82..4c861fd18c 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -14,7 +14,7 @@ declare -A DISPATCH_PATHS=( ) # Max allowed drift (%) -THRESHOLD=10 +THRESHOLD=15 MAX_RETRIES=3 # We'll build once for runtime-benchmarks From a40792ded419c2600ea6839675d5b0b407707de0 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 12:05:33 -0700 Subject: [PATCH 128/226] update drand weights --- pallets/admin-utils/src/tests/mock.rs | 1 - pallets/commitments/src/mock.rs | 1 - pallets/drand/src/lib.rs | 12 ++-- pallets/drand/src/mock.rs | 1 - pallets/drand/src/weights.rs | 80 --------------------------- pallets/subtensor/src/tests/mock.rs | 1 - runtime/src/lib.rs | 1 - 7 files changed, 6 insertions(+), 91 deletions(-) delete mode 100644 pallets/drand/src/weights.rs diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 77ccdfbf5d..eb90172f58 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -310,7 +310,6 @@ impl pallet_scheduler::Config for Test { impl pallet_evm_chain_id::Config for Test {} impl pallet_drand::Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_drand::weights::SubstrateWeight; type AuthorityId = TestAuthId; type Verifier = pallet_drand::verifier::QuicknetVerifier; type UnsignedPriority = ConstU64<{ 1 << 20 }>; diff --git a/pallets/commitments/src/mock.rs b/pallets/commitments/src/mock.rs index c8f6b1e1b2..a5e9f1c4be 100644 --- a/pallets/commitments/src/mock.rs +++ b/pallets/commitments/src/mock.rs @@ -118,7 +118,6 @@ impl pallet_commitments::GetTempoInterface for MockTempoInterface { impl pallet_drand::Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_drand::weights::SubstrateWeight; type AuthorityId = test_crypto::TestAuthId; type Verifier = pallet_drand::verifier::QuicknetVerifier; type UnsignedPriority = ConstU64<{ 1 << 20 }>; diff --git a/pallets/drand/src/lib.rs b/pallets/drand/src/lib.rs index 40bf7ccb9b..30bf76c1cf 100644 --- a/pallets/drand/src/lib.rs +++ b/pallets/drand/src/lib.rs @@ -73,8 +73,6 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -pub mod weights; -pub use weights::*; /// the main drand api endpoint const ENDPOINTS: [&str; 5] = [ @@ -162,8 +160,6 @@ pub mod pallet { type AuthorityId: AppCrypto; /// The overarching runtime event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// A type representing the weights required by the dispatchables of this pallet. - type WeightInfo: WeightInfo; /// something that knows how to verify beacon pulses type Verifier: Verifier; /// A configuration for base priority of unsigned transactions. @@ -309,7 +305,9 @@ pub mod pallet { impl Pallet { /// Verify and write a pulse from the beacon into the runtime #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::write_pulse(pulses_payload.pulses.len() as u32))] + #[pallet::weight(Weight::from_parts(5_708_000_000, 0) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)))] pub fn write_pulse( origin: OriginFor, pulses_payload: PulsesPayload>, @@ -363,7 +361,9 @@ pub mod pallet { /// * `origin`: the root user /// * `config`: the beacon configuration #[pallet::call_index(1)] - #[pallet::weight(T::WeightInfo::set_beacon_config())] + #[pallet::weight(Weight::from_parts(9_878_000, 0) + .saturating_add(T::DbWeight::get().reads(0_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn set_beacon_config( origin: OriginFor, config_payload: BeaconConfigurationPayload>, diff --git a/pallets/drand/src/mock.rs b/pallets/drand/src/mock.rs index ba9e16e6f4..6ef1f2bf8a 100644 --- a/pallets/drand/src/mock.rs +++ b/pallets/drand/src/mock.rs @@ -88,7 +88,6 @@ parameter_types! { impl pallet_drand_bridge::Config for Test { type AuthorityId = crypto::TestAuthId; type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_drand_bridge::weights::SubstrateWeight; type Verifier = QuicknetVerifier; type UnsignedPriority = UnsignedPriority; type HttpFetchTimeout = ConstU64<1_000>; diff --git a/pallets/drand/src/weights.rs b/pallets/drand/src/weights.rs deleted file mode 100644 index 6ab6e2905d..0000000000 --- a/pallets/drand/src/weights.rs +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2024 by Ideal Labs, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//! Autogenerated weights for pallet_template -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 - -// Executed Command: -// ../../target/release/node-template -// benchmark -// pallet -// --chain -// dev -// --pallet -// pallet_template -// --extrinsic -// * -// --steps=50 -// --repeat=20 -// --wasm-execution=compiled -// --output -// pallets/template/src/weights.rs -// --template -// ../../.maintain/frame-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use core::marker::PhantomData; - -/// Weight functions needed for pallet_template. -pub trait WeightInfo { - fn write_pulse(pulses_count: u32) -> Weight; - fn set_beacon_config() -> Weight; -} - -/// Weights for pallet_template using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: `Drand::BeaconConfig` (r:0 w:1) - /// Proof: `Drand::BeaconConfig` (`max_values`: Some(1), `max_size`: Some(238), added: 733, mode: `MaxEncodedLen`) - /// Storage: `Drand::NextUnsignedAt` (r:0 w:1) - /// Proof: `Drand::NextUnsignedAt` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - fn set_beacon_config() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(8_000_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `Drand::BeaconConfig` (r:1 w:0) - /// Proof: `Drand::BeaconConfig` (`max_values`: Some(1), `max_size`: Some(238), added: 733, mode: `MaxEncodedLen`) - fn write_pulse(pulses_count: u32) -> Weight { - // Adjust the weight calculation based on pulses_count - Weight::from_parts(6_000_000 * pulses_count as u64, 0) - .saturating_add(Weight::from_parts(0, 1723 * pulses_count as u64)) - .saturating_add(T::DbWeight::get().reads_writes(1, pulses_count as u64)) - } -} diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index a8ab96be8c..88fc31be0a 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -505,7 +505,6 @@ where impl pallet_drand::Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_drand::weights::SubstrateWeight; type AuthorityId = TestAuthId; type Verifier = pallet_drand::verifier::QuicknetVerifier; type UnsignedPriority = ConstU64<{ 1 << 20 }>; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 64d91e2e73..e5a1786101 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -100,7 +100,6 @@ use pallet_evm::{Account as EVMAccount, BalanceConverter, FeeCalculator, Runner} // Drand impl pallet_drand::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_drand::weights::SubstrateWeight; type AuthorityId = pallet_drand::crypto::TestAuthId; type Verifier = pallet_drand::verifier::QuicknetVerifier; type UnsignedPriority = ConstU64<{ 1 << 20 }>; From 1d50da2762a59d14ad8c591cbf78b95d03851024 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 12:42:37 -0700 Subject: [PATCH 129/226] update drand writes --- pallets/drand/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/drand/src/lib.rs b/pallets/drand/src/lib.rs index 30bf76c1cf..dd172befc0 100644 --- a/pallets/drand/src/lib.rs +++ b/pallets/drand/src/lib.rs @@ -363,7 +363,7 @@ pub mod pallet { #[pallet::call_index(1)] #[pallet::weight(Weight::from_parts(9_878_000, 0) .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)))] + .saturating_add(T::DbWeight::get().writes(2_u64)))] pub fn set_beacon_config( origin: OriginFor, config_payload: BeaconConfigurationPayload>, From 9dc13bd3164fe5ee3a73fed4986e434fb124d24c Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 13:26:52 -0700 Subject: [PATCH 130/226] use benchmarks runner instead of SubtensorCI --- .github/workflows/run-benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 160ee7df8b..d0981ef59f 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -17,7 +17,7 @@ concurrency: jobs: validate-benchmarks: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-validate-benchmarks') }} - runs-on: SubtensorCI + runs-on: Benchmarking steps: - name: Checkout PR branch uses: actions/checkout@v4 From f9fa3cf251b71c6058d0ffb4fc3e14ff03a46eba Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 1 May 2025 13:27:31 -0700 Subject: [PATCH 131/226] remove crowdloan from `validate-benchmarks` --- scripts/benchmark_action.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index 4c861fd18c..34043957de 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -2,7 +2,7 @@ set -euo pipefail # A list of pallets we wish to benchmark -PALLETS=(subtensor admin_utils commitments drand crowdloan) +PALLETS=(subtensor admin_utils commitments drand) # Map of pallet -> dispatch path (relative to this script's directory) declare -A DISPATCH_PATHS=( @@ -10,7 +10,6 @@ declare -A DISPATCH_PATHS=( [admin_utils]="../pallets/admin-utils/src/lib.rs" [commitments]="../pallets/commitments/src/lib.rs" [drand]="../pallets/drand/src/lib.rs" - [crowdloan]="../pallets/crowdloan/src/lib.rs" ) # Max allowed drift (%) From 3d3796c949e2767e1c6e346101632fad6f543d00 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 5 May 2025 16:53:59 +0400 Subject: [PATCH 132/226] Update comments. --- pallets/subtensor/src/macros/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index 8ace006010..af702e8280 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -210,7 +210,7 @@ mod errors { InvalidRecoveredPublicKey, /// SubToken disabled now SubtokenDisabled, - /// Zero max stake amout + /// Estimating the maximum stake for limited staking operations returned zero. ZeroMaxStakeAmount, } } From c28ecc6cfd5cc043d8ca513a402a22a04427a16f Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 5 May 2025 10:51:09 -0400 Subject: [PATCH 133/226] chore: fmt --- pallets/admin-utils/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index a0a3c74abe..9d978061a1 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1539,7 +1539,7 @@ pub mod pallet { enabled ); Ok(()) - } + } /// Sets or updates the hotkey account associated with the owner of a specific subnet. /// From 487c231e533ff9159dfc9457f8920cb01c1617e1 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 17:55:03 +0200 Subject: [PATCH 134/226] added log crate to crowdloan --- Cargo.lock | 1 + pallets/crowdloan/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 65578627f9..3dbcfe75a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6120,6 +6120,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "pallet-balances", "pallet-preimage", "parity-scale-codec", diff --git a/pallets/crowdloan/Cargo.toml b/pallets/crowdloan/Cargo.toml index 1739a85b7c..3098db490e 100644 --- a/pallets/crowdloan/Cargo.toml +++ b/pallets/crowdloan/Cargo.toml @@ -21,6 +21,7 @@ frame-support.workspace = true frame-system.workspace = true sp-runtime.workspace = true sp-std.workspace = true +log = { workspace = true } [dev-dependencies] pallet-balances = { default-features = true, workspace = true } From 39cea2a22b584c0eaf4d589ad769d7654c43fded Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 17:57:22 +0200 Subject: [PATCH 135/226] keep track of contributors count and allow a maximum of contributors, added migration --- pallets/crowdloan/src/lib.rs | 78 +++++++++++++++++-- .../migrate_add_contributors_count.rs | 46 +++++++++++ pallets/crowdloan/src/migrations/mod.rs | 2 + 3 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs create mode 100644 pallets/crowdloan/src/migrations/mod.rs diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 9b49d5e778..392413feba 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -7,7 +7,7 @@ extern crate alloc; -use alloc::{boxed::Box, vec, vec::Vec}; +use alloc::{boxed::Box, vec}; use codec::{Decode, Encode}; use frame_support::{ PalletId, @@ -25,6 +25,7 @@ use frame_support::{ use frame_system::pallet_prelude::*; use scale_info::TypeInfo; use sp_runtime::traits::CheckedSub; +use sp_std::vec::Vec; use weights::WeightInfo; pub use pallet::*; @@ -33,6 +34,7 @@ use subtensor_macros::freeze_struct; pub type CrowdloanId = u32; mod benchmarking; +mod migrations; mod mock; mod tests; pub mod weights; @@ -42,6 +44,9 @@ pub type CurrencyOf = ::Currency; pub type BalanceOf = as fungible::Inspect<::AccountId>>::Balance; +// Define a maximum length for the migration key +type MigrationKeyMaxLen = ConstU32<128>; + pub type BoundedCallOf = Bounded<::RuntimeCall, ::Hashing>; @@ -134,6 +139,10 @@ pub mod pallet { /// The maximum number of contributors that can be refunded in a single refund. #[pallet::constant] type RefundContributorsLimit: Get; + + // The maximum number of contributors that can contribute to a crowdloan. + #[pallet::constant] + type MaxContributors: Get; } /// A map of crowdloan ids to their information. @@ -157,11 +166,21 @@ pub mod pallet { OptionQuery, >; + /// A map of crowdloan ids to their contributors count. + #[pallet::storage] + pub type ContributorsCount = + StorageMap<_, Twox64Concat, CrowdloanId, u32, OptionQuery>; + /// The current crowdloan id that will be set during the finalize call, making it /// temporarily accessible to the dispatched call. #[pallet::storage] pub type CurrentCrowdloanId = StorageValue<_, CrowdloanId, OptionQuery>; + /// Storage for the migration run status. + #[pallet::storage] + pub type HasMigrationRun = + StorageMap<_, Identity, BoundedVec, bool, ValueQuery>; + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -253,6 +272,21 @@ pub mod pallet { NotReadyToDissolve, /// The deposit cannot be withdrawn from the crowdloan. DepositCannotBeWithdrawn, + /// The maximum number of contributors has been reached. + MaxContributorsReached, + } + + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + let mut weight = frame_support::weights::Weight::from_parts(0, 0); + + weight = weight + // Add the contributors count for each crowdloan + .saturating_add(migrations::migrate_add_contributors_count::()); + + weight + } } #[pallet::call] @@ -354,6 +388,7 @@ pub mod pallet { )?; Contributions::::insert(crowdloan_id, &creator, deposit); + ContributorsCount::::insert(crowdloan_id, 1); Self::deposit_event(Event::::Created { crowdloan_id, @@ -398,6 +433,14 @@ pub mod pallet { Error::::ContributionTooLow ); + // Ensure the crowdloan has not reached the maximum number of contributors + let contributors_count = + ContributorsCount::::get(crowdloan_id).ok_or(Error::::InvalidCrowdloanId)?; + ensure!( + contributors_count < T::MaxContributors::get(), + Error::::MaxContributorsReached + ); + // Ensure contribution does not overflow the actual raised amount // and it does not exceed the cap let left_to_raise = crowdloan @@ -415,11 +458,18 @@ pub mod pallet { .checked_add(amount) .ok_or(Error::::Overflow)?; - // Compute the new total contribution and ensure it does not overflow. - let contribution = Contributions::::get(crowdloan_id, &contributor) - .unwrap_or(Zero::zero()) - .checked_add(amount) - .ok_or(Error::::Overflow)?; + // Compute the new total contribution and ensure it does not overflow, we + // also increment the contributor count if the contribution is new. + let contribution = + if let Some(contribution) = Contributions::::get(crowdloan_id, &contributor) { + contribution + .checked_add(amount) + .ok_or(Error::::Overflow)? + } else { + // We have a new contribution + Self::increment_contributor_count(crowdloan_id); + amount + }; // Ensure contributor has enough balance to pay ensure!( @@ -476,6 +526,7 @@ pub mod pallet { Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); } else { Contributions::::remove(crowdloan_id, &who); + Self::decrement_contributor_count(crowdloan_id); } CurrencyOf::::transfer( @@ -630,6 +681,7 @@ pub mod pallet { // Clear refunded contributors for contributor in refunded_contributors { Contributions::::remove(crowdloan_id, &contributor); + Self::decrement_contributor_count(crowdloan_id); } if all_refunded { @@ -682,6 +734,7 @@ pub mod pallet { creator_contribution, Preservation::Expendable, )?; + Contributions::::remove(crowdloan_id, &crowdloan.creator); // Clear the call from the preimage storage if let Some(call) = crowdloan.call { @@ -691,6 +744,7 @@ pub mod pallet { // Remove the crowdloan let _ = frame_system::Pallet::::dec_providers(&crowdloan.funds_account).defensive(); Crowdloans::::remove(crowdloan_id); + ContributorsCount::::remove(crowdloan_id); Self::deposit_event(Event::::Dissolved { crowdloan_id }); Ok(()) @@ -831,4 +885,16 @@ impl Pallet { ); Ok(()) } + + fn increment_contributor_count(crowdloan_id: CrowdloanId) { + ContributorsCount::::mutate(crowdloan_id, |count| { + *count = count.map(|v| v.saturating_add(1)) + }); + } + + fn decrement_contributor_count(crowdloan_id: CrowdloanId) { + ContributorsCount::::mutate(crowdloan_id, |count| { + *count = count.map(|v| v.saturating_sub(1)) + }); + } } diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs new file mode 100644 index 0000000000..684c4b1cff --- /dev/null +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -0,0 +1,46 @@ +use alloc::string::String; +use frame_support::{BoundedVec, traits::Get, weights::Weight}; + +use crate::*; + +pub fn migrate_add_contributors_count() -> Weight { + let migration_name = + BoundedVec::truncate_from(b"migrate_crowdloan_contributors_count".to_vec()); + let mut weight = T::DbWeight::get().reads(1); + + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); + return weight; + } + + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + // Get all crowdloans, there is not so many at the moment so we are safe. + let crowdloan_ids = Crowdloans::::iter_keys().collect::>(); + weight = weight.saturating_add(T::DbWeight::get().reads(crowdloan_ids.len() as u64)); + + for crowdloan_id in crowdloan_ids { + let contributions = Contributions::::iter_key_prefix(crowdloan_id) + .collect::>() + .len(); + weight = weight.saturating_add(T::DbWeight::get().reads(contributions as u64)); + + ContributorsCount::::insert(crowdloan_id, contributions as u32); + } + + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed successfully.", + String::from_utf8_lossy(&migration_name) + ); + + weight +} diff --git a/pallets/crowdloan/src/migrations/mod.rs b/pallets/crowdloan/src/migrations/mod.rs new file mode 100644 index 0000000000..f6701fb83a --- /dev/null +++ b/pallets/crowdloan/src/migrations/mod.rs @@ -0,0 +1,2 @@ +mod migrate_add_contributors_count; +pub use migrate_add_contributors_count::*; From 203a8a3561c70982cbcd5e56a1fd41cee07540a2 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 17:57:32 +0200 Subject: [PATCH 136/226] fix tests --- pallets/crowdloan/src/mock.rs | 2 + pallets/crowdloan/src/tests.rs | 148 +++++++++++++++++++++++++++++++-- 2 files changed, 142 insertions(+), 8 deletions(-) diff --git a/pallets/crowdloan/src/mock.rs b/pallets/crowdloan/src/mock.rs index 980b9fa26b..78cf15717c 100644 --- a/pallets/crowdloan/src/mock.rs +++ b/pallets/crowdloan/src/mock.rs @@ -111,6 +111,7 @@ parameter_types! { pub const MinimumBlockDuration: u64 = 20; pub const MaximumBlockDuration: u64 = 100; pub const RefundContributorsLimit: u32 = 5; + pub const MaxContributors: u32 = 10; } impl pallet_crowdloan::Config for Test { @@ -125,6 +126,7 @@ impl pallet_crowdloan::Config for Test { type MinimumBlockDuration = MinimumBlockDuration; type MaximumBlockDuration = MaximumBlockDuration; type RefundContributorsLimit = RefundContributorsLimit; + type MaxContributors = MaxContributors; } // A test pallet used to test some behavior of the crowdloan pallet diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 45bc61e40a..b978dbadf0 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -1,7 +1,7 @@ #![cfg(test)] #![allow(clippy::arithmetic_side_effects, clippy::unwrap_used)] -use frame_support::{assert_err, assert_ok, traits::StorePreimage}; +use frame_support::{StorageDoubleMap, assert_err, assert_ok, traits::StorePreimage}; use frame_system::pallet_prelude::BlockNumberFor; use sp_core::U256; use sp_runtime::DispatchError; @@ -58,6 +58,11 @@ fn test_create_succeeds() { .collect::>(), vec![(creator, deposit)] ); + // ensure the contributor count is updated + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); // ensure the raised amount is updated correctly assert!( pallet_crowdloan::Crowdloans::::get(crowdloan_id) @@ -330,8 +335,15 @@ fn test_contribute_succeeds() { // run some blocks run_to_block(10); - // first contribution to the crowdloan from creator let crowdloan_id: CrowdloanId = 0; + + // only the creator has contributed so far + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); + + // first contribution to the crowdloan from creator let amount: BalanceOf = 50; assert_ok!(Crowdloan::contribute( RuntimeOrigin::signed(creator), @@ -351,6 +363,10 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, creator), Some(100) ); + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); assert_eq!( Balances::free_balance(creator), 200 - amount - initial_deposit @@ -377,6 +393,10 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), Some(100) ); + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(2) + ); assert_eq!(Balances::free_balance(contributor1), 500 - amount); // third contribution to the crowdloan @@ -400,6 +420,10 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), Some(50) ); + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(3) + ); assert_eq!(Balances::free_balance(contributor2), 200 - amount); // ensure the contributions are present in the funds account @@ -656,6 +680,62 @@ fn test_contribute_fails_if_contribution_is_below_minimum_contribution() { }); } +#[test] +fn test_contribute_fails_if_max_contributors_has_been_reached() { + TestState::default() + .with_balance(U256::from(1), 100) + .with_balance(U256::from(2), 100) + .with_balance(U256::from(3), 100) + .with_balance(U256::from(4), 100) + .with_balance(U256::from(5), 100) + .with_balance(U256::from(6), 100) + .with_balance(U256::from(7), 100) + .with_balance(U256::from(8), 100) + .with_balance(U256::from(9), 100) + .with_balance(U256::from(10), 100) + .with_balance(U256::from(11), 100) + .build_and_execute(|| { + // create a crowdloan + let creator: AccountOf = U256::from(1); + let initial_deposit: BalanceOf = 50; + let min_contribution: BalanceOf = 10; + let cap: BalanceOf = 1000; + let end: BlockNumberFor = 50; + + assert_ok!(Crowdloan::create( + RuntimeOrigin::signed(creator), + initial_deposit, + min_contribution, + cap, + end, + Some(noop_call()), + None + )); + + // run some blocks + run_to_block(10); + + // contribute to the crowdloan + let crowdloan_id: CrowdloanId = 0; + let amount: BalanceOf = 20; + for i in 2..=10 { + let contributor: AccountOf = U256::from(i); + assert_ok!(Crowdloan::contribute( + RuntimeOrigin::signed(contributor), + crowdloan_id, + amount + )); + } + + // try to contribute + let contributor: AccountOf = U256::from(10); + assert_err!( + Crowdloan::contribute(RuntimeOrigin::signed(contributor), crowdloan_id, amount), + pallet_crowdloan::Error::::MaxContributorsReached + ); + }); +} + #[test] fn test_contribute_fails_if_contributor_has_insufficient_balance() { TestState::default() @@ -743,6 +823,12 @@ fn test_withdraw_from_contributor_succeeds() { // run some more blocks past the end of the contribution period run_to_block(60); + // ensure the contributor count is correct + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(3) + ); + // withdraw from contributor1 assert_ok!(Crowdloan::withdraw( RuntimeOrigin::signed(contributor1), @@ -753,6 +839,10 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), None, ); + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(2) + ); // ensure the contributor1 has the correct amount assert_eq!( pallet_balances::Pallet::::free_balance(contributor1), @@ -769,6 +859,10 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), None, ); + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); // ensure the contributor2 has the correct amount assert_eq!( pallet_balances::Pallet::::free_balance(contributor2), @@ -818,6 +912,12 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { amount )); + // ensure the contributor count is correct + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); + // withdraw let crowdloan_id: CrowdloanId = 0; assert_ok!(Crowdloan::withdraw( @@ -835,6 +935,11 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, creator), Some(initial_deposit), ); + // ensure the contributor count hasn't changed because deposit is kept + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); // ensure the crowdloan account has the correct amount let funds_account = pallet_crowdloan::Pallet::::funds_account(crowdloan_id); @@ -1478,6 +1583,12 @@ fn test_refund_succeeds() { )); } + // ensure the contributor count is correct + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(7) + ); + // run some more blocks past the end of the contribution period run_to_block(60); @@ -1487,6 +1598,12 @@ fn test_refund_succeeds() { crowdloan_id )); + // ensure the contributor count is correct, we processed 5 refunds + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(2) + ); + // ensure the crowdloan account has the correct amount let funds_account = pallet_crowdloan::Pallet::::funds_account(crowdloan_id); assert_eq!(Balances::free_balance(funds_account), 350 - 5 * amount); @@ -1510,6 +1627,13 @@ fn test_refund_succeeds() { crowdloan_id )); + // ensure the contributor count is correct, we processed 1 more refund + // keeping deposit + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); + // ensure the crowdloan account has the correct amount assert_eq!( pallet_balances::Pallet::::free_balance(funds_account), @@ -1638,15 +1762,15 @@ fn test_dissolve_succeeds() { // run some blocks past end run_to_block(60); - // refund the contributions let crowdloan_id: CrowdloanId = 0; - assert_ok!(Crowdloan::refund( - RuntimeOrigin::signed(creator), - crowdloan_id - )); + + // ensure the contributor count is correct + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); // dissolve the crowdloan - let crowdloan_id: CrowdloanId = 0; assert_ok!(Crowdloan::dissolve( RuntimeOrigin::signed(creator), crowdloan_id @@ -1655,6 +1779,14 @@ fn test_dissolve_succeeds() { // ensure the crowdloan is removed from the crowdloans map assert!(pallet_crowdloan::Crowdloans::::get(crowdloan_id).is_none()); + // ensure the contributions are removed + assert!(!pallet_crowdloan::Contributions::::contains_prefix( + crowdloan_id + )); + + // ensure the contributor count is removed + assert!(pallet_crowdloan::ContributorsCount::::get(crowdloan_id).is_none()); + // ensure the event is emitted assert_eq!( last_event(), From ea8700e95ccd13c805015e9b189d4420b5cf23e1 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 17:57:51 +0200 Subject: [PATCH 137/226] added MaxContributors to runtime --- runtime/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 88dabca33c..cba54cc3d0 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1447,6 +1447,7 @@ parameter_types! { 432000 // 60 days maximum (60 * 24 * 60 * 60 / 12) }; pub const RefundContributorsLimit: u32 = 50; + pub const MaxContributors: u32 = 500; } impl pallet_crowdloan::Config for Runtime { @@ -1461,6 +1462,7 @@ impl pallet_crowdloan::Config for Runtime { type MinimumBlockDuration = MinimumBlockDuration; type MaximumBlockDuration = MaximumBlockDuration; type RefundContributorsLimit = RefundContributorsLimit; + type MaxContributors = MaxContributors; } // Create the runtime by composing the FRAME pallets that were previously configured. From 6ec5d630a397209ecbc145be9ce2a9fe079900c2 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:01:36 +0200 Subject: [PATCH 138/226] fix migration name --- .../crowdloan/src/migrations/migrate_add_contributors_count.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 684c4b1cff..fc5de151cb 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -4,8 +4,7 @@ use frame_support::{BoundedVec, traits::Get, weights::Weight}; use crate::*; pub fn migrate_add_contributors_count() -> Weight { - let migration_name = - BoundedVec::truncate_from(b"migrate_crowdloan_contributors_count".to_vec()); + let migration_name = BoundedVec::truncate_from(b"migrate_add_contributors_count".to_vec()); let mut weight = T::DbWeight::get().reads(1); if HasMigrationRun::::get(&migration_name) { From c0f51295d67fda7fbb70a307f122ac47beb8c753 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 5 May 2025 11:04:19 -0500 Subject: [PATCH 139/226] Add `start-call` patch for non-fast-blocks node --- .github/workflows/docker-localnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-localnet.yml b/.github/workflows/docker-localnet.yml index c2afccae66..37e82460ff 100644 --- a/.github/workflows/docker-localnet.yml +++ b/.github/workflows/docker-localnet.yml @@ -57,6 +57,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Patch non-fast-block node + run: | + sed -i 's|7 \* 24 \* 60 \* 60 / 12 // 7 days|5 // Only 5 blocks for tests|' runtime/src/lib.rs + - name: Build and push Docker image uses: docker/build-push-action@v6 with: From 1fe18cb0b67644034081397ded2f794361e0448f Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 5 May 2025 11:11:02 -0500 Subject: [PATCH 140/226] bumping spec_version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5f41341546..4c257129aa 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -208,7 +208,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 265, + spec_version: 266, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From d49c04eb16ee59bf86cfac416a919680e1fd8baa Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:18:41 +0200 Subject: [PATCH 141/226] added migration test --- .../migrate_add_contributors_count.rs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index fc5de151cb..cb399634eb 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -43,3 +43,54 @@ pub fn migrate_add_contributors_count() -> Weight { weight } + +#[cfg(test)] +mod tests { + use crate::mock::{Test, TestState}; + + use super::*; + use sp_core::U256; + + #[test] + fn test_migrate_add_contributors_count_works() { + TestState::default().build_and_execute(|| { + Crowdloans::::insert( + 0, + CrowdloanInfo { + creator: U256::from(1), + deposit: 100, + min_contribution: 10, + cap: 1000, + end: 100, + call: None, + finalized: false, + raised: 0, + funds_account: U256::from(2), + target_address: None, + }, + ); + + Contributions::::insert(0, U256::from(1), 100); + Contributions::::insert(0, U256::from(2), 100); + Contributions::::insert(0, U256::from(3), 100); + + assert_eq!(ContributorsCount::::get(0), None); + assert_eq!( + HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + )), + false + ); + + migrate_add_contributors_count::(); + + assert_eq!(ContributorsCount::::get(0), Some(3)); + assert_eq!( + HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + )), + true + ); + }); + } +} From 6b37119bae0f88266215aa63601f56ef71da37ee Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:21:39 +0200 Subject: [PATCH 142/226] cargo clippy --- .../src/migrations/migrate_add_contributors_count.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index cb399634eb..9d610fd94e 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -75,21 +75,19 @@ mod tests { Contributions::::insert(0, U256::from(3), 100); assert_eq!(ContributorsCount::::get(0), None); - assert_eq!( - HasMigrationRun::::get(BoundedVec::truncate_from( + assert!( + !HasMigrationRun::::get(BoundedVec::truncate_from( b"migrate_add_contributors_count".to_vec() - )), - false + )) ); migrate_add_contributors_count::(); assert_eq!(ContributorsCount::::get(0), Some(3)); - assert_eq!( + assert!( HasMigrationRun::::get(BoundedVec::truncate_from( b"migrate_add_contributors_count".to_vec() - )), - true + )) ); }); } From 96cdf6486d82cd1e8eaccfa47f9124a1c97708c0 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:22:17 +0200 Subject: [PATCH 143/226] cargo fmt --- .../migrations/migrate_add_contributors_count.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 9d610fd94e..378e8bcc3d 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -75,20 +75,16 @@ mod tests { Contributions::::insert(0, U256::from(3), 100); assert_eq!(ContributorsCount::::get(0), None); - assert!( - !HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - )) - ); + assert!(!HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + ))); migrate_add_contributors_count::(); assert_eq!(ContributorsCount::::get(0), Some(3)); - assert!( - HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - )) - ); + assert!(HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + ))); }); } } From 83ad744fa1b86c79856c48bcf636611410ae516d Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:06:59 -0700 Subject: [PATCH 144/226] remove deprecated commitments storage --- pallets/commitments/src/lib.rs | 38 ++++++++---------------- pallets/commitments/src/tests.rs | 51 +------------------------------- 2 files changed, 14 insertions(+), 75 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 519d361e66..e5f66c6107 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -116,24 +116,12 @@ pub mod pallet { TooManyFieldsInCommitmentInfo, /// Account is not allow to make commitments to the chain AccountNotAllowedCommit, - /// Account is trying to commit data too fast, rate limit exceeded - CommitmentSetRateLimitExceeded, /// Space Limit Exceeded for the current interval SpaceLimitExceeded, /// Indicates that unreserve returned a leftover, which is unexpected. UnexpectedUnreserveLeftover, } - #[pallet::type_value] - /// *DEPRECATED* Default value for commitment rate limit. - pub fn DefaultRateLimit() -> BlockNumberFor { - T::DefaultRateLimit::get() - } - - /// *DEPRECATED* The rate limit for commitments - #[pallet::storage] - pub type RateLimit = StorageValue<_, BlockNumberFor, ValueQuery, DefaultRateLimit>; - /// Tracks all CommitmentOf that have at least one timelocked field. #[pallet::storage] #[pallet::getter(fn timelocked_index)] @@ -309,19 +297,19 @@ pub mod pallet { } /// Sudo-set the commitment rate limit - #[pallet::call_index(1)] - #[pallet::weight(( - Weight::from_parts(3_596_000, 0) - .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)), - DispatchClass::Operational, - Pays::No - ))] - pub fn set_rate_limit(origin: OriginFor, rate_limit_blocks: u32) -> DispatchResult { - ensure_root(origin)?; - RateLimit::::set(rate_limit_blocks.into()); - Ok(()) - } + // #[pallet::call_index(1)] + // #[pallet::weight(( + // Weight::from_parts(3_596_000, 0) + // .saturating_add(T::DbWeight::get().reads(0_u64)) + // .saturating_add(T::DbWeight::get().writes(1_u64)), + // DispatchClass::Operational, + // Pays::No + // ))] + // pub fn set_rate_limit(origin: OriginFor, rate_limit_blocks: u32) -> DispatchResult { + // ensure_root(origin)?; + // RateLimit::::set(rate_limit_blocks.into()); + // Ok(()) + // } /// Sudo-set MaxSpace #[pallet::call_index(2)] diff --git a/pallets/commitments/src/tests.rs b/pallets/commitments/src/tests.rs index c9b14d188b..f3b7a26bbb 100644 --- a/pallets/commitments/src/tests.rs +++ b/pallets/commitments/src/tests.rs @@ -3,7 +3,7 @@ use sp_std::prelude::*; #[cfg(test)] use crate::{ - CommitmentInfo, CommitmentOf, Config, Data, Error, Event, MaxSpace, Pallet, RateLimit, + CommitmentInfo, CommitmentOf, Config, Data, Error, Event, MaxSpace, Pallet, Registration, RevealedCommitments, TimelockedIndex, UsedSpaceOf, mock::{ Balances, DRAND_QUICKNET_SIG_2000_HEX, DRAND_QUICKNET_SIG_HEX, RuntimeEvent, RuntimeOrigin, @@ -150,39 +150,6 @@ fn set_commitment_too_many_fields_panics() { }); } -// DEPRECATED -// #[test] -// fn set_commitment_rate_limit_exceeded() { -// new_test_ext().execute_with(|| { -// let rate_limit = ::DefaultRateLimit::get(); -// System::::set_block_number(1); -// let info = Box::new(CommitmentInfo { -// fields: BoundedVec::try_from(vec![]).expect("Expected not to panic"), -// }); - -// assert_ok!(Pallet::::set_commitment( -// RuntimeOrigin::signed(1), -// 1, -// info.clone() -// )); - -// // Set block number to just before rate limit expires -// System::::set_block_number(rate_limit); -// assert_noop!( -// Pallet::::set_commitment(RuntimeOrigin::signed(1), 1, info.clone()), -// Error::::CommitmentSetRateLimitExceeded -// ); - -// // Set block number to after rate limit -// System::::set_block_number(rate_limit + 1); -// assert_ok!(Pallet::::set_commitment( -// RuntimeOrigin::signed(1), -// 1, -// info -// )); -// }); -// } - #[test] fn set_commitment_updates_deposit() { new_test_ext().execute_with(|| { @@ -226,22 +193,6 @@ fn set_commitment_updates_deposit() { }); } -#[test] -fn set_rate_limit_works() { - new_test_ext().execute_with(|| { - let default_rate_limit: u64 = ::DefaultRateLimit::get(); - assert_eq!(RateLimit::::get(), default_rate_limit); - - assert_ok!(Pallet::::set_rate_limit(RuntimeOrigin::root(), 200)); - assert_eq!(RateLimit::::get(), 200); - - assert_noop!( - Pallet::::set_rate_limit(RuntimeOrigin::signed(1), 300), - sp_runtime::DispatchError::BadOrigin - ); - }); -} - #[test] fn event_emission_works() { new_test_ext().execute_with(|| { From 85fac141a09732c160dd6038f12ea3168bb58165 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:07:14 -0700 Subject: [PATCH 145/226] fmt --- pallets/commitments/src/lib.rs | 10 +++++----- pallets/commitments/src/tests.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index e5f66c6107..f31310670f 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -300,11 +300,11 @@ pub mod pallet { // #[pallet::call_index(1)] // #[pallet::weight(( // Weight::from_parts(3_596_000, 0) - // .saturating_add(T::DbWeight::get().reads(0_u64)) - // .saturating_add(T::DbWeight::get().writes(1_u64)), - // DispatchClass::Operational, - // Pays::No - // ))] + // .saturating_add(T::DbWeight::get().reads(0_u64)) + // .saturating_add(T::DbWeight::get().writes(1_u64)), + // DispatchClass::Operational, + // Pays::No + // ))] // pub fn set_rate_limit(origin: OriginFor, rate_limit_blocks: u32) -> DispatchResult { // ensure_root(origin)?; // RateLimit::::set(rate_limit_blocks.into()); diff --git a/pallets/commitments/src/tests.rs b/pallets/commitments/src/tests.rs index f3b7a26bbb..5d28e0733b 100644 --- a/pallets/commitments/src/tests.rs +++ b/pallets/commitments/src/tests.rs @@ -3,8 +3,8 @@ use sp_std::prelude::*; #[cfg(test)] use crate::{ - CommitmentInfo, CommitmentOf, Config, Data, Error, Event, MaxSpace, Pallet, - Registration, RevealedCommitments, TimelockedIndex, UsedSpaceOf, + CommitmentInfo, CommitmentOf, Config, Data, Error, Event, MaxSpace, Pallet, Registration, + RevealedCommitments, TimelockedIndex, UsedSpaceOf, mock::{ Balances, DRAND_QUICKNET_SIG_2000_HEX, DRAND_QUICKNET_SIG_HEX, RuntimeEvent, RuntimeOrigin, Test, TestMaxFields, insert_drand_pulse, new_test_ext, produce_ciphertext, From ef47e7a1413a41af62d9d31b5212a504b9e8db12 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:16:17 -0700 Subject: [PATCH 146/226] remove deprecated benchmark --- pallets/commitments/src/benchmarking.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pallets/commitments/src/benchmarking.rs b/pallets/commitments/src/benchmarking.rs index fc1f5f92a4..e66f2a07e8 100644 --- a/pallets/commitments/src/benchmarking.rs +++ b/pallets/commitments/src/benchmarking.rs @@ -55,16 +55,6 @@ mod benchmarks { ); } - #[benchmark] - fn set_rate_limit() { - let new_limit: u32 = 42; - - #[extrinsic_call] - _(RawOrigin::Root, new_limit); - - assert_eq!(RateLimit::::get(), new_limit.into()); - } - #[benchmark] fn set_max_space() { let new_space: u32 = 1_000; From 5a6acbf61ca8576eccccf07a131a2eb5205bcbf1 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:21:19 -0700 Subject: [PATCH 147/226] add migrate_remove_commitments_rate_limit --- pallets/subtensor/src/macros/hooks.rs | 4 +- .../migrate_remove_commitments_rate_limit.rs | 51 +++++++++++++++++++ pallets/subtensor/src/migrations/mod.rs | 1 + 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index ce798456cf..78de392218 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -100,7 +100,9 @@ mod hooks { // Set subtoken enabled for all existed subnets .saturating_add(migrations::migrate_set_subtoken_enabled::migrate_set_subtoken_enabled::()) // Remove all entries in TotalHotkeyColdkeyStakesThisInterval - .saturating_add(migrations::migrate_remove_total_hotkey_coldkey_stakes_this_interval::migrate_remove_total_hotkey_coldkey_stakes_this_interval::()); + .saturating_add(migrations::migrate_remove_total_hotkey_coldkey_stakes_this_interval::migrate_remove_total_hotkey_coldkey_stakes_this_interval::()) + // Wipe the deprecated RateLimit storage item in the commitments pallet + .saturating_add(migrations::migrate_remove_commitments_rate_limit::migrate_remove_commitments_rate_limit::()); weight // Remove all entries in orphaned storage items diff --git a/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs b/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs new file mode 100644 index 0000000000..6ed3e3605e --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs @@ -0,0 +1,51 @@ +use super::*; +use crate::HasMigrationRun; +use frame_support::{traits::Get, weights::Weight}; +use scale_info::prelude::string::String; +use sp_io::{KillStorageResult, hashing::twox_128, storage::clear_prefix}; + +pub fn migrate_remove_commitments_rate_limit() -> Weight { + let migration_name = b"migrate_remove_commitments_rate_limit".to_vec(); + let mut weight = T::DbWeight::get().reads(1); + if HasMigrationRun::::get(&migration_name) { + log::info!("Migration '{:?}' has already run. Skipping.", migration_name); + return weight; + } + + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + // ------------------------------------------------------------- + // Step 1: Remove all entries under the `RateLimit` storage key + // ------------------------------------------------------------- + let mut rate_limit_prefix = Vec::new(); + rate_limit_prefix.extend_from_slice(&twox_128("Commitments".as_bytes())); + rate_limit_prefix.extend_from_slice(&twox_128("RateLimit".as_bytes())); + + let removal_result = clear_prefix(&rate_limit_prefix, Some(u32::MAX)); + let removed_entries = match removal_result { + KillStorageResult::AllRemoved(removed) => removed as u64, + KillStorageResult::SomeRemaining(removed) => { + log::warn!("Failed to remove some `RateLimit` entries."); + removed as u64 + } + }; + + weight = weight.saturating_add(T::DbWeight::get().writes(removed_entries)); + log::info!("Removed {} entries from `RateLimit`.", removed_entries); + + // ------------------------------------------------------------- + // Step 2: Mark this migration as completed + // ------------------------------------------------------------- + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed successfully.", + String::from_utf8_lossy(&migration_name) + ); + + weight +} diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index 064662db25..cf66b387fd 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -32,6 +32,7 @@ pub mod migrate_to_v2_fixed_total_stake; pub mod migrate_total_issuance; pub mod migrate_transfer_ownership_to_foundation; pub mod migrate_upgrade_revealed_commitments; +pub mod migrate_remove_commitments_rate_limit; pub(crate) fn migrate_storage( migration_name: &'static str, From 17715c13f72eb90dca65ce815f2aa63961f07127 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:30:54 -0700 Subject: [PATCH 148/226] add test_migrate_remove_commitments_rate_limit --- pallets/subtensor/src/tests/migration.rs | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index 100bbed24e..e0421b6cff 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -767,3 +767,56 @@ fn test_remove_storage_item Weight>( assert!(!weight.is_zero(), "Migration weight should be non-zero."); }); } + +#[test] +fn test_migrate_remove_commitments_rate_limit() { + new_test_ext(1).execute_with(|| { + // ------------------------------ + // Step 1: Simulate Old Storage Entry + // ------------------------------ + const MIGRATION_NAME: &str = "migrate_remove_commitments_rate_limit"; + + // Build the raw storage key: twox128("Commitments") ++ twox128("RateLimit") + let pallet_prefix = twox_128("Commitments".as_bytes()); + let storage_prefix = twox_128("RateLimit".as_bytes()); + + let mut key = Vec::new(); + key.extend_from_slice(&pallet_prefix); + key.extend_from_slice(&storage_prefix); + + let original_value: u64 = 123; + put_raw(&key, &original_value.encode()); + + let stored_before = get_raw(&key).expect("Expected RateLimit to exist"); + assert_eq!( + u64::decode(&mut &stored_before[..]).expect("Failed to decode RateLimit"), + original_value + ); + + assert!( + !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should not have run yet" + ); + + // ------------------------------ + // Step 2: Run the Migration + // ------------------------------ + let weight = crate::migrations::migrate_remove_commitments_rate_limit:: + migrate_remove_commitments_rate_limit::(); + + assert!( + HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should be marked as completed" + ); + + // ------------------------------ + // Step 3: Verify Migration Effects + // ------------------------------ + assert!( + get_raw(&key).is_none(), + "RateLimit storage should have been cleared" + ); + + assert!(!weight.is_zero(), "Migration weight should be non-zero"); + }); +} \ No newline at end of file From 6f57b8cb5d5170c88218bcb339274bcc17d725a4 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:31:04 -0700 Subject: [PATCH 149/226] fmt --- .../src/migrations/migrate_remove_commitments_rate_limit.rs | 5 ++++- pallets/subtensor/src/migrations/mod.rs | 2 +- pallets/subtensor/src/tests/migration.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs b/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs index 6ed3e3605e..b32d4edc9f 100644 --- a/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs +++ b/pallets/subtensor/src/migrations/migrate_remove_commitments_rate_limit.rs @@ -8,7 +8,10 @@ pub fn migrate_remove_commitments_rate_limit() -> Weight { let migration_name = b"migrate_remove_commitments_rate_limit".to_vec(); let mut weight = T::DbWeight::get().reads(1); if HasMigrationRun::::get(&migration_name) { - log::info!("Migration '{:?}' has already run. Skipping.", migration_name); + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); return weight; } diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index cf66b387fd..5c6347034f 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -15,6 +15,7 @@ pub mod migrate_init_total_issuance; pub mod migrate_orphaned_storage_items; pub mod migrate_populate_owned_hotkeys; pub mod migrate_rao; +pub mod migrate_remove_commitments_rate_limit; pub mod migrate_remove_stake_map; pub mod migrate_remove_total_hotkey_coldkey_stakes_this_interval; pub mod migrate_remove_unused_maps_and_values; @@ -32,7 +33,6 @@ pub mod migrate_to_v2_fixed_total_stake; pub mod migrate_total_issuance; pub mod migrate_transfer_ownership_to_foundation; pub mod migrate_upgrade_revealed_commitments; -pub mod migrate_remove_commitments_rate_limit; pub(crate) fn migrate_storage( migration_name: &'static str, diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index e0421b6cff..1dfac06ad5 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -819,4 +819,4 @@ fn test_migrate_remove_commitments_rate_limit() { assert!(!weight.is_zero(), "Migration weight should be non-zero"); }); -} \ No newline at end of file +} From 0ac6ea8abfa7857384d188c4e358de941656a869 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:41:57 -0700 Subject: [PATCH 150/226] remove rate limit config --- pallets/commitments/src/lib.rs | 4 ---- pallets/commitments/src/mock.rs | 1 - runtime/src/lib.rs | 2 -- 3 files changed, 7 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index f31310670f..d894d71b8f 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -68,10 +68,6 @@ pub mod pallet { #[pallet::constant] type FieldDeposit: Get>; - /// The rate limit for commitments - #[pallet::constant] - type DefaultRateLimit: Get>; - /// Used to retreive the given subnet's tempo type TempoInterface: GetTempoInterface; } diff --git a/pallets/commitments/src/mock.rs b/pallets/commitments/src/mock.rs index a5e9f1c4be..8f9dbb4e5f 100644 --- a/pallets/commitments/src/mock.rs +++ b/pallets/commitments/src/mock.rs @@ -100,7 +100,6 @@ impl pallet_commitments::Config for Test { type CanCommit = TestCanCommit; type FieldDeposit = ConstU64<0>; type InitialDeposit = ConstU64<0>; - type DefaultRateLimit = ConstU64<0>; type TempoInterface = MockTempoInterface; } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4d7ddf58ba..2c1a11d94b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -955,7 +955,6 @@ parameter_types! { pub const MaxCommitFieldsInner: u32 = 1; pub const CommitmentInitialDeposit: Balance = 0; // Free pub const CommitmentFieldDeposit: Balance = 0; // Free - pub const CommitmentRateLimit: BlockNumber = 100; // Allow commitment every 100 blocks } #[subtensor_macros::freeze_struct("7c76bd954afbb54e")] @@ -991,7 +990,6 @@ impl pallet_commitments::Config for Runtime { type MaxFields = MaxCommitFields; type InitialDeposit = CommitmentInitialDeposit; type FieldDeposit = CommitmentFieldDeposit; - type DefaultRateLimit = CommitmentRateLimit; type TempoInterface = TempoInterface; } From 2db3c7ddb3031e10a86fe6c7d02ac703fde35fe3 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:44:59 -0700 Subject: [PATCH 151/226] clippy --- pallets/commitments/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index d894d71b8f..23f9ca5a1f 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -292,7 +292,7 @@ pub mod pallet { Ok(()) } - /// Sudo-set the commitment rate limit + // /// Sudo-set the commitment rate limit // #[pallet::call_index(1)] // #[pallet::weight(( // Weight::from_parts(3_596_000, 0) From 84d185a4c09df62d73f0edf4c859198b037f2011 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:48:49 -0700 Subject: [PATCH 152/226] don't fully remove --- pallets/commitments/src/lib.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 23f9ca5a1f..34bf27566a 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -292,20 +292,20 @@ pub mod pallet { Ok(()) } - // /// Sudo-set the commitment rate limit - // #[pallet::call_index(1)] - // #[pallet::weight(( - // Weight::from_parts(3_596_000, 0) - // .saturating_add(T::DbWeight::get().reads(0_u64)) - // .saturating_add(T::DbWeight::get().writes(1_u64)), - // DispatchClass::Operational, - // Pays::No - // ))] - // pub fn set_rate_limit(origin: OriginFor, rate_limit_blocks: u32) -> DispatchResult { - // ensure_root(origin)?; - // RateLimit::::set(rate_limit_blocks.into()); - // Ok(()) - // } + /// *DEPRECATED* Sudo-set the commitment rate limit + #[pallet::call_index(1)] + #[pallet::weight(( + Weight::from_parts(3_596_000, 0) + .saturating_add(T::DbWeight::get().reads(0_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::No + ))] + pub fn set_rate_limit(origin: OriginFor, _rate_limit_blocks: u32) -> DispatchResult { + ensure_root(origin)?; + // RateLimit::::set(rate_limit_blocks.into()); + Ok(()) + } /// Sudo-set MaxSpace #[pallet::call_index(2)] From 759052ef91b33949b4b9937d20194df12b9e491c Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 5 May 2025 10:52:08 -0700 Subject: [PATCH 153/226] ci: bump CI From e3156db4b943995a5c159c5ac9d2e4cd66954a33 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 5 May 2025 15:33:25 -0400 Subject: [PATCH 154/226] add to StakingHotkeys on inc stake --- pallets/subtensor/src/staking/stake_utils.rs | 21 ++++----- pallets/subtensor/src/tests/staking.rs | 47 ++++++++++++++++++++ 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index a928c53e31..6a5d98476f 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -571,6 +571,14 @@ impl Pallet { netuid: u16, amount: u64, ) -> u64 { + if amount > 0 { + let mut staking_hotkeys = StakingHotkeys::::get(coldkey); + if !staking_hotkeys.contains(hotkey) { + staking_hotkeys.push(hotkey.clone()); + StakingHotkeys::::insert(coldkey, staking_hotkeys.clone()); + } + } + let mut alpha_share_pool = Self::get_alpha_share_pool(hotkey.clone(), netuid); // We expect to add a positive amount here. let actual_alpha = alpha_share_pool.update_value_for_one(coldkey, amount as i64); @@ -848,16 +856,9 @@ impl Pallet { actual_alpha = Self::increase_stake_for_hotkey_and_coldkey_on_subnet( hotkey, coldkey, netuid, alpha, ); - - // Step 4: Update the list of hotkeys staking for this coldkey - let mut staking_hotkeys = StakingHotkeys::::get(coldkey); - if !staking_hotkeys.contains(hotkey) { - staking_hotkeys.push(hotkey.clone()); - StakingHotkeys::::insert(coldkey, staking_hotkeys.clone()); - } } - // Step 5. Increase Tao reserves by the fee amount. + // Step 4. Increase Tao reserves by the fee amount. SubnetTAO::::mutate(netuid, |total| { *total = total.saturating_add(actual_fee); }); @@ -866,7 +867,7 @@ impl Pallet { }); LastColdkeyHotkeyStakeBlock::::insert(coldkey, hotkey, Self::get_current_block_as_u64()); - // Step 6. Deposit and log the staking event. + // Step 5. Deposit and log the staking event. Self::deposit_event(Event::StakeAdded( coldkey.clone(), hotkey.clone(), @@ -885,7 +886,7 @@ impl Pallet { actual_fee ); - // Step 7: Return the amount of alpha staked + // Step 6: Return the amount of alpha staked actual_alpha } diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index 8e9bf6fe09..8172cab9da 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -6111,3 +6111,50 @@ fn test_unstake_all_aggregate_fails() { })); }); } + +#[test] +fn test_increase_stake_for_hotkey_and_coldkey_on_subnet_adds_to_staking_hotkeys_map() { + new_test_ext(1).execute_with(|| { + let coldkey = U256::from(1); + let coldkey1 = U256::from(2); + let hotkey = U256::from(3); + + let netuid = 1; + let stake_amount = 100_000_000_000; + + // Check no entry in the staking hotkeys map + assert!(!StakingHotkeys::::contains_key(coldkey)); + // insert manually + StakingHotkeys::::insert(coldkey, Vec::::new()); + // check entry has no hotkey + assert!(!StakingHotkeys::::get(coldkey).contains(&hotkey)); + + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey, + &coldkey, + netuid, + stake_amount, + ); + + // Check entry exists in the staking hotkeys map + assert!(StakingHotkeys::::contains_key(coldkey)); + // check entry has hotkey + assert!(StakingHotkeys::::get(coldkey).contains(&hotkey)); + + // Check no entry in the staking hotkeys map for coldkey1 + assert!(!StakingHotkeys::::contains_key(coldkey1)); + + // Run increase stake for hotkey and coldkey1 on subnet + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey, + &coldkey1, + netuid, + stake_amount, + ); + + // Check entry exists in the staking hotkeys map for coldkey1 + assert!(StakingHotkeys::::contains_key(coldkey1)); + // check entry has hotkey + assert!(StakingHotkeys::::get(coldkey1).contains(&hotkey)); + }); +} From 2ff2b942beaf9241361d13bc7c6e07a0505e2b2c Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 6 May 2025 15:10:49 +0800 Subject: [PATCH 155/226] Ensure we only reset BondsMovingAverage to 975000 only if it exceeds --- .../src/migrations/migrate_reset_bonds_moving_average.rs | 4 ++-- pallets/subtensor/src/migrations/migrate_reset_max_burn.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs index 2e67e456b7..57018a03c5 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs @@ -24,14 +24,14 @@ pub fn migrate_reset_bonds_moving_average() -> Weight { ); // ------------------------------ - // Step 1: Reset all subnet's BondsMovingAverage to 975000 + // Step 1: Reset all subnet's BondsMovingAverage to 975000 if the value exceeds 975000 // ------------------------------ let mut reset_entries_count = 0u64; for netuid in BondsMovingAverage::::iter_keys() { BondsMovingAverage::::mutate(netuid, |average| { - *average = 975000; + *average = average.min(975000); }); reset_entries_count = reset_entries_count.saturating_add(1); } diff --git a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs index 5cc5f2987b..d5b85ad189 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs @@ -40,7 +40,7 @@ pub fn migrate_reset_max_burn() -> Weight { .saturating_add(T::DbWeight::get().reads_writes(reset_entries_count, reset_entries_count)); log::info!( - "Reset {} subnets from BondsMovingAverage.", + "Reset {} subnets from MaxBurn.", reset_entries_count ); From 6f49d8361edfc62a17b6e47fa8ce2435cb11693d Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 09:39:30 +0200 Subject: [PATCH 156/226] reapply Cargo.lock from devnet-ready --- Cargo.lock | 2341 ++++++++++++++++++++-------------------------------- 1 file changed, 915 insertions(+), 1426 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b49d3ec79..65578627f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,11 +23,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.2" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ - "gimli 0.31.1", + "gimli 0.31.0", ] [[package]] @@ -77,7 +77,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.16", + "getrandom", "once_cell", "version_check", ] @@ -89,10 +89,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.16", + "getrandom", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.21" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -142,44 +142,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "once_cell", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "approx" @@ -201,7 +200,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -294,7 +293,7 @@ dependencies = [ "blake2 0.10.6", "derivative", "digest 0.10.7", - "sha2 0.10.9", + "sha2 0.10.8", "tracing", ] @@ -568,7 +567,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -584,7 +583,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -608,8 +607,8 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", - "synstructure 0.13.2", + "syn 2.0.90", + "synstructure 0.13.1", ] [[package]] @@ -631,7 +630,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -653,9 +652,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.4.0" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" +checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" dependencies = [ "async-lock", "cfg-if", @@ -664,7 +663,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 0.38.44", + "rustix 0.38.37", "slab", "tracing", "windows-sys 0.59.0", @@ -676,20 +675,20 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.3.1", "event-listener-strategy", "pin-project-lite", ] [[package]] name = "async-trait" -version = "0.1.88" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -733,13 +732,13 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.3.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -754,11 +753,11 @@ version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ - "addr2line 0.24.2", + "addr2line 0.24.1", "cfg-if", "libc", "miniz_oxide", - "object 0.36.7", + "object 0.36.4", "rustc-demangle", "windows-targets 0.52.6", ] @@ -795,9 +794,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.7.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bincode" @@ -820,13 +819,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.32", + "prettyplease 0.2.22", "proc-macro2", "quote", "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -853,9 +852,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -892,9 +891,9 @@ dependencies = [ [[package]] name = "blake2b_simd" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e903a20b159e944f91ec8499fe1e55651480c541ea0a584f5d967c49ad9d99" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", "arrayvec", @@ -903,9 +902,9 @@ dependencies = [ [[package]] name = "blake2s_simd" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90f7deecfac93095eb874a40febd69427776e24e1bd7f87f33ac62d6f0174df" +checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" dependencies = [ "arrayref", "arrayvec", @@ -914,9 +913,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.8.2" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -945,9 +944,9 @@ dependencies = [ [[package]] name = "bounded-collections" -version = "0.2.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ad8a0bed7827f0b07a5d23cec2e58cc02038a99e4ca81616cb2bb2025f804d" +checksum = "d32385ecb91a31bddaf908e8dcf4a15aef1bcd3913cc03ebfad02ff6d568abc1" dependencies = [ "log", "parity-scale-codec", @@ -981,15 +980,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-slice-cast" -version = "1.2.3" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byte-tools" @@ -999,9 +998,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.23.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -1011,17 +1010,18 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bzip2-sys" -version = "0.1.13+1.0.8" +version = "0.1.11+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" dependencies = [ "cc", + "libc", "pkg-config", ] @@ -1046,9 +1046,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] @@ -1061,10 +1061,10 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.26", + "semver 1.0.23", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -1075,9 +1075,9 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.2.20" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04da6a0d40b948dfc4fa8f5bbf402b0fc1a64a28dbf7d12ffd683550f2c1b63a" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "jobserver", "libc", @@ -1150,9 +1150,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.41" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1160,7 +1160,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link", + "windows-targets 0.52.6", ] [[package]] @@ -1222,9 +1222,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.37" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ "clap_builder", "clap_derive", @@ -1232,9 +1232,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.37" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" dependencies = [ "anstream", "anstyle", @@ -1245,38 +1245,37 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.32" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "codespan-reporting" -version = "0.12.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "serde", "termcolor", "unicode-width", ] [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "combine" @@ -1290,11 +1289,12 @@ dependencies = [ [[package]] name = "comfy-table" -version = "7.1.4" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a65ebfec4fb190b6f90e944a817d60499ee0744e582530e2c9900a22e591d9a" +checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ - "unicode-segmentation", + "strum 0.26.3", + "strum_macros 0.26.4", "unicode-width", ] @@ -1315,15 +1315,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.11" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", + "lazy_static", "libc", - "once_cell", "unicode-width", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -1347,31 +1347,11 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.16", + "getrandom", "once_cell", "tiny-keccak", ] -[[package]] -name = "const_format" -version = "0.2.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - [[package]] name = "constant_time_eq" version = "0.3.1" @@ -1426,9 +1406,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.17" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1557,9 +1537,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1585,15 +1565,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.21" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" @@ -1615,7 +1595,7 @@ checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", "rand_core", - "typenum 1.18.0", + "typenum 1.17.0", ] [[package]] @@ -1671,73 +1651,58 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "cxx" -version = "1.0.158" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a71ea7f29c73f7ffa64c50b83c9fe4d3a6d4be89a86b009eb80d5a6d3429d741" +checksum = "54ccead7d199d584d139148b04b4a368d1ec7556a1d9ea2548febb1b9d49f9a4" dependencies = [ "cc", - "cxxbridge-cmd", "cxxbridge-flags", "cxxbridge-macro", - "foldhash", "link-cplusplus", ] [[package]] name = "cxx-build" -version = "1.0.158" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36a8232661d66dcf713394726157d3cfe0a89bfc85f52d6e9f9bbc2306797fe7" +checksum = "c77953e99f01508f89f55c494bfa867171ef3a6c8cea03d26975368f2121a5c1" dependencies = [ "cc", "codespan-reporting", + "once_cell", "proc-macro2", "quote", "scratch", - "syn 2.0.101", -] - -[[package]] -name = "cxxbridge-cmd" -version = "1.0.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f44296c8693e9ea226a48f6a122727f77aa9e9e338380cb021accaeeb7ee279" -dependencies = [ - "clap", - "codespan-reporting", - "proc-macro2", - "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "cxxbridge-flags" -version = "1.0.158" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f69c181c176981ae44ba9876e2ea41ce8e574c296b38d06925ce9214fb8e4" +checksum = "65777e06cc48f0cb0152024c77d6cf9e4bdb4408e7b48bea993d42fa0f5b02b6" [[package]] name = "cxxbridge-macro" -version = "1.0.158" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8faff5d4467e0709448187df29ccbf3b0982cc426ee444a193f87b11afb565a8" +checksum = "98532a60dedaebc4848cb2cba5023337cc9ea3af16a5b062633fabfd9f18fb60" dependencies = [ "proc-macro2", "quote", - "rustversion", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "darling" -version = "0.20.11" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -1745,27 +1710,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -1783,15 +1748,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.9.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "data-encoding-macro" -version = "0.1.18" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47ce6c96ea0102f01122a185683611bd5ac8d99e62bc59dd12e6bda344ee673d" +checksum = "f1559b6cba622276d6d63706db152618eeb15b89b3e4041446b05876e352e639" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1799,19 +1764,19 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.16" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976" +checksum = "332d754c0af53bc87c108fed664d121ecf59207ec4196041f04d6ab9002ad33f" dependencies = [ "data-encoding", - "syn 2.0.101", + "syn 1.0.109", ] [[package]] name = "der" -version = "0.7.10" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -1847,9 +1812,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.0" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", "serde", @@ -1874,40 +1839,20 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "derive_more" -version = "0.99.20" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.101", -] - -[[package]] -name = "derive_more" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -1996,23 +1941,23 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "docify" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a772b62b1837c8f060432ddcc10b17aae1453ef17617a99bc07789252d2a5896" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" dependencies = [ "docify_macros", ] [[package]] name = "docify_macros" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e6be249b0a462a14784a99b19bf35a667bb5e09de611738bb7362fa4c95ff7" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" dependencies = [ "common-path", "derive-syn-parse", @@ -2020,9 +1965,9 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.101", + "syn 2.0.90", "termcolor", - "toml 0.8.22", + "toml 0.8.19", "walkdir", ] @@ -2040,15 +1985,15 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dtoa" -version = "1.0.10" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6add3b8cff394282be81f3fc1a0605db594ed69890078ca6e2cab1c408bcf04" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" -version = "0.9.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a36efbb9bfd58e1723780aa04b61aba95ace6a05d9ffabfdb0b43672552f0805" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" dependencies = [ "dyn-clonable-impl", "dyn-clone", @@ -2056,20 +2001,20 @@ dependencies = [ [[package]] name = "dyn-clonable-impl" -version = "0.9.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8671d54058979a37a26f3511fbf8d198ba1aa35ffb202c42587d918d77213a" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 1.0.109", ] [[package]] name = "dyn-clone" -version = "1.0.19" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "ecdsa" @@ -2106,7 +2051,7 @@ dependencies = [ "ed25519", "rand_core", "serde", - "sha2 0.10.9", + "sha2 0.10.8", "subtle 2.6.1", "zeroize", ] @@ -2122,15 +2067,15 @@ dependencies = [ "hashbrown 0.14.5", "hex", "rand_core", - "sha2 0.10.9", + "sha2 0.10.8", "zeroize", ] [[package]] name = "either" -version = "1.15.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" dependencies = [ "serde", ] @@ -2157,9 +2102,9 @@ dependencies = [ [[package]] name = "encode_unicode" -version = "1.0.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "enum-as-inner" @@ -2182,27 +2127,27 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "enumflags2" -version = "0.7.11" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" +checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.11" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" +checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -2226,18 +2171,18 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "equivalent" -version = "1.0.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.11" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -2248,9 +2193,9 @@ checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash", - "impl-codec 0.6.0", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", "tiny-keccak", ] @@ -2281,12 +2226,12 @@ checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash", - "impl-codec 0.6.0", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", - "primitive-types 0.12.2", + "impl-serde", + "primitive-types", "scale-info", - "uint 0.9.5", + "uint", ] [[package]] @@ -2297,9 +2242,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.4.0" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", @@ -2308,11 +2253,11 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.3.1", "pin-project-lite", ] @@ -2330,7 +2275,7 @@ dependencies = [ "evm-runtime", "log", "parity-scale-codec", - "primitive-types 0.12.2", + "primitive-types", "rlp", "scale-info", "serde", @@ -2344,7 +2289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1da6cedc5cedb4208e59467106db0d1f50db01b920920589f8e672c02fdc04f" dependencies = [ "parity-scale-codec", - "primitive-types 0.12.2", + "primitive-types", "scale-info", "serde", ] @@ -2358,7 +2303,7 @@ dependencies = [ "environmental", "evm-core", "evm-runtime", - "primitive-types 0.12.2", + "primitive-types", ] [[package]] @@ -2370,7 +2315,7 @@ dependencies = [ "auto_impl", "environmental", "evm-core", - "primitive-types 0.12.2", + "primitive-types", "sha3", ] @@ -2392,10 +2337,10 @@ dependencies = [ "blake2 0.10.6", "file-guard", "fs-err", - "prettyplease 0.2.32", + "prettyplease 0.2.22", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -2412,9 +2357,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fastrand" -version = "2.3.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fc-api" @@ -2441,7 +2386,7 @@ dependencies = [ "sp-block-builder", "sp-consensus", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -2547,7 +2492,7 @@ dependencies = [ "sp-storage 21.0.0", "sp-timestamp", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -2590,14 +2535,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "ff" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core", "subtle 2.6.1", @@ -2643,9 +2588,9 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.16.3" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f8f43dc520133541781ec03a8cab158ae8b7f7169cdf22e9050aa6cf0fbdfc" +checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" dependencies = [ "either", "futures", @@ -2703,9 +2648,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.5" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" [[package]] name = "foreign-types" @@ -2746,7 +2691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9" dependencies = [ "nonempty", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -2755,7 +2700,7 @@ version = "1.0.0-dev" source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" dependencies = [ "hex", - "impl-serde 0.4.0", + "impl-serde", "libsecp256k1", "log", "parity-scale-codec", @@ -2845,9 +2790,9 @@ dependencies = [ [[package]] name = "fragile" -version = "2.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dd6caf6059519a65843af8fe2a3ae298b14b80179855aeb4adc2c1934ee619" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" @@ -2919,7 +2864,7 @@ dependencies = [ "sp-storage 21.0.0", "sp-trie", "sp-wasm-interface 21.0.1", - "thiserror 1.0.69", + "thiserror", "thousands", ] @@ -3022,11 +2967,11 @@ dependencies = [ "frame-support-procedural-tools 13.0.0", "itertools 0.11.0", "macro_magic", - "proc-macro-warning 1.84.1", + "proc-macro-warning 1.0.2", "proc-macro2", "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -3036,10 +2981,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3363df38464c47a73eb521a4f648bfcc7537a82d70347ef8af3f73b6d019e910" dependencies = [ "frame-support-procedural-tools-derive 11.0.0", - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -3048,10 +2993,10 @@ version = "13.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ "frame-support-procedural-tools-derive 12.0.0", - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -3062,7 +3007,7 @@ checksum = "68672b9ec6fe72d259d3879dc212c5e42e977588cdac830c76f54d9f492aeb58" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -3072,7 +3017,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -3227,9 +3172,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.6.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "futures-core", "pin-project-lite", @@ -3243,7 +3188,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -3307,7 +3252,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ - "typenum 1.18.0", + "typenum 1.17.0", ] [[package]] @@ -3316,7 +3261,7 @@ version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "typenum 1.18.0", + "typenum 1.17.0", "version_check", "zeroize", ] @@ -3333,25 +3278,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.3.2" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasi", ] [[package]] @@ -3397,15 +3330,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "glob" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "governor" @@ -3450,7 +3383,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.9.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -3459,17 +3392,17 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.9" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "http 1.3.1", - "indexmap 2.9.0", + "http 1.1.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -3493,7 +3426,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -3541,9 +3474,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -3561,11 +3494,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.10.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ - "hashbrown 0.15.3", + "hashbrown 0.14.5", ] [[package]] @@ -3592,12 +3525,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" -[[package]] -name = "hermit-abi" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" - [[package]] name = "hex" version = "0.4.3" @@ -3660,11 +3587,22 @@ dependencies = [ [[package]] name = "home" -version = "0.5.11" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", ] [[package]] @@ -3680,9 +3618,9 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -3707,27 +3645,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.3.1", + "http 1.1.0", ] [[package]] name = "http-body-util" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", - "http 1.3.1", + "futures-util", + "http 1.1.0", "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.10.1" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -3737,15 +3675,15 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" -version = "2.2.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.32" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -3758,7 +3696,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -3767,15 +3705,15 @@ dependencies = [ [[package]] name = "hyper" -version = "1.6.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.9", - "http 1.3.1", + "h2 0.4.6", + "http 1.1.0", "http-body 1.0.1", "httparse", "httpdate", @@ -3793,7 +3731,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.30", "log", "rustls 0.21.12", "rustls-native-certs", @@ -3803,15 +3741,15 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.11" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-util", - "http 1.3.1", + "http 1.1.0", "http-body 1.0.1", - "hyper 1.6.0", + "hyper 1.5.0", "pin-project-lite", "tokio", "tower-service", @@ -3819,17 +3757,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.63" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", - "log", "wasm-bindgen", - "windows-core 0.61.0", + "windows-core 0.52.0", ] [[package]] @@ -3841,124 +3778,6 @@ dependencies = [ "cc", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" - -[[package]] -name = "icu_properties" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -3988,23 +3807,12 @@ dependencies = [ [[package]] name = "idna" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" -dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -4019,9 +3827,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.2.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf9d64cfcf380606e64f9a0bcf493616b65331199f984151a6fa11a7b3cde38" +checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io", "core-foundation", @@ -4030,10 +3838,6 @@ dependencies = [ "if-addrs", "ipnet", "log", - "netlink-packet-core", - "netlink-packet-route", - "netlink-proto", - "netlink-sys", "rtnetlink", "system-configuration", "tokio", @@ -4051,7 +3855,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.30", "log", "rand", "tokio", @@ -4068,26 +3872,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-codec" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d40b9d5e17727407e55028eafc22b2dc68781786e6d7eb8a21103f5058e3a14" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-num-traits" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "803d15461ab0dcc56706adf266158acbc44ccf719bf7d0af30705f58b90a4b8c" -dependencies = [ - "integer-sqrt", - "num-traits", - "uint 0.10.0", -] - [[package]] name = "impl-rlp" version = "0.3.0" @@ -4106,24 +3890,15 @@ dependencies = [ "serde", ] -[[package]] -name = "impl-serde" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 1.0.109", ] [[package]] @@ -4158,19 +3933,19 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.9.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.3", + "hashbrown 0.15.2", ] [[package]] name = "inout" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ "generic-array 0.14.7", ] @@ -4216,7 +3991,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.9", + "socket2 0.5.7", "widestring", "windows-sys 0.48.0", "winreg", @@ -4224,19 +3999,19 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.11.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-terminal" -version = "0.4.16" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi 0.5.0", + "hermit-abi 0.4.0", "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -4274,35 +4049,33 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.33" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ - "getrandom 0.3.2", "libc", ] [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ - "once_cell", "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.24.9" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b26c20e2178756451cfeb0661fb74c47dd5988cb7e3939de7e9241fd604d42" +checksum = "c5c71d8c1a731cc4227c2f698d377e7848ca12c8a48866fc5e6951c43a4db843" dependencies = [ "jsonrpsee-core", "jsonrpsee-proc-macros", @@ -4314,51 +4087,51 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.24.9" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456196007ca3a14db478346f58c7238028d55ee15c1df15115596e411ff27925" +checksum = "f2882f6f8acb9fdaec7cefc4fd607119a9bd709831df7d7672a1d3b644628280" dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.3.1", + "http 1.1.0", "http-body 1.0.1", "http-body-util", "jsonrpsee-types", "parking_lot 0.12.3", "rand", - "rustc-hash 2.1.1", + "rustc-hash 2.0.0", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.24.9" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e65763c942dfc9358146571911b0cd1c361c2d63e2d2305622d40d36376ca80" +checksum = "c06c01ae0007548e73412c08e2285ffe5d723195bf268bce67b1b77c3bb2a14d" dependencies = [ "heck 0.5.0", - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "jsonrpsee-server" -version = "0.24.9" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e363146da18e50ad2b51a0a7925fc423137a0b1371af8235b1c231a0647328" +checksum = "82ad8ddc14be1d4290cd68046e7d1d37acd408efed6d3ca08aefcc3ad6da069c" dependencies = [ "futures-util", - "http 1.3.1", + "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.5.0", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", @@ -4367,7 +4140,7 @@ dependencies = [ "serde", "serde_json", "soketto", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", "tokio-util", @@ -4377,14 +4150,14 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.24.9" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a8e70baf945b6b5752fc8eb38c918a48f1234daf11355e07106d963f860089" +checksum = "a178c60086f24cc35bb82f57c651d0d25d99c4742b4d335de04e97fa1f08a8a1" dependencies = [ - "http 1.3.1", + "http 1.1.0", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -4398,7 +4171,7 @@ dependencies = [ "elliptic-curve", "once_cell", "serdect", - "sha2 0.10.9", + "sha2 0.10.8", ] [[package]] @@ -4463,15 +4236,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.172" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libloading" -version = "0.8.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -4479,9 +4252,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.13" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9627da5196e5d8ed0b0495e61e518847578da83483c37288316d9b2e03a7f72" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" @@ -4493,7 +4266,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.16", + "getrandom", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4517,7 +4290,7 @@ dependencies = [ "multiaddr 0.18.2", "pin-project", "rw-stream-sink", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -4558,7 +4331,7 @@ dependencies = [ "libp2p-identity", "log", "multiaddr 0.18.2", - "multihash 0.19.3", + "multihash 0.19.2", "multistream-select", "once_cell", "parking_lot 0.12.3", @@ -4567,7 +4340,7 @@ dependencies = [ "rand", "rw-stream-sink", "smallvec", - "thiserror 1.0.69", + "thiserror", "unsigned-varint 0.7.2", "void", ] @@ -4607,24 +4380,24 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "smallvec", - "thiserror 1.0.69", + "thiserror", "void", ] [[package]] name = "libp2p-identity" -version = "0.2.11" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb68ea10844211a59ce46230909fd0ea040e8a192454d4cc2ee0d53e12280eb" +checksum = "55cca1eb2bc1fd29f099f3daaab7effd01e1a54b7c577d0ed082521034d912e8" dependencies = [ "bs58 0.5.1", "ed25519-dalek", "hkdf", - "multihash 0.19.3", + "multihash 0.19.2", "quick-protobuf", "rand", - "sha2 0.10.9", - "thiserror 2.0.12", + "sha2 0.10.8", + "thiserror", "tracing", "zeroize", ] @@ -4650,10 +4423,10 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "rand", - "sha2 0.10.9", + "sha2 0.10.8", "smallvec", - "thiserror 1.0.69", - "uint 0.9.5", + "thiserror", + "uint", "unsigned-varint 0.7.2", "void", ] @@ -4673,7 +4446,7 @@ dependencies = [ "log", "rand", "smallvec", - "socket2 0.5.9", + "socket2 0.5.7", "tokio", "trust-dns-proto 0.22.0", "void", @@ -4709,14 +4482,14 @@ dependencies = [ "libp2p-identity", "log", "multiaddr 0.18.2", - "multihash 0.19.3", + "multihash 0.19.2", "once_cell", "quick-protobuf", "rand", - "sha2 0.10.9", + "sha2 0.10.8", "snow", "static_assertions", - "thiserror 1.0.69", + "thiserror", "x25519-dalek", "zeroize", ] @@ -4758,8 +4531,8 @@ dependencies = [ "rand", "ring 0.16.20", "rustls 0.21.12", - "socket2 0.5.9", - "thiserror 1.0.69", + "socket2 0.5.7", + "thiserror", "tokio", ] @@ -4814,7 +4587,7 @@ dependencies = [ "proc-macro-warning 0.4.2", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -4830,7 +4603,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "log", - "socket2 0.5.9", + "socket2 0.5.7", "tokio", ] @@ -4848,7 +4621,7 @@ dependencies = [ "ring 0.16.20", "rustls 0.21.12", "rustls-webpki", - "thiserror 1.0.69", + "thiserror", "x509-parser 0.15.1", "yasna", ] @@ -4899,7 +4672,7 @@ dependencies = [ "pin-project-lite", "rw-stream-sink", "soketto", - "thiserror 1.0.69", + "thiserror", "url", "webpki-roots", ] @@ -4913,7 +4686,7 @@ dependencies = [ "futures", "libp2p-core", "log", - "thiserror 1.0.69", + "thiserror", "yamux", ] @@ -4923,9 +4696,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", "libc", - "redox_syscall 0.5.11", + "redox_syscall 0.5.7", ] [[package]] @@ -4959,7 +4732,7 @@ dependencies = [ "rand", "serde", "sha2 0.9.9", - "typenum 1.18.0", + "typenum 1.17.0", ] [[package]] @@ -5004,9 +4777,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.22" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "pkg-config", @@ -5015,9 +4788,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.10" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6f6da007f968f9def0d65a05b187e2960183de70c160204ecfccf0ee330212" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -5030,18 +4803,18 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linked_hash_set" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae85b5be22d9843c80e5fc80e9b64c8a3b1f98f867c709956eca3efff4e92e2" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" dependencies = [ "linked-hash-map", ] [[package]] name = "linregress" -version = "0.5.4" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9eda9dcf4f2a99787827661f312ac3219292549c2ee992bf9a6248ffb066bf7" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" dependencies = [ "nalgebra", ] @@ -5054,15 +4827,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - -[[package]] -name = "linux-raw-sys" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lioness" @@ -5076,12 +4843,6 @@ dependencies = [ "keystream", ] -[[package]] -name = "litemap" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" - [[package]] name = "litep2p" version = "0.6.2" @@ -5096,7 +4857,7 @@ dependencies = [ "futures", "futures-timer", "hex-literal", - "indexmap 2.9.0", + "indexmap 2.6.0", "libc", "mockall 0.12.1", "multiaddr 0.17.1", @@ -5113,21 +4874,21 @@ dependencies = [ "ring 0.16.20", "rustls 0.20.9", "serde", - "sha2 0.10.9", + "sha2 0.10.8", "simple-dns", "smallvec", "snow", - "socket2 0.5.9", + "socket2 0.5.7", "static_assertions", "str0m", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", "tokio-tungstenite", "tokio-util", "tracing", "trust-dns-resolver", - "uint 0.9.5", + "uint", "unsigned-varint 0.8.0", "url", "webpki", @@ -5149,9 +4910,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.27" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" @@ -5168,7 +4929,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.3", + "hashbrown 0.15.2", ] [[package]] @@ -5182,9 +4943,9 @@ dependencies = [ [[package]] name = "lz4" -version = "1.28.1" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20b523e860d03443e98350ceaac5e71c6ba89aea7d960769ec3ce37f4de5af4" +checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725" dependencies = [ "lz4-sys", ] @@ -5217,7 +4978,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -5231,7 +4992,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -5242,7 +5003,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -5253,9 +5014,15 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.101", + "syn 2.0.90", ] +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matchers" version = "0.1.0" @@ -5293,7 +5060,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.44", + "rustix 0.38.37", ] [[package]] @@ -5366,21 +5133,22 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.8" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi 0.3.9", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.52.0", ] @@ -5405,7 +5173,7 @@ dependencies = [ "rand_chacha", "rand_distr", "subtle 2.6.1", - "thiserror 1.0.69", + "thiserror", "zeroize", ] @@ -5435,7 +5203,7 @@ dependencies = [ "fragile", "lazy_static", "mockall_derive 0.12.1", - "predicates 3.1.3", + "predicates 3.1.2", "predicates-tree", ] @@ -5460,7 +5228,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -5493,7 +5261,7 @@ dependencies = [ "data-encoding", "libp2p-identity", "multibase", - "multihash 0.19.3", + "multihash 0.19.2", "percent-encoding", "serde", "static_assertions", @@ -5524,7 +5292,7 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.9", + "sha2 0.10.8", "sha3", "unsigned-varint 0.7.2", ] @@ -5541,16 +5309,16 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.9", + "sha2 0.10.8", "sha3", "unsigned-varint 0.7.2", ] [[package]] name = "multihash" -version = "0.19.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b430e7953c29dd6a09afc29ff0bb69c6e306329ee6794700aee27b76a1aea8d" +checksum = "cc41f430805af9d1cf4adae4ed2149c759b877b01d909a1f40256188d09345d2" dependencies = [ "core2", "unsigned-varint 0.8.0", @@ -5576,12 +5344,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "multimap" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" - [[package]] name = "multistream-select" version = "0.13.0" @@ -5598,17 +5360,29 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.33.2" +version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26aecdf64b707efd1310e3544d709c5c0ac61c13756046aaaba41be5c4f66a3b" +checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4" dependencies = [ "approx", "matrixmultiply", + "nalgebra-macros", "num-complex", "num-rational", "num-traits", "simba", - "typenum 1.18.0", + "typenum 1.17.0", +] + +[[package]] +name = "nalgebra-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -5622,9 +5396,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.14" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ "libc", "log", @@ -5652,20 +5426,21 @@ dependencies = [ [[package]] name = "netlink-packet-core" -version = "0.7.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" +checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" dependencies = [ "anyhow", "byteorder", + "libc", "netlink-packet-utils", ] [[package]] name = "netlink-packet-route" -version = "0.17.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053998cea5a306971f88580d0829e90f270f940befd7cf928da179d4187a5a66" +checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", "bitflags 1.3.2", @@ -5684,28 +5459,29 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "netlink-proto" -version = "0.11.5" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72452e012c2f8d612410d89eea01e2d9b56205274abb35d53f60200b2ec41d60" +checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ "bytes", "futures", "log", "netlink-packet-core", "netlink-sys", - "thiserror 2.0.12", + "thiserror", + "tokio", ] [[package]] name = "netlink-sys" -version = "0.8.7" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23" +checksum = "416060d346fbaf1f23f9512963e3e878f1a78e707cb699ba9215761754244307" dependencies = [ "bytes", "futures", @@ -5722,15 +5498,15 @@ checksum = "a4a43439bf756eed340bdf8feba761e2d50c7d47175d87545cd5cbe4a137c4d1" dependencies = [ "cc", "libc", - "thiserror 1.0.69", + "thiserror", "winapi", ] [[package]] name = "nix" -version = "0.26.4" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -5822,7 +5598,7 @@ dependencies = [ "subtensor-custom-rpc", "subtensor-custom-rpc-runtime-api", "subtensor-runtime-common", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -5843,7 +5619,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "getrandom 0.2.16", + "getrandom", "hex", "log", "pallet-admin-utils", @@ -5881,7 +5657,7 @@ dependencies = [ "rand_chacha", "scale-info", "serde_json", - "sha2 0.10.9", + "sha2 0.10.8", "smallvec", "sp-api", "sp-block-builder", @@ -6066,10 +5842,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -6095,9 +5871,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.7" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -6122,9 +5898,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "opaque-debug" @@ -6144,7 +5923,7 @@ version = "0.10.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -6161,29 +5940,29 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.5.0+3.5.0" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ce546f549326b0e6052b649198487d91320875da901e7bd11a06d1ee3f9c2f" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.108" +version = "0.9.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" +checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" dependencies = [ "cc", "libc", @@ -6324,7 +6103,7 @@ dependencies = [ "parity-scale-codec", "rand_chacha", "scale-info", - "sha2 0.10.9", + "sha2 0.10.8", "sp-core", "sp-io", "sp-runtime", @@ -6373,7 +6152,7 @@ dependencies = [ "scale-info", "serde", "serde_json", - "sha2 0.10.9", + "sha2 0.10.8", "sp-ark-bls12-381", "sp-core", "sp-io", @@ -6719,7 +6498,7 @@ dependencies = [ "serde_bytes", "serde_json", "serde_with", - "sha2 0.10.9", + "sha2 0.10.8", "share-pool", "sp-core", "sp-io", @@ -6880,31 +6659,29 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.7.4" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fde3d0718baf5bc92f577d652001da0f8d54cd03a7974e118d04fc888dc23d" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", "byte-slice-cast", "bytes", - "const_format", "impl-trait-for-tuples", "parity-scale-codec-derive", - "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.7.4" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581c837bb6b9541ce7faa9377c20616e4fb7650f6b0f68bc93c827ee504fb7b3" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 1.0.109", ] [[package]] @@ -6920,7 +6697,7 @@ dependencies = [ "lru 0.8.1", "parity-util-mem-derive", "parking_lot 0.12.3", - "primitive-types 0.12.2", + "primitive-types", "smallvec", "winapi", ] @@ -6991,7 +6768,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.11", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -7052,20 +6829,20 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.8.0" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", - "thiserror 2.0.12", + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.8.0" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" +checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" dependencies = [ "pest", "pest_generator", @@ -7073,26 +6850,26 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.0" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" +checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "pest_meta" -version = "2.8.0" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" +checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" dependencies = [ "once_cell", "pest", - "sha2 0.10.9", + "sha2 0.10.8", ] [[package]] @@ -7102,34 +6879,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.9.0", + "indexmap 2.6.0", ] [[package]] name = "pin-project" -version = "1.1.10" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.10" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -7149,9 +6926,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polkavm" @@ -7162,7 +6939,7 @@ dependencies = [ "libc", "log", "polkavm-assembler", - "polkavm-common 0.9.0", + "polkavm-common", "polkavm-linux-raw", ] @@ -7184,28 +6961,13 @@ dependencies = [ "log", ] -[[package]] -name = "polkavm-common" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ff33982a807d8567645d4784b9b5d7ab87bcb494f534a57cadd9012688e102" - [[package]] name = "polkavm-derive" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" dependencies = [ - "polkavm-derive-impl-macro 0.9.0", -] - -[[package]] -name = "polkavm-derive" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2eb703f3b6404c13228402e98a5eae063fd16b8f58afe334073ec105ee4117e" -dependencies = [ - "polkavm-derive-impl-macro 0.18.0", + "polkavm-derive-impl-macro", ] [[package]] @@ -7214,22 +6976,10 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" dependencies = [ - "polkavm-common 0.9.0", + "polkavm-common", "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "polkavm-derive-impl" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f2116a92e6e96220a398930f4c8a6cda1264206f3e2034fc9982bfd93f261f7" -dependencies = [ - "polkavm-common 0.18.0", - "proc-macro2", - "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -7238,18 +6988,8 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ - "polkavm-derive-impl 0.9.0", - "syn 2.0.101", -] - -[[package]] -name = "polkavm-derive-impl-macro" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c16669ddc7433e34c1007d31080b80901e3e8e523cb9d4b441c3910cf9294b" -dependencies = [ - "polkavm-derive-impl 0.18.1", - "syn 2.0.101", + "polkavm-derive-impl", + "syn 2.0.90", ] [[package]] @@ -7262,7 +7002,7 @@ dependencies = [ "hashbrown 0.14.5", "log", "object 0.32.2", - "polkavm-common 0.9.0", + "polkavm-common", "regalloc2 0.9.3", "rustc-demangle", ] @@ -7275,15 +7015,15 @@ checksum = "26e85d3456948e650dff0cfc85603915847faf893ed1e66b020bb82ef4557120" [[package]] name = "polling" -version = "3.7.4" +version = "3.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" +checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.44", + "rustix 0.38.37", "tracing", "windows-sys 0.59.0", ] @@ -7313,9 +7053,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.11.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -7325,11 +7065,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.21" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.8.25", + "zerocopy", ] [[package]] @@ -7363,7 +7103,7 @@ source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac88233 dependencies = [ "case", "num_enum", - "prettyplease 0.2.32", + "prettyplease 0.2.22", "proc-macro2", "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", @@ -7386,9 +7126,9 @@ dependencies = [ [[package]] name = "predicates" -version = "3.1.3" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "predicates-core", @@ -7396,15 +7136,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.9" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" [[package]] name = "predicates-tree" -version = "1.0.12" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" dependencies = [ "predicates-core", "termtree", @@ -7422,12 +7162,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.32" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -7437,23 +7177,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", - "impl-codec 0.6.0", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", - "uint 0.9.5", -] - -[[package]] -name = "primitive-types" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" -dependencies = [ - "fixed-hash", - "impl-codec 0.7.1", - "impl-num-traits", - "uint 0.10.0", + "uint", ] [[package]] @@ -7462,15 +7190,15 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "thiserror 1.0.69", + "thiserror", "toml 0.5.11", ] [[package]] name = "proc-macro-crate" -version = "3.3.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] @@ -7507,25 +7235,25 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "proc-macro-warning" -version = "1.84.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75eea531cfcd120e0851a3f8aed42c4841f78c889eefafd96339c72677ae42c3" +checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -7541,12 +7269,12 @@ dependencies = [ "frame-support-procedural-tools 10.0.0", "itertools 0.10.5", "macro_magic", - "proc-macro-warning 1.84.1", + "proc-macro-warning 1.0.2", "proc-macro2", "quote", "regex", "sp-crypto-hashing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -7560,7 +7288,7 @@ dependencies = [ "lazy_static", "memchr", "parking_lot 0.12.3", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -7583,7 +7311,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -7617,7 +7345,7 @@ dependencies = [ "itertools 0.10.5", "lazy_static", "log", - "multimap 0.8.3", + "multimap", "petgraph", "prettyplease 0.1.25", "prost 0.11.9", @@ -7638,14 +7366,14 @@ dependencies = [ "heck 0.5.0", "itertools 0.12.1", "log", - "multimap 0.10.0", + "multimap", "once_cell", "petgraph", - "prettyplease 0.2.32", + "prettyplease 0.2.22", "prost 0.12.6", "prost-types 0.12.6", "regex", - "syn 2.0.101", + "syn 2.0.90", "tempfile", ] @@ -7672,7 +7400,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -7695,28 +7423,34 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.26" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e944464ec8536cd1beb0bbfd96987eb5e3b72f2ecdafdc5c769a37f1fa2ae1f" +checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" dependencies = [ "cc", ] [[package]] name = "quanta" -version = "0.12.5" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd1fe6824cea6538803de3ff1bc0cf3949024db3d43c9643024bfb33a807c0e" +checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" dependencies = [ "crossbeam-utils", "libc", "once_cell", "raw-cpuid", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "web-sys", "winapi", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quick-protobuf" version = "0.8.1" @@ -7735,7 +7469,7 @@ dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", - "thiserror 1.0.69", + "thiserror", "unsigned-varint 0.7.2", ] @@ -7751,7 +7485,7 @@ dependencies = [ "quinn-udp 0.3.2", "rustc-hash 1.1.0", "rustls 0.20.9", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", "webpki", @@ -7770,7 +7504,7 @@ dependencies = [ "quinn-udp 0.4.1", "rustc-hash 1.1.0", "rustls 0.21.12", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", ] @@ -7787,7 +7521,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.20.9", "slab", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tracing", "webpki", @@ -7805,7 +7539,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.21.12", "slab", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tracing", ] @@ -7831,26 +7565,20 @@ checksum = "055b4e778e8feb9f93c4e439f71dc2156ef13360b432b799e179a8c4cdf0b1d7" dependencies = [ "bytes", "libc", - "socket2 0.5.9", + "socket2 0.5.7", "tracing", "windows-sys 0.48.0", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" - [[package]] name = "radium" version = "0.7.0" @@ -7884,7 +7612,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.16", + "getrandom", ] [[package]] @@ -7908,11 +7636,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.5.0" +version = "11.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6df7ab838ed27997ba19a4664507e6f82b41fe6e20be42929332156e5e85146" +checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", ] [[package]] @@ -7964,11 +7692,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.11" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", ] [[package]] @@ -7977,29 +7705,29 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.16", + "getrandom", "libredox", - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.24" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.24" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -8029,13 +7757,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.9", + "regex-automata 0.4.8", "regex-syntax 0.8.5", ] @@ -8050,9 +7778,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -8073,9 +7801,13 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "resolv-conf" -version = "0.7.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7c8f7f733062b66dc1c63f9db168ac0b97a9210e247fa90fdc9ad08f51b302" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] [[package]] name = "rfc6979" @@ -8104,13 +7836,13 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.14" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.16", + "getrandom", "libc", "untrusted 0.9.0", "windows-sys 0.52.0", @@ -8165,41 +7897,38 @@ checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746" [[package]] name = "rpassword" -version = "7.4.0" +version = "7.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d4c8b64f049c6721ec8ccec37ddfc3d641c4a7fca57e8f2a89de509c73df39" +checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f" dependencies = [ "libc", "rtoolbox", - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] name = "rtnetlink" -version = "0.13.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a552eb82d19f38c3beed3f786bd23aa434ceb9ac43ab44419ca6d67a7e186c0" +checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" dependencies = [ "futures", "log", - "netlink-packet-core", "netlink-packet-route", - "netlink-packet-utils", "netlink-proto", - "netlink-sys", "nix", - "thiserror 1.0.69", + "thiserror", "tokio", ] [[package]] name = "rtoolbox" -version = "0.0.3" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cc970b249fbe527d6e02e0a227762c9108b2f49d81094fe357ffc6d14d7f6f" +checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] @@ -8216,9 +7945,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.1.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc-hex" @@ -8241,7 +7970,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.26", + "semver 1.0.23", ] [[package]] @@ -8269,28 +7998,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.9.0", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - -[[package]] -name = "rustix" -version = "1.0.7" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.9.4", - "windows-sys 0.59.0", + "linux-raw-sys 0.4.14", + "windows-sys 0.52.0", ] [[package]] @@ -8311,7 +8027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", - "ring 0.17.14", + "ring 0.17.13", "rustls-webpki", "sct", ] @@ -8343,15 +8059,15 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.14", + "ring 0.17.13", "untrusted 0.9.0", ] [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "rw-stream-sink" @@ -8366,9 +8082,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe-math" @@ -8390,9 +8106,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323" +checksum = "c3460605018fdc9612bce72735cba0d27efbcd9904780d44c7e3a9948f96148a" dependencies = [ "bytemuck", ] @@ -8414,7 +8130,7 @@ dependencies = [ "log", "sp-core", "sp-wasm-interface 21.0.1", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8486,10 +8202,10 @@ name = "sc-chain-spec-derive" version = "12.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -8529,7 +8245,7 @@ dependencies = [ "sp-panic-handler", "sp-runtime", "sp-version", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -8607,7 +8323,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8636,7 +8352,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8672,7 +8388,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8729,7 +8445,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8749,7 +8465,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8784,7 +8500,7 @@ dependencies = [ "sp-runtime", "sp-timestamp", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8842,7 +8558,7 @@ dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface 21.0.1", - "thiserror 1.0.69", + "thiserror", "wasm-instrument", ] @@ -8903,7 +8619,7 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-keystore", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8932,7 +8648,7 @@ dependencies = [ "sp-keystore", "sp-mixnet", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8977,7 +8693,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", "unsigned-varint 0.7.2", @@ -9041,7 +8757,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9076,7 +8792,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", ] @@ -9111,9 +8827,9 @@ dependencies = [ "litep2p", "log", "multiaddr 0.18.2", - "multihash 0.19.3", + "multihash 0.19.2", "rand", - "thiserror 1.0.69", + "thiserror", "zeroize", ] @@ -9127,7 +8843,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "hyper 0.14.32", + "hyper 0.14.30", "hyper-rustls", "log", "num_cpus", @@ -9209,7 +8925,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9221,9 +8937,9 @@ dependencies = [ "forwarded-header-value", "futures", "governor", - "http 1.3.1", + "http 1.1.0", "http-body-util", - "hyper 1.6.0", + "hyper 1.5.0", "ip_network", "jsonrpsee", "log", @@ -9263,7 +8979,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", ] @@ -9326,7 +9042,7 @@ dependencies = [ "static_init", "substrate-prometheus-endpoint", "tempfile", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", "tracing-futures", @@ -9348,7 +9064,7 @@ name = "sc-sysinfo" version = "38.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "derive_more 0.99.20", + "derive_more", "futures", "libc", "log", @@ -9380,7 +9096,7 @@ dependencies = [ "sc-utils", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", "wasm-timer", ] @@ -9407,10 +9123,10 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-tracing 17.0.1", - "thiserror 1.0.69", + "thiserror", "tracing", "tracing-log", - "tracing-subscriber 0.3.19", + "tracing-subscriber 0.3.18", ] [[package]] @@ -9418,10 +9134,10 @@ name = "sc-tracing-proc-macro" version = "11.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -9448,7 +9164,7 @@ dependencies = [ "sp-tracing 17.0.1", "sp-transaction-pool", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9464,7 +9180,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9498,7 +9214,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" dependencies = [ - "derive_more 0.99.20", + "derive_more", "parity-scale-codec", "scale-bits", "scale-type-resolver", @@ -9507,13 +9223,13 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.6" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "bitvec", "cfg-if", - "derive_more 1.0.0", + "derive_more", "parity-scale-codec", "scale-info-derive", "serde", @@ -9521,14 +9237,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.6" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 1.0.109", ] [[package]] @@ -9539,18 +9255,18 @@ checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "schnellru" -version = "0.2.4" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" +checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" dependencies = [ "ahash 0.8.11", "cfg-if", @@ -9571,7 +9287,7 @@ dependencies = [ "merlin", "rand_core", "serde_bytes", - "sha2 0.10.9", + "sha2 0.10.8", "subtle 2.6.1", "zeroize", ] @@ -9584,9 +9300,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scratch" -version = "1.0.8" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f6280af86e5f559536da57a45ebc84948833b3bee313a7dd25232e09c878a52" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -9594,7 +9310,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.14", + "ring 0.17.13", "untrusted 0.9.0", ] @@ -9610,7 +9326,7 @@ dependencies = [ "log", "rand", "slab", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9661,7 +9377,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -9670,9 +9386,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -9698,9 +9414,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.26" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -9719,9 +9435,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -9737,9 +9453,9 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.17" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] @@ -9756,20 +9472,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -9823,7 +9539,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -9883,9 +9599,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.9" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -9928,9 +9644,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.5" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -9947,9 +9663,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.9.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -9964,7 +9680,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cae9a3fcdadafb6d97f4c0e007e4247b114ee0f119f650c3cbf3a8b3a1479694" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", ] [[package]] @@ -9996,9 +9712,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.15.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snap" @@ -10017,9 +9733,9 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek", "rand_core", - "ring 0.17.14", + "ring 0.17.13", "rustc_version 0.4.1", - "sha2 0.10.9", + "sha2 0.10.8", "subtle 2.6.1", ] @@ -10035,9 +9751,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.9" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -10045,14 +9761,14 @@ dependencies = [ [[package]] name = "soketto" -version = "0.8.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721" +checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ "base64 0.22.1", "bytes", "futures", - "http 1.3.1", + "http 1.1.0", "httparse", "log", "rand", @@ -10078,7 +9794,7 @@ dependencies = [ "sp-state-machine", "sp-trie", "sp-version", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10089,10 +9805,10 @@ dependencies = [ "Inflector", "blake2 0.10.6", "expander", - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -10124,7 +9840,7 @@ dependencies = [ [[package]] name = "sp-ark-bls12-381" version = "0.4.2" -source = "git+https://github.com/paritytech/substrate-curves#f08093a5f7c32778eae1295430ec064dccd062a6" +source = "git+https://github.com/paritytech/substrate-curves#caa2eed74beb885dd07c7db5f916f2281dad818f" dependencies = [ "ark-bls12-381-ext", "sp-crypto-ec-utils 0.10.0", @@ -10155,7 +9871,7 @@ dependencies = [ "sp-database", "sp-runtime", "sp-state-machine", - "thiserror 1.0.69", + "thiserror", "tracing", ] @@ -10171,7 +9887,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10251,7 +9967,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.4.0", + "impl-serde", "itertools 0.11.0", "k256", "libsecp256k1", @@ -10261,7 +9977,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", "paste", - "primitive-types 0.12.2", + "primitive-types", "rand", "scale-info", "schnorrkel", @@ -10276,7 +9992,7 @@ dependencies = [ "sp-storage 21.0.0", "ss58-registry", "substrate-bip39", - "thiserror 1.0.69", + "thiserror", "tracing", "w3f-bls", "zeroize", @@ -10285,7 +10001,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -10331,7 +10047,7 @@ dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.9", + "sha2 0.10.8", "sha3", "twox-hash", ] @@ -10344,7 +10060,7 @@ dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.9", + "sha2 0.10.8", "sha3", "twox-hash", ] @@ -10356,7 +10072,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -10375,23 +10091,23 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "environmental", "parity-scale-codec", @@ -10430,7 +10146,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10444,7 +10160,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", - "polkavm-derive 0.9.1", + "polkavm-derive", "rustversion", "secp256k1", "sp-core", @@ -10485,7 +10201,7 @@ name = "sp-maybe-compressed-blob" version = "11.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "thiserror 1.0.69", + "thiserror", "zstd 0.12.4", ] @@ -10569,13 +10285,13 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive 0.18.0", - "primitive-types 0.13.1", + "polkavm-derive", + "primitive-types", "sp-externalities 0.25.0", "sp-runtime-interface-proc-macro 17.0.0", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk)", @@ -10593,8 +10309,8 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive 0.9.1", - "primitive-types 0.12.2", + "polkavm-derive", + "primitive-types", "sp-externalities 0.29.0", "sp-runtime-interface-proc-macro 18.0.0", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", @@ -10607,14 +10323,14 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "Inflector", "expander", - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -10624,10 +10340,10 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "Inflector", "expander", - "proc-macro-crate 3.3.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -10672,7 +10388,7 @@ dependencies = [ "sp-externalities 0.29.0", "sp-panic-handler", "sp-trie", - "thiserror 1.0.69", + "thiserror", "tracing", "trie-db", ] @@ -10689,7 +10405,7 @@ dependencies = [ "parity-scale-codec", "rand", "scale-info", - "sha2 0.10.9", + "sha2 0.10.8", "sp-api", "sp-application-crypto", "sp-core", @@ -10697,7 +10413,7 @@ dependencies = [ "sp-externalities 0.29.0", "sp-runtime", "sp-runtime-interface 28.0.0", - "thiserror 1.0.69", + "thiserror", "x25519-dalek", ] @@ -10709,14 +10425,14 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ - "impl-serde 0.5.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -10728,7 +10444,7 @@ name = "sp-storage" version = "21.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -10744,18 +10460,18 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber 0.3.19", + "tracing-subscriber 0.3.18", ] [[package]] @@ -10766,7 +10482,7 @@ dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber 0.3.19", + "tracing-subscriber 0.3.18", ] [[package]] @@ -10809,7 +10525,7 @@ dependencies = [ "schnellru", "sp-core", "sp-externalities 0.29.0", - "thiserror 1.0.69", + "thiserror", "tracing", "trie-db", "trie-root", @@ -10820,7 +10536,7 @@ name = "sp-version" version = "37.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "parity-wasm", "scale-info", @@ -10829,7 +10545,7 @@ dependencies = [ "sp-runtime", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", "sp-version-proc-macro", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10840,13 +10556,13 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#03f3c2991d1175913bf9d66e0e5b54e543a34ca4" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -10914,11 +10630,21 @@ dependencies = [ "der", ] +[[package]] +name = "sqlformat" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790" +dependencies = [ + "nom", + "unicode_categories", +] + [[package]] name = "sqlx" -version = "0.8.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c3a85280daca669cfd3bcb68a337882a8bc57ec882f72c5d13a430613a738e" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" dependencies = [ "sqlx-core", "sqlx-macros", @@ -10927,32 +10653,37 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.8.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f743f2a3cea30a58cd479013f75550e879009e3a02f616f18ca699335aa248c3" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" dependencies = [ - "base64 0.22.1", + "atoi", + "byteorder", "bytes", "crc", "crossbeam-queue", "either", - "event-listener 5.4.0", + "event-listener 5.3.1", + "futures-channel", "futures-core", "futures-intrusive", "futures-io", "futures-util", - "hashbrown 0.15.3", - "hashlink 0.10.0", - "indexmap 2.9.0", + "hashbrown 0.14.5", + "hashlink 0.9.1", + "hex", + "indexmap 2.6.0", "log", "memchr", "native-tls", "once_cell", + "paste", "percent-encoding", "serde", - "sha2 0.10.9", + "sha2 0.10.8", "smallvec", - "thiserror 2.0.12", + "sqlformat", + "thiserror", "tokio", "tokio-stream", "tracing", @@ -10961,22 +10692,22 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.8.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4200e0fde19834956d4252347c12a083bdcb237d7a1a1446bffd8768417dce" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" dependencies = [ "proc-macro2", "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "sqlx-macros-core" -version = "0.8.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882ceaa29cade31beca7129b6beeb05737f44f82dbe2a9806ecea5a7093d00b7" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" dependencies = [ "dotenvy", "either", @@ -10987,10 +10718,10 @@ dependencies = [ "quote", "serde", "serde_json", - "sha2 0.10.9", + "sha2 0.10.8", "sqlx-core", "sqlx-sqlite", - "syn 2.0.101", + "syn 2.0.90", "tempfile", "tokio", "url", @@ -10998,9 +10729,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.8.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c26083e9a520e8eb87a06b12347679b142dc2ea29e6e409f805644a7a979a5bc" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" dependencies = [ "atoi", "flume", @@ -11015,16 +10746,15 @@ dependencies = [ "serde", "serde_urlencoded", "sqlx-core", - "thiserror 2.0.12", "tracing", "url", ] [[package]] name = "ss58-registry" -version = "1.51.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19409f13998e55816d1c728395af0b52ec066206341d939e22e7766df9b494b8" +checksum = "43fce22ed1df64d04b262351c8f9d5c6da4f76f79f25ad15529792f893fad25d" dependencies = [ "Inflector", "num-format", @@ -11083,9 +10813,9 @@ dependencies = [ [[package]] name = "static_init_macro" -version = "1.0.4" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1389c88ddd739ec6d3f8f83343764a0e944cd23cfbf126a9796a714b0b6edd6f" +checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" dependencies = [ "cfg_aliases", "memchr", @@ -11110,7 +10840,7 @@ dependencies = [ "sctp-proto", "serde", "sha-1", - "thiserror 1.0.69", + "thiserror", "tracing", ] @@ -11158,7 +10888,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -11169,7 +10899,7 @@ dependencies = [ "hmac 0.12.1", "pbkdf2", "schnorrkel", - "sha2 0.10.9", + "sha2 0.10.8", "zeroize", ] @@ -11215,11 +10945,11 @@ version = "0.17.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ "http-body-util", - "hyper 1.6.0", + "hyper 1.5.0", "hyper-util", "log", "prometheus", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -11247,7 +10977,7 @@ dependencies = [ "sp-version", "strum 0.26.3", "tempfile", - "toml 0.8.22", + "toml 0.8.19", "walkdir", "wasm-opt", ] @@ -11262,7 +10992,7 @@ dependencies = [ "quote", "rayon", "subtensor-linting", - "syn 2.0.101", + "syn 2.0.90", "walkdir", ] @@ -11300,7 +11030,7 @@ dependencies = [ "proc-macro2", "procedural-fork", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -11310,7 +11040,7 @@ dependencies = [ "ahash 0.8.11", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -11354,7 +11084,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", - "semver 1.0.26", + "semver 1.0.23", "toml_edit", ] @@ -11383,9 +11113,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -11406,31 +11136,31 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "system-configuration" -version = "0.6.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.9.0", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -11450,14 +11180,14 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.19.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ + "cfg-if", "fastrand", - "getrandom 0.3.2", "once_cell", - "rustix 1.0.7", + "rustix 0.38.37", "windows-sys 0.59.0", ] @@ -11472,58 +11202,38 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ - "rustix 1.0.7", + "rustix 0.38.37", "windows-sys 0.59.0", ] [[package]] name = "termtree" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" - -[[package]] -name = "thiserror" -version = "1.0.69" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" -dependencies = [ - "thiserror-impl 2.0.12", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", + "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.12" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -11563,9 +11273,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.41" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -11578,15 +11288,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.22" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -11601,21 +11311,11 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -11649,7 +11349,7 @@ dependencies = [ "serde", "serde_cbor", "serde_json", - "sha2 0.10.9", + "sha2 0.10.8", "sha3", "w3f-bls", ] @@ -11667,7 +11367,7 @@ dependencies = [ "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.9", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.52.0", ] @@ -11680,7 +11380,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -11695,9 +11395,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.17" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -11722,9 +11422,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -11745,9 +11445,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.22" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", @@ -11757,33 +11457,26 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.9" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.26" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.9.0", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", - "toml_write", "winnow", ] -[[package]] -name = "toml_write" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" - [[package]] name = "tower" version = "0.4.13" @@ -11805,9 +11498,9 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.6.0", "bytes", - "http 1.3.1", + "http 1.1.0", "http-body 1.0.1", "http-body-util", "pin-project-lite", @@ -11829,9 +11522,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", @@ -11841,20 +11534,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -11892,9 +11585,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -11950,7 +11643,7 @@ dependencies = [ "rand", "smallvec", "socket2 0.4.10", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tokio", "tracing", @@ -11975,7 +11668,7 @@ dependencies = [ "once_cell", "rand", "smallvec", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tokio", "tracing", @@ -11997,7 +11690,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", "trust-dns-proto 0.23.2", @@ -12030,7 +11723,7 @@ dependencies = [ "rand", "rustls 0.21.12", "sha1", - "thiserror 1.0.69", + "thiserror", "url", "utf-8", ] @@ -12058,9 +11751,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.18.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -12080,29 +11773,17 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "uint" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-bidi" -version = "0.3.18" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -12113,17 +11794,11 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" - [[package]] name = "unicode-width" -version = "0.2.0" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" @@ -12131,6 +11806,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "universal-hash" version = "0.5.1" @@ -12177,12 +11858,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.4" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", - "idna 1.0.3", + "idna 0.5.0", "percent-encoding", ] @@ -12192,18 +11873,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -12212,9 +11881,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" -version = "0.1.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vcpkg" @@ -12252,9 +11921,9 @@ dependencies = [ "rand", "rand_chacha", "rand_core", - "sha2 0.10.9", + "sha2 0.10.8", "sha3", - "thiserror 1.0.69", + "thiserror", "zeroize", ] @@ -12283,59 +11952,49 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", "once_cell", - "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", + "once_cell", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", - "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12343,25 +12002,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" -dependencies = [ - "unicode-ident", -] +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-instrument" @@ -12383,7 +12039,7 @@ dependencies = [ "strum 0.24.1", "strum_macros 0.24.3", "tempfile", - "thiserror 1.0.69", + "thiserror", "wasm-opt-cxx-sys", "wasm-opt-sys", ] @@ -12488,7 +12144,7 @@ dependencies = [ "log", "rustix 0.36.17", "serde", - "sha2 0.10.9", + "sha2 0.10.8", "toml 0.5.11", "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", @@ -12510,7 +12166,7 @@ dependencies = [ "log", "object 0.30.4", "target-lexicon", - "thiserror 1.0.69", + "thiserror", "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", @@ -12545,7 +12201,7 @@ dependencies = [ "object 0.30.4", "serde", "target-lexicon", - "thiserror 1.0.69", + "thiserror", "wasmparser", "wasmtime-types", ] @@ -12628,15 +12284,15 @@ checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", - "thiserror 1.0.69", + "thiserror", "wasmparser", ] [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -12648,7 +12304,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.14", + "ring 0.17.13", "untrusted 0.9.0", ] @@ -12667,14 +12323,14 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.44", + "rustix 0.38.37", ] [[package]] name = "wide" -version = "0.7.32" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b5576b9a81633f3e8df296ce0063042a73507636cbe956c61133dd7034ab22" +checksum = "b828f995bf1e9622031f8009f8481a85406ce1f4d4588ff746d872043e855690" dependencies = [ "bytemuck", "safe_arch", @@ -12682,9 +12338,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" @@ -12719,92 +12375,32 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.53.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc5cf48f83140dcaab716eeaea345f9e93d0018fb81162753a3f76c3397b538" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core 0.53.0", - "windows-targets 0.52.6", + "windows-core 0.51.1", + "windows-targets 0.48.5", ] [[package]] name = "windows-core" -version = "0.53.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcc5b895a6377f1ab9fa55acedab1fd5ac0db66ad1e6c7f47e28a22e446a5dd" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-result 0.1.2", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] name = "windows-core" -version = "0.61.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result 0.3.2", - "windows-strings", -] - -[[package]] -name = "windows-implement" -version = "0.60.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", -] - -[[package]] -name = "windows-interface" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", -] - -[[package]] -name = "windows-link" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" - -[[package]] -name = "windows-result" -version = "0.1.2" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-result" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" -dependencies = [ - "windows-link", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -13036,9 +12632,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.7" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -13053,27 +12649,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags 2.9.0", -] - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "wyz" version = "0.5.1" @@ -13108,7 +12683,7 @@ dependencies = [ "nom", "oid-registry 0.6.1", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -13125,7 +12700,7 @@ dependencies = [ "nom", "oid-registry 0.7.1", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -13137,14 +12712,14 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] name = "xml-rs" -version = "0.8.26" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda" +checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" [[package]] name = "xmltree" @@ -13179,46 +12754,14 @@ dependencies = [ "time", ] -[[package]] -name = "yoke" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", - "synstructure 0.13.2", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy" -version = "0.8.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" -dependencies = [ - "zerocopy-derive 0.8.25", + "byteorder", + "zerocopy-derive", ] [[package]] @@ -13229,39 +12772,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", -] - -[[package]] -name = "zerofrom" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", - "synstructure 0.13.2", + "syn 2.0.90", ] [[package]] @@ -13281,29 +12792,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "zerovec" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", + "syn 2.0.90", ] [[package]] @@ -13346,9 +12835,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.15+zstd.1.5.7" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", From 016e7f3dbdce0eac2faa69349a7d72d8b3658d2e Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 11:00:02 +0200 Subject: [PATCH 157/226] propagate log/std in Cargo.toml --- pallets/crowdloan/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/crowdloan/Cargo.toml b/pallets/crowdloan/Cargo.toml index 3098db490e..e8d582fa44 100644 --- a/pallets/crowdloan/Cargo.toml +++ b/pallets/crowdloan/Cargo.toml @@ -40,6 +40,7 @@ std = [ "sp-runtime/std", "sp-std/std", "sp-io/std", + "log/std", "sp-core/std", "pallet-balances/std", "pallet-preimage/std", From 26652746adf15bf2c8540c1c7b608ea228d537b4 Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 6 May 2025 17:14:51 +0800 Subject: [PATCH 158/226] Fixes --- .../src/migrations/migrate_reset_bonds_moving_average.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs index 57018a03c5..5bb442af18 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs @@ -31,7 +31,7 @@ pub fn migrate_reset_bonds_moving_average() -> Weight { for netuid in BondsMovingAverage::::iter_keys() { BondsMovingAverage::::mutate(netuid, |average| { - *average = average.min(975000); + *average = (*average).min(975000); }); reset_entries_count = reset_entries_count.saturating_add(1); } From d924289a0bec12e33a35ccdd2fcd9e4ab70483cf Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 6 May 2025 17:38:36 +0800 Subject: [PATCH 159/226] cargo fmt --- pallets/subtensor/src/migrations/migrate_reset_max_burn.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs index d5b85ad189..a2662f7de3 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs @@ -39,10 +39,7 @@ pub fn migrate_reset_max_burn() -> Weight { weight = weight .saturating_add(T::DbWeight::get().reads_writes(reset_entries_count, reset_entries_count)); - log::info!( - "Reset {} subnets from MaxBurn.", - reset_entries_count - ); + log::info!("Reset {} subnets from MaxBurn.", reset_entries_count); // ------------------------------ // Step 2: Mark Migration as Completed From 632c1c9918fb67c2fc52eeacf2d38860c505ee3c Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 6 May 2025 14:20:52 +0400 Subject: [PATCH 160/226] Update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 6fff6e5363..637042c456 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1719,9 +1719,9 @@ mod dispatches { /// May emit a `StakeSwapped` event on success. #[pallet::call_index(87)] #[pallet::weight(( - Weight::from_parts(190_100_000, 0) - .saturating_add(T::DbWeight::get().reads(13)) - .saturating_add(T::DbWeight::get().writes(9)), + Weight::from_parts(221_600_000, 0) + .saturating_add(T::DbWeight::get().reads(25)) + .saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::No ))] From 991832c2cad452d206e0cdd47599a6570bf67766 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 6 May 2025 09:20:03 -0400 Subject: [PATCH 161/226] ignore test that takes CLI input --- pallets/subtensor/src/tests/consensus.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/subtensor/src/tests/consensus.rs b/pallets/subtensor/src/tests/consensus.rs index 2e576572cc..e1db49203e 100644 --- a/pallets/subtensor/src/tests/consensus.rs +++ b/pallets/subtensor/src/tests/consensus.rs @@ -484,6 +484,7 @@ fn split_graph( // Map the retention graph for consensus guarantees with an single epoch on a graph with 512 nodes, of which the first 64 are validators, the graph is split into a major and minor set, each setting specific weight on itself and the complement on the other. #[test] +#[ignore] // Not an automated test! fn map_consensus_guarantees() { let netuid: u16 = 1; let network_n: u16 = 512; From 48a87e294480d4b0be2ad178340929aa9da80dcb Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 6 May 2025 19:25:22 +0400 Subject: [PATCH 162/226] Rename error SameSubnetId -> SameNetuid --- pallets/subtensor/src/macros/errors.rs | 2 +- pallets/subtensor/src/staking/stake_utils.rs | 5 +---- pallets/subtensor/src/tests/move_stake.rs | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index 4e6494650a..69a8fe1646 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -213,6 +213,6 @@ mod errors { /// Estimating the maximum stake for limited staking operations returned zero. ZeroMaxStakeAmount, /// Invalid netuid duplication - SameSubnetId, + SameNetuid, } } diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index a793a56edc..65280c8a43 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -1012,10 +1012,7 @@ impl Pallet { ) -> Result<(), Error> { // Ensure stake transition is actually happening if origin_coldkey == destination_coldkey && origin_hotkey == destination_hotkey { - ensure!( - origin_netuid != destination_netuid, - Error::::SameSubnetId - ); + ensure!(origin_netuid != destination_netuid, Error::::SameNetuid); } // Ensure that both subnets exist. diff --git a/pallets/subtensor/src/tests/move_stake.rs b/pallets/subtensor/src/tests/move_stake.rs index 0590fb9a1c..dd85ab9075 100644 --- a/pallets/subtensor/src/tests/move_stake.rs +++ b/pallets/subtensor/src/tests/move_stake.rs @@ -596,7 +596,7 @@ fn test_do_move_same_hotkey_fails() { netuid, alpha, ), - Err(Error::::SameSubnetId.into()) + Err(Error::::SameNetuid.into()) ); // Check that stake remains unchanged @@ -1309,7 +1309,7 @@ fn test_do_swap_same_subnet() { netuid, alpha_before ), - Err(Error::::SameSubnetId.into()) + Err(Error::::SameNetuid.into()) ); let alpha_after = From 08dd35e086c33b2b345842e17ea49ac8cf1ca19a Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 18:07:12 +0200 Subject: [PATCH 163/226] move contributors count to Crowdloan struct and update migration --- pallets/crowdloan/Cargo.toml | 4 +- pallets/crowdloan/src/lib.rs | 34 +--- .../migrate_add_contributors_count.rs | 166 ++++++++++++++---- pallets/crowdloan/src/tests.rs | 87 +++++---- 4 files changed, 181 insertions(+), 110 deletions(-) diff --git a/pallets/crowdloan/Cargo.toml b/pallets/crowdloan/Cargo.toml index e8d582fa44..b662d7269f 100644 --- a/pallets/crowdloan/Cargo.toml +++ b/pallets/crowdloan/Cargo.toml @@ -22,12 +22,12 @@ frame-system.workspace = true sp-runtime.workspace = true sp-std.workspace = true log = { workspace = true } +sp-core = { default-features = true, workspace = true } +sp-io = { default-features = true, workspace = true } [dev-dependencies] pallet-balances = { default-features = true, workspace = true } pallet-preimage = { default-features = true, workspace = true } -sp-core = { default-features = true, workspace = true } -sp-io = { default-features = true, workspace = true } [features] default = ["std"] diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 392413feba..b25807151a 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -51,7 +51,7 @@ pub type BoundedCallOf = Bounded<::RuntimeCall, ::Hashing>; /// A struct containing the information about a crowdloan. -#[freeze_struct("6b86ccf70fc1b8f1")] +#[freeze_struct("5db9538284491545")] #[derive(Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct CrowdloanInfo { /// The creator of the crowdloan. @@ -76,6 +76,8 @@ pub struct CrowdloanInfo { pub call: Option, /// Whether the crowdloan has been finalized. pub finalized: bool, + /// The number of contributors to the crowdloan. + pub contributors_count: u32, } pub type CrowdloanInfoOf = CrowdloanInfo< @@ -166,11 +168,6 @@ pub mod pallet { OptionQuery, >; - /// A map of crowdloan ids to their contributors count. - #[pallet::storage] - pub type ContributorsCount = - StorageMap<_, Twox64Concat, CrowdloanId, u32, OptionQuery>; - /// The current crowdloan id that will be set during the finalize call, making it /// temporarily accessible to the dispatched call. #[pallet::storage] @@ -376,6 +373,7 @@ pub mod pallet { target_address, call, finalized: false, + contributors_count: 1, }; Crowdloans::::insert(crowdloan_id, &crowdloan); @@ -388,7 +386,6 @@ pub mod pallet { )?; Contributions::::insert(crowdloan_id, &creator, deposit); - ContributorsCount::::insert(crowdloan_id, 1); Self::deposit_event(Event::::Created { crowdloan_id, @@ -434,10 +431,8 @@ pub mod pallet { ); // Ensure the crowdloan has not reached the maximum number of contributors - let contributors_count = - ContributorsCount::::get(crowdloan_id).ok_or(Error::::InvalidCrowdloanId)?; ensure!( - contributors_count < T::MaxContributors::get(), + crowdloan.contributors_count < T::MaxContributors::get(), Error::::MaxContributorsReached ); @@ -467,7 +462,7 @@ pub mod pallet { .ok_or(Error::::Overflow)? } else { // We have a new contribution - Self::increment_contributor_count(crowdloan_id); + crowdloan.contributors_count += 1; amount }; @@ -526,7 +521,7 @@ pub mod pallet { Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); } else { Contributions::::remove(crowdloan_id, &who); - Self::decrement_contributor_count(crowdloan_id); + crowdloan.contributors_count -= 1; } CurrencyOf::::transfer( @@ -676,12 +671,12 @@ pub mod pallet { refund_count = refund_count.checked_add(1).ok_or(Error::::Overflow)?; } + crowdloan.contributors_count -= refund_count; Crowdloans::::insert(crowdloan_id, &crowdloan); // Clear refunded contributors for contributor in refunded_contributors { Contributions::::remove(crowdloan_id, &contributor); - Self::decrement_contributor_count(crowdloan_id); } if all_refunded { @@ -744,7 +739,6 @@ pub mod pallet { // Remove the crowdloan let _ = frame_system::Pallet::::dec_providers(&crowdloan.funds_account).defensive(); Crowdloans::::remove(crowdloan_id); - ContributorsCount::::remove(crowdloan_id); Self::deposit_event(Event::::Dissolved { crowdloan_id }); Ok(()) @@ -885,16 +879,4 @@ impl Pallet { ); Ok(()) } - - fn increment_contributor_count(crowdloan_id: CrowdloanId) { - ContributorsCount::::mutate(crowdloan_id, |count| { - *count = count.map(|v| v.saturating_add(1)) - }); - } - - fn decrement_contributor_count(crowdloan_id: CrowdloanId) { - ContributorsCount::::mutate(crowdloan_id, |count| { - *count = count.map(|v| v.saturating_sub(1)) - }); - } } diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 378e8bcc3d..d5fbc4ec97 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -1,8 +1,26 @@ use alloc::string::String; -use frame_support::{BoundedVec, traits::Get, weights::Weight}; +use frame_support::{BoundedVec, migration::storage_key_iter, traits::Get, weights::Weight}; use crate::*; +mod old_storage { + use super::*; + + #[derive(Encode, Decode, Debug)] + pub struct OldCrowdloanInfo { + pub creator: AccountId, + pub deposit: Balance, + pub min_contribution: Balance, + pub end: BlockNumber, + pub cap: Balance, + pub funds_account: AccountId, + pub raised: Balance, + pub target_address: Option, + pub call: Option, + pub finalized: bool, + } +} + pub fn migrate_add_contributors_count() -> Weight { let migration_name = BoundedVec::truncate_from(b"migrate_add_contributors_count".to_vec()); let mut weight = T::DbWeight::get().reads(1); @@ -20,17 +38,44 @@ pub fn migrate_add_contributors_count() -> Weight { String::from_utf8_lossy(&migration_name) ); - // Get all crowdloans, there is not so many at the moment so we are safe. - let crowdloan_ids = Crowdloans::::iter_keys().collect::>(); - weight = weight.saturating_add(T::DbWeight::get().reads(crowdloan_ids.len() as u64)); - - for crowdloan_id in crowdloan_ids { - let contributions = Contributions::::iter_key_prefix(crowdloan_id) + let pallet_name = b"Crowdloan"; + let item_name = b"Crowdloans"; + let crowdloans = storage_key_iter::< + CrowdloanId, + old_storage::OldCrowdloanInfo< + T::AccountId, + BalanceOf, + BlockNumberFor, + BoundedCallOf, + >, + Twox64Concat, + >(pallet_name, item_name) + .collect::>(); + weight = weight.saturating_add(T::DbWeight::get().reads(crowdloans.len() as u64)); + + for (id, crowdloan) in crowdloans { + let contributions = Contributions::::iter_key_prefix(id) .collect::>() .len(); weight = weight.saturating_add(T::DbWeight::get().reads(contributions as u64)); - ContributorsCount::::insert(crowdloan_id, contributions as u32); + Crowdloans::::insert( + id, + CrowdloanInfo { + creator: crowdloan.creator, + deposit: crowdloan.deposit, + min_contribution: crowdloan.min_contribution, + end: crowdloan.end, + cap: crowdloan.cap, + funds_account: crowdloan.funds_account, + raised: crowdloan.raised, + target_address: crowdloan.target_address, + call: crowdloan.call, + finalized: crowdloan.finalized, + contributors_count: contributions as u32, + }, + ); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); } HasMigrationRun::::insert(&migration_name, true); @@ -46,42 +91,93 @@ pub fn migrate_add_contributors_count() -> Weight { #[cfg(test)] mod tests { - use crate::mock::{Test, TestState}; + use frame_support::{Hashable, storage::unhashed::put_raw}; + use sp_core::U256; + use sp_io::hashing::twox_128; use super::*; - use sp_core::U256; + use crate::mock::{Test, TestState}; #[test] fn test_migrate_add_contributors_count_works() { TestState::default().build_and_execute(|| { - Crowdloans::::insert( - 0, - CrowdloanInfo { - creator: U256::from(1), - deposit: 100, - min_contribution: 10, - cap: 1000, - end: 100, - call: None, - finalized: false, - raised: 0, - funds_account: U256::from(2), - target_address: None, - }, - ); - - Contributions::::insert(0, U256::from(1), 100); - Contributions::::insert(0, U256::from(2), 100); - Contributions::::insert(0, U256::from(3), 100); - - assert_eq!(ContributorsCount::::get(0), None); - assert!(!HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - ))); + let pallet_name = twox_128(b"Crowdloan"); + let storage_name = twox_128(b"Crowdloans"); + let prefix = [pallet_name, storage_name].concat(); + + let items = vec![ + ( + old_storage::OldCrowdloanInfo { + creator: U256::from(1), + deposit: 100u64, + min_contribution: 10u64, + end: 100u64, + cap: 1000u64, + funds_account: U256::from(2), + raised: 0u64, + target_address: None, + call: None::>, + finalized: false, + }, + vec![(U256::from(1), 100)], + ), + ( + old_storage::OldCrowdloanInfo { + creator: U256::from(1), + deposit: 100u64, + min_contribution: 10u64, + end: 100u64, + cap: 1000u64, + funds_account: U256::from(2), + raised: 0u64, + target_address: None, + call: None::>, + finalized: false, + }, + vec![ + (U256::from(1), 100), + (U256::from(2), 100), + (U256::from(3), 100), + ], + ), + ( + old_storage::OldCrowdloanInfo { + creator: U256::from(1), + deposit: 100u64, + min_contribution: 10u64, + end: 100u64, + cap: 1000u64, + funds_account: U256::from(2), + raised: 0u64, + target_address: None, + call: None::>, + finalized: false, + }, + vec![ + (U256::from(1), 100), + (U256::from(2), 100), + (U256::from(3), 100), + (U256::from(4), 100), + (U256::from(5), 100), + ], + ), + ]; + + for (id, (crowdloan, contributions)) in items.into_iter().enumerate() { + let key = [prefix.clone(), (id as u32).twox_64_concat()].concat(); + put_raw(&key, &crowdloan.encode()); + + for (contributor, amount) in contributions { + Contributions::::insert(id as u32, contributor, amount); + } + } migrate_add_contributors_count::(); - assert_eq!(ContributorsCount::::get(0), Some(3)); + assert!(Crowdloans::::get(0).is_some_and(|c| c.contributors_count == 1)); + assert!(Crowdloans::::get(1).is_some_and(|c| c.contributors_count == 3)); + assert!(Crowdloans::::get(2).is_some_and(|c| c.contributors_count == 5)); + assert!(HasMigrationRun::::get(BoundedVec::truncate_from( b"migrate_add_contributors_count".to_vec() ))); diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index b978dbadf0..1e03854b1f 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -46,6 +46,7 @@ fn test_create_succeeds() { target_address: None, call: Some(call), finalized: false, + contributors_count: 1, }) ); // ensure the crowdloan account has the deposit @@ -58,11 +59,6 @@ fn test_create_succeeds() { .collect::>(), vec![(creator, deposit)] ); - // ensure the contributor count is updated - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) - ); // ensure the raised amount is updated correctly assert!( pallet_crowdloan::Crowdloans::::get(crowdloan_id) @@ -338,9 +334,9 @@ fn test_contribute_succeeds() { let crowdloan_id: CrowdloanId = 0; // only the creator has contributed so far - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // first contribution to the crowdloan from creator @@ -363,9 +359,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, creator), Some(100) ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); assert_eq!( Balances::free_balance(creator), @@ -393,9 +389,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), Some(100) ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(2) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 2) ); assert_eq!(Balances::free_balance(contributor1), 500 - amount); @@ -420,9 +416,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), Some(50) ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(3) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 3) ); assert_eq!(Balances::free_balance(contributor2), 200 - amount); @@ -824,9 +820,9 @@ fn test_withdraw_from_contributor_succeeds() { run_to_block(60); // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(3) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 3) ); // withdraw from contributor1 @@ -839,9 +835,9 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), None, ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(2) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 2) ); // ensure the contributor1 has the correct amount assert_eq!( @@ -859,9 +855,9 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), None, ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // ensure the contributor2 has the correct amount assert_eq!( @@ -913,9 +909,9 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { )); // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // withdraw @@ -936,9 +932,9 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { Some(initial_deposit), ); // ensure the contributor count hasn't changed because deposit is kept - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // ensure the crowdloan account has the correct amount @@ -1584,9 +1580,9 @@ fn test_refund_succeeds() { } // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(7) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 7) ); // run some more blocks past the end of the contribution period @@ -1599,9 +1595,9 @@ fn test_refund_succeeds() { )); // ensure the contributor count is correct, we processed 5 refunds - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(2) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 2) ); // ensure the crowdloan account has the correct amount @@ -1629,9 +1625,9 @@ fn test_refund_succeeds() { // ensure the contributor count is correct, we processed 1 more refund // keeping deposit - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // ensure the crowdloan account has the correct amount @@ -1765,9 +1761,9 @@ fn test_dissolve_succeeds() { let crowdloan_id: CrowdloanId = 0; // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // dissolve the crowdloan @@ -1784,9 +1780,6 @@ fn test_dissolve_succeeds() { crowdloan_id )); - // ensure the contributor count is removed - assert!(pallet_crowdloan::ContributorsCount::::get(crowdloan_id).is_none()); - // ensure the event is emitted assert_eq!( last_event(), From e79e783765fddb1f606993f6078c74ad9604c956 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 18:26:48 +0200 Subject: [PATCH 164/226] fix benchmark --- pallets/crowdloan/Cargo.toml | 4 ++-- pallets/crowdloan/src/benchmarking.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pallets/crowdloan/Cargo.toml b/pallets/crowdloan/Cargo.toml index b662d7269f..e8d582fa44 100644 --- a/pallets/crowdloan/Cargo.toml +++ b/pallets/crowdloan/Cargo.toml @@ -22,12 +22,12 @@ frame-system.workspace = true sp-runtime.workspace = true sp-std.workspace = true log = { workspace = true } -sp-core = { default-features = true, workspace = true } -sp-io = { default-features = true, workspace = true } [dev-dependencies] pallet-balances = { default-features = true, workspace = true } pallet-preimage = { default-features = true, workspace = true } +sp-core = { default-features = true, workspace = true } +sp-io = { default-features = true, workspace = true } [features] default = ["std"] diff --git a/pallets/crowdloan/src/benchmarking.rs b/pallets/crowdloan/src/benchmarking.rs index e36f792261..0891baf5af 100644 --- a/pallets/crowdloan/src/benchmarking.rs +++ b/pallets/crowdloan/src/benchmarking.rs @@ -68,6 +68,7 @@ mod benchmarks { target_address: Some(target_address.clone()), call: Some(T::Preimages::bound(*call).unwrap()), finalized: false, + contributors_count: 1, }) ); // ensure the creator has been deducted the deposit From 3f565fb3c4d91bfd262e94d5fbce5a4c0fc0e405 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 18:28:28 +0200 Subject: [PATCH 165/226] fix arithmetic --- pallets/crowdloan/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index b25807151a..1d4ed4e263 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -462,7 +462,10 @@ pub mod pallet { .ok_or(Error::::Overflow)? } else { // We have a new contribution - crowdloan.contributors_count += 1; + crowdloan.contributors_count = crowdloan + .contributors_count + .checked_add(1) + .ok_or(Error::::Overflow)?; amount }; @@ -521,7 +524,10 @@ pub mod pallet { Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); } else { Contributions::::remove(crowdloan_id, &who); - crowdloan.contributors_count -= 1; + crowdloan.contributors_count = crowdloan + .contributors_count + .checked_sub(1) + .ok_or(Error::::Underflow)?; } CurrencyOf::::transfer( @@ -671,7 +677,10 @@ pub mod pallet { refund_count = refund_count.checked_add(1).ok_or(Error::::Overflow)?; } - crowdloan.contributors_count -= refund_count; + crowdloan.contributors_count = crowdloan + .contributors_count + .checked_sub(refund_count) + .ok_or(Error::::Underflow)?; Crowdloans::::insert(crowdloan_id, &crowdloan); // Clear refunded contributors From 3bebc53dfbbf1a7846c532f7b57047797f878985 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 6 May 2025 13:36:57 -0400 Subject: [PATCH 166/226] fix name of storage value in evm test --- evm-tests/test/subnet.precompile.hyperparameter.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm-tests/test/subnet.precompile.hyperparameter.test.ts b/evm-tests/test/subnet.precompile.hyperparameter.test.ts index cfd5d6d6d2..57efd64f77 100644 --- a/evm-tests/test/subnet.precompile.hyperparameter.test.ts +++ b/evm-tests/test/subnet.precompile.hyperparameter.test.ts @@ -481,7 +481,7 @@ describe("Test the Subnet precompile contract", () => { const tx = await contract.setYuma3Enabled(netuid, newValue); await tx.wait(); - let onchainValue = await api.query.SubtensorModule.Yuma3Enabled.getValue(netuid) + let onchainValue = await api.query.SubtensorModule.Yuma3On.getValue(netuid) let valueFromContract = Boolean( await contract.getYuma3Enabled(netuid) From a58750fda68f400cec003afd13aa43b913865f13 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 6 May 2025 12:47:30 -0500 Subject: [PATCH 167/226] extend patch step for localnet docker image --- .github/workflows/docker-localnet.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-localnet.yml b/.github/workflows/docker-localnet.yml index 37e82460ff..3f24cd169d 100644 --- a/.github/workflows/docker-localnet.yml +++ b/.github/workflows/docker-localnet.yml @@ -59,7 +59,8 @@ jobs: - name: Patch non-fast-block node run: | - sed -i 's|7 \* 24 \* 60 \* 60 / 12 // 7 days|5 // Only 5 blocks for tests|' runtime/src/lib.rs + perl -0777 -i -pe 's|7 \* 24 \* 60 \* 60 / 12 // 7 days|5 // Only 5 blocks for tests|' runtime/src/lib.rs + perl -0777 -i -pe 's|pub fn DefaultPendingCooldown\(\) -> u64 \{\s*if cfg!\(feature = "fast-blocks"\) \{\s*return 15;\s*\}\s*7_200\s*\}|pub fn DefaultPendingCooldown() -> u64 {\n 15\n }|g' pallets/subtensor/src/lib.rs - name: Build and push Docker image uses: docker/build-push-action@v6 From c9322a0960816b52003b877769fa3021117599d4 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 6 May 2025 13:01:04 -0500 Subject: [PATCH 168/226] bumping spec_version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2c1a11d94b..a70315d324 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -207,7 +207,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 266, + spec_version: 267, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 9a445380156434c1bcd776e525cc04be628c25f2 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 6 May 2025 14:20:14 -0400 Subject: [PATCH 169/226] add set yuma3 enabled to ABI --- evm-tests/src/contracts/subnet.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/evm-tests/src/contracts/subnet.ts b/evm-tests/src/contracts/subnet.ts index 9ddc2da873..eacdaf3aca 100644 --- a/evm-tests/src/contracts/subnet.ts +++ b/evm-tests/src/contracts/subnet.ts @@ -591,6 +591,24 @@ export const ISubnetABI = [ stateMutability: "view", type: "function", }, + { + inputs: [ + { + internalType: "uint16", + name: "netuid", + type: "uint16", + }, + { + internalType: "bool", + name: "yuma3Enabled", + type: "bool", + }, + ], + name: "setYuma3Enabled", + outputs: [], + stateMutability: "payable", + type: "function", + }, { inputs: [ { From 79490d334e99b9308cdb71604c38ae8e5e6aaa1c Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 09:22:46 +0200 Subject: [PATCH 170/226] added freeze_struct to OldCrowdloanInfo --- .../crowdloan/src/migrations/migrate_add_contributors_count.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index d5fbc4ec97..3b094843ce 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -1,11 +1,13 @@ use alloc::string::String; use frame_support::{BoundedVec, migration::storage_key_iter, traits::Get, weights::Weight}; +use subtensor_macros::freeze_struct; use crate::*; mod old_storage { use super::*; + #[freeze_struct("84bcbf9b8d3f0ddf")] #[derive(Encode, Decode, Debug)] pub struct OldCrowdloanInfo { pub creator: AccountId, From d3736c262dacedd09d09ebaf7a06a4f98d39ac0c Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 12:03:56 +0200 Subject: [PATCH 171/226] upgrade polkadot sdk to polkadot-stable2409-7 and frontier to last master commit --- Cargo.lock | 411 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 196 ++++++++++++------------- 2 files changed, 302 insertions(+), 305 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65578627f9..4109abb5bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2364,7 +2364,7 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "async-trait", "fp-storage", @@ -2376,7 +2376,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "async-trait", "fp-consensus", @@ -2392,7 +2392,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "async-trait", "ethereum", @@ -2422,7 +2422,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "fc-db", "fc-storage", @@ -2445,7 +2445,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "ethereum-types", @@ -2468,7 +2468,6 @@ dependencies = [ "rand", "rlp", "sc-client-api", - "sc-consensus-aura", "sc-network", "sc-network-sync", "sc-rpc", @@ -2482,7 +2481,6 @@ dependencies = [ "sp-block-builder", "sp-blockchain", "sp-consensus", - "sp-consensus-aura", "sp-core", "sp-externalities 0.29.0", "sp-inherents", @@ -2490,7 +2488,6 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-storage 21.0.0", - "sp-timestamp", "substrate-prometheus-endpoint", "thiserror", "tokio", @@ -2499,7 +2496,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "ethereum-types", @@ -2508,13 +2505,13 @@ dependencies = [ "rustc-hex", "serde", "serde_json", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", ] [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "ethereum-types", @@ -2670,7 +2667,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", ] @@ -2697,7 +2694,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "hex", "impl-serde", @@ -2716,7 +2713,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "parity-scale-codec", @@ -2727,7 +2724,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "ethereum-types", @@ -2739,7 +2736,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "evm", "frame-support", @@ -2754,7 +2751,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "ethereum-types", @@ -2770,7 +2767,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "frame-support", "parity-scale-codec", @@ -2782,7 +2779,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "parity-scale-codec", "serde", @@ -2797,7 +2794,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-support-procedural", @@ -2821,7 +2818,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "43.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "Inflector", "array-bytes", @@ -2871,7 +2868,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "aquamarine", "frame-support", @@ -2901,7 +2898,7 @@ dependencies = [ [[package]] name = "frame-metadata-hash-extension" version = "0.6.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "docify", @@ -2915,8 +2912,8 @@ dependencies = [ [[package]] name = "frame-support" -version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "38.2.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "aquamarine", "array-bytes", @@ -2939,7 +2936,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-crypto-hashing-proc-macro", - "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-genesis-builder", "sp-inherents", "sp-io", @@ -2947,7 +2944,7 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-state-machine", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-tracing 17.0.1", "sp-weights", "static_assertions", @@ -2956,8 +2953,8 @@ dependencies = [ [[package]] name = "frame-support-procedural" -version = "30.0.3" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "30.0.6" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "Inflector", "cfg-expr", @@ -2970,7 +2967,7 @@ dependencies = [ "proc-macro-warning 1.0.2", "proc-macro2", "quote", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "syn 2.0.90", ] @@ -2990,7 +2987,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support-procedural-tools-derive 12.0.0", "proc-macro-crate 3.2.0", @@ -3013,7 +3010,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "12.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "proc-macro2", "quote", @@ -3023,7 +3020,7 @@ dependencies = [ [[package]] name = "frame-system" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "cfg-if", "docify", @@ -3035,7 +3032,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-version", "sp-weights", ] @@ -3043,7 +3040,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -3057,7 +3054,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "parity-scale-codec", @@ -3067,7 +3064,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "parity-scale-codec", @@ -5669,7 +5666,7 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-storage 21.0.0", "sp-tracing 17.0.1", "sp-transaction-pool", @@ -6004,7 +6001,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-tracing 17.0.1", "sp-weights", "substrate-fixed", @@ -6014,7 +6011,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-system", @@ -6030,7 +6027,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-system", @@ -6042,8 +6039,8 @@ dependencies = [ [[package]] name = "pallet-balances" -version = "39.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "39.0.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "frame-benchmarking", @@ -6058,7 +6055,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "fp-evm", "frame-support", @@ -6082,7 +6079,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "subtensor-macros", ] @@ -6107,7 +6104,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "subtensor-macros", "tle", "w3f-bls", @@ -6127,7 +6124,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "subtensor-macros", ] @@ -6167,7 +6164,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "ethereum", "ethereum-types", @@ -6189,7 +6186,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "environmental", "evm", @@ -6212,7 +6209,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "frame-support", "frame-system", @@ -6223,7 +6220,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "fp-evm", "num", @@ -6232,7 +6229,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "fp-evm", "tiny-keccak", @@ -6241,7 +6238,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "fp-evm", "ripemd", @@ -6251,7 +6248,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -6273,7 +6270,7 @@ dependencies = [ [[package]] name = "pallet-hotfix-sufficients" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "frame-benchmarking", "frame-support", @@ -6288,7 +6285,7 @@ dependencies = [ [[package]] name = "pallet-insecure-randomness-collective-flip" version = "26.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-system", @@ -6301,7 +6298,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -6317,7 +6314,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -6332,7 +6329,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -6365,7 +6362,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -6389,14 +6386,14 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "subtensor-macros", ] [[package]] name = "pallet-root-testing" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-system", @@ -6410,15 +6407,15 @@ dependencies = [ [[package]] name = "pallet-safe-mode" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "frame-benchmarking", "frame-support", "frame-system", "pallet-balances", - "pallet-proxy 38.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "pallet-utility 38.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "pallet-proxy 38.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", + "pallet-utility 38.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "parity-scale-codec", "scale-info", "sp-arithmetic", @@ -6428,7 +6425,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "39.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "frame-benchmarking", @@ -6445,7 +6442,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-system", @@ -6503,7 +6500,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-tracing 17.0.1", "sp-version", "substrate-fixed", @@ -6515,7 +6512,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "frame-benchmarking", @@ -6530,7 +6527,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "frame-benchmarking", @@ -6548,8 +6545,8 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" -version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "38.0.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-support", "frame-system", @@ -6564,7 +6561,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "41.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6580,7 +6577,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6611,7 +6608,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-benchmarking", "frame-support", @@ -7075,7 +7072,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "environmental", "evm", @@ -7099,14 +7096,14 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" dependencies = [ "case", "num_enum", "prettyplease 0.2.22", "proc-macro2", "quote", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "syn 1.0.109", ] @@ -8091,7 +8088,7 @@ name = "safe-math" version = "0.1.0" dependencies = [ "num-traits", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "substrate-fixed", ] @@ -8125,7 +8122,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "29.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "log", "sp-core", @@ -8136,7 +8133,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.45.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "futures", "futures-timer", @@ -8158,7 +8155,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.42.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "sp-api", @@ -8173,7 +8170,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "docify", @@ -8189,7 +8186,7 @@ dependencies = [ "serde_json", "sp-blockchain", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-genesis-builder", "sp-io", "sp-runtime", @@ -8200,7 +8197,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "12.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", @@ -8211,7 +8208,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.47.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "chrono", @@ -8252,7 +8249,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "fnv", "futures", @@ -8278,8 +8275,8 @@ dependencies = [ [[package]] name = "sc-client-db" -version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "0.44.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "hash-db", "kvdb", @@ -8305,7 +8302,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "futures", @@ -8329,7 +8326,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.45.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "futures", @@ -8358,7 +8355,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.45.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "fork-tree", @@ -8383,7 +8380,7 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-slots", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-inherents", "sp-keystore", "sp-runtime", @@ -8394,7 +8391,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8407,7 +8404,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.30.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "ahash 0.8.11", "array-bytes", @@ -8441,7 +8438,7 @@ dependencies = [ "sp-consensus", "sp-consensus-grandpa", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", @@ -8451,7 +8448,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.30.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "finality-grandpa", "futures", @@ -8471,7 +8468,7 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.46.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "assert_matches", "async-trait", @@ -8506,7 +8503,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "futures", @@ -8529,7 +8526,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.40.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -8552,7 +8549,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.35.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "polkavm", "sc-allocator", @@ -8565,7 +8562,7 @@ dependencies = [ [[package]] name = "sc-executor-polkavm" version = "0.32.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "log", "polkavm", @@ -8576,7 +8573,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.35.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "anyhow", "cfg-if", @@ -8594,7 +8591,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "console", "futures", @@ -8611,7 +8608,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "33.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "parking_lot 0.12.3", @@ -8625,7 +8622,7 @@ dependencies = [ [[package]] name = "sc-mixnet" version = "0.15.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "arrayvec", @@ -8653,8 +8650,8 @@ dependencies = [ [[package]] name = "sc-network" -version = "0.45.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "0.45.6" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "async-channel", @@ -8705,7 +8702,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -8723,7 +8720,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.45.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "ahash 0.8.11", "futures", @@ -8741,8 +8738,8 @@ dependencies = [ [[package]] name = "sc-network-light" -version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "0.44.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "async-channel", @@ -8762,8 +8759,8 @@ dependencies = [ [[package]] name = "sc-network-sync" -version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "0.44.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "async-channel", @@ -8799,8 +8796,8 @@ dependencies = [ [[package]] name = "sc-network-transactions" -version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "0.44.1" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "futures", @@ -8819,7 +8816,7 @@ dependencies = [ [[package]] name = "sc-network-types" version = "0.12.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "bs58 0.5.1", "ed25519-dalek", @@ -8836,7 +8833,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "40.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "bytes", @@ -8870,7 +8867,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.18.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -8879,7 +8876,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "40.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "futures", "jsonrpsee", @@ -8911,7 +8908,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.44.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -8930,8 +8927,8 @@ dependencies = [ [[package]] name = "sc-rpc-server" -version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "17.1.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "dyn-clone", "forwarded-header-value", @@ -8955,7 +8952,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.45.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "futures", @@ -8987,7 +8984,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.46.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "directories", @@ -9051,7 +9048,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.36.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "log", "parity-scale-codec", @@ -9062,7 +9059,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "derive_more", "futures", @@ -9075,15 +9072,15 @@ dependencies = [ "serde", "serde_json", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-io", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", ] [[package]] name = "sc-telemetry" version = "25.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "chrono", "futures", @@ -9103,7 +9100,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "37.0.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "chrono", "console", @@ -9132,7 +9129,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", @@ -9143,7 +9140,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "futures", @@ -9159,7 +9156,7 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-runtime", "sp-tracing 17.0.1", "sp-transaction-pool", @@ -9170,7 +9167,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "futures", @@ -9186,7 +9183,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-channel", "futures", @@ -9632,7 +9629,7 @@ name = "share-pool" version = "0.1.0" dependencies = [ "safe-math", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "substrate-fixed", ] @@ -9778,7 +9775,7 @@ dependencies = [ [[package]] name = "sp-api" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "hash-db", @@ -9800,7 +9797,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "Inflector", "blake2 0.10.6", @@ -9814,7 +9811,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "scale-info", @@ -9826,7 +9823,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "26.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "integer-sqrt", @@ -9849,7 +9846,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "sp-api", "sp-inherents", @@ -9859,7 +9856,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "37.0.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "futures", "parity-scale-codec", @@ -9878,7 +9875,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.40.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "futures", @@ -9893,7 +9890,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.40.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "parity-scale-codec", @@ -9909,7 +9906,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.40.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "parity-scale-codec", @@ -9927,7 +9924,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "finality-grandpa", "log", @@ -9944,7 +9941,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.40.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "scale-info", @@ -9955,7 +9952,7 @@ dependencies = [ [[package]] name = "sp-core" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "bitflags 1.3.2", @@ -9984,11 +9981,11 @@ dependencies = [ "secp256k1", "secrecy", "serde", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", + "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-externalities 0.29.0", "sp-runtime-interface 28.0.0", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-storage 21.0.0", "ss58-registry", "substrate-bip39", @@ -10021,7 +10018,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.14.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -10055,7 +10052,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "blake2b_simd", "byteorder", @@ -10068,17 +10065,17 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "quote", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "syn 2.0.90", ] [[package]] name = "sp-database" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "kvdb", "parking_lot 0.12.3", @@ -10087,7 +10084,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "proc-macro2", "quote", @@ -10117,7 +10114,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.29.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "environmental", "parity-scale-codec", @@ -10127,7 +10124,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.15.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "scale-info", @@ -10139,7 +10136,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10151,8 +10148,8 @@ dependencies = [ [[package]] name = "sp-io" -version = "38.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "38.0.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "bytes", "docify", @@ -10164,7 +10161,7 @@ dependencies = [ "rustversion", "secp256k1", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-externalities 0.29.0", "sp-keystore", "sp-runtime-interface 28.0.0", @@ -10178,7 +10175,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "39.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "sp-core", "sp-runtime", @@ -10188,7 +10185,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.40.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -10199,7 +10196,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "thiserror", "zstd 0.12.4", @@ -10208,7 +10205,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.7.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -10218,7 +10215,7 @@ dependencies = [ [[package]] name = "sp-mixnet" version = "0.12.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "scale-info", @@ -10229,7 +10226,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "sp-api", "sp-core", @@ -10239,7 +10236,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "backtrace", "lazy_static", @@ -10249,7 +10246,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "32.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "rustc-hash 1.1.0", "serde", @@ -10258,8 +10255,8 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "39.0.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "39.0.5" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "either", @@ -10277,7 +10274,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-weights", "tracing", ] @@ -10304,7 +10301,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "28.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10313,7 +10310,7 @@ dependencies = [ "primitive-types", "sp-externalities 0.29.0", "sp-runtime-interface-proc-macro 18.0.0", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-storage 21.0.0", "sp-tracing 17.0.1", "sp-wasm-interface 21.0.1", @@ -10336,7 +10333,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "18.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "Inflector", "expander", @@ -10349,7 +10346,7 @@ dependencies = [ [[package]] name = "sp-session" version = "36.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "scale-info", @@ -10363,7 +10360,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "36.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -10376,7 +10373,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.43.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "hash-db", "log", @@ -10396,7 +10393,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "18.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "aes-gcm", "curve25519-dalek", @@ -10409,7 +10406,7 @@ dependencies = [ "sp-api", "sp-application-crypto", "sp-core", - "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-externalities 0.29.0", "sp-runtime", "sp-runtime-interface 28.0.0", @@ -10420,7 +10417,7 @@ dependencies = [ [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" [[package]] name = "sp-std" @@ -10442,19 +10439,19 @@ dependencies = [ [[package]] name = "sp-storage" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "impl-serde", "parity-scale-codec", "ref-cast", "serde", - "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", ] [[package]] name = "sp-timestamp" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "parity-scale-codec", @@ -10477,7 +10474,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "17.0.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "tracing", @@ -10488,7 +10485,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "sp-api", "sp-runtime", @@ -10497,7 +10494,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "34.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "async-trait", "parity-scale-codec", @@ -10511,7 +10508,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "ahash 0.8.11", "hash-db", @@ -10534,7 +10531,7 @@ dependencies = [ [[package]] name = "sp-version" version = "37.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10543,7 +10540,7 @@ dependencies = [ "serde", "sp-crypto-hashing-proc-macro", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "sp-version-proc-macro", "thiserror", ] @@ -10551,7 +10548,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10573,7 +10570,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "21.0.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -10585,7 +10582,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "31.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "bounded-collections", "parity-scale-codec", @@ -10593,7 +10590,7 @@ dependencies = [ "serde", "smallvec", "sp-arithmetic", - "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-debug-derive 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", ] [[package]] @@ -10773,8 +10770,8 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staging-xcm" -version = "14.2.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "14.2.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "bounded-collections", @@ -10894,7 +10891,7 @@ dependencies = [ [[package]] name = "substrate-bip39" version = "0.6.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "hmac 0.12.1", "pbkdf2", @@ -10906,7 +10903,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" [[package]] name = "substrate-fixed" @@ -10922,7 +10919,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "39.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "docify", "frame-system-rpc-runtime-api", @@ -10942,7 +10939,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.17.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "http-body-util", "hyper 1.5.0", @@ -10955,8 +10952,8 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" -version = "24.0.1" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +version = "24.0.2" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "array-bytes", "build-helper", @@ -11063,7 +11060,7 @@ dependencies = [ "precompile-utils", "sp-core", "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7)", "subtensor-runtime-common", ] @@ -12707,7 +12704,7 @@ dependencies = [ [[package]] name = "xcm-procedural" version = "10.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409-7#0c9644766f02c872f51e5b72adf1051189fe9126" dependencies = [ "Inflector", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 08cdfbf91e..07194af70d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,127 +100,127 @@ approx = "0.5" subtensor-macros = { path = "support/macros" } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } pallet-proxy = { path = "pallets/proxy", default-features = false } -pallet-safe-mode = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +pallet-safe-mode = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } pallet-utility = { path = "pallets/utility", default-features = false } -pallet-root-testing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +pallet-root-testing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-chain-spec-derive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } +sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-chain-spec-derive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-executor = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-network = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-service = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-storage = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sp-weights = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-storage = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-version = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sp-weights = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } substrate-fixed = { git = "https://github.com/opentensor/substrate-fixed.git", tag = "v0.5.9" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" } +substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7" } -sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } # Frontier -fp-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = [ +fp-evm = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false, features = [ "serde", ] } -fp-account = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fc-storage = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fc-db = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fc-api = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = [ +fp-account = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-storage = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-db = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-api = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false, features = [ "rpc-binary-search-estimate", ] } -fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } +fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } # Frontier FRAME -pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } -pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false } +pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } #DRAND pallet-drand = { path = "pallets/drand", default-features = false } -sp-crypto-ec-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", features = [ +sp-crypto-ec-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", features = [ "bls12-381", ] } getrandom = { version = "0.2.15", features = [ "custom", ], default-features = false } -sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false } +sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } w3f-bls = { version = "=0.1.3", default-features = false } ark-crypto-primitives = { version = "0.4.0", default-features = false, features = [ "r1cs", @@ -268,4 +268,4 @@ runtime-benchmarks = [ "node-subtensor-runtime/runtime-benchmarks", ] metadata-hash = ["node-subtensor-runtime/metadata-hash"] -pow-faucet = [] \ No newline at end of file +pow-faucet = [] From dc7eb20e7ffb6e7ced9af33c5f7a9e31936152e0 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 12:15:19 +0200 Subject: [PATCH 172/226] fix EvmBalance/SubstrateBalance issues --- precompiles/src/extensions.rs | 14 +++++++------- precompiles/src/staking.rs | 22 ++++++++++++++++------ runtime/src/lib.rs | 14 +++++++++----- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/precompiles/src/extensions.rs b/precompiles/src/extensions.rs index 2d3d65a41c..1c90922c57 100644 --- a/precompiles/src/extensions.rs +++ b/precompiles/src/extensions.rs @@ -6,8 +6,8 @@ use frame_support::dispatch::{GetDispatchInfo, Pays, PostDispatchInfo}; use frame_system::RawOrigin; use pallet_admin_utils::{PrecompileEnable, PrecompileEnum}; use pallet_evm::{ - AddressMapping, BalanceConverter, ExitError, GasWeightMapping, Precompile, PrecompileFailure, - PrecompileHandle, PrecompileResult, + AddressMapping, BalanceConverter, EvmBalance, ExitError, GasWeightMapping, Precompile, + PrecompileFailure, PrecompileHandle, PrecompileResult, }; use precompile_utils::EvmResult; use sp_core::{H160, U256, blake2_256}; @@ -27,14 +27,14 @@ pub(crate) trait PrecompileHandleExt: PrecompileHandle { where R: pallet_evm::Config, { - let amount = self.context().apparent_value; - ::BalanceConverter::into_substrate_balance(amount).ok_or( - PrecompileFailure::Error { + let amount = EvmBalance::new(self.context().apparent_value); + let result = ::BalanceConverter::into_substrate_balance(amount) + .ok_or(PrecompileFailure::Error { exit_status: ExitError::Other( "error converting balance from ETH to subtensor".into(), ), - }, - ) + })?; + Ok(result.into()) } /// Dispatches a runtime call, but also checks and records the gas costs. diff --git a/precompiles/src/staking.rs b/precompiles/src/staking.rs index 20a7bccf19..21f50bc917 100644 --- a/precompiles/src/staking.rs +++ b/precompiles/src/staking.rs @@ -30,7 +30,8 @@ use core::marker::PhantomData; use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; use frame_system::RawOrigin; use pallet_evm::{ - AddressMapping, BalanceConverter, ExitError, PrecompileFailure, PrecompileHandle, + AddressMapping, BalanceConverter, EvmBalance, ExitError, PrecompileFailure, PrecompileHandle, + SubstrateBalance, }; use precompile_utils::EvmResult; use sp_core::{H256, U256}; @@ -401,10 +402,11 @@ where let account_id = handle.caller_account_id::(); let hotkey = R::AccountId::from(address.0); let netuid = try_u16_from_u256(netuid)?; + let amount = EvmBalance::new(amount); let amount_unstaked = ::BalanceConverter::into_substrate_balance(amount) + .map(|amount| amount.into_u64_saturating()) .ok_or(ExitError::OutOfFund)?; - let amount_unstaked = amount_unstaked.unique_saturated_into(); let call = pallet_subtensor::Call::::remove_stake { hotkey, netuid, @@ -425,8 +427,9 @@ where // get total stake of coldkey let total_stake = pallet_subtensor::Pallet::::get_total_stake_for_coldkey(&coldkey); // Convert to EVM decimals - let stake_u256 = U256::from(total_stake); + let stake_u256: SubstrateBalance = total_stake.into(); let stake_eth = ::BalanceConverter::into_evm_balance(stake_u256) + .map(|amount| amount.into_u256()) .ok_or(ExitError::InvalidRange)?; Ok(stake_eth) @@ -443,8 +446,9 @@ where // get total stake of hotkey let total_stake = pallet_subtensor::Pallet::::get_total_stake_for_hotkey(&hotkey); // Convert to EVM decimals - let stake_u256 = U256::from(total_stake); + let stake_u256: SubstrateBalance = total_stake.into(); let stake_eth = ::BalanceConverter::into_evm_balance(stake_u256) + .map(|amount| amount.into_u256()) .ok_or(ExitError::InvalidRange)?; Ok(stake_eth) @@ -464,8 +468,9 @@ where let stake = pallet_subtensor::Pallet::::get_stake_for_hotkey_and_coldkey_on_subnet( &hotkey, &coldkey, netuid, ); - let stake = U256::from(stake); + let stake: SubstrateBalance = stake.into(); let stake = ::BalanceConverter::into_evm_balance(stake) + .map(|amount| amount.into_u256()) .ok_or(ExitError::InvalidRange)?; Ok(stake) @@ -503,15 +508,20 @@ where account_id: &::AccountId, amount: U256, ) -> Result<(), PrecompileFailure> { + let amount = EvmBalance::new(amount); let amount_sub = ::BalanceConverter::into_substrate_balance(amount) .ok_or(ExitError::OutOfFund)?; // Create a transfer call from the smart contract to the caller + let value = amount_sub + .into_u64_saturating() + .try_into() + .map_err(|_| ExitError::Other("Failed to convert u64 to Balance".into()))?; let transfer_call = ::RuntimeCall::from( pallet_balances::Call::::transfer_allow_death { dest: account_id.clone().into(), - value: amount_sub.unique_saturated_into(), + value, }, ); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2c1a11d94b..8b9f965d07 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -95,7 +95,9 @@ use scale_info::TypeInfo; // Frontier use fp_rpc::TransactionStatus; use pallet_ethereum::{Call::transact, PostLogContent, Transaction as EthereumTransaction}; -use pallet_evm::{Account as EVMAccount, BalanceConverter, FeeCalculator, Runner}; +use pallet_evm::{ + Account as EVMAccount, BalanceConverter, EvmBalance, FeeCalculator, Runner, SubstrateBalance, +}; // Drand impl pallet_drand::Config for Runtime { @@ -1237,11 +1239,12 @@ pub struct SubtensorEvmBalanceConverter; impl BalanceConverter for SubtensorEvmBalanceConverter { /// Convert from Substrate balance (u64) to EVM balance (U256) - fn into_evm_balance(value: U256) -> Option { + fn into_evm_balance(value: SubstrateBalance) -> Option { + let value = value.into_u256(); if let Some(evm_value) = value.checked_mul(U256::from(EVM_TO_SUBSTRATE_DECIMALS)) { // Ensure the result fits within the maximum U256 value if evm_value <= U256::MAX { - Some(evm_value) + Some(EvmBalance::new(evm_value)) } else { // Log value too large log::debug!( @@ -1261,11 +1264,12 @@ impl BalanceConverter for SubtensorEvmBalanceConverter { } /// Convert from EVM balance (U256) to Substrate balance (u64) - fn into_substrate_balance(value: U256) -> Option { + fn into_substrate_balance(value: EvmBalance) -> Option { + let value = value.into_u256(); if let Some(substrate_value) = value.checked_div(U256::from(EVM_TO_SUBSTRATE_DECIMALS)) { // Ensure the result fits within the TAO balance type (u64) if substrate_value <= U256::from(u64::MAX) { - Some(substrate_value) + Some(SubstrateBalance::new(substrate_value)) } else { // Log value too large log::debug!( From d8e6c5686aee4b834c8b3363c4ccb56e9cd9959e Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 15:30:15 +0200 Subject: [PATCH 173/226] fix frontier dependencies commit hash + added fc-aura --- Cargo.lock | 67 +++++++++++++++++++++++++++----------------- Cargo.toml | 47 ++++++++++++++++--------------- node/Cargo.toml | 1 + node/src/ethereum.rs | 3 +- 4 files changed, 69 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4109abb5bd..e5f60b8447 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2364,7 +2364,7 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "async-trait", "fp-storage", @@ -2373,10 +2373,26 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "fc-aura" +version = "1.0.0-dev" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +dependencies = [ + "fc-rpc", + "fp-storage", + "sc-client-api", + "sc-consensus-aura", + "sp-api", + "sp-consensus-aura", + "sp-inherents", + "sp-runtime", + "sp-timestamp", +] + [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "async-trait", "fp-consensus", @@ -2392,7 +2408,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "async-trait", "ethereum", @@ -2422,7 +2438,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "fc-db", "fc-storage", @@ -2445,7 +2461,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "ethereum-types", @@ -2496,7 +2512,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "ethereum-types", @@ -2511,7 +2527,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "ethereum-types", @@ -2694,7 +2710,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "hex", "impl-serde", @@ -2713,7 +2729,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "parity-scale-codec", @@ -2724,7 +2740,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "ethereum-types", @@ -2736,7 +2752,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "evm", "frame-support", @@ -2751,7 +2767,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "ethereum-types", @@ -2767,7 +2783,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "frame-support", "parity-scale-codec", @@ -2779,7 +2795,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "parity-scale-codec", "serde", @@ -3693,7 +3709,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -5523,6 +5539,7 @@ dependencies = [ "async-trait", "clap", "fc-api", + "fc-aura", "fc-consensus", "fc-db", "fc-mapping-sync", @@ -6055,7 +6072,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "fp-evm", "frame-support", @@ -6164,7 +6181,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "ethereum", "ethereum-types", @@ -6186,7 +6203,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "environmental", "evm", @@ -6209,7 +6226,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "frame-support", "frame-system", @@ -6220,7 +6237,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "fp-evm", "num", @@ -6229,7 +6246,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "fp-evm", "tiny-keccak", @@ -6238,7 +6255,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "fp-evm", "ripemd", @@ -6270,7 +6287,7 @@ dependencies = [ [[package]] name = "pallet-hotfix-sufficients" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "frame-benchmarking", "frame-support", @@ -7072,7 +7089,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "environmental", "evm", @@ -7096,7 +7113,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=9462b36d09#9462b36d092f36ffee175434881b611f5c170780" +source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" dependencies = [ "case", "num_enum", diff --git a/Cargo.toml b/Cargo.toml index 07194af70d..4eea2a7823 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -182,35 +182,36 @@ sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } # Frontier -fp-evm = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false, features = [ +fp-evm = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false, features = [ "serde", ] } -fp-account = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fc-storage = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fc-db = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fc-api = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false, features = [ +fp-account = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-storage = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-db = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-api = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false, features = [ "rpc-binary-search-estimate", ] } -fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-aura = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } # Frontier FRAME -pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } -pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "9462b36d09", default-features = false } +pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } #DRAND pallet-drand = { path = "pallets/drand", default-features = false } diff --git a/node/Cargo.toml b/node/Cargo.toml index 6cea8f6950..52ccf20de3 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -99,6 +99,7 @@ fc-api = { workspace = true } fc-rpc = { workspace = true } fc-rpc-core = { workspace = true } fp-rpc = { workspace = true } +fc-aura = { workspace = true } fc-mapping-sync = { workspace = true } fp-consensus = { workspace = true } thiserror = { workspace = true } diff --git a/node/src/ethereum.rs b/node/src/ethereum.rs index 158bd84807..d5493d7d70 100644 --- a/node/src/ethereum.rs +++ b/node/src/ethereum.rs @@ -2,9 +2,10 @@ pub use fc_consensus::FrontierBlockImport; use fc_rpc::{ Debug, DebugApiServer, Eth, EthApiServer, EthConfig, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, EthSigner, EthTask, Net, NetApiServer, Web3, - Web3ApiServer, pending::AuraConsensusDataProvider, + Web3ApiServer, }; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; +use fc_aura::AuraConsensusDataProvider; /// Frontier DB backend type. pub use fc_storage::{StorageOverride, StorageOverrideHandler}; use fp_rpc::ConvertTransaction; From 0e603a4543d066caf84ab0f078e86d8d63196b52 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 15:30:31 +0200 Subject: [PATCH 174/226] fix tests --- runtime/src/lib.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8b9f965d07..cd506d8659 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -2258,8 +2258,8 @@ fn check_whitelist() { #[test] fn test_into_substrate_balance_valid() { // Valid conversion within u64 range - let evm_balance = U256::from(1_000_000_000_000_000_000u128); // 1 TAO in EVM - let expected_substrate_balance = U256::from(1_000_000_000u128); // 1 TAO in Substrate + let evm_balance: EvmBalance = 1_000_000_000_000_000_000u128.into(); // 1 TAO in EVM + let expected_substrate_balance: SubstrateBalance = 1_000_000_000u128.into(); // 1 TAO in Substrate let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance); assert_eq!(result, Some(expected_substrate_balance)); @@ -2268,8 +2268,8 @@ fn test_into_substrate_balance_valid() { #[test] fn test_into_substrate_balance_large_value() { // Maximum valid balance for u64 - let evm_balance = U256::from(u64::MAX) * U256::from(EVM_TO_SUBSTRATE_DECIMALS); // Max u64 TAO in EVM - let expected_substrate_balance = U256::from(u64::MAX); + let evm_balance = EvmBalance::new(U256::from(u64::MAX) * U256::from(EVM_TO_SUBSTRATE_DECIMALS)); // Max u64 TAO in EVM + let expected_substrate_balance = SubstrateBalance::new(U256::from(u64::MAX)); let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance); assert_eq!(result, Some(expected_substrate_balance)); @@ -2278,8 +2278,9 @@ fn test_into_substrate_balance_large_value() { #[test] fn test_into_substrate_balance_exceeds_u64() { // EVM balance that exceeds u64 after conversion - let evm_balance = - (U256::from(u64::MAX) + U256::from(1)) * U256::from(EVM_TO_SUBSTRATE_DECIMALS); + let evm_balance = EvmBalance::new( + (U256::from(u64::MAX) + U256::from(1)) * U256::from(EVM_TO_SUBSTRATE_DECIMALS), + ); let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance); assert_eq!(result, None); // Exceeds u64, should return None @@ -2288,8 +2289,8 @@ fn test_into_substrate_balance_exceeds_u64() { #[test] fn test_into_substrate_balance_precision_loss() { // EVM balance with precision loss - let evm_balance = U256::from(1_000_000_000_123_456_789u128); // 1 TAO + extra precision in EVM - let expected_substrate_balance = U256::from(1_000_000_000u128); // Truncated to 1 TAO in Substrate + let evm_balance = EvmBalance::new(U256::from(1_000_000_000_123_456_789u128)); // 1 TAO + extra precision in EVM + let expected_substrate_balance = SubstrateBalance::new(U256::from(1_000_000_000u128)); // Truncated to 1 TAO in Substrate let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance); assert_eq!(result, Some(expected_substrate_balance)); @@ -2298,8 +2299,8 @@ fn test_into_substrate_balance_precision_loss() { #[test] fn test_into_substrate_balance_zero_value() { // Zero balance should convert to zero - let evm_balance = U256::from(0); - let expected_substrate_balance = U256::from(0); + let evm_balance = EvmBalance::new(U256::from(0)); + let expected_substrate_balance = SubstrateBalance::new(U256::from(0)); let result = SubtensorEvmBalanceConverter::into_substrate_balance(evm_balance); assert_eq!(result, Some(expected_substrate_balance)); @@ -2308,8 +2309,8 @@ fn test_into_substrate_balance_zero_value() { #[test] fn test_into_evm_balance_valid() { // Valid conversion from Substrate to EVM - let substrate_balance = U256::from(1_000_000_000u128); // 1 TAO in Substrate - let expected_evm_balance = U256::from(1_000_000_000_000_000_000u128); // 1 TAO in EVM + let substrate_balance: SubstrateBalance = 1_000_000_000u128.into(); // 1 TAO in Substrate + let expected_evm_balance = EvmBalance::new(U256::from(1_000_000_000_000_000_000u128)); // 1 TAO in EVM let result = SubtensorEvmBalanceConverter::into_evm_balance(substrate_balance); assert_eq!(result, Some(expected_evm_balance)); @@ -2318,8 +2319,9 @@ fn test_into_evm_balance_valid() { #[test] fn test_into_evm_balance_overflow() { // Substrate balance larger than u64::MAX but valid within U256 - let substrate_balance = U256::from(u64::MAX) + U256::from(1); // Large balance - let expected_evm_balance = substrate_balance * U256::from(EVM_TO_SUBSTRATE_DECIMALS); + let substrate_balance = SubstrateBalance::new(U256::from(u64::MAX) + U256::from(1)); // Large balance + let expected_evm_balance = + EvmBalance::new(substrate_balance.into_u256() * U256::from(EVM_TO_SUBSTRATE_DECIMALS)); let result = SubtensorEvmBalanceConverter::into_evm_balance(substrate_balance); assert_eq!(result, Some(expected_evm_balance)); // Should return the scaled value From 70d01dcff0f28b2294bb55d47980098f720cc113 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 15:34:05 +0200 Subject: [PATCH 175/226] cargo fmt --- node/src/ethereum.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/ethereum.rs b/node/src/ethereum.rs index d5493d7d70..c708efd714 100644 --- a/node/src/ethereum.rs +++ b/node/src/ethereum.rs @@ -1,3 +1,4 @@ +use fc_aura::AuraConsensusDataProvider; pub use fc_consensus::FrontierBlockImport; use fc_rpc::{ Debug, DebugApiServer, Eth, EthApiServer, EthConfig, EthDevSigner, EthFilter, @@ -5,7 +6,6 @@ use fc_rpc::{ Web3ApiServer, }; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; -use fc_aura::AuraConsensusDataProvider; /// Frontier DB backend type. pub use fc_storage::{StorageOverride, StorageOverrideHandler}; use fp_rpc::ConvertTransaction; From 067cd620e2443c8e03d47f5670fbbecce717a3fa Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 18:17:44 +0200 Subject: [PATCH 176/226] change frontier commit hash following frontier upgrade --- Cargo.lock | 50 +++++++++++++++++++++++++------------------------- Cargo.toml | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5f60b8447..53168c152d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2364,7 +2364,7 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "async-trait", "fp-storage", @@ -2376,7 +2376,7 @@ dependencies = [ [[package]] name = "fc-aura" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "fc-rpc", "fp-storage", @@ -2392,7 +2392,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "async-trait", "fp-consensus", @@ -2408,7 +2408,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "async-trait", "ethereum", @@ -2438,7 +2438,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "fc-db", "fc-storage", @@ -2461,7 +2461,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "ethereum-types", @@ -2512,7 +2512,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "ethereum-types", @@ -2527,7 +2527,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "ethereum-types", @@ -2710,7 +2710,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "hex", "impl-serde", @@ -2729,7 +2729,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "parity-scale-codec", @@ -2740,7 +2740,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "ethereum-types", @@ -2752,7 +2752,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "evm", "frame-support", @@ -2767,7 +2767,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "ethereum-types", @@ -2783,7 +2783,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "frame-support", "parity-scale-codec", @@ -2795,7 +2795,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "parity-scale-codec", "serde", @@ -6072,7 +6072,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "fp-evm", "frame-support", @@ -6181,7 +6181,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "ethereum", "ethereum-types", @@ -6203,7 +6203,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "environmental", "evm", @@ -6226,7 +6226,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "frame-support", "frame-system", @@ -6237,7 +6237,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "fp-evm", "num", @@ -6246,7 +6246,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "fp-evm", "tiny-keccak", @@ -6255,7 +6255,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "fp-evm", "ripemd", @@ -6287,7 +6287,7 @@ dependencies = [ [[package]] name = "pallet-hotfix-sufficients" version = "1.0.0" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "frame-benchmarking", "frame-support", @@ -7089,7 +7089,7 @@ dependencies = [ [[package]] name = "precompile-utils" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "environmental", "evm", @@ -7113,7 +7113,7 @@ dependencies = [ [[package]] name = "precompile-utils-macro" version = "0.1.0" -source = "git+https://github.com/opentensor/frontier?rev=b902a66fff#b902a66fffadcfb63a8fe83256fd92c1c6cf73f3" +source = "git+https://github.com/opentensor/frontier?rev=cd6bca14a3#cd6bca14a366cc7cb1c3b1b1d7bc8213667e4126" dependencies = [ "case", "num_enum", diff --git a/Cargo.toml b/Cargo.toml index 4eea2a7823..548bc5af63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -182,36 +182,36 @@ sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409-7", default-features = false } # Frontier -fp-evm = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false, features = [ +fp-evm = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false, features = [ "serde", ] } -fp-account = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-storage = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-db = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-api = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false, features = [ +fp-account = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-storage = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-db = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-api = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false, features = [ "rpc-binary-search-estimate", ] } -fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-aura = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-aura = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } # Frontier FRAME -pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } -pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "b902a66fff", default-features = false } +pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } +pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "cd6bca14a3", default-features = false } #DRAND pallet-drand = { path = "pallets/drand", default-features = false } From 89278bb114e1c3fbb82e85fdf683c0e1e0364230 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 7 May 2025 13:13:11 -0400 Subject: [PATCH 177/226] remove direct indexing --- pallets/subtensor/src/epoch/math.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 5898ced70c..6a53cb135b 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -1228,7 +1228,7 @@ pub fn mat_vec_mul(matrix: &[Vec], vector: &[I32F32]) -> Vec } // Element-wise product of matrix and vector -#[allow(dead_code, clippy::indexing_slicing)] +#[allow(dead_code)] pub fn mat_vec_mul_sparse( matrix: &[Vec<(u16, I32F32)>], vector: &[I32F32], @@ -1239,7 +1239,9 @@ pub fn mat_vec_mul_sparse( if let Some(vector_value) = vector.get(*j as usize) { let new_value = value.saturating_mul(*vector_value); if new_value != I32F32::saturating_from_num(0.0) { - result[i].push((*j, new_value)); + if let Some(result_row) = result.get_mut(i) { + result_row.push((*j, new_value)); + } } } } From ca5d4b260afa04d666c2ada3cfc5f9779a9fb87f Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 7 May 2025 13:40:39 -0400 Subject: [PATCH 178/226] have Dockerfile use a local user instead of root * also use rust:latest so we don't have to keep bumping --- Dockerfile | 127 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 44 deletions(-) diff --git a/Dockerfile b/Dockerfile index 44e4bbe12f..3d0e1600aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,14 @@ -ARG BASE_IMAGE=rust:1.83 -FROM $BASE_IMAGE AS base_builder +# ------------------------------------------------------------------------------ +# Subtensor Dockerfile (hardened, full-functionality) +# – Builds production and local binaries +# – Final runtime images run as non-root `subtensor` user (UID/GID 10001) +# ------------------------------------------------------------------------------ + +############################################################################### +# ---------- 1. Common build environment ------------------------------------- +############################################################################### +ARG BASE_IMAGE=rust:latest +FROM ${BASE_IMAGE} AS base_builder LABEL ai.opentensor.image.authors="operations@opentensor.ai" \ ai.opentensor.image.vendor="Opentensor Foundation" \ @@ -7,58 +16,88 @@ LABEL ai.opentensor.image.authors="operations@opentensor.ai" \ ai.opentensor.image.description="Opentensor Subtensor Blockchain" \ ai.opentensor.image.documentation="https://docs.bittensor.com" -RUN rustup update stable -RUN rustup target add wasm32-unknown-unknown --toolchain stable - +# Rust targets +RUN rustup update stable && \ + rustup target add wasm32-unknown-unknown --toolchain stable -# Set up Rust environment +# Build prerequisites ENV RUST_BACKTRACE=1 -RUN apt-get update && apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev -RUN rm -rf /var/lib/apt/lists/* +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + curl build-essential protobuf-compiler clang git pkg-config libssl-dev && \ + rm -rf /var/lib/apt/lists/* -# Copy entire repository +# Copy entire repository once for all build stages (maximises cache hits) COPY . /build WORKDIR /build -# -# Image for building prod -# +############################################################################### +# ---------- 2. Production build stage --------------------------------------- +############################################################################### FROM base_builder AS prod_builder -# Build the project -RUN cargo build -p node-subtensor --profile production --features="metadata-hash" --locked -# Verify the binary was produced -RUN test -e /build/target/production/node-subtensor -EXPOSE 30333 9933 9944 -# -# Final prod image -# -FROM $BASE_IMAGE AS subtensor -# Copy all chainspec files -COPY --from=prod_builder /build/*.json / -COPY --from=prod_builder /build/chainspecs/*.json / -# Copy final binary -COPY --from=prod_builder /build/target/production/node-subtensor /usr/local/bin +# Build the production binary (profile defined in Cargo.toml) +RUN cargo build -p node-subtensor --profile production --features "metadata-hash" --locked \ + && test -e /build/target/production/node-subtensor # sanity-check +############################################################################### +# ---------- 3. Final production image (hardened) ---------------------------- +############################################################################### +FROM ${BASE_IMAGE} AS subtensor + +# ---- security hardening: create least-privilege user ---- +RUN addgroup --system --gid 10001 subtensor && \ + adduser --system --uid 10001 --gid 10001 --home /home/subtensor --disabled-password subtensor + +# Writable data directory to be used as --base-path +RUN mkdir -p /data && chown -R subtensor:subtensor /data + +# Workdir for the non-root user +WORKDIR /home/subtensor + +# Copy chainspecs and binary with correct ownership +COPY --chown=subtensor:subtensor --from=prod_builder /build/*.json ./ +COPY --chown=subtensor:subtensor --from=prod_builder /build/chainspecs/*.json ./chainspecs/ +COPY --from=prod_builder /build/target/production/node-subtensor /usr/local/bin/ +RUN chown subtensor:subtensor /usr/local/bin/node-subtensor -# -# Image for building local -# -FROM base_builder AS local_builder -# Build the project -RUN cargo build --workspace --profile release --features="pow-faucet" -# Verify the binary was produced -RUN test -e /build/target/release/node-subtensor EXPOSE 30333 9933 9944 +USER subtensor +ENTRYPOINT ["node-subtensor"] +CMD ["--base-path","/data"] +############################################################################### +# ---------- 4. Local build stage -------------------------------------------- +############################################################################### +FROM base_builder AS local_builder + +# Build the workspace in release mode with the pow-faucet feature +RUN cargo build --workspace --profile release --features "pow-faucet" \ + && test -e /build/target/release/node-subtensor # sanity-check + +############################################################################### +# ---------- 5. Final local image (hardened) ---------------------------------- +############################################################################### +FROM ${BASE_IMAGE} AS subtensor-local + +# Least-privilege user +RUN addgroup --system --gid 10001 subtensor && \ + adduser --system --uid 10001 --gid 10001 --home /home/subtensor --disabled-password subtensor -# -# Final local image -# -FROM $BASE_IMAGE AS subtensor-local -# Copy all chainspec files -COPY --from=local_builder /build/*.json / -COPY --from=local_builder /build/chainspecs/*.json / -# Copy final binary -COPY --from=local_builder /build/target/release/node-subtensor /usr/local/bin -RUN "node-subtensor" build-spec --disable-default-bootnode --raw --chain local > /localnet.json +RUN mkdir -p /data && chown -R subtensor:subtensor /data +WORKDIR /home/subtensor + +# Copy artifacts +COPY --chown=subtensor:subtensor --from=local_builder /build/*.json ./ +COPY --chown=subtensor:subtensor --from=local_builder /build/chainspecs/*.json ./chainspecs/ +COPY --from=local_builder /build/target/release/node-subtensor /usr/local/bin/ +RUN chown subtensor:subtensor /usr/local/bin/node-subtensor + +# Generate a local chainspec for convenience (run as root before user switch) +RUN node-subtensor build-spec --disable-default-bootnode --raw --chain local > /localnet.json \ + && chown subtensor:subtensor /localnet.json + +EXPOSE 30333 9933 9944 +USER subtensor +ENTRYPOINT ["node-subtensor"] +CMD ["--base-path","/data","--chain","/localnet.json"] From 5f43a5f06ddeb24bf6283606d21ad53175a2eeb4 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 7 May 2025 13:47:27 -0400 Subject: [PATCH 179/226] clean up --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3d0e1600aa..447ed98b5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Subtensor Dockerfile (hardened, full-functionality) +# Subtensor Dockerfile (hardened) # – Builds production and local binaries # – Final runtime images run as non-root `subtensor` user (UID/GID 10001) # ------------------------------------------------------------------------------ From f8b239b91f1c8a485a9b9143e7433303e3670e9c Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 13:08:23 -0700 Subject: [PATCH 180/226] only respect the `skip-validate-benchmarks` label --- .github/workflows/run-benchmarks.yml | 50 ++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index d0981ef59f..9821c92a9f 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -4,10 +4,8 @@ name: Validate-Benchmarks on: pull_request: types: - - labeled - - unlabeled - - synchronize - opened + - synchronize workflow_dispatch: concurrency: @@ -25,26 +23,72 @@ jobs: ref: ${{ github.head_ref }} fetch-depth: 0 + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + + - name: Check skip label + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if echo "$labels" | grep -q "skip-validate-benchmarks"; then + echo "Skip label found - stopping." + exit 0 + fi + - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler + - name: Check skip label + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if echo "$labels" | grep -q "skip-validate-benchmarks"; then + echo "Skip label found - stopping." + exit 0 + fi + - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable + - name: Check skip label + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if echo "$labels" | grep -q "skip-validate-benchmarks"; then + echo "Skip label found - stopping." + exit 0 + fi + - name: Cache Rust build uses: Swatinem/rust-cache@v2 with: key: bench-${{ hashFiles('**/Cargo.lock') }} + - name: Check skip label + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if echo "$labels" | grep -q "skip-validate-benchmarks"; then + echo "Skip label found - stopping." + exit 0 + fi + - name: Build node with benchmarks run: | cargo build --profile production -p node-subtensor --features runtime-benchmarks + - name: Check skip label + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if echo "$labels" | grep -q "skip-validate-benchmarks"; then + echo "Skip label found - stopping." + exit 0 + fi + - name: Run & validate benchmarks run: | chmod +x scripts/benchmark_action.sh From f15a42f9099e39888d9d4d196a84cf915c28e0d7 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 13:38:17 -0700 Subject: [PATCH 181/226] update exit code --- .github/workflows/run-benchmarks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 9821c92a9f..18e298fa46 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -34,7 +34,7 @@ jobs: labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then echo "Skip label found - stopping." - exit 0 + exit 1 fi - name: Install system dependencies @@ -47,7 +47,7 @@ jobs: labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then echo "Skip label found - stopping." - exit 0 + exit 1 fi - name: Install Rust toolchain @@ -61,7 +61,7 @@ jobs: labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then echo "Skip label found - stopping." - exit 0 + exit 1 fi - name: Cache Rust build @@ -74,7 +74,7 @@ jobs: labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then echo "Skip label found - stopping." - exit 0 + exit 1 fi - name: Build node with benchmarks @@ -86,7 +86,7 @@ jobs: labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then echo "Skip label found - stopping." - exit 0 + exit 1 fi - name: Run & validate benchmarks From f5eec3b43bfc06e979388cab8024255b68d85f5b Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 14:10:45 -0700 Subject: [PATCH 182/226] stop moving on in skip case --- .github/workflows/run-benchmarks.yml | 54 ++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 18e298fa46..4dd6425d27 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -16,80 +16,104 @@ jobs: validate-benchmarks: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-validate-benchmarks') }} runs-on: Benchmarking + + env: + SKIP_BENCHMARKS: '0' + steps: - - name: Checkout PR branch + - name: Check out PR branch + if: ${{ env.SKIP_BENCHMARKS != '1' }} uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} fetch-depth: 0 - name: Install GitHub CLI + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | sudo apt-get update sudo apt-get install -y gh echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - name: Check skip label + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "Skip label found - stopping." - exit 1 + echo "skip-validate-benchmarks label found — skipping benchmarks." + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" fi - name: Install system dependencies + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | sudo apt-get update sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - name: Check skip label + - name: Check skip label again + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "Skip label found - stopping." - exit 1 + echo "skip-validate-benchmarks label found — skipping benchmarks." + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" fi - name: Install Rust toolchain + if: ${{ env.SKIP_BENCHMARKS != '1' }} uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - - name: Check skip label + - name: Check skip label again + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "Skip label found - stopping." - exit 1 + echo "skip-validate-benchmarks label found — skipping benchmarks." + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" fi - name: Cache Rust build + if: ${{ env.SKIP_BENCHMARKS != '1' }} uses: Swatinem/rust-cache@v2 with: key: bench-${{ hashFiles('**/Cargo.lock') }} - - name: Check skip label + - name: Check skip label again + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "Skip label found - stopping." - exit 1 + echo "skip-validate-benchmarks label found — skipping benchmarks." + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" fi - name: Build node with benchmarks + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | cargo build --profile production -p node-subtensor --features runtime-benchmarks - - name: Check skip label + - name: Check skip label again + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "Skip label found - stopping." - exit 1 + echo "skip-validate-benchmarks label found — skipping benchmarks." + echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" fi - name: Run & validate benchmarks + if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | chmod +x scripts/benchmark_action.sh ./scripts/benchmark_action.sh + + - name: Check skip label after run + if: ${{ env.SKIP_BENCHMARKS != '1' }} + run: | + labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + if echo "$labels" | grep -q "skip-validate-benchmarks"; then + echo "skip-validate-benchmarks label was found — but benchmarks already ran." + # Nothing else to skip now, but you can do something else if desired. From 7df461bd7198e5b68d91d8146a9b2a395b38b4f5 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 14:13:56 -0700 Subject: [PATCH 183/226] update names --- .github/workflows/run-benchmarks.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 4dd6425d27..2532629fb2 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -50,7 +50,7 @@ jobs: sudo apt-get update sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - name: Check skip label again + - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') @@ -66,7 +66,7 @@ jobs: profile: minimal toolchain: stable - - name: Check skip label again + - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') @@ -81,7 +81,7 @@ jobs: with: key: bench-${{ hashFiles('**/Cargo.lock') }} - - name: Check skip label again + - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') @@ -95,7 +95,7 @@ jobs: run: | cargo build --profile production -p node-subtensor --features runtime-benchmarks - - name: Check skip label again + - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') From 4c62519bf0bb456b63166f2323e9bdd0f53f4b9a Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 14:28:57 -0700 Subject: [PATCH 184/226] rerun on label removed --- .github/workflows/label-triggers.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index f3c330f85c..e736c05804 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -10,6 +10,7 @@ on: permissions: issues: write pull-requests: write + contents: write jobs: comment_on_breaking_change: @@ -26,3 +27,19 @@ jobs: repo: context.repo.repo, body: '@opentensor/cerebrum / @opentensor/gyrus / @opentensor/cortex breaking change detected! Please prepare accordingly!' }) + + re_run_validate_benchmarks: + name: "Re-run Validate-Benchmarks if skip-validate-benchmarks is removed" + runs-on: ubuntu-latest + if: github.event.action == 'unlabeled' && github.event.label.name == 'skip-validate-benchmarks' + steps: + - name: Trigger Benchmarks workflow_dispatch + uses: actions/github-script@v6 + with: + script: | + github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'run-benchmarks.yml', + ref: context.payload.pull_request.head.ref + }) From 3b9b9b254f057a461db7ff6eaa69b7f8d713915e Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 14:36:41 -0700 Subject: [PATCH 185/226] fix? --- .github/workflows/label-triggers.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index e736c05804..ef999be100 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -1,6 +1,6 @@ name: Label Triggers on: - pull_request: + pull_request_target: types: - labeled - unlabeled @@ -11,6 +11,7 @@ permissions: issues: write pull-requests: write contents: write + actions: write jobs: comment_on_breaking_change: From 57a8290265aa49faf22f874e477084bf2b3aba19 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 14:39:10 -0700 Subject: [PATCH 186/226] fix?? --- .github/workflows/label-triggers.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index ef999be100..54eddd1222 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -1,6 +1,6 @@ name: Label Triggers on: - pull_request_target: + pull_request: types: - labeled - unlabeled @@ -10,8 +10,8 @@ on: permissions: issues: write pull-requests: write - contents: write - actions: write + contents: write + actions: write jobs: comment_on_breaking_change: From c75a1ac23d1755b844699ea23ef89073987c91df Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 15:07:06 -0700 Subject: [PATCH 187/226] fix? --- .github/workflows/label-triggers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index 54eddd1222..8852dfc782 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -1,6 +1,6 @@ name: Label Triggers on: - pull_request: + pull_request_target:: types: - labeled - unlabeled From 0ab04cead40dcc14905d10bb669ff15caa5573ca Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 15:31:05 -0700 Subject: [PATCH 188/226] oops --- .github/workflows/label-triggers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index 8852dfc782..709b711bc7 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -1,6 +1,6 @@ name: Label Triggers on: - pull_request_target:: + pull_request_target: types: - labeled - unlabeled From 79d16e8ece576b9c18f2ace8511eb0a4ee9bf4f4 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 15:51:49 -0700 Subject: [PATCH 189/226] fix? --- .github/workflows/label-triggers.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index 709b711bc7..c5a558bd3e 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -1,6 +1,6 @@ name: Label Triggers on: - pull_request_target: + pull_request: types: - labeled - unlabeled @@ -37,6 +37,7 @@ jobs: - name: Trigger Benchmarks workflow_dispatch uses: actions/github-script@v6 with: + github_token: ${{ secrets.GITHUB_TOKEN }} script: | github.rest.actions.createWorkflowDispatch({ owner: context.repo.owner, From b637720fe2269cff621391fb5b10673e5b85fd7f Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 15:59:53 -0700 Subject: [PATCH 190/226] revert rerun --- .github/workflows/label-triggers.yml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/label-triggers.yml b/.github/workflows/label-triggers.yml index c5a558bd3e..bcf43e4c23 100644 --- a/.github/workflows/label-triggers.yml +++ b/.github/workflows/label-triggers.yml @@ -10,8 +10,6 @@ on: permissions: issues: write pull-requests: write - contents: write - actions: write jobs: comment_on_breaking_change: @@ -27,21 +25,4 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: '@opentensor/cerebrum / @opentensor/gyrus / @opentensor/cortex breaking change detected! Please prepare accordingly!' - }) - - re_run_validate_benchmarks: - name: "Re-run Validate-Benchmarks if skip-validate-benchmarks is removed" - runs-on: ubuntu-latest - if: github.event.action == 'unlabeled' && github.event.label.name == 'skip-validate-benchmarks' - steps: - - name: Trigger Benchmarks workflow_dispatch - uses: actions/github-script@v6 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'run-benchmarks.yml', - ref: context.payload.pull_request.head.ref - }) + }) \ No newline at end of file From df21554b7a28eadb9a68739e622789273062bf1a Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 6 May 2025 15:10:49 +0800 Subject: [PATCH 191/226] Ensure we only reset BondsMovingAverage to 975000 only if it exceeds --- .../src/migrations/migrate_reset_bonds_moving_average.rs | 2 +- pallets/subtensor/src/migrations/migrate_reset_max_burn.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs index 5bb442af18..57018a03c5 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs @@ -31,7 +31,7 @@ pub fn migrate_reset_bonds_moving_average() -> Weight { for netuid in BondsMovingAverage::::iter_keys() { BondsMovingAverage::::mutate(netuid, |average| { - *average = (*average).min(975000); + *average = average.min(975000); }); reset_entries_count = reset_entries_count.saturating_add(1); } diff --git a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs index a2662f7de3..d5b85ad189 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs @@ -39,7 +39,10 @@ pub fn migrate_reset_max_burn() -> Weight { weight = weight .saturating_add(T::DbWeight::get().reads_writes(reset_entries_count, reset_entries_count)); - log::info!("Reset {} subnets from MaxBurn.", reset_entries_count); + log::info!( + "Reset {} subnets from MaxBurn.", + reset_entries_count + ); // ------------------------------ // Step 2: Mark Migration as Completed From 8bec1629660c270c34dfcc95c23a2455bf946047 Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 6 May 2025 17:14:51 +0800 Subject: [PATCH 192/226] Fixes --- .../src/migrations/migrate_reset_bonds_moving_average.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs index 57018a03c5..5bb442af18 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_bonds_moving_average.rs @@ -31,7 +31,7 @@ pub fn migrate_reset_bonds_moving_average() -> Weight { for netuid in BondsMovingAverage::::iter_keys() { BondsMovingAverage::::mutate(netuid, |average| { - *average = average.min(975000); + *average = (*average).min(975000); }); reset_entries_count = reset_entries_count.saturating_add(1); } From 4610c8bfd849973235bc6ec69e077c1bf63cbd2f Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 6 May 2025 17:38:36 +0800 Subject: [PATCH 193/226] cargo fmt --- pallets/subtensor/src/migrations/migrate_reset_max_burn.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs index d5b85ad189..a2662f7de3 100644 --- a/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs +++ b/pallets/subtensor/src/migrations/migrate_reset_max_burn.rs @@ -39,10 +39,7 @@ pub fn migrate_reset_max_burn() -> Weight { weight = weight .saturating_add(T::DbWeight::get().reads_writes(reset_entries_count, reset_entries_count)); - log::info!( - "Reset {} subnets from MaxBurn.", - reset_entries_count - ); + log::info!("Reset {} subnets from MaxBurn.", reset_entries_count); // ------------------------------ // Step 2: Mark Migration as Completed From 8493bbfa151c370304d441a5266dd86be14cfd45 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Fri, 2 May 2025 16:38:56 +0400 Subject: [PATCH 194/226] Introduce SameSubnetId error for move and swap stake extrinsics. --- pallets/subtensor/src/macros/errors.rs | 4 ++-- pallets/subtensor/src/staking/stake_utils.rs | 5 ++++- pallets/subtensor/src/tests/move_stake.rs | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index 69a8fe1646..a5bf028831 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -210,9 +210,9 @@ mod errors { InvalidRecoveredPublicKey, /// SubToken disabled now SubtokenDisabled, - /// Estimating the maximum stake for limited staking operations returned zero. + /// Zero max stake amount ZeroMaxStakeAmount, /// Invalid netuid duplication - SameNetuid, + SameSubnetId, } } diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index 65280c8a43..a793a56edc 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -1012,7 +1012,10 @@ impl Pallet { ) -> Result<(), Error> { // Ensure stake transition is actually happening if origin_coldkey == destination_coldkey && origin_hotkey == destination_hotkey { - ensure!(origin_netuid != destination_netuid, Error::::SameNetuid); + ensure!( + origin_netuid != destination_netuid, + Error::::SameSubnetId + ); } // Ensure that both subnets exist. diff --git a/pallets/subtensor/src/tests/move_stake.rs b/pallets/subtensor/src/tests/move_stake.rs index dd85ab9075..0590fb9a1c 100644 --- a/pallets/subtensor/src/tests/move_stake.rs +++ b/pallets/subtensor/src/tests/move_stake.rs @@ -596,7 +596,7 @@ fn test_do_move_same_hotkey_fails() { netuid, alpha, ), - Err(Error::::SameNetuid.into()) + Err(Error::::SameSubnetId.into()) ); // Check that stake remains unchanged @@ -1309,7 +1309,7 @@ fn test_do_swap_same_subnet() { netuid, alpha_before ), - Err(Error::::SameNetuid.into()) + Err(Error::::SameSubnetId.into()) ); let alpha_after = From f974a94f379766bc14f83671456c59a315620787 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 6 May 2025 19:25:22 +0400 Subject: [PATCH 195/226] Rename error SameSubnetId -> SameNetuid --- pallets/subtensor/src/macros/errors.rs | 2 +- pallets/subtensor/src/staking/stake_utils.rs | 5 +---- pallets/subtensor/src/tests/move_stake.rs | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index a5bf028831..2a8e5bc346 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -213,6 +213,6 @@ mod errors { /// Zero max stake amount ZeroMaxStakeAmount, /// Invalid netuid duplication - SameSubnetId, + SameNetuid, } } diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index a793a56edc..65280c8a43 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -1012,10 +1012,7 @@ impl Pallet { ) -> Result<(), Error> { // Ensure stake transition is actually happening if origin_coldkey == destination_coldkey && origin_hotkey == destination_hotkey { - ensure!( - origin_netuid != destination_netuid, - Error::::SameSubnetId - ); + ensure!(origin_netuid != destination_netuid, Error::::SameNetuid); } // Ensure that both subnets exist. diff --git a/pallets/subtensor/src/tests/move_stake.rs b/pallets/subtensor/src/tests/move_stake.rs index 0590fb9a1c..dd85ab9075 100644 --- a/pallets/subtensor/src/tests/move_stake.rs +++ b/pallets/subtensor/src/tests/move_stake.rs @@ -596,7 +596,7 @@ fn test_do_move_same_hotkey_fails() { netuid, alpha, ), - Err(Error::::SameSubnetId.into()) + Err(Error::::SameNetuid.into()) ); // Check that stake remains unchanged @@ -1309,7 +1309,7 @@ fn test_do_swap_same_subnet() { netuid, alpha_before ), - Err(Error::::SameSubnetId.into()) + Err(Error::::SameNetuid.into()) ); let alpha_after = From 5862a43b2f718f9012943b6349511811d6255083 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 17:57:22 +0200 Subject: [PATCH 196/226] keep track of contributors count and allow a maximum of contributors, added migration --- pallets/crowdloan/src/lib.rs | 34 +++- .../migrate_add_contributors_count.rs | 160 +----------------- 2 files changed, 34 insertions(+), 160 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 1d4ed4e263..2615d78bf3 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -168,6 +168,11 @@ pub mod pallet { OptionQuery, >; + /// A map of crowdloan ids to their contributors count. + #[pallet::storage] + pub type ContributorsCount = + StorageMap<_, Twox64Concat, CrowdloanId, u32, OptionQuery>; + /// The current crowdloan id that will be set during the finalize call, making it /// temporarily accessible to the dispatched call. #[pallet::storage] @@ -386,6 +391,7 @@ pub mod pallet { )?; Contributions::::insert(crowdloan_id, &creator, deposit); + ContributorsCount::::insert(crowdloan_id, 1); Self::deposit_event(Event::::Created { crowdloan_id, @@ -431,8 +437,10 @@ pub mod pallet { ); // Ensure the crowdloan has not reached the maximum number of contributors + let contributors_count = + ContributorsCount::::get(crowdloan_id).ok_or(Error::::InvalidCrowdloanId)?; ensure!( - crowdloan.contributors_count < T::MaxContributors::get(), + contributors_count < T::MaxContributors::get(), Error::::MaxContributorsReached ); @@ -462,10 +470,7 @@ pub mod pallet { .ok_or(Error::::Overflow)? } else { // We have a new contribution - crowdloan.contributors_count = crowdloan - .contributors_count - .checked_add(1) - .ok_or(Error::::Overflow)?; + Self::increment_contributor_count(crowdloan_id); amount }; @@ -524,10 +529,7 @@ pub mod pallet { Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); } else { Contributions::::remove(crowdloan_id, &who); - crowdloan.contributors_count = crowdloan - .contributors_count - .checked_sub(1) - .ok_or(Error::::Underflow)?; + Self::decrement_contributor_count(crowdloan_id); } CurrencyOf::::transfer( @@ -686,6 +688,7 @@ pub mod pallet { // Clear refunded contributors for contributor in refunded_contributors { Contributions::::remove(crowdloan_id, &contributor); + Self::decrement_contributor_count(crowdloan_id); } if all_refunded { @@ -748,6 +751,7 @@ pub mod pallet { // Remove the crowdloan let _ = frame_system::Pallet::::dec_providers(&crowdloan.funds_account).defensive(); Crowdloans::::remove(crowdloan_id); + ContributorsCount::::remove(crowdloan_id); Self::deposit_event(Event::::Dissolved { crowdloan_id }); Ok(()) @@ -888,4 +892,16 @@ impl Pallet { ); Ok(()) } + + fn increment_contributor_count(crowdloan_id: CrowdloanId) { + ContributorsCount::::mutate(crowdloan_id, |count| { + *count = count.map(|v| v.saturating_add(1)) + }); + } + + fn decrement_contributor_count(crowdloan_id: CrowdloanId) { + ContributorsCount::::mutate(crowdloan_id, |count| { + *count = count.map(|v| v.saturating_sub(1)) + }); + } } diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 3b094843ce..684c4b1cff 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -1,30 +1,11 @@ use alloc::string::String; -use frame_support::{BoundedVec, migration::storage_key_iter, traits::Get, weights::Weight}; -use subtensor_macros::freeze_struct; +use frame_support::{BoundedVec, traits::Get, weights::Weight}; use crate::*; -mod old_storage { - use super::*; - - #[freeze_struct("84bcbf9b8d3f0ddf")] - #[derive(Encode, Decode, Debug)] - pub struct OldCrowdloanInfo { - pub creator: AccountId, - pub deposit: Balance, - pub min_contribution: Balance, - pub end: BlockNumber, - pub cap: Balance, - pub funds_account: AccountId, - pub raised: Balance, - pub target_address: Option, - pub call: Option, - pub finalized: bool, - } -} - pub fn migrate_add_contributors_count() -> Weight { - let migration_name = BoundedVec::truncate_from(b"migrate_add_contributors_count".to_vec()); + let migration_name = + BoundedVec::truncate_from(b"migrate_crowdloan_contributors_count".to_vec()); let mut weight = T::DbWeight::get().reads(1); if HasMigrationRun::::get(&migration_name) { @@ -40,44 +21,17 @@ pub fn migrate_add_contributors_count() -> Weight { String::from_utf8_lossy(&migration_name) ); - let pallet_name = b"Crowdloan"; - let item_name = b"Crowdloans"; - let crowdloans = storage_key_iter::< - CrowdloanId, - old_storage::OldCrowdloanInfo< - T::AccountId, - BalanceOf, - BlockNumberFor, - BoundedCallOf, - >, - Twox64Concat, - >(pallet_name, item_name) - .collect::>(); - weight = weight.saturating_add(T::DbWeight::get().reads(crowdloans.len() as u64)); + // Get all crowdloans, there is not so many at the moment so we are safe. + let crowdloan_ids = Crowdloans::::iter_keys().collect::>(); + weight = weight.saturating_add(T::DbWeight::get().reads(crowdloan_ids.len() as u64)); - for (id, crowdloan) in crowdloans { - let contributions = Contributions::::iter_key_prefix(id) + for crowdloan_id in crowdloan_ids { + let contributions = Contributions::::iter_key_prefix(crowdloan_id) .collect::>() .len(); weight = weight.saturating_add(T::DbWeight::get().reads(contributions as u64)); - Crowdloans::::insert( - id, - CrowdloanInfo { - creator: crowdloan.creator, - deposit: crowdloan.deposit, - min_contribution: crowdloan.min_contribution, - end: crowdloan.end, - cap: crowdloan.cap, - funds_account: crowdloan.funds_account, - raised: crowdloan.raised, - target_address: crowdloan.target_address, - call: crowdloan.call, - finalized: crowdloan.finalized, - contributors_count: contributions as u32, - }, - ); - weight = weight.saturating_add(T::DbWeight::get().writes(1)); + ContributorsCount::::insert(crowdloan_id, contributions as u32); } HasMigrationRun::::insert(&migration_name, true); @@ -90,99 +44,3 @@ pub fn migrate_add_contributors_count() -> Weight { weight } - -#[cfg(test)] -mod tests { - use frame_support::{Hashable, storage::unhashed::put_raw}; - use sp_core::U256; - use sp_io::hashing::twox_128; - - use super::*; - use crate::mock::{Test, TestState}; - - #[test] - fn test_migrate_add_contributors_count_works() { - TestState::default().build_and_execute(|| { - let pallet_name = twox_128(b"Crowdloan"); - let storage_name = twox_128(b"Crowdloans"); - let prefix = [pallet_name, storage_name].concat(); - - let items = vec![ - ( - old_storage::OldCrowdloanInfo { - creator: U256::from(1), - deposit: 100u64, - min_contribution: 10u64, - end: 100u64, - cap: 1000u64, - funds_account: U256::from(2), - raised: 0u64, - target_address: None, - call: None::>, - finalized: false, - }, - vec![(U256::from(1), 100)], - ), - ( - old_storage::OldCrowdloanInfo { - creator: U256::from(1), - deposit: 100u64, - min_contribution: 10u64, - end: 100u64, - cap: 1000u64, - funds_account: U256::from(2), - raised: 0u64, - target_address: None, - call: None::>, - finalized: false, - }, - vec![ - (U256::from(1), 100), - (U256::from(2), 100), - (U256::from(3), 100), - ], - ), - ( - old_storage::OldCrowdloanInfo { - creator: U256::from(1), - deposit: 100u64, - min_contribution: 10u64, - end: 100u64, - cap: 1000u64, - funds_account: U256::from(2), - raised: 0u64, - target_address: None, - call: None::>, - finalized: false, - }, - vec![ - (U256::from(1), 100), - (U256::from(2), 100), - (U256::from(3), 100), - (U256::from(4), 100), - (U256::from(5), 100), - ], - ), - ]; - - for (id, (crowdloan, contributions)) in items.into_iter().enumerate() { - let key = [prefix.clone(), (id as u32).twox_64_concat()].concat(); - put_raw(&key, &crowdloan.encode()); - - for (contributor, amount) in contributions { - Contributions::::insert(id as u32, contributor, amount); - } - } - - migrate_add_contributors_count::(); - - assert!(Crowdloans::::get(0).is_some_and(|c| c.contributors_count == 1)); - assert!(Crowdloans::::get(1).is_some_and(|c| c.contributors_count == 3)); - assert!(Crowdloans::::get(2).is_some_and(|c| c.contributors_count == 5)); - - assert!(HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - ))); - }); - } -} From 774a5fcdd0a0d82df0b2e7f11c214e597d42d635 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 17:57:32 +0200 Subject: [PATCH 197/226] fix tests --- pallets/crowdloan/src/tests.rs | 84 +++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 1e03854b1f..2fdc84c0a7 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -59,6 +59,11 @@ fn test_create_succeeds() { .collect::>(), vec![(creator, deposit)] ); + // ensure the contributor count is updated + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); // ensure the raised amount is updated correctly assert!( pallet_crowdloan::Crowdloans::::get(crowdloan_id) @@ -334,9 +339,9 @@ fn test_contribute_succeeds() { let crowdloan_id: CrowdloanId = 0; // only the creator has contributed so far - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 1) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) ); // first contribution to the crowdloan from creator @@ -363,6 +368,10 @@ fn test_contribute_succeeds() { pallet_crowdloan::Crowdloans::::get(crowdloan_id) .is_some_and(|c| c.contributors_count == 1) ); + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) + ); assert_eq!( Balances::free_balance(creator), 200 - amount - initial_deposit @@ -389,9 +398,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), Some(100) ); - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 2) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(2) ); assert_eq!(Balances::free_balance(contributor1), 500 - amount); @@ -416,9 +425,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), Some(50) ); - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 3) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(3) ); assert_eq!(Balances::free_balance(contributor2), 200 - amount); @@ -820,9 +829,9 @@ fn test_withdraw_from_contributor_succeeds() { run_to_block(60); // ensure the contributor count is correct - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 3) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(3) ); // withdraw from contributor1 @@ -835,9 +844,9 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), None, ); - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 2) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(2) ); // ensure the contributor1 has the correct amount assert_eq!( @@ -855,9 +864,9 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), None, ); - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 1) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) ); // ensure the contributor2 has the correct amount assert_eq!( @@ -909,9 +918,9 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { )); // ensure the contributor count is correct - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 1) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) ); // withdraw @@ -932,9 +941,9 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { Some(initial_deposit), ); // ensure the contributor count hasn't changed because deposit is kept - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 1) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) ); // ensure the crowdloan account has the correct amount @@ -1580,9 +1589,9 @@ fn test_refund_succeeds() { } // ensure the contributor count is correct - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 7) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(7) ); // run some more blocks past the end of the contribution period @@ -1595,9 +1604,9 @@ fn test_refund_succeeds() { )); // ensure the contributor count is correct, we processed 5 refunds - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 2) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(2) ); // ensure the crowdloan account has the correct amount @@ -1625,9 +1634,9 @@ fn test_refund_succeeds() { // ensure the contributor count is correct, we processed 1 more refund // keeping deposit - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 1) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) ); // ensure the crowdloan account has the correct amount @@ -1761,9 +1770,9 @@ fn test_dissolve_succeeds() { let crowdloan_id: CrowdloanId = 0; // ensure the contributor count is correct - assert!( - pallet_crowdloan::Crowdloans::::get(crowdloan_id) - .is_some_and(|c| c.contributors_count == 1) + assert_eq!( + pallet_crowdloan::ContributorsCount::::get(crowdloan_id), + Some(1) ); // dissolve the crowdloan @@ -1780,6 +1789,9 @@ fn test_dissolve_succeeds() { crowdloan_id )); + // ensure the contributor count is removed + assert!(pallet_crowdloan::ContributorsCount::::get(crowdloan_id).is_none()); + // ensure the event is emitted assert_eq!( last_event(), From d3477071aec6ca1c39c8a3a4910239646cebf45d Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:01:36 +0200 Subject: [PATCH 198/226] fix migration name --- .../crowdloan/src/migrations/migrate_add_contributors_count.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 684c4b1cff..fc5de151cb 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -4,8 +4,7 @@ use frame_support::{BoundedVec, traits::Get, weights::Weight}; use crate::*; pub fn migrate_add_contributors_count() -> Weight { - let migration_name = - BoundedVec::truncate_from(b"migrate_crowdloan_contributors_count".to_vec()); + let migration_name = BoundedVec::truncate_from(b"migrate_add_contributors_count".to_vec()); let mut weight = T::DbWeight::get().reads(1); if HasMigrationRun::::get(&migration_name) { From 017f3ff09e35ff085eef0c3bd99c69cb191106ea Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:18:41 +0200 Subject: [PATCH 199/226] added migration test --- .../migrate_add_contributors_count.rs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index fc5de151cb..cb399634eb 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -43,3 +43,54 @@ pub fn migrate_add_contributors_count() -> Weight { weight } + +#[cfg(test)] +mod tests { + use crate::mock::{Test, TestState}; + + use super::*; + use sp_core::U256; + + #[test] + fn test_migrate_add_contributors_count_works() { + TestState::default().build_and_execute(|| { + Crowdloans::::insert( + 0, + CrowdloanInfo { + creator: U256::from(1), + deposit: 100, + min_contribution: 10, + cap: 1000, + end: 100, + call: None, + finalized: false, + raised: 0, + funds_account: U256::from(2), + target_address: None, + }, + ); + + Contributions::::insert(0, U256::from(1), 100); + Contributions::::insert(0, U256::from(2), 100); + Contributions::::insert(0, U256::from(3), 100); + + assert_eq!(ContributorsCount::::get(0), None); + assert_eq!( + HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + )), + false + ); + + migrate_add_contributors_count::(); + + assert_eq!(ContributorsCount::::get(0), Some(3)); + assert_eq!( + HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + )), + true + ); + }); + } +} From 291878918eb5607f81c959830679786436eba296 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:21:39 +0200 Subject: [PATCH 200/226] cargo clippy --- .../src/migrations/migrate_add_contributors_count.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index cb399634eb..9d610fd94e 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -75,21 +75,19 @@ mod tests { Contributions::::insert(0, U256::from(3), 100); assert_eq!(ContributorsCount::::get(0), None); - assert_eq!( - HasMigrationRun::::get(BoundedVec::truncate_from( + assert!( + !HasMigrationRun::::get(BoundedVec::truncate_from( b"migrate_add_contributors_count".to_vec() - )), - false + )) ); migrate_add_contributors_count::(); assert_eq!(ContributorsCount::::get(0), Some(3)); - assert_eq!( + assert!( HasMigrationRun::::get(BoundedVec::truncate_from( b"migrate_add_contributors_count".to_vec() - )), - true + )) ); }); } From ae65d498948c7c3a1b7f3f7cd1ba00a744234e06 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Mon, 5 May 2025 18:22:17 +0200 Subject: [PATCH 201/226] cargo fmt --- .../migrations/migrate_add_contributors_count.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 9d610fd94e..378e8bcc3d 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -75,20 +75,16 @@ mod tests { Contributions::::insert(0, U256::from(3), 100); assert_eq!(ContributorsCount::::get(0), None); - assert!( - !HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - )) - ); + assert!(!HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + ))); migrate_add_contributors_count::(); assert_eq!(ContributorsCount::::get(0), Some(3)); - assert!( - HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - )) - ); + assert!(HasMigrationRun::::get(BoundedVec::truncate_from( + b"migrate_add_contributors_count".to_vec() + ))); }); } } From d3c05ee6589d0ed1503c636d50e10a46839bda92 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 18:07:12 +0200 Subject: [PATCH 202/226] move contributors count to Crowdloan struct and update migration --- pallets/crowdloan/Cargo.toml | 4 +- pallets/crowdloan/src/lib.rs | 33 +--- .../migrate_add_contributors_count.rs | 166 ++++++++++++++---- pallets/crowdloan/src/tests.rs | 84 ++++----- 4 files changed, 173 insertions(+), 114 deletions(-) diff --git a/pallets/crowdloan/Cargo.toml b/pallets/crowdloan/Cargo.toml index e8d582fa44..b662d7269f 100644 --- a/pallets/crowdloan/Cargo.toml +++ b/pallets/crowdloan/Cargo.toml @@ -22,12 +22,12 @@ frame-system.workspace = true sp-runtime.workspace = true sp-std.workspace = true log = { workspace = true } +sp-core = { default-features = true, workspace = true } +sp-io = { default-features = true, workspace = true } [dev-dependencies] pallet-balances = { default-features = true, workspace = true } pallet-preimage = { default-features = true, workspace = true } -sp-core = { default-features = true, workspace = true } -sp-io = { default-features = true, workspace = true } [features] default = ["std"] diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index 2615d78bf3..b25807151a 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -168,11 +168,6 @@ pub mod pallet { OptionQuery, >; - /// A map of crowdloan ids to their contributors count. - #[pallet::storage] - pub type ContributorsCount = - StorageMap<_, Twox64Concat, CrowdloanId, u32, OptionQuery>; - /// The current crowdloan id that will be set during the finalize call, making it /// temporarily accessible to the dispatched call. #[pallet::storage] @@ -391,7 +386,6 @@ pub mod pallet { )?; Contributions::::insert(crowdloan_id, &creator, deposit); - ContributorsCount::::insert(crowdloan_id, 1); Self::deposit_event(Event::::Created { crowdloan_id, @@ -437,10 +431,8 @@ pub mod pallet { ); // Ensure the crowdloan has not reached the maximum number of contributors - let contributors_count = - ContributorsCount::::get(crowdloan_id).ok_or(Error::::InvalidCrowdloanId)?; ensure!( - contributors_count < T::MaxContributors::get(), + crowdloan.contributors_count < T::MaxContributors::get(), Error::::MaxContributorsReached ); @@ -470,7 +462,7 @@ pub mod pallet { .ok_or(Error::::Overflow)? } else { // We have a new contribution - Self::increment_contributor_count(crowdloan_id); + crowdloan.contributors_count += 1; amount }; @@ -529,7 +521,7 @@ pub mod pallet { Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); } else { Contributions::::remove(crowdloan_id, &who); - Self::decrement_contributor_count(crowdloan_id); + crowdloan.contributors_count -= 1; } CurrencyOf::::transfer( @@ -679,16 +671,12 @@ pub mod pallet { refund_count = refund_count.checked_add(1).ok_or(Error::::Overflow)?; } - crowdloan.contributors_count = crowdloan - .contributors_count - .checked_sub(refund_count) - .ok_or(Error::::Underflow)?; + crowdloan.contributors_count -= refund_count; Crowdloans::::insert(crowdloan_id, &crowdloan); // Clear refunded contributors for contributor in refunded_contributors { Contributions::::remove(crowdloan_id, &contributor); - Self::decrement_contributor_count(crowdloan_id); } if all_refunded { @@ -751,7 +739,6 @@ pub mod pallet { // Remove the crowdloan let _ = frame_system::Pallet::::dec_providers(&crowdloan.funds_account).defensive(); Crowdloans::::remove(crowdloan_id); - ContributorsCount::::remove(crowdloan_id); Self::deposit_event(Event::::Dissolved { crowdloan_id }); Ok(()) @@ -892,16 +879,4 @@ impl Pallet { ); Ok(()) } - - fn increment_contributor_count(crowdloan_id: CrowdloanId) { - ContributorsCount::::mutate(crowdloan_id, |count| { - *count = count.map(|v| v.saturating_add(1)) - }); - } - - fn decrement_contributor_count(crowdloan_id: CrowdloanId) { - ContributorsCount::::mutate(crowdloan_id, |count| { - *count = count.map(|v| v.saturating_sub(1)) - }); - } } diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index 378e8bcc3d..d5fbc4ec97 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -1,8 +1,26 @@ use alloc::string::String; -use frame_support::{BoundedVec, traits::Get, weights::Weight}; +use frame_support::{BoundedVec, migration::storage_key_iter, traits::Get, weights::Weight}; use crate::*; +mod old_storage { + use super::*; + + #[derive(Encode, Decode, Debug)] + pub struct OldCrowdloanInfo { + pub creator: AccountId, + pub deposit: Balance, + pub min_contribution: Balance, + pub end: BlockNumber, + pub cap: Balance, + pub funds_account: AccountId, + pub raised: Balance, + pub target_address: Option, + pub call: Option, + pub finalized: bool, + } +} + pub fn migrate_add_contributors_count() -> Weight { let migration_name = BoundedVec::truncate_from(b"migrate_add_contributors_count".to_vec()); let mut weight = T::DbWeight::get().reads(1); @@ -20,17 +38,44 @@ pub fn migrate_add_contributors_count() -> Weight { String::from_utf8_lossy(&migration_name) ); - // Get all crowdloans, there is not so many at the moment so we are safe. - let crowdloan_ids = Crowdloans::::iter_keys().collect::>(); - weight = weight.saturating_add(T::DbWeight::get().reads(crowdloan_ids.len() as u64)); - - for crowdloan_id in crowdloan_ids { - let contributions = Contributions::::iter_key_prefix(crowdloan_id) + let pallet_name = b"Crowdloan"; + let item_name = b"Crowdloans"; + let crowdloans = storage_key_iter::< + CrowdloanId, + old_storage::OldCrowdloanInfo< + T::AccountId, + BalanceOf, + BlockNumberFor, + BoundedCallOf, + >, + Twox64Concat, + >(pallet_name, item_name) + .collect::>(); + weight = weight.saturating_add(T::DbWeight::get().reads(crowdloans.len() as u64)); + + for (id, crowdloan) in crowdloans { + let contributions = Contributions::::iter_key_prefix(id) .collect::>() .len(); weight = weight.saturating_add(T::DbWeight::get().reads(contributions as u64)); - ContributorsCount::::insert(crowdloan_id, contributions as u32); + Crowdloans::::insert( + id, + CrowdloanInfo { + creator: crowdloan.creator, + deposit: crowdloan.deposit, + min_contribution: crowdloan.min_contribution, + end: crowdloan.end, + cap: crowdloan.cap, + funds_account: crowdloan.funds_account, + raised: crowdloan.raised, + target_address: crowdloan.target_address, + call: crowdloan.call, + finalized: crowdloan.finalized, + contributors_count: contributions as u32, + }, + ); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); } HasMigrationRun::::insert(&migration_name, true); @@ -46,42 +91,93 @@ pub fn migrate_add_contributors_count() -> Weight { #[cfg(test)] mod tests { - use crate::mock::{Test, TestState}; + use frame_support::{Hashable, storage::unhashed::put_raw}; + use sp_core::U256; + use sp_io::hashing::twox_128; use super::*; - use sp_core::U256; + use crate::mock::{Test, TestState}; #[test] fn test_migrate_add_contributors_count_works() { TestState::default().build_and_execute(|| { - Crowdloans::::insert( - 0, - CrowdloanInfo { - creator: U256::from(1), - deposit: 100, - min_contribution: 10, - cap: 1000, - end: 100, - call: None, - finalized: false, - raised: 0, - funds_account: U256::from(2), - target_address: None, - }, - ); - - Contributions::::insert(0, U256::from(1), 100); - Contributions::::insert(0, U256::from(2), 100); - Contributions::::insert(0, U256::from(3), 100); - - assert_eq!(ContributorsCount::::get(0), None); - assert!(!HasMigrationRun::::get(BoundedVec::truncate_from( - b"migrate_add_contributors_count".to_vec() - ))); + let pallet_name = twox_128(b"Crowdloan"); + let storage_name = twox_128(b"Crowdloans"); + let prefix = [pallet_name, storage_name].concat(); + + let items = vec![ + ( + old_storage::OldCrowdloanInfo { + creator: U256::from(1), + deposit: 100u64, + min_contribution: 10u64, + end: 100u64, + cap: 1000u64, + funds_account: U256::from(2), + raised: 0u64, + target_address: None, + call: None::>, + finalized: false, + }, + vec![(U256::from(1), 100)], + ), + ( + old_storage::OldCrowdloanInfo { + creator: U256::from(1), + deposit: 100u64, + min_contribution: 10u64, + end: 100u64, + cap: 1000u64, + funds_account: U256::from(2), + raised: 0u64, + target_address: None, + call: None::>, + finalized: false, + }, + vec![ + (U256::from(1), 100), + (U256::from(2), 100), + (U256::from(3), 100), + ], + ), + ( + old_storage::OldCrowdloanInfo { + creator: U256::from(1), + deposit: 100u64, + min_contribution: 10u64, + end: 100u64, + cap: 1000u64, + funds_account: U256::from(2), + raised: 0u64, + target_address: None, + call: None::>, + finalized: false, + }, + vec![ + (U256::from(1), 100), + (U256::from(2), 100), + (U256::from(3), 100), + (U256::from(4), 100), + (U256::from(5), 100), + ], + ), + ]; + + for (id, (crowdloan, contributions)) in items.into_iter().enumerate() { + let key = [prefix.clone(), (id as u32).twox_64_concat()].concat(); + put_raw(&key, &crowdloan.encode()); + + for (contributor, amount) in contributions { + Contributions::::insert(id as u32, contributor, amount); + } + } migrate_add_contributors_count::(); - assert_eq!(ContributorsCount::::get(0), Some(3)); + assert!(Crowdloans::::get(0).is_some_and(|c| c.contributors_count == 1)); + assert!(Crowdloans::::get(1).is_some_and(|c| c.contributors_count == 3)); + assert!(Crowdloans::::get(2).is_some_and(|c| c.contributors_count == 5)); + assert!(HasMigrationRun::::get(BoundedVec::truncate_from( b"migrate_add_contributors_count".to_vec() ))); diff --git a/pallets/crowdloan/src/tests.rs b/pallets/crowdloan/src/tests.rs index 2fdc84c0a7..1e03854b1f 100644 --- a/pallets/crowdloan/src/tests.rs +++ b/pallets/crowdloan/src/tests.rs @@ -59,11 +59,6 @@ fn test_create_succeeds() { .collect::>(), vec![(creator, deposit)] ); - // ensure the contributor count is updated - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) - ); // ensure the raised amount is updated correctly assert!( pallet_crowdloan::Crowdloans::::get(crowdloan_id) @@ -339,9 +334,9 @@ fn test_contribute_succeeds() { let crowdloan_id: CrowdloanId = 0; // only the creator has contributed so far - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // first contribution to the crowdloan from creator @@ -368,10 +363,6 @@ fn test_contribute_succeeds() { pallet_crowdloan::Crowdloans::::get(crowdloan_id) .is_some_and(|c| c.contributors_count == 1) ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) - ); assert_eq!( Balances::free_balance(creator), 200 - amount - initial_deposit @@ -398,9 +389,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), Some(100) ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(2) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 2) ); assert_eq!(Balances::free_balance(contributor1), 500 - amount); @@ -425,9 +416,9 @@ fn test_contribute_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), Some(50) ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(3) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 3) ); assert_eq!(Balances::free_balance(contributor2), 200 - amount); @@ -829,9 +820,9 @@ fn test_withdraw_from_contributor_succeeds() { run_to_block(60); // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(3) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 3) ); // withdraw from contributor1 @@ -844,9 +835,9 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor1), None, ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(2) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 2) ); // ensure the contributor1 has the correct amount assert_eq!( @@ -864,9 +855,9 @@ fn test_withdraw_from_contributor_succeeds() { pallet_crowdloan::Contributions::::get(crowdloan_id, contributor2), None, ); - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // ensure the contributor2 has the correct amount assert_eq!( @@ -918,9 +909,9 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { )); // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // withdraw @@ -941,9 +932,9 @@ fn test_withdraw_from_creator_with_contribution_over_deposit_succeeds() { Some(initial_deposit), ); // ensure the contributor count hasn't changed because deposit is kept - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // ensure the crowdloan account has the correct amount @@ -1589,9 +1580,9 @@ fn test_refund_succeeds() { } // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(7) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 7) ); // run some more blocks past the end of the contribution period @@ -1604,9 +1595,9 @@ fn test_refund_succeeds() { )); // ensure the contributor count is correct, we processed 5 refunds - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(2) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 2) ); // ensure the crowdloan account has the correct amount @@ -1634,9 +1625,9 @@ fn test_refund_succeeds() { // ensure the contributor count is correct, we processed 1 more refund // keeping deposit - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // ensure the crowdloan account has the correct amount @@ -1770,9 +1761,9 @@ fn test_dissolve_succeeds() { let crowdloan_id: CrowdloanId = 0; // ensure the contributor count is correct - assert_eq!( - pallet_crowdloan::ContributorsCount::::get(crowdloan_id), - Some(1) + assert!( + pallet_crowdloan::Crowdloans::::get(crowdloan_id) + .is_some_and(|c| c.contributors_count == 1) ); // dissolve the crowdloan @@ -1789,9 +1780,6 @@ fn test_dissolve_succeeds() { crowdloan_id )); - // ensure the contributor count is removed - assert!(pallet_crowdloan::ContributorsCount::::get(crowdloan_id).is_none()); - // ensure the event is emitted assert_eq!( last_event(), From 677749addd8a733dea1b60092dd683dedec46638 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 18:26:48 +0200 Subject: [PATCH 203/226] fix benchmark --- pallets/crowdloan/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/crowdloan/Cargo.toml b/pallets/crowdloan/Cargo.toml index b662d7269f..e8d582fa44 100644 --- a/pallets/crowdloan/Cargo.toml +++ b/pallets/crowdloan/Cargo.toml @@ -22,12 +22,12 @@ frame-system.workspace = true sp-runtime.workspace = true sp-std.workspace = true log = { workspace = true } -sp-core = { default-features = true, workspace = true } -sp-io = { default-features = true, workspace = true } [dev-dependencies] pallet-balances = { default-features = true, workspace = true } pallet-preimage = { default-features = true, workspace = true } +sp-core = { default-features = true, workspace = true } +sp-io = { default-features = true, workspace = true } [features] default = ["std"] From 8d238964b7ed41733b046c942dac0edde1fcb949 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 6 May 2025 18:28:28 +0200 Subject: [PATCH 204/226] fix arithmetic --- pallets/crowdloan/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pallets/crowdloan/src/lib.rs b/pallets/crowdloan/src/lib.rs index b25807151a..1d4ed4e263 100644 --- a/pallets/crowdloan/src/lib.rs +++ b/pallets/crowdloan/src/lib.rs @@ -462,7 +462,10 @@ pub mod pallet { .ok_or(Error::::Overflow)? } else { // We have a new contribution - crowdloan.contributors_count += 1; + crowdloan.contributors_count = crowdloan + .contributors_count + .checked_add(1) + .ok_or(Error::::Overflow)?; amount }; @@ -521,7 +524,10 @@ pub mod pallet { Contributions::::insert(crowdloan_id, &who, crowdloan.deposit); } else { Contributions::::remove(crowdloan_id, &who); - crowdloan.contributors_count -= 1; + crowdloan.contributors_count = crowdloan + .contributors_count + .checked_sub(1) + .ok_or(Error::::Underflow)?; } CurrencyOf::::transfer( @@ -671,7 +677,10 @@ pub mod pallet { refund_count = refund_count.checked_add(1).ok_or(Error::::Overflow)?; } - crowdloan.contributors_count -= refund_count; + crowdloan.contributors_count = crowdloan + .contributors_count + .checked_sub(refund_count) + .ok_or(Error::::Underflow)?; Crowdloans::::insert(crowdloan_id, &crowdloan); // Clear refunded contributors From f7363820324ed73b37b65f5ae2324e0aef28498c Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 7 May 2025 09:22:46 +0200 Subject: [PATCH 205/226] added freeze_struct to OldCrowdloanInfo --- .../crowdloan/src/migrations/migrate_add_contributors_count.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs index d5fbc4ec97..3b094843ce 100644 --- a/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs +++ b/pallets/crowdloan/src/migrations/migrate_add_contributors_count.rs @@ -1,11 +1,13 @@ use alloc::string::String; use frame_support::{BoundedVec, migration::storage_key_iter, traits::Get, weights::Weight}; +use subtensor_macros::freeze_struct; use crate::*; mod old_storage { use super::*; + #[freeze_struct("84bcbf9b8d3f0ddf")] #[derive(Encode, Decode, Debug)] pub struct OldCrowdloanInfo { pub creator: AccountId, From b43e332f97ca0696490695872fa51526682ac108 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 7 May 2025 13:40:39 -0400 Subject: [PATCH 206/226] have Dockerfile use a local user instead of root * also use rust:latest so we don't have to keep bumping --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 447ed98b5e..3d0e1600aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Subtensor Dockerfile (hardened) +# Subtensor Dockerfile (hardened, full-functionality) # – Builds production and local binaries # – Final runtime images run as non-root `subtensor` user (UID/GID 10001) # ------------------------------------------------------------------------------ From 7ca5bcbeba67c37014a4eb040beb08dedd3971ad Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 7 May 2025 13:47:27 -0400 Subject: [PATCH 207/226] clean up --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3d0e1600aa..447ed98b5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # ------------------------------------------------------------------------------ -# Subtensor Dockerfile (hardened, full-functionality) +# Subtensor Dockerfile (hardened) # – Builds production and local binaries # – Final runtime images run as non-root `subtensor` user (UID/GID 10001) # ------------------------------------------------------------------------------ From 04a86f825d16a9d4b1f2dbf7c763bf6d463b30cd Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 4 Feb 2025 08:06:49 +0000 Subject: [PATCH 208/226] add yuma4 scenario test --- pallets/subtensor/src/tests/epoch.rs | 155 +++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index e4b2f02574..840c77dba7 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3197,3 +3197,158 @@ fn assert_approx_eq_vec_of_vec( } } } + +// test Yuma 4 scenarios over a sequence of epochs. +fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) { + let block_number = System::block_number(); + let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead + add_network(netuid, tempo, 0); + + SubtensorModule::set_max_allowed_uids(netuid, n); + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + SubtensorModule::set_max_registrations_per_block(netuid, n); + SubtensorModule::set_target_registrations_per_interval(netuid, n); + SubtensorModule::set_weights_set_rate_limit(netuid, 0); + SubtensorModule::set_min_allowed_weights(netuid, 1); + SubtensorModule::set_max_weight_limit(netuid, u16::MAX); + SubtensorModule::set_bonds_penalty(netuid, 0); + + // === Register + for key in 0..n as u64 { + SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), max_stake); + let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( + netuid, + block_number, + key * 1_000_000, + &U256::from(key), + ); + assert_ok!(SubtensorModule::register( + <::RuntimeOrigin>::signed(U256::from(key)), + netuid, + block_number, + nonce, + work, + U256::from(key), + U256::from(key) + )); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &U256::from(key), + &U256::from(key), + netuid, + stakes[key as usize], + ); + } + assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); + assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); + + // Enable Liquid Alpha + SubtensorModule::set_kappa(netuid, 0); + SubtensorModule::set_liquid_alpha_enabled(netuid, true); + + SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.9), I32F32::from_num(0.99)); + + // === Issue validator permits + SubtensorModule::set_max_allowed_validators(netuid, 3); + assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), 3); + SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators + next_block(); // run to next block to ensure weights are set on nodes after their registration block +} + +fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) { + next_block(); + if sparse { + SubtensorModule::epoch(netuid, 1_000_000_000); + } else { + SubtensorModule::epoch_dense(netuid, 1_000_000_000); + } + let bonds = SubtensorModule::get_bonds(netuid); + + // server 1 + assert_eq!(bonds[0][3], target_bonds[0][0]); + assert_eq!(bonds[1][3], target_bonds[1][0]); + assert_eq!(bonds[2][3], target_bonds[2][0]); + + // server 2 + assert_eq!(bonds[0][4], target_bonds[0][1]); + assert_eq!(bonds[1][4], target_bonds[1][1]); + assert_eq!(bonds[2][4], target_bonds[2][1]); +} + +#[test] +fn test_yuma_4_kappa_moves_last() { + new_test_ext(1).execute_with(|| { + let sparse: bool = false; + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // Validator A: kappa / Big validator (0.8) - moves last + // Validator B: Small eager validator (0.1) - moves first + // Validator C: Small lazy validator (0.1) - moves second + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_4_scenario(netuid, n, max_stake, stakes); + + // Initially, consensus is achieved by all Validators + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![u16::MAX, 0], + 0 + )); + } + let target = vec![vec![65535, 0], vec![65535, 0], vec![65535, 0]]; + run_epoch_check_bonds(netuid, sparse, target); + + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 1 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + let target = vec![vec![65535, 0], vec![220, 65535], vec![65535, 0]]; + run_epoch_check_bonds(netuid, sparse, target); + + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 2 + for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]] + .iter() + .enumerate() + { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + weights.to_vec(), + 0 + )); + } + let target = vec![vec![65535, 0], vec![1, 65535], vec![329, 64878]]; + run_epoch_check_bonds(netuid, sparse, target); + + // Subsequent epochs All validators -> Server 2 + for uid in [0, 1, 2] { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid)), + netuid, + vec![3, 4], + vec![0, u16::MAX], + 0 + )); + } + let target = vec![vec![65535, 11866], vec![0, 65535], vec![328, 64996]]; + run_epoch_check_bonds(netuid, sparse, target); + }) +} From 4a16441c56ac178b96022c143db9f896d10280ac Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 5 Feb 2025 14:09:34 +0000 Subject: [PATCH 209/226] fix alpha values --- pallets/subtensor/src/tests/epoch.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 840c77dba7..97c74c5335 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3242,7 +3242,7 @@ fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); // Enable Liquid Alpha - SubtensorModule::set_kappa(netuid, 0); + SubtensorModule::set_kappa(netuid, u16::MAX / 2); SubtensorModule::set_liquid_alpha_enabled(netuid, true); SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.9), I32F32::from_num(0.99)); @@ -3299,7 +3299,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 0], vec![65535, 0], vec![65535, 0]]; + let target = vec![vec![656, 0], vec![656, 0], vec![656, 0]]; run_epoch_check_bonds(netuid, sparse, target); // Validator A -> Server 1 @@ -3317,7 +3317,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 0], vec![220, 65535], vec![65535, 0]]; + let target = vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]]; run_epoch_check_bonds(netuid, sparse, target); // Validator A -> Server 1 @@ -3335,7 +3335,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 0], vec![1, 65535], vec![329, 64878]]; + let target = vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]]; run_epoch_check_bonds(netuid, sparse, target); // Subsequent epochs All validators -> Server 2 @@ -3348,7 +3348,7 @@ fn test_yuma_4_kappa_moves_last() { 0 )); } - let target = vec![vec![65535, 11866], vec![0, 65535], vec![328, 64996]]; + let target = vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]]; run_epoch_check_bonds(netuid, sparse, target); }) } From 5cd75279d13c5b07058079842b668c8d5c3ecf3f Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 11 Feb 2025 12:03:40 +0000 Subject: [PATCH 210/226] tests cleanup wip --- pallets/subtensor/src/tests/epoch.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 97c74c5335..9366869272 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -3262,16 +3262,39 @@ fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) SubtensorModule::epoch_dense(netuid, 1_000_000_000); } let bonds = SubtensorModule::get_bonds(netuid); + let dividends = SubtensorModule::get_dividends(netuid); + // Check the bonds // server 1 assert_eq!(bonds[0][3], target_bonds[0][0]); assert_eq!(bonds[1][3], target_bonds[1][0]); assert_eq!(bonds[2][3], target_bonds[2][0]); - // server 2 assert_eq!(bonds[0][4], target_bonds[0][1]); assert_eq!(bonds[1][4], target_bonds[1][1]); assert_eq!(bonds[2][4], target_bonds[2][1]); + + // Check the dividends + let epsilon = I32F32::from_num(1e-3); + for (dividend, target_dividend) in dividends.iter().zip(target_dividends.iter()) { + assert_approx_eq( + u16_proportion_to_fixed(*dividend), + fixed(*target_dividend), + epsilon, + ); + } +} + +fn set_yuma_4_weights(netuid: u16, weights: Vec>) { + for (uid, weight) in weights.iter().enumerate() { + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(U256::from(uid as u64)), + netuid, + vec![3, 4], + weight.to_vec(), + 0 + )); + } } #[test] From 1b541e61e4e0b2bffb3cb12290aac6803b5f1111 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Mon, 17 Feb 2025 12:13:27 +0000 Subject: [PATCH 211/226] add BondsResetOn param --- hyperparameters.md | 2 ++ pallets/admin-utils/src/tests/mock.rs | 2 ++ pallets/subtensor/src/lib.rs | 15 ++++++++++++++- pallets/subtensor/src/macros/config.rs | 3 +++ pallets/subtensor/src/macros/events.rs | 2 ++ pallets/subtensor/src/tests/mock.rs | 2 ++ pallets/subtensor/src/utils/misc.rs | 8 ++++++++ runtime/src/lib.rs | 2 ++ 8 files changed, 35 insertions(+), 1 deletion(-) diff --git a/hyperparameters.md b/hyperparameters.md index c8d2ce1106..66ab41c203 100644 --- a/hyperparameters.md +++ b/hyperparameters.md @@ -33,6 +33,7 @@ MaxRegistrationsPerBlock: u16 = 1; PruningScore : u16 = u16::MAX; BondsMovingAverage: u64 = 900_000; BondsPenalty: u16 = 0; +BondsResetOn: bool = false; WeightsVersionKey: u64 = 1020; MinDifficulty: u64 = 10_000_000; MaxDifficulty: u64 = u64::MAX / 4; @@ -72,6 +73,7 @@ MaxRegistrationsPerBlock: u16 = 1; PruningScore : u16 = u16::MAX; BondsMovingAverage: u64 = 900_000; BondsPenalty: u16 = 0; +BondsResetOn: bool = false; WeightsVersionKey: u64 = 400; MinDifficulty: u64 = 10_000_000; MaxDifficulty: u64 = u64::MAX / 4; diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 3b87445dc8..ff9c21f22a 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -87,6 +87,7 @@ parameter_types! { pub const InitialMaxAllowedUids: u16 = 2; pub const InitialBondsMovingAverage: u64 = 900_000; pub const InitialBondsPenalty: u16 = u16::MAX; + pub const InitialBondsResetOn: bool = 0; pub const InitialStakePruningMin: u16 = 0; pub const InitialFoundationDistribution: u64 = 0; pub const InitialDefaultDelegateTake: u16 = 11_796; // 18% honest number. @@ -168,6 +169,7 @@ impl pallet_subtensor::Config for Test { type InitialPruningScore = InitialPruningScore; type InitialBondsMovingAverage = InitialBondsMovingAverage; type InitialBondsPenalty = InitialBondsPenalty; + type InitialBondsResetOn = InitialBondsResetOn; type InitialMaxAllowedValidators = InitialMaxAllowedValidators; type InitialDefaultDelegateTake = InitialDefaultDelegateTake; type InitialMinDelegateTake = InitialMinDelegateTake; diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 2194c49764..789c0bd10a 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -695,8 +695,13 @@ pub mod pallet { pub fn DefaultBondsPenalty() -> u16 { T::InitialBondsPenalty::get() } + /// Default value for bonds reset - will not reset bonds #[pallet::type_value] + pub fn DefaultBondsResetOn() -> bool { + T::InitialBondsResetOn::get() + } /// Default validator prune length. + #[pallet::type_value] pub fn DefaultValidatorPruneLen() -> u64 { T::InitialValidatorPruneLen::get() } @@ -804,7 +809,11 @@ pub mod pallet { pub fn DefaultAlphaValues() -> (u16, u16) { (45875, 58982) } - + #[pallet::type_value] + /// Default value for network max stake. + pub fn DefaultNetworkMaxStake() -> u64 { + T::InitialNetworkMaxStake::get() + } #[pallet::type_value] /// Default value for coldkey swap schedule duration pub fn DefaultColdkeySwapScheduleDuration() -> BlockNumberFor { @@ -1370,6 +1379,10 @@ pub mod pallet { /// --- MAP ( netuid ) --> bonds_penalty pub type BondsPenalty = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultBondsPenalty>; + #[pallet::storage] + /// --- MAP ( netuid ) --> bonds_reset + pub type BondsResetOn = + StorageMap<_, Identity, u16, bool, ValueQuery, DefaultBondsResetOn>; /// --- MAP ( netuid ) --> weights_set_rate_limit #[pallet::storage] pub type WeightsSetRateLimit = diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index 4291b67c6f..188372987e 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -96,6 +96,9 @@ mod config { /// Initial bonds penalty. #[pallet::constant] type InitialBondsPenalty: Get; + /// Initial bonds reset. + #[pallet::constant] + type InitialBondsResetOn: Get; /// Initial target registrations per interval. #[pallet::constant] type InitialTargetRegistrationsPerInterval: Get; diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index ccbfed9eff..557a4b97c6 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -83,6 +83,8 @@ mod events { BondsMovingAverageSet(u16, u64), /// bonds penalty is set for a subnet. BondsPenaltySet(u16, u16), + /// bonds reset is set for a subnet. + BondsResetOnSet(u16, bool), /// setting the max number of allowed validators on a subnet. MaxAllowedValidatorsSet(u16, u16), /// the axon server information is added to the network. diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index ba1395843c..e10b5c4db2 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -139,6 +139,7 @@ parameter_types! { pub const InitialMaxAllowedUids: u16 = 2; pub const InitialBondsMovingAverage: u64 = 900_000; pub const InitialBondsPenalty:u16 = u16::MAX; + pub const InitialBondsResetOn: bool = false; pub const InitialStakePruningMin: u16 = 0; pub const InitialFoundationDistribution: u64 = 0; pub const InitialDefaultDelegateTake: u16 = 11_796; // 18%, same as in production @@ -377,6 +378,7 @@ impl crate::Config for Test { type InitialPruningScore = InitialPruningScore; type InitialBondsMovingAverage = InitialBondsMovingAverage; type InitialBondsPenalty = InitialBondsPenalty; + type InitialBondsResetOn = InitialBondsResetOn; type InitialMaxAllowedValidators = InitialMaxAllowedValidators; type InitialDefaultDelegateTake = InitialDefaultDelegateTake; type InitialMinDelegateTake = InitialMinDelegateTake; diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index b375cc66e4..357a537f21 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -582,6 +582,14 @@ impl Pallet { Self::deposit_event(Event::BondsPenaltySet(netuid, bonds_penalty)); } + pub fn get_bonds_reset(netuid: u16) -> bool { + BondsResetOn::::get(netuid) + } + pub fn set_bonds_reset(netuid: u16, bonds_reset: bool) { + BondsResetOn::::insert(netuid, bonds_reset); + Self::deposit_event(Event::BondsResetOnSet(netuid, bonds_reset)); + } + pub fn get_max_registrations_per_block(netuid: u16) -> u16 { MaxRegistrationsPerBlock::::get(netuid) } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9fc76f69dc..11792dd93f 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1041,6 +1041,7 @@ parameter_types! { pub const SubtensorInitialPruningScore : u16 = u16::MAX; pub const SubtensorInitialBondsMovingAverage: u64 = 900_000; pub const SubtensorInitialBondsPenalty: u16 = u16::MAX; + pub const SubtensorInitialBondsResetOn: bool = false; pub const SubtensorInitialDefaultTake: u16 = 11_796; // 18% honest number. pub const SubtensorInitialMinDelegateTake: u16 = 0; // Allow 0% delegate take pub const SubtensorInitialDefaultChildKeyTake: u16 = 0; // Allow 0% childkey take @@ -1096,6 +1097,7 @@ impl pallet_subtensor::Config for Runtime { type InitialMaxAllowedUids = SubtensorInitialMaxAllowedUids; type InitialBondsMovingAverage = SubtensorInitialBondsMovingAverage; type InitialBondsPenalty = SubtensorInitialBondsPenalty; + type InitialBondsResetOn = SubtensorInitialBondsResetOn; type InitialIssuance = SubtensorInitialIssuance; type InitialMinAllowedWeights = SubtensorInitialMinAllowedWeights; type InitialEmissionValue = SubtensorInitialEmissionValue; From 5d14a1be4c235835c420ce0e588deb2f6548e424 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Mon, 17 Feb 2025 12:23:25 +0000 Subject: [PATCH 212/226] add OnMetadataCommitment hook --- pallets/admin-utils/src/tests/mock.rs | 2 +- pallets/commitments/src/lib.rs | 13 ++++++++++++- pallets/commitments/src/weights.rs | 6 +++--- pallets/subtensor/src/epoch/run_epoch.rs | 9 +++++++++ runtime/src/lib.rs | 14 +++++++++++++- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index ff9c21f22a..7c6a000b09 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -87,7 +87,7 @@ parameter_types! { pub const InitialMaxAllowedUids: u16 = 2; pub const InitialBondsMovingAverage: u64 = 900_000; pub const InitialBondsPenalty: u16 = u16::MAX; - pub const InitialBondsResetOn: bool = 0; + pub const InitialBondsResetOn: bool = false; pub const InitialStakePruningMin: u16 = 0; pub const InitialFoundationDistribution: u64 = 0; pub const InitialDefaultDelegateTake: u16 = 11_796; // 18% honest number. diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 34bf27566a..20c7b43752 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -56,6 +56,9 @@ pub mod pallet { /// Interface to access-limit metadata commitments type CanCommit: CanCommit; + /// Interface to trigger other pallets when metadata is committed + type OnMetadataCommitment: OnMetadataCommitment; + /// The maximum number of additional fields that can be added to a commitment #[pallet::constant] type MaxFields: Get + TypeInfo + 'static; @@ -193,7 +196,7 @@ pub mod pallet { netuid: u16, info: Box>, ) -> DispatchResult { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin.clone())?; ensure!( T::CanCommit::can_commit(netuid, &who), Error::::AccountNotAllowedCommit @@ -349,6 +352,14 @@ impl CanCommit for () { } } +pub trait OnMetadataCommitment { + fn on_metadata_commitment(netuid: u16, account: &AccountId); +} + +impl OnMetadataCommitment for () { + fn on_metadata_commitment(_: u16, _: &A) {} +} + /************************************************************ CallType definition ************************************************************/ diff --git a/pallets/commitments/src/weights.rs b/pallets/commitments/src/weights.rs index b91017e050..e1bd05fcc7 100644 --- a/pallets/commitments/src/weights.rs +++ b/pallets/commitments/src/weights.rs @@ -53,7 +53,7 @@ impl WeightInfo for SubstrateWeight { fn set_rate_limit() -> Weight { Weight::from_parts(10_000_000, 2000) .saturating_add(RocksDbWeight::get().reads(1_u64)) - } + } } // For backwards compatibility and tests. @@ -76,5 +76,5 @@ impl WeightInfo for () { fn set_rate_limit() -> Weight { Weight::from_parts(10_000_000, 2000) .saturating_add(RocksDbWeight::get().reads(1_u64)) - } -} \ No newline at end of file + } +} diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 62027f9636..931cf0d776 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -1294,4 +1294,13 @@ impl Pallet { ); Ok(()) } + + pub fn do_reset_bonds(netuid: u16, account_id: T::AccountId) -> Result<(), DispatchError> { + // check bonds reset enabled for this subnet + let bonds_reset_enabled: bool = Self::get_bonds_reset(netuid); + if !bonds_reset_enabled { + return Ok(()); + } + Ok(()) + } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 11792dd93f..979ecc3998 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -26,7 +26,7 @@ use frame_support::{ }, }; use frame_system::{EnsureNever, EnsureRoot, EnsureRootWithSuccess, RawOrigin}; -use pallet_commitments::CanCommit; +use pallet_commitments::{CanCommit, OnMetadataCommitment}; use pallet_grandpa::{ AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, fg_primitives, }; @@ -980,12 +980,24 @@ impl CanCommit for AllowCommitments { } } +pub struct ResetBondsOnCommit; +impl OnMetadataCommitment for ResetBondsOnCommit { + #[cfg(not(feature = "runtime-benchmarks"))] + fn on_metadata_commitment(netuid: u16, address: &AccountId) { + SubtensorModule::do_reset_bonds(netuid, address); + } + + #[cfg(feature = "runtime-benchmarks")] + fn on_metadata_commitment(_: u16, _: &AccountId) {} +} + impl pallet_commitments::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type WeightInfo = pallet_commitments::weights::SubstrateWeight; type CanCommit = AllowCommitments; + type OnMetadataCommitment = ResetBondsOnCommit; type MaxFields = MaxCommitFields; type InitialDeposit = CommitmentInitialDeposit; From c0544298aaf86cdd1939d7bbd1edef916ae7b17d Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Thu, 20 Feb 2025 06:21:20 +0000 Subject: [PATCH 213/226] add bonds reset --- pallets/subtensor/src/epoch/run_epoch.rs | 12 +++ pallets/subtensor/src/lib.rs | 5 - pallets/subtensor/src/tests/epoch.rs | 121 +++++++++++++++++++++++ 3 files changed, 133 insertions(+), 5 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 931cf0d776..a1b792e9fb 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -1301,6 +1301,18 @@ impl Pallet { if !bonds_reset_enabled { return Ok(()); } + + // Reset all bonds for this subnet + log::info!( + "Reseting bonds for netuid: {:?} triggered by {:?}", + netuid, + account_id + ); + let n = Self::get_subnetwork_n(netuid); + let new_bonds_row: Vec<(u16, u16)> = (0..n).zip(vec![0; n as usize]).collect(); + for uid in 0..n { + Bonds::::insert(netuid, uid, new_bonds_row.clone()); + } Ok(()) } } diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 789c0bd10a..585cab0ed0 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -810,11 +810,6 @@ pub mod pallet { (45875, 58982) } #[pallet::type_value] - /// Default value for network max stake. - pub fn DefaultNetworkMaxStake() -> u64 { - T::InitialNetworkMaxStake::get() - } - #[pallet::type_value] /// Default value for coldkey swap schedule duration pub fn DefaultColdkeySwapScheduleDuration() -> BlockNumberFor { T::InitialColdkeySwapScheduleDuration::get() diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 9366869272..0a9c2d9a63 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2765,6 +2765,38 @@ fn test_compute_ema_bonds_with_liquid_alpha_sparse_empty() { ); } +#[test] +fn test_bonds_reset() { + new_test_ext(1).execute_with(|| { + let netuid = 1; + let n: u16 = 10; + SubnetworkN::::insert(netuid, n); + SubtensorModule::set_max_allowed_uids(netuid, n); + let initial_bonds: Vec<(u16, u16)> = (1..n).map(|i| (i, i)).collect(); + for uid in 0..n { + Bonds::::insert(netuid, uid, initial_bonds.clone()); + } + + SubtensorModule::set_bonds_reset(netuid, false); + let _ = SubtensorModule::do_reset_bonds(netuid, U256::from(0)); + // should noop + let new_bonds = SubtensorModule::get_bonds(netuid); + let target_bond: Vec<_> = (0..n).map(u16_to_fixed).collect(); + for new_bond in new_bonds.iter() { + assert_eq!(new_bond, &target_bond); + } + + SubtensorModule::set_bonds_reset(netuid, true); + let _ = SubtensorModule::do_reset_bonds(netuid, U256::from(0)); + // should reset all netuid bonds to 0 + let new_bonds = SubtensorModule::get_bonds(netuid); + let target_bond: Vec = vec![I32F32::from(0); n as usize]; + for new_bond in new_bonds.iter() { + assert_eq!(new_bond, &target_bond); + } + }) +} + #[test] fn test_get_set_alpha() { new_test_ext(1).execute_with(|| { @@ -3375,3 +3407,92 @@ fn test_yuma_4_kappa_moves_last() { run_epoch_check_bonds(netuid, sparse, target); }) } + +#[test] +fn test_yuma_4_bonds_reset() { + new_test_ext(1).execute_with(|| { + let sparse: bool = true; + let n: u16 = 5; // 3 validators, 2 servers + let netuid: u16 = 1; + let max_stake: u64 = 8; + + // "Case 8 - big vali moves late, then late" + // Big dishonest lazy vali. (0.8) + // Small eager-eager vali. (0.1) + // Small eager-eager vali 2. (0.1) + let stakes: Vec = vec![8, 1, 1, 0, 0]; + + setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + + // target bonds and dividends for specific epoch + let targets_dividends: std::collections::HashMap<_, _> = [ + (0, vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000]), + (1, vec![0.8894, 0.0553, 0.0553, 0.0000, 0.0000]), + (2, vec![0.2686, 0.3656, 0.3656, 0.0000, 0.0000]), + (19, vec![0.7267, 0.1366, 0.1366, 0.0000, 0.0000]), + (20, vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000]), + (21, vec![0.8893, 0.0553, 0.0553, 0.0000, 0.0000]), + (40, vec![0.7306, 0.1346, 0.1346, 0.0000, 0.0000]), + ] + .into_iter() + .collect(); + let targets_bonds: std::collections::HashMap<_, _> = [ + (0, vec![vec![656, 0], vec![656, 0], vec![656, 0]]), + (1, vec![vec![1305, 0], vec![649, 6553], vec![649, 6553]]), + (2, vec![vec![1174, 656], vec![584, 7143], vec![584, 7143]]), + (19, vec![vec![191, 10847], vec![93, 16313], vec![93, 16313]]), + (20, vec![vec![0, 656], vec![0, 656], vec![0, 656]]), + (21, vec![vec![0, 1305], vec![6553, 649], vec![6553, 649]]), + (40, vec![vec![11394, 171], vec![16805, 83], vec![16805, 83]]), + ] + .into_iter() + .collect(); + + for epoch in 0..=40 { + log::warn!("Epoch: {}", epoch); + match epoch { + 0 => { + // All validators -> Server 1 + set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + } + 1 => { + // Validator A -> Server 1 + // Validator B -> Server 2 + // Validator C -> Server 2 + set_yuma_4_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]], + ); + } + (2..=20) => { + // All validators -> Server 2 + set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); + if epoch == 20 { + let _ = SubtensorModule::do_reset_bonds(netuid, U256::from(0)); + } + } + 21 => { + // Validator A -> Server 2 + // Validator B -> Server 1 + // Validator C -> Server 1 + set_yuma_4_weights( + netuid, + vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], + ); + } + _ => { + // All validators -> Server 1 + set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + } + }; + + if let Some((target_dividend, target_bond)) = + targets_dividends.get(&epoch).zip(targets_bonds.get(&epoch)) + { + run_epoch_and_check_bonds_dividends(netuid, sparse, target_bond, target_dividend); + } else { + run_epoch(netuid, sparse); + } + } + }) +} From 249901a1abc4a24aa14137fad42c8dd3a16e9090 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Wed, 26 Feb 2025 13:51:16 +0000 Subject: [PATCH 214/226] add ResetBondsFlag check for set_commitment --- pallets/commitments/src/lib.rs | 10 +++++++++- pallets/commitments/src/mock.rs | 1 + pallets/commitments/src/tests.rs | 3 +++ pallets/commitments/src/types.rs | 12 ++++++++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 20c7b43752..0221b3f670 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -75,7 +75,7 @@ pub mod pallet { type TempoInterface: GetTempoInterface; } - /// Used to retreive the given subnet's tempo + /// Used to retreive the given subnet's tempo pub trait GetTempoInterface { /// Used to retreive the epoch index for the given subnet. fn get_epoch_index(netuid: u16, cur_block: u64) -> u64; @@ -227,6 +227,14 @@ pub mod pallet { usage.used_space = 0; } + // check if ResetBondsFlag is set in the fields + for field in info.fields.iter() { + if let Data::ResetBondsFlag = field { + T::OnMetadataCommitment::on_metadata_commitment(netuid, &who); + break; + } + } + let max_allowed = MaxSpace::::get() as u64; ensure!( usage.used_space.saturating_add(required_space) <= max_allowed, diff --git a/pallets/commitments/src/mock.rs b/pallets/commitments/src/mock.rs index 8f9dbb4e5f..4e6aa123bd 100644 --- a/pallets/commitments/src/mock.rs +++ b/pallets/commitments/src/mock.rs @@ -101,6 +101,7 @@ impl pallet_commitments::Config for Test { type FieldDeposit = ConstU64<0>; type InitialDeposit = ConstU64<0>; type TempoInterface = MockTempoInterface; + type OnMetadataCommitment = (); } pub struct MockTempoInterface; diff --git a/pallets/commitments/src/tests.rs b/pallets/commitments/src/tests.rs index 5d28e0733b..55e406eb53 100644 --- a/pallets/commitments/src/tests.rs +++ b/pallets/commitments/src/tests.rs @@ -34,6 +34,7 @@ fn manual_data_type_info() { Data::ShaThree256(_) => "ShaThree256".to_string(), Data::Raw(bytes) => format!("Raw{}", bytes.len()), Data::TimelockEncrypted { .. } => "TimelockEncrypted".to_string(), + Data::ResetBondsFlag => "ResetBondsFlag".to_string(), }; if let scale_info::TypeDef::Variant(variant) = &type_info.type_def { let variant = variant @@ -63,6 +64,7 @@ fn manual_data_type_info() { let reveal_round_len = reveal_round.encode().len() as u32; // Typically 8 bytes encrypted_len + reveal_round_len } + Data::ResetBondsFlag => 0, }; assert_eq!( encoded.len() as u32 - 1, // Subtract variant byte @@ -89,6 +91,7 @@ fn manual_data_type_info() { Data::Sha256(Default::default()), Data::Keccak256(Default::default()), Data::ShaThree256(Default::default()), + Data::ResetBondsFlag, ]; // Add Raw instances for all possible sizes diff --git a/pallets/commitments/src/types.rs b/pallets/commitments/src/types.rs index 0f1d2302a5..a537514f61 100644 --- a/pallets/commitments/src/types.rs +++ b/pallets/commitments/src/types.rs @@ -58,6 +58,8 @@ pub enum Data { encrypted: BoundedVec>, reveal_round: u64, }, + /// Flag to trigger bonds reset for subnet + ResetBondsFlag, } impl Data { @@ -79,6 +81,7 @@ impl Data { | Data::Keccak256(arr) | Data::ShaThree256(arr) => arr.len() as u64, Data::TimelockEncrypted { encrypted, .. } => encrypted.len() as u64, + Data::ResetBondsFlag => 0, } } } @@ -108,6 +111,7 @@ impl Decode for Data { reveal_round, } } + 135 => Data::ResetBondsFlag, _ => return Err(codec::Error::from("invalid leading byte")), }) } @@ -136,6 +140,7 @@ impl Encode for Data { r.extend_from_slice(&reveal_round.encode()); r } + Data::ResetBondsFlag => vec![135], } } } @@ -158,7 +163,9 @@ impl TypeInfo for Data { type Identity = Self; fn type_info() -> Type { - let variants = Variants::new().variant("None", |v| v.index(0)); + let variants = Variants::new() + .variant("None", |v| v.index(0)) + .variant("ResetBondsFlag", |v| v.index(135)); // create a variant for all sizes of Raw data from 0-32 let variants = data_raw_variants!( @@ -321,7 +328,8 @@ impl TypeInfo for Data { }) .field(|f| f.name("reveal_round").ty::()), ) - }); + }) + .variant("ResetBondsFlag", |v| v.index(135)); Type::builder() .path(Path::new("Data", module_path!())) From 6222e219b976b7274eff1f1925b555d49eafcc8d Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Fri, 21 Mar 2025 13:35:21 +0000 Subject: [PATCH 215/226] fix bonds reset --- pallets/subtensor/src/epoch/run_epoch.rs | 34 +++++-- pallets/subtensor/src/tests/epoch.rs | 121 +++++++++++++++++++---- 2 files changed, 124 insertions(+), 31 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index a1b792e9fb..9658a7a9f1 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -1302,17 +1302,31 @@ impl Pallet { return Ok(()); } - // Reset all bonds for this subnet - log::info!( - "Reseting bonds for netuid: {:?} triggered by {:?}", - netuid, - account_id - ); - let n = Self::get_subnetwork_n(netuid); - let new_bonds_row: Vec<(u16, u16)> = (0..n).zip(vec![0; n as usize]).collect(); - for uid in 0..n { - Bonds::::insert(netuid, uid, new_bonds_row.clone()); + if let Ok(uid) = Self::get_uid_for_net_and_hotkey(netuid, &account_id) { + for (i, bonds_vec) in + as IterableStorageDoubleMap>>::iter_prefix( + netuid, + ) + { + Bonds::::insert( + netuid, + i, + bonds_vec + .clone() + .iter() + .filter(|(j, _)| *j != uid) + .collect::>(), + ); + } + log::debug!("Reset bonds for {:?}, netuid {:?}", account_id, netuid); + } else { + log::warn!( + "Uid not found for {:?}, netuid {:?} - skipping bonds reset", + account_id, + netuid + ); } + Ok(()) } } diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 0a9c2d9a63..f8ddc33235 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -5,7 +5,7 @@ )] use super::mock::*; -use crate::epoch::math::safe_exp; +use crate::epoch::math::{fixed, safe_exp, u16_proportion_to_fixed, u16_to_fixed}; use crate::*; use approx::assert_abs_diff_eq; @@ -2770,15 +2770,41 @@ fn test_bonds_reset() { new_test_ext(1).execute_with(|| { let netuid = 1; let n: u16 = 10; + add_network(netuid, u16::MAX - 1, 0); SubnetworkN::::insert(netuid, n); SubtensorModule::set_max_allowed_uids(netuid, n); + SubtensorModule::set_max_registrations_per_block(netuid, n); + SubtensorModule::set_target_registrations_per_interval(netuid, n); + for key in 0..n as u64 { + SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), 10); + let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( + netuid, + 0, + key * 1_000_000, + &U256::from(key), + ); + assert_ok!(SubtensorModule::register( + <::RuntimeOrigin>::signed(U256::from(key)), + netuid, + 0, + nonce, + work, + U256::from(key), + U256::from(key) + )); + } + let initial_bonds: Vec<(u16, u16)> = (1..n).map(|i| (i, i)).collect(); for uid in 0..n { Bonds::::insert(netuid, uid, initial_bonds.clone()); } + let uid_to_reset = 7; + let hotkey = SubtensorModule::get_hotkey_for_net_and_uid(netuid, uid_to_reset) + .expect("Hotkey not found"); + SubtensorModule::set_bonds_reset(netuid, false); - let _ = SubtensorModule::do_reset_bonds(netuid, U256::from(0)); + let _ = SubtensorModule::do_reset_bonds(netuid, hotkey); // should noop let new_bonds = SubtensorModule::get_bonds(netuid); let target_bond: Vec<_> = (0..n).map(u16_to_fixed).collect(); @@ -2787,12 +2813,10 @@ fn test_bonds_reset() { } SubtensorModule::set_bonds_reset(netuid, true); - let _ = SubtensorModule::do_reset_bonds(netuid, U256::from(0)); - // should reset all netuid bonds to 0 + let _ = SubtensorModule::do_reset_bonds(netuid, hotkey); let new_bonds = SubtensorModule::get_bonds(netuid); - let target_bond: Vec = vec![I32F32::from(0); n as usize]; for new_bond in new_bonds.iter() { - assert_eq!(new_bond, &target_bond); + assert_eq!(new_bond[uid_to_reset as usize], 0); } }) } @@ -3423,39 +3447,89 @@ fn test_yuma_4_bonds_reset() { let stakes: Vec = vec![8, 1, 1, 0, 0]; setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + SubtensorModule::set_bonds_reset(netuid, true); // target bonds and dividends for specific epoch let targets_dividends: std::collections::HashMap<_, _> = [ (0, vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000]), - (1, vec![0.8894, 0.0553, 0.0553, 0.0000, 0.0000]), - (2, vec![0.2686, 0.3656, 0.3656, 0.0000, 0.0000]), - (19, vec![0.7267, 0.1366, 0.1366, 0.0000, 0.0000]), - (20, vec![0.8000, 0.1000, 0.1000, 0.0000, 0.0000]), - (21, vec![0.8893, 0.0553, 0.0553, 0.0000, 0.0000]), - (40, vec![0.7306, 0.1346, 0.1346, 0.0000, 0.0000]), + (1, vec![0.8944, 0.0528, 0.0528, 0.0000, 0.0000]), + (2, vec![0.5230, 0.2385, 0.2385, 0.0000, 0.0000]), + (19, vec![0.7919, 0.1040, 0.1040, 0.0000, 0.0000]), + (20, vec![0.7928, 0.1036, 0.1036, 0.0000, 0.0000]), + (21, vec![0.8467, 0.0766, 0.0766, 0.0000, 0.0000]), + (40, vec![0.7928, 0.1036, 0.1036, 0.0000, 0.0000]), ] .into_iter() .collect(); let targets_bonds: std::collections::HashMap<_, _> = [ - (0, vec![vec![656, 0], vec![656, 0], vec![656, 0]]), - (1, vec![vec![1305, 0], vec![649, 6553], vec![649, 6553]]), - (2, vec![vec![1174, 656], vec![584, 7143], vec![584, 7143]]), - (19, vec![vec![191, 10847], vec![93, 16313], vec![93, 16313]]), - (20, vec![vec![0, 656], vec![0, 656], vec![0, 656]]), - (21, vec![vec![0, 1305], vec![6553, 649], vec![6553, 649]]), - (40, vec![vec![11394, 171], vec![16805, 83], vec![16805, 83]]), + ( + 0, + vec![ + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + vec![0.1013, 0.0000], + ], + ), + ( + 1, + vec![ + vec![0.1924, 0.0000], + vec![0.0908, 0.2987], + vec![0.0908, 0.2987], + ], + ), + ( + 2, + vec![ + vec![0.1715, 0.1013], + vec![0.0815, 0.3697], + vec![0.0815, 0.3697], + ], + ), + ( + 19, + vec![ + vec![0.0269, 0.8539], + vec![0.0131, 0.8975], + vec![0.0131, 0.8975], + ], + ), + ( + 20, + vec![ + vec![0.0000, 0.8687], + vec![0.0000, 0.9079], + vec![0.0000, 0.9079], + ], + ), + ( + 21, + vec![ + vec![0.0000, 0.8820], + vec![0.2987, 0.6386], + vec![0.2987, 0.6386], + ], + ), + ( + 40, + vec![ + vec![0.8687, 0.0578], + vec![0.9079, 0.0523], + vec![0.9079, 0.0523], + ], + ), ] .into_iter() .collect(); for epoch in 0..=40 { - log::warn!("Epoch: {}", epoch); match epoch { 0 => { // All validators -> Server 1 set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } 1 => { + // validators B, C switch // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 2 @@ -3465,13 +3539,17 @@ fn test_yuma_4_bonds_reset() { ); } (2..=20) => { + // validator A copies weights // All validators -> Server 2 set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); if epoch == 20 { - let _ = SubtensorModule::do_reset_bonds(netuid, U256::from(0)); + let hotkey = SubtensorModule::get_hotkey_for_net_and_uid(netuid, 3) + .expect("Hotkey not found"); + let _ = SubtensorModule::do_reset_bonds(netuid, hotkey); } } 21 => { + // validators B, C switch back // Validator A -> Server 2 // Validator B -> Server 1 // Validator C -> Server 1 @@ -3481,6 +3559,7 @@ fn test_yuma_4_bonds_reset() { ); } _ => { + // validator A copies weights // All validators -> Server 1 set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); } From 59bcbf1ef07e6e73fe90111f3f1769abcf36d8bd Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 25 Mar 2025 12:56:11 +0000 Subject: [PATCH 216/226] fix rebase --- pallets/subtensor/src/epoch/run_epoch.rs | 4 +- pallets/subtensor/src/tests/epoch.rs | 200 ++--------------------- runtime/src/lib.rs | 2 +- 3 files changed, 15 insertions(+), 191 deletions(-) diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 9658a7a9f1..af48420779 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -1295,14 +1295,14 @@ impl Pallet { Ok(()) } - pub fn do_reset_bonds(netuid: u16, account_id: T::AccountId) -> Result<(), DispatchError> { + pub fn do_reset_bonds(netuid: u16, account_id: &T::AccountId) -> Result<(), DispatchError> { // check bonds reset enabled for this subnet let bonds_reset_enabled: bool = Self::get_bonds_reset(netuid); if !bonds_reset_enabled { return Ok(()); } - if let Ok(uid) = Self::get_uid_for_net_and_hotkey(netuid, &account_id) { + if let Ok(uid) = Self::get_uid_for_net_and_hotkey(netuid, account_id) { for (i, bonds_vec) in as IterableStorageDoubleMap>>::iter_prefix( netuid, diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index f8ddc33235..8878a94850 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2804,7 +2804,7 @@ fn test_bonds_reset() { .expect("Hotkey not found"); SubtensorModule::set_bonds_reset(netuid, false); - let _ = SubtensorModule::do_reset_bonds(netuid, hotkey); + let _ = SubtensorModule::do_reset_bonds(netuid, &hotkey); // should noop let new_bonds = SubtensorModule::get_bonds(netuid); let target_bond: Vec<_> = (0..n).map(u16_to_fixed).collect(); @@ -2813,7 +2813,7 @@ fn test_bonds_reset() { } SubtensorModule::set_bonds_reset(netuid, true); - let _ = SubtensorModule::do_reset_bonds(netuid, hotkey); + let _ = SubtensorModule::do_reset_bonds(netuid, &hotkey); let new_bonds = SubtensorModule::get_bonds(netuid); for new_bond in new_bonds.iter() { assert_eq!(new_bond[uid_to_reset as usize], 0); @@ -3254,186 +3254,8 @@ fn assert_approx_eq_vec_of_vec( } } -// test Yuma 4 scenarios over a sequence of epochs. -fn setup_yuma_4_scenario(netuid: u16, n: u16, max_stake: u64, stakes: Vec) { - let block_number = System::block_number(); - let tempo: u16 = u16::MAX - 1; // high tempo to skip automatic epochs in on_initialize, use manual epochs instead - add_network(netuid, tempo, 0); - - SubtensorModule::set_max_allowed_uids(netuid, n); - assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); - SubtensorModule::set_max_registrations_per_block(netuid, n); - SubtensorModule::set_target_registrations_per_interval(netuid, n); - SubtensorModule::set_weights_set_rate_limit(netuid, 0); - SubtensorModule::set_min_allowed_weights(netuid, 1); - SubtensorModule::set_max_weight_limit(netuid, u16::MAX); - SubtensorModule::set_bonds_penalty(netuid, 0); - - // === Register - for key in 0..n as u64 { - SubtensorModule::add_balance_to_coldkey_account(&U256::from(key), max_stake); - let (nonce, work): (u64, Vec) = SubtensorModule::create_work_for_block_number( - netuid, - block_number, - key * 1_000_000, - &U256::from(key), - ); - assert_ok!(SubtensorModule::register( - <::RuntimeOrigin>::signed(U256::from(key)), - netuid, - block_number, - nonce, - work, - U256::from(key), - U256::from(key) - )); - SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( - &U256::from(key), - &U256::from(key), - netuid, - stakes[key as usize], - ); - } - assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), n); - assert_eq!(SubtensorModule::get_subnetwork_n(netuid), n); - - // Enable Liquid Alpha - SubtensorModule::set_kappa(netuid, u16::MAX / 2); - SubtensorModule::set_liquid_alpha_enabled(netuid, true); - - SubtensorModule::set_alpha_values_32(netuid, I32F32::from_num(0.9), I32F32::from_num(0.99)); - - // === Issue validator permits - SubtensorModule::set_max_allowed_validators(netuid, 3); - assert_eq!(SubtensorModule::get_max_allowed_validators(netuid), 3); - SubtensorModule::epoch(netuid, 1_000_000_000); // run first epoch to set allowed validators - next_block(); // run to next block to ensure weights are set on nodes after their registration block -} - -fn run_epoch_check_bonds(netuid: u16, sparse: bool, target_bonds: Vec>) { - next_block(); - if sparse { - SubtensorModule::epoch(netuid, 1_000_000_000); - } else { - SubtensorModule::epoch_dense(netuid, 1_000_000_000); - } - let bonds = SubtensorModule::get_bonds(netuid); - let dividends = SubtensorModule::get_dividends(netuid); - - // Check the bonds - // server 1 - assert_eq!(bonds[0][3], target_bonds[0][0]); - assert_eq!(bonds[1][3], target_bonds[1][0]); - assert_eq!(bonds[2][3], target_bonds[2][0]); - // server 2 - assert_eq!(bonds[0][4], target_bonds[0][1]); - assert_eq!(bonds[1][4], target_bonds[1][1]); - assert_eq!(bonds[2][4], target_bonds[2][1]); - - // Check the dividends - let epsilon = I32F32::from_num(1e-3); - for (dividend, target_dividend) in dividends.iter().zip(target_dividends.iter()) { - assert_approx_eq( - u16_proportion_to_fixed(*dividend), - fixed(*target_dividend), - epsilon, - ); - } -} - -fn set_yuma_4_weights(netuid: u16, weights: Vec>) { - for (uid, weight) in weights.iter().enumerate() { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid as u64)), - netuid, - vec![3, 4], - weight.to_vec(), - 0 - )); - } -} - -#[test] -fn test_yuma_4_kappa_moves_last() { - new_test_ext(1).execute_with(|| { - let sparse: bool = false; - let n: u16 = 5; // 3 validators, 2 servers - let netuid: u16 = 1; - let max_stake: u64 = 8; - - // Validator A: kappa / Big validator (0.8) - moves last - // Validator B: Small eager validator (0.1) - moves first - // Validator C: Small lazy validator (0.1) - moves second - let stakes: Vec = vec![8, 1, 1, 0, 0]; - - setup_yuma_4_scenario(netuid, n, max_stake, stakes); - - // Initially, consensus is achieved by all Validators - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![u16::MAX, 0], - 0 - )); - } - let target = vec![vec![656, 0], vec![656, 0], vec![656, 0]]; - run_epoch_check_bonds(netuid, sparse, target); - - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 1 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } - let target = vec![vec![1305, 0], vec![649, 6553], vec![1305, 0]]; - run_epoch_check_bonds(netuid, sparse, target); - - // Validator A -> Server 1 - // Validator B -> Server 2 - // Validator C -> Server 2 - for (uid, weights) in [vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]] - .iter() - .enumerate() - { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - weights.to_vec(), - 0 - )); - } - let target = vec![vec![1947, 0], vec![642, 12451], vec![1291, 6553]]; - run_epoch_check_bonds(netuid, sparse, target); - - // Subsequent epochs All validators -> Server 2 - for uid in [0, 1, 2] { - assert_ok!(SubtensorModule::set_weights( - RuntimeOrigin::signed(U256::from(uid)), - netuid, - vec![3, 4], - vec![0, u16::MAX], - 0 - )); - } - let target = vec![vec![1752, 656], vec![577, 12982], vec![1161, 7143]]; - run_epoch_check_bonds(netuid, sparse, target); - }) -} - #[test] -fn test_yuma_4_bonds_reset() { +fn test_yuma_3_bonds_reset() { new_test_ext(1).execute_with(|| { let sparse: bool = true; let n: u16 = 5; // 3 validators, 2 servers @@ -3446,7 +3268,7 @@ fn test_yuma_4_bonds_reset() { // Small eager-eager vali 2. (0.1) let stakes: Vec = vec![8, 1, 1, 0, 0]; - setup_yuma_4_scenario(netuid, n, sparse, max_stake, stakes); + setup_yuma_3_scenario(netuid, n, sparse, max_stake, stakes); SubtensorModule::set_bonds_reset(netuid, true); // target bonds and dividends for specific epoch @@ -3526,26 +3348,27 @@ fn test_yuma_4_bonds_reset() { match epoch { 0 => { // All validators -> Server 1 - set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); } 1 => { // validators B, C switch // Validator A -> Server 1 // Validator B -> Server 2 // Validator C -> Server 2 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![0, u16::MAX]], + vec![3, 4], ); } (2..=20) => { // validator A copies weights // All validators -> Server 2 - set_yuma_4_weights(netuid, vec![vec![0, u16::MAX]; 3]); + set_yuma_3_weights(netuid, vec![vec![0, u16::MAX]; 3], vec![3, 4]); if epoch == 20 { let hotkey = SubtensorModule::get_hotkey_for_net_and_uid(netuid, 3) .expect("Hotkey not found"); - let _ = SubtensorModule::do_reset_bonds(netuid, hotkey); + let _ = SubtensorModule::do_reset_bonds(netuid, &hotkey); } } 21 => { @@ -3553,15 +3376,16 @@ fn test_yuma_4_bonds_reset() { // Validator A -> Server 2 // Validator B -> Server 1 // Validator C -> Server 1 - set_yuma_4_weights( + set_yuma_3_weights( netuid, vec![vec![0, u16::MAX], vec![u16::MAX, 0], vec![u16::MAX, 0]], + vec![3, 4], ); } _ => { // validator A copies weights // All validators -> Server 1 - set_yuma_4_weights(netuid, vec![vec![u16::MAX, 0]; 3]); + set_yuma_3_weights(netuid, vec![vec![u16::MAX, 0]; 3], vec![3, 4]); } }; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 979ecc3998..b4bcf097b9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -984,7 +984,7 @@ pub struct ResetBondsOnCommit; impl OnMetadataCommitment for ResetBondsOnCommit { #[cfg(not(feature = "runtime-benchmarks"))] fn on_metadata_commitment(netuid: u16, address: &AccountId) { - SubtensorModule::do_reset_bonds(netuid, address); + let _ = SubtensorModule::do_reset_bonds(netuid, address); } #[cfg(feature = "runtime-benchmarks")] From 6ae811b84ece0ddb19a02d4863bc5d521721f8db Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Fri, 4 Apr 2025 19:09:48 +0100 Subject: [PATCH 217/226] increased commitment fields to allow for reset_bonds flag --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index b4bcf097b9..96b3495773 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -952,7 +952,7 @@ impl pallet_registry::Config for Runtime { } parameter_types! { - pub const MaxCommitFieldsInner: u32 = 1; + pub const MaxCommitFieldsInner: u32 = 2; pub const CommitmentInitialDeposit: Balance = 0; // Free pub const CommitmentFieldDeposit: Balance = 0; // Free } From f1229200946ca511af8277fd58bfff09dafa9a52 Mon Sep 17 00:00:00 2001 From: Andreea Popescu Date: Tue, 6 May 2025 08:41:53 +0100 Subject: [PATCH 218/226] add LastBondsReset tracking --- pallets/commitments/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 0221b3f670..d0d8d14c9b 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -151,6 +151,19 @@ pub mod pallet { BlockNumberFor, OptionQuery, >; + + #[pallet::storage] + #[pallet::getter(fn last_bonds_reset)] + pub(super) type LastBondsReset = StorageDoubleMap< + _, + Identity, + u16, + Twox64Concat, + T::AccountId, + BlockNumberFor, + OptionQuery, + >; + #[pallet::storage] #[pallet::getter(fn revealed_commitments)] pub(super) type RevealedCommitments = StorageDoubleMap< @@ -230,6 +243,8 @@ pub mod pallet { // check if ResetBondsFlag is set in the fields for field in info.fields.iter() { if let Data::ResetBondsFlag = field { + // track when bonds reset was last triggered + >::insert(netuid, &who, cur_block); T::OnMetadataCommitment::on_metadata_commitment(netuid, &who); break; } From 9bcf700bc9906e9005e57f709fcd3a9625f64489 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 20:09:48 -0700 Subject: [PATCH 219/226] remove comment --- .github/workflows/run-benchmarks.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 2532629fb2..710b20c1e2 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -115,5 +115,4 @@ jobs: run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "skip-validate-benchmarks label was found — but benchmarks already ran." - # Nothing else to skip now, but you can do something else if desired. + echo "skip-validate-benchmarks label was found — but benchmarks already ran." \ No newline at end of file From a35a6d5ee4019700b30f4ca62bae378de3e13456 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 7 May 2025 21:49:55 -0700 Subject: [PATCH 220/226] fix? --- .github/workflows/run-benchmarks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 710b20c1e2..245444a288 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -115,4 +115,5 @@ jobs: run: | labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') if echo "$labels" | grep -q "skip-validate-benchmarks"; then - echo "skip-validate-benchmarks label was found — but benchmarks already ran." \ No newline at end of file + echo "skip-validate-benchmarks label was found — but benchmarks already ran." + fi From c91987b86f4f795b98a98d7debf1fa276648ab0d Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 8 May 2025 08:58:20 -0700 Subject: [PATCH 221/226] remove unneeded step --- .github/workflows/run-benchmarks.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 245444a288..305de40095 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -28,13 +28,6 @@ jobs: ref: ${{ github.head_ref }} fetch-depth: 0 - - name: Install GitHub CLI - if: ${{ env.SKIP_BENCHMARKS != '1' }} - run: | - sudo apt-get update - sudo apt-get install -y gh - echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | From 8162058cf182b151ca4255ff8089c0faf4d4b46f Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 8 May 2025 09:06:09 -0700 Subject: [PATCH 222/226] bump CI From 9db9dd904d8c601a34754a63592a469a2742697a Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 8 May 2025 09:07:48 -0700 Subject: [PATCH 223/226] add CLI step --- .github/workflows/run-benchmarks.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 305de40095..245444a288 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -28,6 +28,13 @@ jobs: ref: ${{ github.head_ref }} fetch-depth: 0 + - name: Install GitHub CLI + if: ${{ env.SKIP_BENCHMARKS != '1' }} + run: | + sudo apt-get update + sudo apt-get install -y gh + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | From 4920ad8e4389ad5a81b1ffa066ec93ca1d2d176e Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 8 May 2025 09:14:29 -0700 Subject: [PATCH 224/226] fix --- .github/workflows/run-benchmarks.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 245444a288..fa831ee482 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -14,7 +14,6 @@ concurrency: jobs: validate-benchmarks: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-validate-benchmarks') }} runs-on: Benchmarking env: @@ -28,13 +27,6 @@ jobs: ref: ${{ github.head_ref }} fetch-depth: 0 - - name: Install GitHub CLI - if: ${{ env.SKIP_BENCHMARKS != '1' }} - run: | - sudo apt-get update - sudo apt-get install -y gh - echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | From 9d12f6c854f0fabe97c8b00bd4586e7c6c4d0523 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 8 May 2025 09:16:17 -0700 Subject: [PATCH 225/226] Update run-benchmarks.yml --- .github/workflows/run-benchmarks.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index fa831ee482..6040485eca 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -27,6 +27,13 @@ jobs: ref: ${{ github.head_ref }} fetch-depth: 0 + - name: Install GitHub CLI + if: ${{ env.SKIP_BENCHMARKS != '1' }} + run: | + sudo apt-get update + sudo apt-get install -y gh + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + - name: Check skip label if: ${{ env.SKIP_BENCHMARKS != '1' }} run: | From 987cd4b80a714153daacb171f7bfb13d8fd89728 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 8 May 2025 15:47:32 -0400 Subject: [PATCH 226/226] bump