@@ -448,6 +448,7 @@ async fn main() -> Result<()> {
448448 & chain_state,
449449 & valid_voters,
450450 & state_root_consensus,
451+ & state_manager,
451452 ) ;
452453 info ! (
453454 "Validator set: {} active validators" ,
@@ -509,6 +510,7 @@ async fn main() -> Result<()> {
509510 & chain_state,
510511 & valid_voters,
511512 & state_root_consensus,
513+ & state_manager,
512514 ) ;
513515 info ! (
514516 "Validator set: {} active validators" ,
@@ -1238,7 +1240,7 @@ async fn main() -> Result<()> {
12381240 match sync_metagraph( client, netuid) . await {
12391241 Ok ( mg) => {
12401242 info!( "Metagraph refreshed: {} neurons" , mg. n) ;
1241- update_validator_set_from_metagraph( & mg, & validator_set, & chain_state, & valid_voters, & state_root_consensus) ;
1243+ update_validator_set_from_metagraph( & mg, & validator_set, & chain_state, & valid_voters, & state_root_consensus, & state_manager ) ;
12421244 if let Some ( sc) = subtensor_client. as_mut( ) {
12431245 sc. set_metagraph( mg) ;
12441246 }
@@ -1453,10 +1455,14 @@ fn update_validator_set_from_metagraph(
14531455 state_root_consensus : & Arc <
14541456 parking_lot:: Mutex < platform_distributed_storage:: state_consensus:: StateRootConsensus > ,
14551457 > ,
1458+ state_manager : & Arc < StateManager > ,
14561459) {
14571460 let mut cs = chain_state. write ( ) ;
14581461 cs. registered_hotkeys . clear ( ) ;
14591462
1463+ // Collect validators for P2P state manager
1464+ let mut p2p_validators: Vec < ( Hotkey , u64 ) > = Vec :: new ( ) ;
1465+
14601466 for neuron in metagraph. neurons . values ( ) {
14611467 let hotkey_bytes: [ u8 ; 32 ] = neuron. hotkey . clone ( ) . into ( ) ;
14621468 let hotkey = Hotkey ( hotkey_bytes) ;
@@ -1476,8 +1482,9 @@ fn update_validator_set_from_metagraph(
14761482 // Use the same min_stake threshold as the P2P validator set (10000 TAO = 10e12 RAO)
14771483 if stake >= 10_000_000_000_000 {
14781484 cs. validators . entry ( hotkey. clone ( ) ) . or_insert_with ( || {
1479- platform_core:: ValidatorInfo :: new ( hotkey, platform_core:: Stake ( stake) )
1485+ platform_core:: ValidatorInfo :: new ( hotkey. clone ( ) , platform_core:: Stake ( stake) )
14801486 } ) ;
1487+ p2p_validators. push ( ( hotkey, stake) ) ;
14811488 }
14821489 }
14831490
@@ -1487,6 +1494,13 @@ fn update_validator_set_from_metagraph(
14871494 state_root_consensus. lock ( ) . set_valid_voters ( voter_hotkeys) ;
14881495
14891496 cs. update_hash ( ) ;
1497+
1498+ // Sync validators to P2P state manager for storage consensus
1499+ state_manager. apply ( |state| {
1500+ for ( hotkey, stake) in p2p_validators {
1501+ state. update_validator ( hotkey, stake) ;
1502+ }
1503+ } ) ;
14901504}
14911505
14921506async fn handle_network_event (
0 commit comments