From c9fd50ab0f3635411fd594a865c87b109918ba97 Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 2 Oct 2025 20:56:20 +0800 Subject: [PATCH 1/7] always include the netuid in selective metagraph --- pallets/subtensor/src/rpc_info/metagraph.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index 57c2e15c7f..55dc31b213 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -869,6 +869,18 @@ impl Pallet { None } else { let mut result = SelectiveMetagraph::default(); + let netuid_index = + SelectiveMetagraphIndex::from_index(SelectiveMetagraphIndex::Netuid as usize); + + // always include netuid even the metagraph_indexes doesn't contain it + if let Some(netuid_index) = netuid_index { + let netuid_index = netuid_index as u16; + if !metagraph_indexes.contains(&netuid_index) { + let value = Self::get_single_selective_mechagraph(netuid, mecid, netuid_index); + result.merge_value(&value, netuid_index as usize); + } + } + for index in metagraph_indexes.iter() { let value = Self::get_single_selective_mechagraph(netuid, mecid, *index); result.merge_value(&value, *index as usize); From c34937d7037b9bccec1ad073e00e931274e97a47 Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 2 Oct 2025 21:04:01 +0800 Subject: [PATCH 2/7] bump 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 931653bfc3..3327d1889a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -223,7 +223,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: 324, + spec_version: 325, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 9049548d32f7a76ce4952ff489d081e1afaba4f6 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 3 Oct 2025 00:18:48 +0800 Subject: [PATCH 3/7] rename variable to avoid confusion --- pallets/subtensor/src/rpc_info/metagraph.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index 55dc31b213..df00ac43c1 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -869,15 +869,19 @@ impl Pallet { None } else { let mut result = SelectiveMetagraph::default(); - let netuid_index = + let netuid_in_metagraph_index = SelectiveMetagraphIndex::from_index(SelectiveMetagraphIndex::Netuid as usize); // always include netuid even the metagraph_indexes doesn't contain it - if let Some(netuid_index) = netuid_index { - let netuid_index = netuid_index as u16; - if !metagraph_indexes.contains(&netuid_index) { - let value = Self::get_single_selective_mechagraph(netuid, mecid, netuid_index); - result.merge_value(&value, netuid_index as usize); + if let Some(netuid_in_metagraph_index) = netuid_in_metagraph_index { + let netuid_in_metagraph_index = netuid_in_metagraph_index as u16; + if !metagraph_indexes.contains(&netuid_in_metagraph_index) { + let value = Self::get_single_selective_mechagraph( + netuid, + mecid, + netuid_in_metagraph_index, + ); + result.merge_value(&value, netuid_in_metagraph_index as usize); } } From 5a33d8dd5dd4a750cf264c06061912a5b68fcfe9 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 3 Oct 2025 00:19:59 +0800 Subject: [PATCH 4/7] cargo clippy --- pallets/subtensor/src/rpc_info/metagraph.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index df00ac43c1..dfd7581c33 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -869,6 +869,8 @@ impl Pallet { None } else { let mut result = SelectiveMetagraph::default(); + + result.netuid = netuid.into(); let netuid_in_metagraph_index = SelectiveMetagraphIndex::from_index(SelectiveMetagraphIndex::Netuid as usize); From 8fed8c810bdabd02f03dde1d67d5649723b998f7 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 3 Oct 2025 00:21:06 +0800 Subject: [PATCH 5/7] cargo fix --- pallets/subtensor/src/rpc_info/metagraph.rs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index dfd7581c33..8236196eb4 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -870,22 +870,8 @@ impl Pallet { } else { let mut result = SelectiveMetagraph::default(); + // alwayseven the metagraph_indexes doesn't contain it result.netuid = netuid.into(); - let netuid_in_metagraph_index = - SelectiveMetagraphIndex::from_index(SelectiveMetagraphIndex::Netuid as usize); - - // always include netuid even the metagraph_indexes doesn't contain it - if let Some(netuid_in_metagraph_index) = netuid_in_metagraph_index { - let netuid_in_metagraph_index = netuid_in_metagraph_index as u16; - if !metagraph_indexes.contains(&netuid_in_metagraph_index) { - let value = Self::get_single_selective_mechagraph( - netuid, - mecid, - netuid_in_metagraph_index, - ); - result.merge_value(&value, netuid_in_metagraph_index as usize); - } - } for index in metagraph_indexes.iter() { let value = Self::get_single_selective_mechagraph(netuid, mecid, *index); From a32553191c2c0f591c62a4b04bf5cd43dd24402b Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 3 Oct 2025 00:21:46 +0800 Subject: [PATCH 6/7] use parameter directly --- pallets/subtensor/src/rpc_info/metagraph.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index 8236196eb4..8c4d4d6ab7 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -870,7 +870,7 @@ impl Pallet { } else { let mut result = SelectiveMetagraph::default(); - // alwayseven the metagraph_indexes doesn't contain it + // always include netuid even the metagraph_indexes doesn't contain it result.netuid = netuid.into(); for index in metagraph_indexes.iter() { From e7b079886c6d45f291131a9baf9ee300888e5a25 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 3 Oct 2025 00:25:14 +0800 Subject: [PATCH 7/7] use parameter directly --- pallets/subtensor/src/rpc_info/metagraph.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index 8c4d4d6ab7..2ec772b2c6 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -870,13 +870,13 @@ impl Pallet { } else { let mut result = SelectiveMetagraph::default(); - // always include netuid even the metagraph_indexes doesn't contain it - result.netuid = netuid.into(); - for index in metagraph_indexes.iter() { let value = Self::get_single_selective_mechagraph(netuid, mecid, *index); result.merge_value(&value, *index as usize); } + // always include netuid even the metagraph_indexes doesn't contain it + result.netuid = netuid.into(); + Some(result) } }