mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 04:31:51 +00:00
## Issue Addressed NA ## Proposed Changes Target the `master` branch of the canonical Geth repo, rather than @MariusVanDerWijden's fork. In [this tweet](https://twitter.com/vdWijden/status/1506899633741705217?s=20&t=yraR-qFAtSDCYtl_gyoeiw), Marius states: > We merged all important changes for [#TheMerge](https://twitter.com/hashtag/TheMerge?src=hashtag_click) into [@go_ethereum](https://twitter.com/go_ethereum) 's master branch. So no need to use my fork anymore! Changes will be applied (in old geth fashion) directly to master. My merge-kiln-v2 branch is already stale, so please switch, you can also use --kiln to join Kiln ## Additional Info NA
111 lines
3.2 KiB
Rust
111 lines
3.2 KiB
Rust
use crate::build_utils;
|
|
use crate::execution_engine::GenericExecutionEngine;
|
|
use crate::genesis_json::geth_genesis_json;
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::{Child, Command, Output};
|
|
use std::{env, fs::File};
|
|
use tempfile::TempDir;
|
|
use unused_port::unused_tcp_port;
|
|
|
|
const GETH_BRANCH: &str = "master";
|
|
const GETH_REPO_URL: &str = "https://github.com/ethereum/go-ethereum";
|
|
|
|
pub fn build_result(repo_dir: &Path) -> Output {
|
|
Command::new("make")
|
|
.arg("geth")
|
|
.current_dir(&repo_dir)
|
|
.output()
|
|
.expect("failed to make geth")
|
|
}
|
|
|
|
pub fn build(execution_clients_dir: &Path) {
|
|
let repo_dir = execution_clients_dir.join("go-ethereum");
|
|
|
|
if !repo_dir.exists() {
|
|
// Clone the repo
|
|
assert!(build_utils::clone_repo(
|
|
execution_clients_dir,
|
|
GETH_REPO_URL
|
|
));
|
|
}
|
|
|
|
// Checkout the correct branch
|
|
assert!(build_utils::checkout_branch(&repo_dir, GETH_BRANCH));
|
|
|
|
// Update the branch
|
|
assert!(build_utils::update_branch(&repo_dir, GETH_BRANCH));
|
|
|
|
// Build geth
|
|
build_utils::check_command_output(build_result(&repo_dir), "make failed");
|
|
}
|
|
|
|
/*
|
|
* Geth-specific Implementation for GenericExecutionEngine
|
|
*/
|
|
|
|
#[derive(Clone)]
|
|
pub struct GethEngine;
|
|
|
|
impl GethEngine {
|
|
fn binary_path() -> PathBuf {
|
|
let manifest_dir: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();
|
|
manifest_dir
|
|
.join("execution_clients")
|
|
.join("go-ethereum")
|
|
.join("build")
|
|
.join("bin")
|
|
.join("geth")
|
|
}
|
|
}
|
|
|
|
impl GenericExecutionEngine for GethEngine {
|
|
fn init_datadir() -> TempDir {
|
|
let datadir = TempDir::new().unwrap();
|
|
|
|
let genesis_json_path = datadir.path().join("genesis.json");
|
|
let mut file = File::create(&genesis_json_path).unwrap();
|
|
let json = geth_genesis_json();
|
|
serde_json::to_writer(&mut file, &json).unwrap();
|
|
|
|
let output = Command::new(Self::binary_path())
|
|
.arg("--datadir")
|
|
.arg(datadir.path().to_str().unwrap())
|
|
.arg("init")
|
|
.arg(genesis_json_path.to_str().unwrap())
|
|
.output()
|
|
.expect("failed to init geth");
|
|
|
|
build_utils::check_command_output(output, "geth init failed");
|
|
|
|
datadir
|
|
}
|
|
|
|
fn start_client(
|
|
datadir: &TempDir,
|
|
http_port: u16,
|
|
http_auth_port: u16,
|
|
jwt_secret_path: PathBuf,
|
|
) -> Child {
|
|
let network_port = unused_tcp_port().unwrap();
|
|
|
|
Command::new(Self::binary_path())
|
|
.arg("--datadir")
|
|
.arg(datadir.path().to_str().unwrap())
|
|
.arg("--http")
|
|
.arg("--http.api")
|
|
.arg("engine,eth")
|
|
.arg("--http.port")
|
|
.arg(http_port.to_string())
|
|
.arg("--authrpc.port")
|
|
.arg(http_auth_port.to_string())
|
|
.arg("--port")
|
|
.arg(network_port.to_string())
|
|
.arg("--authrpc.jwtsecret")
|
|
.arg(jwt_secret_path.as_path().to_str().unwrap())
|
|
.stdout(build_utils::build_stdio())
|
|
.stderr(build_utils::build_stdio())
|
|
.spawn()
|
|
.expect("failed to start geth")
|
|
}
|
|
}
|