@@ -2,7 +2,6 @@ mod config;
2
2
use std:: time:: Duration ;
3
3
4
4
pub use config:: * ;
5
- use ledger:: proofs:: witness:: transaction_snark:: CONSTRAINT_CONSTANTS ;
6
5
use node:: {
7
6
p2p:: connection:: outgoing:: P2pConnectionOutgoingInitOpts , ActionKind , BlockProducerConfig ,
8
7
State ,
@@ -195,28 +194,33 @@ impl Simulator {
195
194
self . set_up_normal_nodes ( & mut runner) . await ;
196
195
self . set_up_block_producer_nodes ( & mut runner) . await ;
197
196
198
- let three_block_times =
199
- Duration :: from_millis ( CONSTRAINT_CONSTANTS . block_window_duration_ms * 3 ) ;
200
197
let run_until = self . config . run_until . clone ( ) ;
201
198
let mut timeout = self . config . run_until_timeout ;
202
199
let mut rng = rand:: rngs:: StdRng :: seed_from_u64 ( 1 ) ;
203
200
204
201
while !timeout. is_zero ( ) {
205
202
let t = redux:: Instant :: now ( ) ;
203
+ tokio:: task:: yield_now ( ) . await ;
206
204
let _ = runner
207
205
. run (
208
- Duration :: from_millis ( 50 ) ,
206
+ Duration :: ZERO ,
209
207
|_, _, _| RunDecision :: ContinueExec ,
210
208
|_, _, _, _| false ,
211
209
)
212
210
. await ;
213
211
214
- for ( _ , node) in runner. nodes_iter ( ) {
212
+ for ( node_id , node) in runner. nodes_iter ( ) {
215
213
let Some ( best_tip) = node. state ( ) . transition_frontier . best_tip ( ) else {
216
214
continue ;
217
215
} ;
218
216
let consensus_state = & best_tip. header ( ) . protocol_state . body . consensus_state ;
219
217
218
+ eprintln ! (
219
+ "[node_status] node_{node_id} {} - {} [{}]" ,
220
+ best_tip. height( ) ,
221
+ best_tip. hash( ) ,
222
+ best_tip. producer( )
223
+ ) ;
220
224
match & run_until {
221
225
SimulatorRunUntil :: Epoch ( epoch) => {
222
226
let cur_epoch = consensus_state. epoch_count . as_u32 ( ) ;
@@ -228,15 +232,16 @@ impl Simulator {
228
232
}
229
233
230
234
// advance global time randomly.
231
- let elapsed = t. elapsed ( ) . as_nanos ( ) as u64 ;
232
- let max_advance_time = ( elapsed * 20 ) . min ( three_block_times. as_nanos ( ) as u64 ) ;
233
- let by_nanos = rng. gen_range ( elapsed..max_advance_time) ;
235
+ let advance_time = Duration :: from_millis ( rng. gen_range ( 1 ..300 ) ) ;
236
+ let elapsed = t. elapsed ( ) ;
237
+ let by_nanos = advance_time. as_nanos ( ) as u64 ;
238
+ eprintln ! ( "[TIME] elapsed {elapsed:?}; advance_by: {advance_time:?}" ) ;
234
239
runner
235
240
. exec_step ( ScenarioStep :: AdvanceTime { by_nanos } )
236
241
. await
237
242
. unwrap ( ) ;
238
243
239
- timeout -= t . elapsed ( ) ;
244
+ timeout = timeout . saturating_sub ( elapsed ) ;
240
245
}
241
246
242
247
panic ! ( "simulation timed out" ) ;
0 commit comments