Skip to content

feat(ethexe-cli): Add multi-validator dev mode via --dev-validators flag#5201

Open
playX18 wants to merge 10 commits intomasterfrom
ap-multiple-validators-dev
Open

feat(ethexe-cli): Add multi-validator dev mode via --dev-validators flag#5201
playX18 wants to merge 10 commits intomasterfrom
ap-multiple-validators-dev

Conversation

@playX18
Copy link
Member

@playX18 playX18 commented Mar 6, 2026

Required for #5169.

@gear-tech/dev

@playX18 playX18 self-assigned this Mar 6, 2026
@playX18 playX18 added A0-pleasereview PR is ready to be reviewed by the team D8-ethexe ethexe-related PR labels Mar 6, 2026
@semanticdiff-com
Copy link

semanticdiff-com bot commented Mar 6, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  ethexe/cli/src/commands/run.rs  23% smaller
  ethexe/service/src/config.rs  1% smaller
  ethexe/cli/src/params/network.rs  0% smaller
  ethexe/cli/src/params/node.rs  0% smaller
  ethexe/ethereum/src/deploy.rs  0% smaller
  ethexe/service/src/lib.rs Unsupported file format

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the ethexe-cli by enabling a multi-validator development mode. Users can now specify the number of validators to run locally, streamlining the testing and simulation of network behavior with multiple participants. This change facilitates more robust development and debugging of validator-related functionalities by allowing a more realistic local network setup.

Highlights

  • Multi-Validator Dev Mode: Added a new --dev-validators flag to the ethexe-cli to specify the number of validators to run in a development environment.
  • Concurrent Validator Services: Implemented the ability to run multiple validator services concurrently, each with its own isolated configuration and network identity.
  • Dynamic Key Management: Updated the development environment configuration to dynamically generate, manage, and deploy contracts for multiple validator keys and addresses.
Changelog
  • ethexe/cli/src/commands/run.rs
    • Imported NetworkParams, Config, and JoinSet for multi-validator support.
    • Initialized extra_validator_keys to store additional validator public keys.
    • Modified the call to configure_dev_environment to pass the number of dev_validators and receive a vector of public keys.
    • Updated primary validator assignment to use the first key from the returned vector.
    • Added logic to enable network parameters and store extra validator keys if dev_validators is greater than 1.
    • Refactored the service run logic to conditionally call a new run_multi_validator function when multiple validators are configured.
    • Implemented run_multi_validator to spawn and manage multiple validator services concurrently using tokio::task::JoinSet.
  • ethexe/cli/src/params/network.rs
    • Added a dev_defaults associated function to create default network parameters suitable for development mode.
  • ethexe/cli/src/params/node.rs
    • Added a dev_validators field to the NodeParams struct, exposed as a CLI argument.
    • Defined DEFAULT_DEV_VALIDATORS constant for the new field.
    • Updated the MergeParams implementation to correctly handle the dev_validators parameter during merging.
  • ethexe/ethereum/src/deploy.rs
    • Modified generate_secret_sharing_commitment to dynamically calculate max_signers based on the number of provided identifiers, instead of a fixed value.
  • ethexe/service/src/config.rs
    • Implemented clone_for_dev_validator method to create a new Config instance for a secondary validator, including a temporary database path and a new network identity.
    • Derived the Clone trait for the NodeConfig struct to enable cloning configurations.
  • ethexe/service/src/lib.rs
    • Reduced RESERVED_DEV_ACCOUNTS from 2 to 1.
    • Modified configure_dev_environment signature to accept dev_validators and return a Vec<PublicKey>.
    • Adjusted pre_funded_accounts calculation to include the number of dev_validators.
    • Updated the logic within configure_dev_environment to import and log multiple validator keys and addresses.
    • Modified EthereumDeployer to deploy with a vector of validator addresses.
    • Updated balance setting and token minting to iterate over all generated validator addresses, ensuring each validator is funded.
    • Changed the return type of configure_dev_environment to include a vector of public keys.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a multi-validator development mode, configured via the --dev-validators flag. The changes span across the CLI, service, and Ethereum deployment logic to support spinning up multiple validator instances. The implementation is mostly solid, but I've found one area in the service configuration where error handling can be improved to prevent potential panics.

@playX18 playX18 marked this pull request as draft March 10, 2026 03:02
@playX18
Copy link
Member Author

playX18 commented Mar 10, 2026

Converting to draft. Running multiple validators in one process does not seem feasibly. Instead will focus on deployment scripts and compose files that achieve the same functionality. Will close once solution is available.

@playX18 playX18 marked this pull request as ready for review March 12, 2026 04:51
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a multi-validator development mode, which is a significant feature enhancement. The implementation is mostly solid, with changes spanning across the CLI, service, and Ethereum deployment logic to support multiple validators. However, I've identified a critical issue in the concurrency handling within run_multi_validator where a blocking call is made in an async context, which could lead to runtime stalls. My review provides a specific code suggestion to address this by using tokio::task::spawn_blocking and futures::future::join_all for correctly handling thread joining in an async environment.

Comment on lines +217 to +222
// Wait for any thread to finish (join returns Result<Result<_, _>, _>)
for handle in handles {
if let Err(e) = handle.join() {
log::error!("Validator thread panicked: {:?}", e);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using std::thread::JoinHandle::join() within an async block is an anti-pattern as it blocks the asynchronous runtime's worker thread. This can lead to performance issues or even deadlocks. It's better to move blocking operations to a dedicated thread pool using tokio::task::spawn_blocking.

Additionally, the comment 'Wait for any thread to finish' is misleading, as the loop waits for all threads to complete sequentially. The implementation should be updated to wait for all threads concurrently without blocking the executor.

The suggested change uses futures::future::join_all, which may require adding use futures::future; to your imports.

                // Wait for all threads to finish.
                let join_tasks = handles.into_iter().map(|handle| {
                    tokio::task::spawn_blocking(move || {
                        if let Err(e) = handle.join() {
                            log::error!("Validator thread panicked: {:?}", e);
                        }
                    })
                });

                futures::future::join_all(join_tasks).await;
References
  1. The current implementation has a concurrency risk by using a blocking join call inside an async block, which can stall the executor. The style guide (line 24) requires special attention to concurrency risks when code changes touch async or parallel processing behavior. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview PR is ready to be reviewed by the team D8-ethexe ethexe-related PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants