From bd422b633e998f6055a5b994de01e390d76ed4cd Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Sun, 28 Sep 2025 21:39:50 +0300 Subject: [PATCH] Fix the lighthouse node tracing issue --- Cargo.toml | 3 +- crates/node/src/lighthouse_geth.rs | 103 ++++++++++++++++++++++------- run_tests.sh | 5 +- 3 files changed, 83 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 32c59f2..a1865f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,8 +80,9 @@ default-features = false features = [ "json-abi", "providers", - "provider-ipc", "provider-ws", + "provider-ipc", + "provider-http", "provider-debug-api", "reqwest", "rpc-types", diff --git a/crates/node/src/lighthouse_geth.rs b/crates/node/src/lighthouse_geth.rs index a53eefb..5a51cb8 100644 --- a/crates/node/src/lighthouse_geth.rs +++ b/crates/node/src/lighthouse_geth.rs @@ -35,16 +35,19 @@ use alloy::{ ext::DebugApi, fillers::{CachedNonceManager, ChainIdFiller, FillProvider, NonceFiller, TxFiller}, }, - rpc::types::{ - EIP1186AccountProofResponse, TransactionRequest, - trace::geth::{DiffMode, GethDebugTracingOptions, PreStateConfig, PreStateFrame}, + rpc::{ + client::{BuiltInConnectionString, ClientBuilder, RpcClient}, + types::{ + EIP1186AccountProofResponse, TransactionRequest, + trace::geth::{DiffMode, GethDebugTracingOptions, PreStateConfig, PreStateFrame}, + }, }, }; use anyhow::Context as _; use revive_common::EVMVersion; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_with::serde_as; -use tracing::{Instrument, instrument}; +use tracing::{Instrument, info, instrument}; use revive_dt_common::{ fs::clear_directory, @@ -75,7 +78,8 @@ static NODE_COUNT: AtomicU32 = AtomicU32::new(0); pub struct LighthouseGethNode { /* Node Identifier */ id: u32, - connection_string: String, + ws_connection_string: String, + http_connection_string: String, enclave_name: String, /* Directory Paths */ @@ -104,7 +108,6 @@ impl LighthouseGethNode { const BASE_DIRECTORY: &str = "lighthouse"; const LOGS_DIRECTORY: &str = "logs"; - const IPC_FILE_NAME: &str = "geth.ipc"; const CONFIG_FILE_NAME: &str = "config.yaml"; const TRANSACTION_INDEXING_ERROR: &str = "transaction indexing is in progress"; @@ -137,10 +140,8 @@ impl LighthouseGethNode { Self { /* Node Identifier */ id, - connection_string: base_directory - .join(Self::IPC_FILE_NAME) - .display() - .to_string(), + ws_connection_string: String::default(), + http_connection_string: String::default(), enclave_name: format!( "enclave-{}-{}", SystemTime::now() @@ -316,28 +317,75 @@ impl LighthouseGethNode { stdout }; - self.connection_string = stdout + self.http_connection_string = stdout + .split("el-1-geth-lighthouse") + .nth(1) + .and_then(|str| str.split(" rpc").nth(1)) + .and_then(|str| str.split("->").nth(1)) + .and_then(|str| str.split("\n").next()) + .and_then(|str| str.trim().split(" ").next()) + .map(|str| format!("http://{}", str.trim())) + .context("Failed to find the HTTP connection string of Kurtosis")?; + self.ws_connection_string = stdout .split("el-1-geth-lighthouse") .nth(1) .and_then(|str| str.split("ws").nth(1)) .and_then(|str| str.split("->").nth(1)) .and_then(|str| str.split("\n").next()) + .and_then(|str| str.trim().split(" ").next()) .map(|str| format!("ws://{}", str.trim())) .context("Failed to find the WS connection string of Kurtosis")?; + info!( + http_connection_string = self.http_connection_string, + ws_connection_string = self.ws_connection_string, + "Discovered the connection strings for the node" + ); + Ok(self) } #[instrument( level = "info", skip_all, - fields(lighthouse_node_id = self.id, connection_string = self.connection_string), + fields(lighthouse_node_id = self.id, connection_string = self.ws_connection_string), err(Debug), )] - async fn provider( + async fn ws_provider( &self, ) -> anyhow::Result, impl Provider, Ethereum>> { + let client = ClientBuilder::default() + .connect_with(BuiltInConnectionString::Ws( + self.ws_connection_string.as_str().parse().unwrap(), + None, + )) + .await?; + Ok(self.provider(client)) + } + + #[instrument( + level = "info", + skip_all, + fields(lighthouse_node_id = self.id, connection_string = self.ws_connection_string), + err(Debug), + )] + async fn http_provider( + &self, + ) -> anyhow::Result, impl Provider, Ethereum>> + { + let client = ClientBuilder::default() + .connect_with(BuiltInConnectionString::Http( + self.http_connection_string.as_str().parse().unwrap(), + )) + .await?; + Ok(self.provider(client)) + } + + fn provider( + &self, + rpc_client: RpcClient, + ) -> FillProvider, impl Provider, Ethereum> { ProviderBuilder::new() .disable_recommended_fillers() .filler(FallbackGasFiller::new( @@ -348,21 +396,19 @@ impl LighthouseGethNode { .filler(self.chain_id_filler.clone()) .filler(NonceFiller::new(self.nonce_manager.clone())) .wallet(self.wallet.clone()) - .connect(&self.connection_string) - .await - .context("Failed to create the provider for Kurtosis") + .connect_client(rpc_client) } /// Funds all of the accounts in the Ethereum wallet from the initially funded account. #[instrument( level = "info", skip_all, - fields(lighthouse_node_id = self.id, connection_string = self.connection_string), + fields(lighthouse_node_id = self.id, connection_string = self.ws_connection_string), err(Debug), )] async fn fund_all_accounts(&self) -> anyhow::Result<()> { let mut providers = - futures::future::try_join_all((0..100).map(|_| self.provider()).collect::>()) + futures::future::try_join_all((0..100).map(|_| self.ws_provider()).collect::>()) .await .context("Failed to create the providers")? .into_iter() @@ -407,6 +453,13 @@ impl LighthouseGethNode { tx_hashes.remove(hash); } + info!( + block.number = block_number, + block.timestamp = block.header.timestamp, + remaining_transactions = tx_hashes.len(), + "Discovered new block in funding accounts" + ); + block_number += 1 } @@ -490,13 +543,13 @@ impl EthereumNode for LighthouseGethNode { } fn connection_string(&self) -> &str { - &self.connection_string + &self.ws_connection_string } #[instrument( level = "info", skip_all, - fields(lighthouse_node_id = self.id, connection_string = self.connection_string), + fields(lighthouse_node_id = self.id, connection_string = self.ws_connection_string), err, )] fn execute_transaction( @@ -506,7 +559,7 @@ impl EthereumNode for LighthouseGethNode { { Box::pin(async move { let provider = self - .provider() + .ws_provider() .await .map(Arc::new) .context("Failed to create provider for transaction submission")?; @@ -523,7 +576,7 @@ impl EthereumNode for LighthouseGethNode { { Box::pin(async move { let provider = Arc::new( - self.provider() + self.http_provider() .await .context("Failed to create provider for tracing")?, ); @@ -584,7 +637,7 @@ impl EthereumNode for LighthouseGethNode { address: Address, ) -> Pin> + '_>> { Box::pin(async move { - self.provider() + self.ws_provider() .await .context("Failed to get the Geth provider")? .get_balance(address) @@ -600,7 +653,7 @@ impl EthereumNode for LighthouseGethNode { keys: Vec, ) -> Pin> + '_>> { Box::pin(async move { - self.provider() + self.ws_provider() .await .context("Failed to get the Geth provider")? .get_proof(address, keys) @@ -616,7 +669,7 @@ impl EthereumNode for LighthouseGethNode { ) -> Pin>> + '_>> { Box::pin(async move { let id = self.id; - let provider = self.provider().await?; + let provider = self.ws_provider().await?; Ok(Arc::new(LighthouseGethNodeResolver { id, provider }) as Arc) }) } diff --git a/run_tests.sh b/run_tests.sh index 0cc646e..5e33e87 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -89,12 +89,13 @@ echo "This may take a while..." echo "" # Run the tool -RUST_LOG="info" cargo run --release -- execute-tests \ +RUST_LOG="info,alloy_pubsub::service=error" cargo run --release -- execute-tests \ --platform geth-evm-solc \ --platform lighthouse-geth-evm-solc \ --corpus "$CORPUS_FILE" \ --working-directory "$WORKDIR" \ - --concurrency.number-of-nodes 5 \ + --concurrency.number-of-nodes 3 \ + --wallet.additional-keys 10000 \ --kitchensink.path "$SUBSTRATE_NODE_BIN" \ --revive-dev-node.path "$REVIVE_DEV_NODE_BIN" \ --eth-rpc.path "$ETH_RPC_BIN" \