1- use std:: { iter , str :: FromStr , time:: Duration } ;
1+ use std:: time:: Duration ;
22
3- use node:: { account:: AccountSecretKey , BlockProducerConfig } ;
3+ use mina_p2p_messages:: v2;
4+ use node:: transition_frontier:: genesis:: { GenesisConfig , NonStakers } ;
45
56use crate :: {
6- node:: { RustNodeBlockProducerTestingConfig , RustNodeTestingConfig } ,
7- scenario :: ListenerNode ,
8- scenarios :: ClusterRunner ,
7+ node:: Recorder ,
8+ scenarios :: { ClusterRunner , RunCfgAdvanceTime } ,
9+ simulator :: { Simulator , SimulatorConfig , SimulatorRunUntil } ,
910} ;
1011
1112/// Create and Sync up 50 nodes, one amoung them is block producer.
@@ -19,66 +20,31 @@ use crate::{
1920pub struct MultiNodePubsubPropagateBlock ;
2021
2122impl MultiNodePubsubPropagateBlock {
22- const WORKERS : usize = 4 ;
23+ const WORKERS : usize = 20 ;
2324
2425 pub async fn run ( self , mut runner : ClusterRunner < ' _ > ) {
25- // let seed_node = ListenerNode::Custom(
26- // "/ip4/34.135.63.47/tcp/10001/p2p/12D3KooWLjs54xHzVmMmGYb7W5RVibqbwD1co7M2ZMfPgPm7iAag"
27- // .parse()
28- // .unwrap(),
29- // );
30-
31- let seed_config = RustNodeTestingConfig :: devnet_default ( )
32- . max_peers ( 100 )
33- . ask_initial_peers_interval ( Duration :: from_secs ( 60 * 60 ) ) ;
34-
35- let seed_node = ListenerNode :: Rust ( runner. add_rust_node ( seed_config) ) ;
36-
37- // for account B62qrztYfPinaKqpXaYGY6QJ3SSW2NNKs7SajBLF1iFNXW9BoALN2Aq
38- let sec_key =
39- AccountSecretKey :: from_str ( "EKEEpMELfQkMbJDt2fB4cFXKwSf1x4t7YD4twREy5yuJ84HBZtF9" )
40- . unwrap ( ) ;
41-
42- let producer_node = runner. add_rust_node ( RustNodeTestingConfig {
43- initial_time : redux:: Timestamp :: ZERO ,
44- genesis : node:: config:: DEVNET_CONFIG . clone ( ) ,
45- max_peers : 10 ,
46- ask_initial_peers_interval : Duration :: from_secs ( 60 * 60 ) ,
47- initial_peers : vec ! [ seed_node. clone( ) ] ,
48- peer_id : Default :: default ( ) ,
49- block_producer : Some ( RustNodeBlockProducerTestingConfig {
50- config : BlockProducerConfig {
51- pub_key : sec_key. public_key ( ) . into ( ) ,
52- custom_coinbase_receiver : None ,
53- proposed_protocol_version : None ,
54- } ,
55- sec_key,
56- } ) ,
57- snark_worker : None ,
58- timeouts : Default :: default ( ) ,
59- libp2p_port : None ,
60- recorder : Default :: default ( ) ,
61- } ) ;
62-
63- tokio:: time:: sleep ( Duration :: from_secs ( 2 ) ) . await ;
64-
65- eprintln ! ( "Producer node connected" ) ;
66-
67- let worker_config = RustNodeTestingConfig :: devnet_default ( )
68- . initial_peers ( vec ! [ seed_node] )
69- . max_peers ( 10 )
70- . ask_initial_peers_interval ( Duration :: from_secs ( 60 * 60 ) ) ;
71- let workers = iter:: repeat ( worker_config)
72- . take ( Self :: WORKERS )
73- . map ( |config| runner. add_rust_node ( config) )
74- . collect :: < Vec < _ > > ( ) ;
75-
76- runner
77- . run_until_nodes_synced ( Duration :: from_secs ( 10 * 60 ) , & workers)
78- . await
79- . unwrap ( ) ;
80-
81- let _ = producer_node;
82- // TODO:
26+ let initial_time = redux:: Timestamp :: global_now ( ) ;
27+ let mut constants = v2:: PROTOCOL_CONSTANTS . clone ( ) ;
28+ constants. genesis_state_timestamp =
29+ v2:: BlockTimeTimeStableV1 ( ( u64:: from ( initial_time) / 1_000_000 ) . into ( ) ) ;
30+ let genesis_cfg = GenesisConfig :: Counts {
31+ whales : 1 ,
32+ fish : 0 ,
33+ non_stakers : NonStakers :: None ,
34+ constants,
35+ } ;
36+ let config = SimulatorConfig {
37+ genesis : genesis_cfg. into ( ) ,
38+ seed_nodes : 1 ,
39+ normal_nodes : Self :: WORKERS ,
40+ snark_workers : 1 ,
41+ block_producers : 1 ,
42+ advance_time : RunCfgAdvanceTime :: Rand ( 1 ..=200 ) ,
43+ run_until : SimulatorRunUntil :: BlockchainLength ( 3 ) ,
44+ run_until_timeout : Duration :: from_secs ( 10 * 60 ) ,
45+ recorder : Recorder :: StateWithInputActions ,
46+ } ;
47+ let mut simulator = Simulator :: new ( initial_time, config) ;
48+ simulator. run ( & mut runner) . await ;
8349 }
8450}
0 commit comments