diff --git a/crates/common/src/types/identifiers.rs b/crates/common/src/types/identifiers.rs index d642f98..349081c 100644 --- a/crates/common/src/types/identifiers.rs +++ b/crates/common/src/types/identifiers.rs @@ -29,6 +29,8 @@ use strum::{AsRefStr, Display, EnumString, IntoStaticStr}; pub enum PlatformIdentifier { /// The Go-ethereum reference full node EVM implementation with the solc compiler. GethEvmSolc, + /// The Lighthouse Go-ethereum reference full node EVM implementation with the solc compiler. + LighthouseGethEvmSolc, /// The kitchensink node with the PolkaVM backend with the resolc compiler. KitchensinkPolkavmResolc, /// The kitchensink node with the REVM backend with the solc compiler. @@ -87,6 +89,8 @@ pub enum CompilerIdentifier { pub enum NodeIdentifier { /// The go-ethereum node implementation. Geth, + /// The go-ethereum node implementation. + LighthouseGeth, /// The Kitchensink node implementation. Kitchensink, /// The revive dev node implementation. diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 8bc93e2..dbf576b 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -13,7 +13,9 @@ use anyhow::Context as _; use revive_dt_common::types::*; use revive_dt_compiler::{SolidityCompiler, revive_resolc::Resolc, solc::Solc}; use revive_dt_config::*; -use revive_dt_node::{Node, geth::GethNode, substrate::SubstrateNode}; +use revive_dt_node::{ + Node, geth::GethNode, lighthouse_geth::LighthouseGethNode, substrate::SubstrateNode, +}; use revive_dt_node_interaction::EthereumNode; use tracing::info; @@ -104,6 +106,51 @@ impl Platform for GethEvmSolcPlatform { } } +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] +pub struct LighthouseGethEvmSolcPlatform; + +impl Platform for LighthouseGethEvmSolcPlatform { + fn platform_identifier(&self) -> PlatformIdentifier { + PlatformIdentifier::LighthouseGethEvmSolc + } + + fn node_identifier(&self) -> NodeIdentifier { + NodeIdentifier::LighthouseGeth + } + + fn vm_identifier(&self) -> VmIdentifier { + VmIdentifier::Evm + } + + fn compiler_identifier(&self) -> CompilerIdentifier { + CompilerIdentifier::Solc + } + + fn new_node( + &self, + context: Context, + ) -> anyhow::Result>>> { + let genesis_configuration = AsRef::::as_ref(&context); + let genesis = genesis_configuration.genesis()?.clone(); + Ok(thread::spawn(move || { + let node = LighthouseGethNode::new(context); + let node = spawn_node::(node, genesis)?; + Ok(Box::new(node) as Box<_>) + })) + } + + fn new_compiler( + &self, + context: Context, + version: Option, + ) -> Pin>>>> { + Box::pin(async move { + let compiler = Solc::new(context, version).await; + compiler.map(|compiler| Box::new(compiler) as Box) + }) + } +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] pub struct KitchensinkPolkavmResolcPlatform; @@ -316,6 +363,9 @@ impl From for Box { fn from(value: PlatformIdentifier) -> Self { match value { PlatformIdentifier::GethEvmSolc => Box::new(GethEvmSolcPlatform) as Box<_>, + PlatformIdentifier::LighthouseGethEvmSolc => { + Box::new(LighthouseGethEvmSolcPlatform) as Box<_> + } PlatformIdentifier::KitchensinkPolkavmResolc => { Box::new(KitchensinkPolkavmResolcPlatform) as Box<_> } @@ -336,6 +386,9 @@ impl From for &dyn Platform { fn from(value: PlatformIdentifier) -> Self { match value { PlatformIdentifier::GethEvmSolc => &GethEvmSolcPlatform as &dyn Platform, + PlatformIdentifier::LighthouseGethEvmSolc => { + &LighthouseGethEvmSolcPlatform as &dyn Platform + } PlatformIdentifier::KitchensinkPolkavmResolc => { &KitchensinkPolkavmResolcPlatform as &dyn Platform } diff --git a/crates/node/src/lighthouse_geth.rs b/crates/node/src/lighthouse_geth.rs index 87de521..44c6066 100644 --- a/crates/node/src/lighthouse_geth.rs +++ b/crates/node/src/lighthouse_geth.rs @@ -245,7 +245,7 @@ impl LighthouseGethNode { execution_layer_port_publisher_parameters: Some( PortPublisherSingleItemParameters { enabled: Some(true), - public_port_start: None, + public_port_start: Some(32000 + self.id as u16 * 1000), }, ), consensus_layer_port_publisher_parameters: Default::default(), @@ -281,14 +281,10 @@ impl LighthouseGethNode { ProcessReadinessWaitBehavior::TimeBoundedWaitFunction { max_wait_duration: Duration::from_secs(5 * 60), check_function: Box::new(|stdout, stderr| { - for line in [stdout, stderr] - .iter() - .flatten() - .map(|line| line.to_lowercase()) - { - if line.contains("error encountered") { + for line in [stdout, stderr].iter().flatten() { + if line.to_lowercase().contains("error encountered") { anyhow::bail!("Encountered an error when starting Kurtosis") - } else if line.contains("status") && line.contains("running") { + } else if line.contains("RUNNING") { return Ok(true); } }