diff --git a/bin/oe/run.rs b/bin/oe/run.rs index 92dc4feb5..c58504c86 100644 --- a/bin/oe/run.rs +++ b/bin/oe/run.rs @@ -723,7 +723,7 @@ impl RunningClient { .name("diamond-node-force-quit".to_string()) .spawn(move || { - let duration_soft = 5; + let duration_soft = 15; // we make a force quit if after 90 seconds, if this shutdown routine std::thread::sleep(Duration::from_secs(duration_soft)); warn!(target: "shutdown", "shutdown not happened within {duration_soft} seconds, starting force exiting the process."); diff --git a/crates/ethcore/src/engines/hbbft/hbbft_state.rs b/crates/ethcore/src/engines/hbbft/hbbft_state.rs index 725e5b75f..fe94ec2bd 100644 --- a/crates/ethcore/src/engines/hbbft/hbbft_state.rs +++ b/crates/ethcore/src/engines/hbbft/hbbft_state.rs @@ -222,10 +222,29 @@ impl HbbftState { } if sks.is_none() { - info!(target: "engine", "We are not part of the HoneyBadger validator set - running as regular node."); + info!(target: "engine", "We are not part of the HoneyBadger validator set - Running as regular node."); peers_service .send_message(HbbftConnectToPeersMessage::DisconnectAllValidators) .ok()?; + + if self.is_validator() { + let is_syncing = if let Some(full) = client.as_full_client() { + full.is_major_syncing() + } else { + info!(target: "engine", "Node was a validator: cannot be determinated, because client is not a full client. (https://github.com/DMDcoin/diamond-node/issues/322.)"); + return Some(()); + }; + + if is_syncing { + debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined in https://github.com/DMDcoin/diamond-node/issues/322."); + } else { + info!(target: "engine", "Node was a validator, and became regular node. shutting down Node as defined in https://github.com/DMDcoin/diamond-node/issues/322."); + // for unit tests no problem, demand shutddown won't to anything if its a unit test. + // e2e tests needs adaptation. + // this gracefully shuts down a node, if it was a validator before, but now it is not anymore. + client.demand_shutdown(); + } + } return Some(()); }