Skip to content

Commit

Permalink
fix online-node selector
Browse files Browse the repository at this point in the history
  • Loading branch information
haxjump committed Oct 9, 2024
1 parent 496ce21 commit 5fcf15e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
25 changes: 18 additions & 7 deletions src/ddev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use chaindev::{
};
use ruc::*;
use serde::{Deserialize, Serialize};
use std::{env, fs, str::FromStr};
use std::{collections::HashSet, env, fs, str::FromStr};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct EnvCfg {
Expand Down Expand Up @@ -333,7 +333,10 @@ fi "#
let online_nodes = e
.nodes_should_be_online
.iter()
.copied()
.map(|(k, _)| k)
.filter(|k| *k < n.id) // early nodes only
.collect::<HashSet<_>>() // for random purpose
.into_iter()
.take(5)
.collect::<Vec<_>>();

Expand Down Expand Up @@ -433,7 +436,7 @@ fi "#

let cmd_run_part_0 = format!(
r#"
nohup {geth} \
{geth} \
--syncmode=full \
--gcmode={el_gc_mode} \
--networkid=$(grep -Po '(?<="chainId":)\s*\d+' {el_genesis} | tr -d ' ') \
Expand Down Expand Up @@ -476,7 +479,7 @@ fi "#

let cmd_run_part_0 = format!(
r#"
nohup {reth} node \
{reth} node \
--chain={el_genesis} \
--datadir={el_dir} \
--log.file.directory={el_dir}/logs \
Expand Down Expand Up @@ -538,7 +541,8 @@ nohup {reth} node \
let cmd_run_part_0 = format!(
r#"
mkdir -p {cl_bn_dir} || exit 1
nohup {lighthouse} beacon_node \
{lighthouse} beacon_node \
--testnet-dir={cl_genesis} \
--datadir={cl_bn_dir} \
--staking \
Expand Down Expand Up @@ -603,7 +607,8 @@ fi "#
let cmd_run_part_1 = format!(
r#"
mkdir -p {cl_vc_dir} || exit 1
nohup {lighthouse} validator_client \
{lighthouse} validator_client \
--testnet-dir={cl_genesis} \
--datadir={cl_vc_dir}\
--beacon-nodes='{beacon_nodes}' \
Expand All @@ -627,10 +632,16 @@ nohup {lighthouse} validator_client \

format!(
r#"
{prepare_cmd}
{el_cmd}
{cl_bn_cmd}
{cl_vc_cmd} "#
{cl_vc_cmd}
"#
)
}

Expand Down
25 changes: 18 additions & 7 deletions src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use chaindev::{
};
use ruc::*;
use serde::{Deserialize, Serialize};
use std::fs;
use std::{collections::HashSet, fs};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct EnvCfg {
Expand Down Expand Up @@ -221,7 +221,10 @@ fi "#
let online_nodes = e
.nodes_should_be_online
.iter()
.copied()
.map(|(k, _)| k)
.filter(|k| *k < n.id) // early nodes only
.collect::<HashSet<_>>() // for random purpose
.into_iter()
.take(5)
.collect::<Vec<_>>();

Expand Down Expand Up @@ -313,7 +316,7 @@ fi "#

let cmd_run_part_0 = format!(
r#"
nohup {geth} \
{geth} \
--syncmode=full \
--gcmode={el_gc_mode} \
--networkid=$(grep -Po '(?<="chainId":)\s*\d+' {el_genesis} | tr -d ' ') \
Expand Down Expand Up @@ -356,7 +359,7 @@ fi "#

let cmd_run_part_0 = format!(
r#"
nohup {reth} node \
{reth} node \
--chain={el_genesis} \
--datadir={el_dir} \
--log.file.directory={el_dir}/logs \
Expand Down Expand Up @@ -418,7 +421,8 @@ nohup {reth} node \
let cmd_run_part_0 = format!(
r#"
mkdir -p {cl_bn_dir} || exit 1
nohup {lighthouse} beacon_node \
{lighthouse} beacon_node \
--testnet-dir={cl_genesis} \
--datadir={cl_bn_dir} \
--staking \
Expand Down Expand Up @@ -486,7 +490,8 @@ fi "#
let cmd_run_part_1 = format!(
r#"
mkdir -p {cl_vc_dir} || exit 1
nohup {lighthouse} validator_client \
{lighthouse} validator_client \
--testnet-dir={cl_genesis} \
--datadir={cl_vc_dir}\
--beacon-nodes='{beacon_nodes}' \
Expand All @@ -510,10 +515,16 @@ nohup {lighthouse} validator_client \

format!(
r#"
{prepare_cmd}
{el_cmd}
{cl_bn_cmd}
{cl_vc_cmd} "#
{cl_vc_cmd}
"#
)
}

Expand Down

0 comments on commit 5fcf15e

Please sign in to comment.