Skip to content

Commit 58d734d

Browse files
committed
fix: all validators fetch weights from bootstrap RPC for consistency
Remove bootstrap-only local weight computation. All validators now fetch weights from the bootstrap RPC (chain.platform.network) before submitting to Bittensor, ensuring identical weights across the network. Local computation is kept as fallback if the RPC is unreachable.
1 parent 6004d20 commit 58d734d

File tree

1 file changed

+29
-45
lines changed

1 file changed

+29
-45
lines changed

bins/validator-node/src/main.rs

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,18 +1924,13 @@ async fn main() -> Result<()> {
19241924
}
19251925
}
19261926
}
1927-
// During bootstrap, non-bootstrap validators fetch from bootstrap RPC
1928-
let in_bootstrap = state_manager.apply(|s| s.is_in_bootstrap_period());
1929-
let precomputed = if in_bootstrap && keypair.ss58_address() != platform_core::constants::BOOTSTRAP_VALIDATOR_SS58 {
1930-
match fetch_remote_weights().await {
1931-
Ok(remote) if !remote.is_empty() => {
1932-
info!("Bootstrap RPC pre-compute: using {} entries from bootstrap validator", remote.len());
1933-
remote
1934-
}
1935-
_ => precomputed,
1927+
// All validators fetch from bootstrap RPC for consistency
1928+
let precomputed = match fetch_remote_weights().await {
1929+
Ok(remote) if !remote.is_empty() => {
1930+
info!("RPC pre-compute: using {} entries from bootstrap RPC", remote.len());
1931+
remote
19361932
}
1937-
} else {
1938-
precomputed
1933+
_ => precomputed,
19391934
};
19401935

19411936
if !precomputed.is_empty() {
@@ -4845,8 +4840,6 @@ async fn handle_block_event(
48454840
return;
48464841
}
48474842

4848-
let in_bootstrap = state_manager.apply(|s| s.is_in_bootstrap_period());
4849-
48504843
// Single submission path: collect WASM weights, convert hotkey->UID,
48514844
// apply emission_weight, and submit directly via Subtensor.
48524845
if let (Some(st), Some(sig)) = (subtensor.as_ref(), signer.as_ref()) {
@@ -5061,40 +5054,31 @@ async fn handle_block_event(
50615054
}
50625055
};
50635056

5064-
// During bootstrap, non-bootstrap validators MUST use the bootstrap
5065-
// validator's weights to guarantee all validators submit identical
5066-
// weights on-chain. Only the bootstrap validator computes weights
5067-
// from WASM; everyone else fetches them via RPC.
5068-
let weights_to_submit = if in_bootstrap {
5069-
let our_ss58 = _keypair.ss58_address();
5070-
if our_ss58 == platform_core::constants::BOOTSTRAP_VALIDATOR_SS58 {
5071-
info!("Bootstrap validator: using locally computed weights");
5072-
weights_to_submit
5073-
} else {
5074-
info!("Bootstrap: fetching weights from bootstrap validator RPC");
5075-
match fetch_remote_weights().await {
5076-
Ok(remote) if !remote.is_empty() => {
5077-
info!(
5078-
"Bootstrap: using {} mechanism entries from bootstrap validator",
5079-
remote.len()
5080-
);
5081-
remote
5082-
}
5083-
Ok(_) => {
5084-
warn!("Bootstrap: remote weights empty, falling back to local");
5085-
weights_to_submit
5086-
}
5087-
Err(e) => {
5088-
warn!(
5089-
"Bootstrap: failed to fetch remote weights ({}), falling back to local",
5090-
e
5091-
);
5092-
weights_to_submit
5093-
}
5057+
// ALL validators (including bootstrap) fetch weights from the
5058+
// bootstrap RPC to guarantee everyone submits identical weights.
5059+
// Local computation is used only as fallback if the RPC is unreachable.
5060+
let weights_to_submit = {
5061+
info!("Fetching weights from bootstrap validator RPC");
5062+
match fetch_remote_weights().await {
5063+
Ok(remote) if !remote.is_empty() => {
5064+
info!(
5065+
"Using {} mechanism entries from bootstrap RPC",
5066+
remote.len()
5067+
);
5068+
remote
5069+
}
5070+
Ok(_) => {
5071+
warn!("Remote weights empty, falling back to locally computed");
5072+
weights_to_submit
5073+
}
5074+
Err(e) => {
5075+
warn!(
5076+
"Failed to fetch remote weights ({}), falling back to locally computed",
5077+
e
5078+
);
5079+
weights_to_submit
50945080
}
50955081
}
5096-
} else {
5097-
weights_to_submit
50985082
};
50995083

51005084
// Store computed weights in chain state for the subnet_getWeights RPC

0 commit comments

Comments
 (0)