From cd07fd4d78e604017470da749a33b94c85acce83 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 19 Jul 2024 21:13:24 +0700 Subject: [PATCH] fix(drive): drive and tenderdash are constantly restarting (#1978) --- .../initialization/init_chain/v0/mod.rs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs index 08beb8c7627..5a1c4b9225c 100644 --- a/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/initialization/init_chain/v0/mod.rs @@ -31,9 +31,27 @@ where request, )?; - // We get core height early, as this also verifies mn_rr fork - let core_height = - self.initial_core_height(request.initial_core_height, platform_version)?; + // Wait until we have an initial core height to start the chain + let core_height = loop { + match self.initial_core_height(request.initial_core_height, platform_version) { + Ok(height) => break height, + Err(e) => match e { + Error::Execution(ExecutionError::InitializationForkNotActive(_)) + | Error::Execution(ExecutionError::InitializationBadCoreLockedHeight { + .. + }) => { + tracing::warn!( + error = ?e, + "Failed to obtain deterministic initial core height to start the chain. Retrying in 30 seconds.", + ); + + // We need to wait for the fork to be active + std::thread::sleep(std::time::Duration::from_secs(30)); + } + e => return Err(e), + }, + } + }; let genesis_time = request.genesis_time;