@@ -9,9 +9,9 @@ use tycho_collator::validator::{
99} ;
1010use tycho_crypto:: ed25519;
1111use tycho_network:: { DhtClient , PeerInfo } ;
12- use tycho_slasher_traits:: NoopValidatorEventsListener ;
12+ use tycho_slasher_traits:: NoopValidatorEventsRecorder ;
1313use tycho_types:: cell:: HashBytes ;
14- use tycho_types:: models:: { BlockId , ShardIdent , ValidatorDescription } ;
14+ use tycho_types:: models:: { BlockId , IndexedValidatorDescription , ShardIdent , ValidatorDescription } ;
1515use tycho_util:: futures:: JoinTask ;
1616
1717mod common;
@@ -24,7 +24,7 @@ struct ValidatorNode {
2424}
2525
2626impl ValidatorNode {
27- fn generate ( zerostate_id : & BlockId , rng : & mut impl rand:: Rng ) -> Self {
27+ fn generate ( zerostate_id : & BlockId , rng : & mut impl rand:: Rng , idx : u16 ) -> Self {
2828 let secret_key = rng. random :: < ed25519:: SecretKey > ( ) ;
2929 let keypair = Arc :: new ( ed25519:: KeyPair :: from ( & secret_key) ) ;
3030
@@ -33,6 +33,7 @@ impl ValidatorNode {
3333 peer_id : * validator_network. network . peer_id ( ) ,
3434 public_key : keypair. public_key ,
3535 weight : 1 ,
36+ validator_idx : idx,
3637 } ;
3738
3839 let network = & validator_network. network ;
@@ -46,7 +47,7 @@ impl ValidatorNode {
4647 validator_network,
4748 keypair. clone ( ) ,
4849 ValidatorStdImplConfig :: default ( ) ,
49- Arc :: new ( NoopValidatorEventsListener ) ,
50+ Arc :: new ( NoopValidatorEventsRecorder ) ,
5051 ) ;
5152
5253 Self {
@@ -64,7 +65,7 @@ fn generate_network(
6465 rng : & mut impl rand:: Rng ,
6566) -> Vec < ValidatorNode > {
6667 let nodes = ( 0 ..node_count)
67- . map ( |_ | ValidatorNode :: generate ( zerostate_id, rng) )
68+ . map ( |i | ValidatorNode :: generate ( zerostate_id, rng, i as u16 ) )
6869 . collect :: < Vec < _ > > ( ) ;
6970
7071 for i in 0 ..nodes. len ( ) {
@@ -83,16 +84,19 @@ fn generate_network(
8384 nodes
8485}
8586
86- fn make_description ( seqno : u32 , nodes : & [ ValidatorNode ] ) -> Vec < ValidatorDescription > {
87+ fn make_description ( seqno : u32 , nodes : & [ ValidatorNode ] ) -> Vec < IndexedValidatorDescription > {
8788 let mut validators = Vec :: with_capacity ( nodes. len ( ) ) ;
8889 let mut prev_total_weight = 0 ;
89- for node in nodes {
90- validators. push ( ValidatorDescription {
91- public_key : HashBytes ( * node. descr . public_key . as_bytes ( ) ) ,
92- weight : 1 ,
93- adnl_addr : Some ( HashBytes ( * node. descr . peer_id . as_bytes ( ) ) ) ,
94- mc_seqno_since : seqno,
95- prev_total_weight,
90+ for ( i, node) in nodes. iter ( ) . enumerate ( ) {
91+ validators. push ( IndexedValidatorDescription {
92+ desc : ValidatorDescription {
93+ public_key : HashBytes ( * node. descr . public_key . as_bytes ( ) ) ,
94+ weight : 1 ,
95+ adnl_addr : Some ( HashBytes ( * node. descr . peer_id . as_bytes ( ) ) ) ,
96+ mc_seqno_since : seqno,
97+ prev_total_weight,
98+ } ,
99+ validator_idx : i as u16 ,
96100 } ) ;
97101 prev_total_weight += node. descr . weight ;
98102 }
0 commit comments