Skip to content

Commit

Permalink
dft
Browse files Browse the repository at this point in the history
  • Loading branch information
haxjump committed Oct 8, 2024
1 parent ddb9314 commit 1f8fb58
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub const EL_LOG_NAME: &str = "el.log";
pub const CL_BN_LOG_NAME: &str = "cl.bn.log";
pub const CL_VC_LOG_NAME: &str = "cl.vc.log";

// TODO: fix me
pub const FEE_RECIPIENT: &str = "0x47102e476Bb96e616756ea7701C227547080Ea48";

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CustomInfo {
pub el_geth_bin: String,
Expand Down
96 changes: 89 additions & 7 deletions src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl NodeCmdGenerator<Node<Ports>, EnvMeta<CustomInfo, Node<Ports>>> for CmdGene
.copied()
.take(5)
.collect::<Vec<_>>();

let (el_rpc_endpoints, cl_bn_rpc_endpoints): (Vec<_>, Vec<_>) = e
.nodes
.values()
Expand All @@ -205,6 +206,10 @@ impl NodeCmdGenerator<Node<Ports>, EnvMeta<CustomInfo, Node<Ports>>> for CmdGene
})
.unzip();

////////////////////////////////////////////////
// EL
////////////////////////////////////////////////

let el_dir = format!("{home}/el");
let el_genesis = format!("{genesis_dir}/genesis.json");
let el_discovery_port = n.ports.el_discovery;
Expand All @@ -213,10 +218,12 @@ impl NodeCmdGenerator<Node<Ports>, EnvMeta<CustomInfo, Node<Ports>>> for CmdGene
let el_rpc_ws_port = n.ports.el_rpc_ws;
let el_engine_port = n.ports.el_engine_api;
let el_metric_port = n.ports.el_metric;

let el_rpc_endpoints = el_rpc_endpoints
.iter()
.map(|i| i.as_str())
.collect::<Vec<_>>();

let el_bootnodes =
info!(el_get_boot_nodes(&el_rpc_endpoints)).unwrap_or_default();

Expand Down Expand Up @@ -259,7 +266,7 @@ fi
--authrpc.addr={local_ip} --authrpc.port={el_engine_port}\
--authrpc.jwtsecret={auth_jwt} \
--metrics \
--metrics.port={el_metric_port}"#
--metrics.port={el_metric_port} "#
);

let cmd_run_part_1 = if el_bootnodes.is_empty() {
Expand Down Expand Up @@ -303,7 +310,7 @@ fi
--ws.api='admin,debug,eth,net,txpool,web3,rpc' \
--authrpc.addr={local_ip} --authrpc.port={el_engine_port}\
--authrpc.jwtsecret={auth_jwt} \
--metrics='{ext_ip}:{el_metric_port}'"#
--metrics='{ext_ip}:{el_metric_port}' "#
);

let mut cmd_run_part_1 = if el_bootnodes.is_empty() {
Expand All @@ -323,17 +330,92 @@ fi
pnk!(Err(eg!("The fucking world is over!")))
};

////////////////////////////////////////////////
// CL
////////////////////////////////////////////////

let lighthouse = &e.custom_data.cl_bin;

let cl_dir = format!("{home}/cl");
let cl_genesis = genesis_dir;
let cl_bn_discovery_port = n.ports.cl_discovery;
let cl_bn_discovery_quic_port = n.ports.cl_discovery_quic;
let cl_bn_rpc_port = n.ports.cl_bn_rpc;
let cl_vc_rpc_port = n.ports.cl_vc_rpc;
let cl_bn_metric_port = n.ports.cl_bn_metric;
let cl_vc_metric_port = n.ports.cl_vc_metric;

let cl_slots_per_rp = if matches!(n.kind, NodeKind::FullNode) {
2048
} else {
32
};

let cl_bn_rpc_endpoints = cl_bn_rpc_endpoints
.iter()
.map(|i| i.as_str())
.collect::<Vec<_>>();

let (cl_bn_bootnodes, cl_bn_trusted_peers) =
info!(cl_get_boot_nodes(&cl_bn_rpc_endpoints)).unwrap_or_default();

// For `ddev`, should change to `n.host.addr`
let checkpoint_sync_url = e
.nodes_should_be_online
.iter()
.take(1)
.flat_map(|n| e.bootstraps.get(n).or_else(|| e.nodes.get(n)))
.next()
.map(|n| format!("http://{ext_ip}:{}", n.ports.cl_bn_rpc));

let cl_bn_cmd = {
let cl_bn_rpc_endpoints = cl_bn_rpc_endpoints
.iter()
.map(|i| i.as_str())
.collect::<Vec<_>>();
let cmd_run_part_0 = format!(
r#"
{lighthouse} beacon_node \
--testnet-dir={cl_genesis} \
--datadir=${cl_dir} \
--staking \
--slots-per-restore-point={cl_slots_per_rp} \
--enr-address={ext_ip} \
--disable-enr-auto-update \
--disable-upnp \
--listen-address={local_ip} \
--port={cl_bn_discovery_port} \
--discovery-port={cl_bn_discovery_port} \
--quic-port={cl_bn_discovery_quic_port}\
--execution-endpoints='http://{local_ip}:{el_engine_port}' \
--jwt-secrets={auth_jwt} \
--suggested-fee-recipient={FEE_RECIPIENT} \
--http --http-address={local_ip} \
--http-port={cl_bn_rpc_port} --http-allow-origin='*' \
--metrics --metrics-address={local_ip} \
--metrics-port={cl_bn_metric_port} --metrics-allow-origin='*' "#
);

format!("")
let mut cmd_run_part_1 = if cl_bn_bootnodes.is_empty() {
String::new()
} else {
format!(" --boot-nodes='{cl_bn_bootnodes}' --trusted-peers='{cl_bn_trusted_peers}'")
};

if let Some(url) = checkpoint_sync_url {
cmd_run_part_1.push_str(&format!(" --checkpoint-sync-url={url}"));
}

// Disable this line in the `ddev` mod
cmd_run_part_1.push_str(" --enable-private-discovery");

let cmd_run_part_2 = format!(" >>{cl_dir}/{EL_LOG_NAME} 2>&1 ");

cmd_run_part_0 + &cmd_run_part_1 + &cmd_run_part_2
};

let cl_vc_cmd = format!("");

////////////////////////////////////////////////
// FINAL
////////////////////////////////////////////////

format!(
"{el_cmd} >>{0}/{EL_LOG_NAME} 2>&1 &
{cl_bn_cmd} >>{0}/{CL_BN_LOG_NAME} 2>&1 &
Expand Down

0 comments on commit 1f8fb58

Please sign in to comment.