-
Notifications
You must be signed in to change notification settings - Fork 25
feat: replace HIVE_LEAN_TEST_DRIVER env var with test-driver subcommand #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IbrahimIjai
wants to merge
5
commits into
lambdaclass:main
Choose a base branch
from
IbrahimIjai:feat/issue-359-test-driver-subcommand
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+50
β51
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bd94609
feat: replace HIVE_LEAN_TEST_DRIVER env var with test-driver subcommand
IbrahimIjai 94ee85c
Merge branch 'main' into feat/issue-359-test-driver-subcommand
MegaRedHand 2a0281c
Merge branch 'main' into feat/issue-359-test-driver-subcommand
pablodeymo 4023b12
Merge branch 'main' into feat/issue-359-test-driver-subcommand
pablodeymo e8e6d2b
Merge branch 'main' into feat/issue-359-test-driver-subcommand
IbrahimIjai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,24 @@ const ASCII_ART: &str = r#" | |
|
|
||
| #[derive(Debug, clap::Parser)] | ||
| #[command(name = "ethlambda", author = "LambdaClass", version = version::CLIENT_VERSION, about = "ethlambda consensus client")] | ||
| struct CliOptions { | ||
| struct Cli { | ||
| #[command(subcommand)] | ||
| command: Commands, | ||
| } | ||
|
|
||
| #[derive(Debug, clap::Subcommand)] | ||
| enum Commands { | ||
| /// Run the consensus node. | ||
| Node(Box<NodeArgs>), | ||
| /// Run in Hive test-driver mode (spec-asset suites only). | ||
| /// | ||
| /// Skips the consensus/p2p stack and exposes only the | ||
| /// `/lean/v0/test_driver/...` endpoints driven by the hive simulator. | ||
| TestDriver(TestDriverArgs), | ||
| } | ||
|
|
||
| #[derive(Debug, clap::Args)] | ||
| struct NodeArgs { | ||
| /// Path to the chain genesis config (e.g., config.yaml). | ||
| #[arg(long)] | ||
| genesis: PathBuf, | ||
|
|
@@ -116,6 +133,16 @@ struct CliOptions { | |
| data_dir: PathBuf, | ||
| } | ||
|
|
||
| #[derive(Debug, clap::Args)] | ||
| struct TestDriverArgs { | ||
| #[arg(long, default_value = "127.0.0.1")] | ||
| http_address: IpAddr, | ||
| #[arg(long, default_value = "5052")] | ||
| api_port: u16, | ||
| #[arg(long, default_value = "5054")] | ||
| metrics_port: u16, | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> eyre::Result<()> { | ||
| let filter = EnvFilter::builder() | ||
|
|
@@ -125,34 +152,37 @@ async fn main() -> eyre::Result<()> { | |
| tracing::subscriber::set_global_default(subscriber) | ||
| .wrap_err("failed to set global tracing subscriber")?; | ||
|
|
||
| let options = CliOptions::parse(); | ||
| let cli = Cli::parse(); | ||
|
|
||
| // Initialize metrics | ||
| ethlambda_blockchain::metrics::init(); | ||
| ethlambda_blockchain::metrics::set_node_info("ethlambda", version::CLIENT_VERSION); | ||
| ethlambda_blockchain::metrics::set_node_start_time(); | ||
|
|
||
| let rpc_config = RpcConfig { | ||
| http_address: options.http_address, | ||
| api_port: options.api_port, | ||
| metrics_port: options.metrics_port, | ||
| }; | ||
|
|
||
| println!("{ASCII_ART}"); | ||
|
|
||
| info!(version = version::CLIENT_VERSION, "Starting ethlambda"); | ||
|
|
||
| // Hive lean spec-asset suites boot the client with | ||
| // HIVE_LEAN_TEST_DRIVER=1 so it skips the consensus/p2p stack and | ||
| // exposes only the `/lean/v0/test_driver/...` endpoints driven by the | ||
| // simulator. Detected here before any config / key / genesis loading | ||
| // so the driver run doesn't touch --node-key, --custom-network-config-dir, | ||
| // or any other consensus prerequisite the hive shim doesn't bother to | ||
| // provision. | ||
| if ethlambda_rpc::test_driver::test_driver_enabled() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep the env-var path too, for now. We can move it to the node command, making |
||
| info!("HIVE_LEAN_TEST_DRIVER detected; booting in test-driver mode"); | ||
| return run_test_driver(rpc_config).await; | ||
| match cli.command { | ||
| Commands::TestDriver(args) => { | ||
| let rpc_config = RpcConfig { | ||
| http_address: args.http_address, | ||
| api_port: args.api_port, | ||
| metrics_port: args.metrics_port, | ||
| }; | ||
| info!("Booting in test-driver mode"); | ||
| return run_test_driver(rpc_config).await; | ||
| } | ||
| Commands::Node(options) => run_node(*options).await, | ||
| } | ||
|
pablodeymo marked this conversation as resolved.
|
||
| } | ||
|
|
||
| async fn run_node(options: NodeArgs) -> eyre::Result<()> { | ||
| let rpc_config = RpcConfig { | ||
| http_address: options.http_address, | ||
| api_port: options.api_port, | ||
| metrics_port: options.metrics_port, | ||
| }; | ||
|
|
||
| let node_p2p_key = read_hex_file_bytes(&options.node_key).wrap_err_with(|| { | ||
| format!( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to have this option as the default subcommand in order to make easier to run the hot path.