From ca043f55ad3726d8caa70283d6538bdbe5cf7f3c Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 2 Nov 2022 03:05:04 -0400 Subject: [PATCH] Use a rounded genesis to obtain sufficient synchrony within the Docker env --- substrate/tendermint/client/src/authority/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/substrate/tendermint/client/src/authority/mod.rs b/substrate/tendermint/client/src/authority/mod.rs index 281ca0bc..1f176876 100644 --- a/substrate/tendermint/client/src/authority/mod.rs +++ b/substrate/tendermint/client/src/authority/mod.rs @@ -78,6 +78,11 @@ impl TendermintAuthority { fn get_last(&self) -> (::Hash, (BlockNumber, u64)) { let info = self.import.client.info(); + // TODO: Genesis start time + BLOCK_TIME + let mut fake_genesis = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(); + // Round up to the nearest 5s increment + fake_genesis += 5 - (fake_genesis % 5); + ( info.finalized_hash, ( @@ -99,8 +104,7 @@ impl TendermintAuthority { .as_ref(), ) .map(|commit| commit.end_time) - // TODO: Genesis start time + BLOCK_TIME - .unwrap_or_else(|_| SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()), + .unwrap_or(fake_genesis), ), ) } @@ -189,9 +193,11 @@ impl TendermintAuthority { } // Handle any received messages - // This inner loop enables handling all pending messages before acquiring the out-queue lock + // This inner loop enables handling all pending messages before acquiring the out-queue lock // again - futures::poll!(&mut gossip); + // TODO: Move to a select model. The disadvantage of this is we'll more frequently acquire + // the above lock, despite lack of reason to do so + let _ = futures::poll!(&mut gossip); 'inner: loop { match recv.try_next() { Ok(Some(msg)) => handle