diff --git a/testing/simulator/src/basic_sim.rs b/testing/simulator/src/basic_sim.rs index e1cef95cd3..5c9baa2349 100644 --- a/testing/simulator/src/basic_sim.rs +++ b/testing/simulator/src/basic_sim.rs @@ -206,7 +206,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> { node.server.all_payloads_valid(); }); - let duration_to_genesis = network.duration_to_genesis().await; + let duration_to_genesis = network.duration_to_genesis().await?; println!("Duration to genesis: {}", duration_to_genesis.as_secs()); sleep(duration_to_genesis).await; diff --git a/testing/simulator/src/fallback_sim.rs b/testing/simulator/src/fallback_sim.rs index 3859257fb7..0690ab242c 100644 --- a/testing/simulator/src/fallback_sim.rs +++ b/testing/simulator/src/fallback_sim.rs @@ -194,7 +194,7 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> { ); } - let duration_to_genesis = network.duration_to_genesis().await; + let duration_to_genesis = network.duration_to_genesis().await?; println!("Duration to genesis: {}", duration_to_genesis.as_secs()); sleep(duration_to_genesis).await; diff --git a/testing/simulator/src/local_network.rs b/testing/simulator/src/local_network.rs index 7b9327a7aa..59efc09baa 100644 --- a/testing/simulator/src/local_network.rs +++ b/testing/simulator/src/local_network.rs @@ -459,7 +459,7 @@ impl LocalNetwork { .map(|body| body.unwrap().data.finalized.epoch) } - pub async fn duration_to_genesis(&self) -> Duration { + pub async fn duration_to_genesis(&self) -> Result { let nodes = self.remote_nodes().expect("Failed to get remote nodes"); let bootnode = nodes.first().expect("Should contain bootnode"); let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); @@ -471,6 +471,9 @@ impl LocalNetwork { .data .genesis_time, ); - genesis_time - now + genesis_time.checked_sub(now).ok_or( + "The genesis time has already passed since all nodes started. The node startup time \ + may have regressed, and the current `GENESIS_DELAY` is no longer sufficient.", + ) } }