Skip to content

rust testnet cli tool#117

Merged
ljoss17 merged 54 commits into
mainfrom
sryps/rust-testnet-cli
Dec 2, 2025
Merged

rust testnet cli tool#117
ljoss17 merged 54 commits into
mainfrom
sryps/rust-testnet-cli

Conversation

@sryps

@sryps sryps commented Nov 21, 2025

Copy link
Copy Markdown
Collaborator
╰─➤  emerald testnet help                                                                                                                                                                                                              
Generate testnet configuration                                                                                                                                                                                                         
                                                                                                                                                                                                                                       
Usage: emerald testnet [OPTIONS] [COMMAND]                                                                                                                                                                                             
                                                                                                                                                                                                                                       
Commands:                                                                                                                                                                                                                              
  generate    Generate testnet configuration (explicit)                                                                                                                                                                                
  start       Start a complete testnet with Reth + Emerald nodes                                                                                                                                                                       
  status      Show status of all nodes in the testnet                                                                                                                                                                                  
  add-node    Add a non-validator node to an existing testnet                                                                                                                                                                          
  start-node  Start a specific node by ID                                                                                                                                                                                              
  stop-node   Stop a specific node by ID                                                                                                                                                                                               
  stop        Stop all nodes in the testnet
  rm          Remove all testnet data
  help        Print this message or the help of the given subcommand(s)

Testnet tool to replace using docker/Make

@sryps sryps requested review from jmalicevic and ljoss17 November 21, 2025 19:53
@sryps sryps marked this pull request as ready for review November 21, 2025 21:30
Comment thread cli/src/cmd/testnet/start.rs Outdated
Comment on lines +171 to +175
private_keys: if self.node_keys.is_empty() {
None
} else {
Some(self.node_keys.clone())
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should be able to directly use Option<T> for the node_keys:

    #[clap(long = "node-keys")]
    pub node_keys: Option<Vec<String>>,

Which will allow this simplification

Suggested change
private_keys: if self.node_keys.is_empty() {
None
} else {
Some(self.node_keys.clone())
},
private_keys: self.node_keys.clone(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done in f2f825f

Comment on lines +454 to +465
let shell_cmd = format!(
"nohup {} > {} 2>&1 & echo $! > {}",
cmd,
log_file_path.display(),
pid_file.display()
);

Command::new("sh")
.arg("-c")
.arg(&shell_cmd)
.spawn()
.context("Failed to spawn emerald process")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason we can't spawn and retrieve the using something like:

Command::new(cmd)
...
.spawn()?;
let pid = child.id();

And write pid to the pid_file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I tried that and the parent pid stayed attached to the child process and then when I tried to kill one single child process the process was bricked and sat in the stack...it kept happening and I couldnt find a solution. Given the short deadline I opted to just use a shell to spawn and move on.
It should be fixed that way eventually, I just didnt have the time or capacity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done in 6299e7c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually it's a bit more tricky, I had to revert that commit

node_home.display()
));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO: make sure that the node is not already started

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done in 4a0e880

@ljoss17 ljoss17 merged commit a613a6d into main Dec 2, 2025
5 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.

4 participants