Skip to content

I322 autoshutdown of ex validators#324

Merged
SurfingNerd merged 3 commits intoDMDcoin:devfrom
SurfingNerd:i322-autoshutdown-of-ex-validators
Dec 1, 2025
Merged

I322 autoshutdown of ex validators#324
SurfingNerd merged 3 commits intoDMDcoin:devfrom
SurfingNerd:i322-autoshutdown-of-ex-validators

Conversation

@SurfingNerd
Copy link
Collaborator

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements automatic shutdown functionality for nodes that transition from being validators to regular nodes, as defined in issue #322. The implementation includes a safeguard to prevent shutdown during major sync operations.

  • Added logic to detect when a node transitions from validator to regular node status
  • Implemented conditional shutdown that skips the operation if the node is currently syncing
  • Increased the graceful shutdown timeout from 5 to 15 seconds to allow more time for cleanup

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 5 comments.

File Description
crates/ethcore/src/engines/hbbft/hbbft_state.rs Implements auto-shutdown logic for ex-validators with sync detection to prevent premature shutdown
bin/oe/run.rs Increases soft shutdown timeout from 5 to 15 seconds to accommodate validator shutdown process

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} 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 wont to anything if its a unit test.
// e2e tests needs adaption.
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "adaption" should be "adaptation".

Suggested change
// e2e tests needs adaption.
// e2e tests needs adaptation.

Copilot uses AI. Check for mistakes.
Comment on lines 231 to 242
if client
.as_full_client()
.expect("full client")
.is_major_syncing()
{
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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 wont to anything if its a unit test.
// e2e tests needs adaption.
// this gracefully shuts down a node, if it was a validator before, but now it is not anymore.
client.demand_shutdown();
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .expect("full client") will panic if as_full_client() returns None. Consider using proper error handling instead of panicking, especially in validator shutdown logic. For example:

if let Some(full_client) = client.as_full_client() {
    if full_client.is_major_syncing() {
        // handle syncing case
    } else {
        // handle shutdown case
    }
}
Suggested change
if client
.as_full_client()
.expect("full client")
.is_major_syncing()
{
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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 wont to anything if its a unit test.
// e2e tests needs adaption.
// this gracefully shuts down a node, if it was a validator before, but now it is not anymore.
client.demand_shutdown();
if let Some(full_client) = client.as_full_client() {
if full_client.is_major_syncing() {
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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 wont to anything if its a unit test.
// e2e tests needs adaption.
// this gracefully shuts down a node, if it was a validator before, but now it is not anymore.
client.demand_shutdown();
}
} else {
warn!(target: "engine", "Could not obtain full client for validator shutdown logic.");

Copilot uses AI. Check for mistakes.
Comment on lines 236 to 238
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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.");
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple spelling and grammar errors in this debug message:

  • "inhttps" should be "in https" (missing space)
  • "Node" should be lowercase "node" for consistency (appears twice)
Suggested change
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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.");
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.");

Copilot uses AI. Check for mistakes.
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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 wont to anything if its a unit test.
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple spelling and grammar errors in this comment:

  • "shutddown" should be "shutdown"
  • "wont to anything" should be "won't do anything"
  • Missing period at the end of the sentence
Suggested change
// for unit tests no problem, demand shutddown wont to anything if its a unit test.
// For unit tests, no problem; demand shutdown won't do anything if it's a unit test.

Copilot uses AI. Check for mistakes.
Comment on lines 236 to 238
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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.");
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar improvements needed:

  • "shutting down Node" should be "shutting down node" (lowercase 'node' for consistency)
  • Consider capitalizing the first word after the period in the URL reference
Suggested change
debug!(target: "engine", "Node was a validator, and became regular node, but we are syncing, not shutting down Node as defined inhttps://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.");
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. 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.");

Copilot uses AI. Check for mistakes.
@SurfingNerd SurfingNerd merged commit 1150219 into DMDcoin:dev Dec 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants