Files
lighthouse/testing/execution_engine_integration/src/geth.rs
Jimmy Chen 9c45a0e8c1 Use old geth version due to breaking changes. (#6936)
A temporary workaround for the failing execution tests for geth.

https://github.com/sigp/lighthouse/actions/runs/13192297954

The test is broken due to the following breaking changes in geth that requires updating our tests:
1. removal of `personal` namespace in v1.14.12: See #30704
2. removal of `totalDifficulty` field from RPC in v1.14.11. See #30386.

Using an older version for now (` 1.14.10`) as we need to get things merged for the upcoming release.

Will create a separate issue to fix this.
2025-02-07 04:53:14 +00:00

126 lines
4.1 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};
use tempfile::TempDir;
use unused_port::unused_tcp4_port;
// This is not currently used due to the following breaking changes in geth that requires updating our tests:
// 1. removal of `personal` namespace in v1.14.12: See #30704
// 2. removal of `totalDifficulty` field from RPC in v1.14.11. See #30386.
// 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
build_utils::clone_repo(execution_clients_dir, GETH_REPO_URL).unwrap();
}
// Get the latest tag on the branch
// let last_release = build_utils::get_latest_release(&repo_dir, GETH_BRANCH).unwrap();
// Using an older release due to breaking changes in recent releases. See comment on `GETH_BRANCH` const.
let release_tag = "v1.14.10";
build_utils::checkout(&repo_dir, dbg!(release_tag)).unwrap();
// Build geth
build_utils::check_command_output(build_result(&repo_dir), || {
format!("geth make failed using release {release_tag}")
});
}
pub fn clean(execution_clients_dir: &Path) {
let repo_dir = execution_clients_dir.join("go-ethereum");
if let Err(e) = fs::remove_dir_all(repo_dir) {
eprintln!("Error while deleting folder: {}", e);
}
}
/*
* 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 = fs::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".into());
datadir
}
fn start_client(
datadir: &TempDir,
http_port: u16,
http_auth_port: u16,
jwt_secret_path: PathBuf,
) -> Child {
let network_port = unused_tcp4_port().unwrap();
Command::new(Self::binary_path())
.arg("--datadir")
.arg(datadir.path().to_str().unwrap())
.arg("--http")
.arg("--http.api")
.arg("engine,eth,personal")
.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("--allow-insecure-unlock")
.arg("--authrpc.jwtsecret")
.arg(jwt_secret_path.as_path().to_str().unwrap())
// This flag is required to help Geth perform reliably when feeding it blocks
// one-by-one. For more information, see:
//
// https://github.com/sigp/lighthouse/pull/3382#issuecomment-1197680345
.arg("--syncmode=full")
.stdout(build_utils::build_stdio())
.stderr(build_utils::build_stdio())
.spawn()
.expect("failed to start geth")
}
}