diff --git a/protocol-testing/docker-compose.yaml b/protocol-testing/docker-compose.yaml index 0e91bad..2ff4867 100644 --- a/protocol-testing/docker-compose.yaml +++ b/protocol-testing/docker-compose.yaml @@ -24,7 +24,7 @@ services: db: condition: service_healthy environment: - RUST_LOG: "protocol_testing=info" + RUST_LOG: "${RUST_LOG:-protocol_testing=info}" DATABASE_URL: postgres://postgres:mypassword@db:5432/tycho_indexer_0 RPC_URL: "${RPC_URL}" SUBSTREAMS_API_TOKEN: "${SUBSTREAMS_API_TOKEN}" diff --git a/protocol-testing/src/main.rs b/protocol-testing/src/main.rs index 3a0d371..ed230a5 100644 --- a/protocol-testing/src/main.rs +++ b/protocol-testing/src/main.rs @@ -32,10 +32,6 @@ struct Args { #[arg(long)] match_test: Option, - /// Enable tycho logs - #[arg(long, default_value_t = false)] - tycho_logs: bool, - /// Postgres database URL for the Tycho indexer #[arg(long, default_value = "postgres://postgres:mypassword@localhost:5431/tycho_indexer_0")] db_url: String, @@ -94,7 +90,6 @@ fn main() -> miette::Result<()> { args.root_path()?, args.package, args.match_test, - args.tycho_logs, args.db_url, args.vm_traces, ); diff --git a/protocol-testing/src/test_runner.rs b/protocol-testing/src/test_runner.rs index ecc2a29..fe753ac 100644 --- a/protocol-testing/src/test_runner.rs +++ b/protocol-testing/src/test_runner.rs @@ -42,7 +42,6 @@ use crate::{ }; pub struct TestRunner { - tycho_logs: bool, db_url: String, vm_traces: bool, substreams_path: PathBuf, @@ -55,7 +54,6 @@ impl TestRunner { root_path: PathBuf, protocol: String, match_test: Option, - tycho_logs: bool, db_url: String, vm_traces: bool, ) -> Self { @@ -65,14 +63,7 @@ impl TestRunner { let evm_path = root_path.join("evm"); let adapter_contract_builder = AdapterContractBuilder::new(evm_path.to_string_lossy().to_string()); - Self { - tycho_logs, - db_url, - vm_traces, - substreams_path, - adapter_contract_builder, - match_test, - } + Self { db_url, vm_traces, substreams_path, adapter_contract_builder, match_test } } pub fn run_tests(&self) -> miette::Result<()> { @@ -191,8 +182,7 @@ impl TestRunner { let spkg_path = build_spkg(&substreams_yaml_path, test.start_block).wrap_err("Failed to build spkg")?; - let tycho_runner = - TychoRunner::new(self.db_url.clone(), initialized_accounts, self.tycho_logs); + let tycho_runner = TychoRunner::new(self.db_url.clone(), initialized_accounts); tycho_runner .run_tycho( diff --git a/protocol-testing/src/tycho_runner.rs b/protocol-testing/src/tycho_runner.rs index cfe6709..26dab37 100644 --- a/protocol-testing/src/tycho_runner.rs +++ b/protocol-testing/src/tycho_runner.rs @@ -6,23 +6,21 @@ use std::{ time::Duration, }; -use dotenv::dotenv; use miette::{IntoDiagnostic, WrapErr}; -use tracing::debug; +use tracing::{debug, info}; use crate::config::ProtocolComponentWithTestConfig; pub struct TychoRunner { db_url: String, initialized_accounts: Vec, - with_binary_logs: bool, } // TODO: Currently Tycho-Indexer cannot be run as a lib. We need to expose the entrypoints to allow // running it as a lib impl TychoRunner { - pub fn new(db_url: String, initialized_accounts: Vec, with_binary_logs: bool) -> Self { - Self { db_url, initialized_accounts, with_binary_logs } + pub fn new(db_url: String, initialized_accounts: Vec) -> Self { + Self { db_url, initialized_accounts } } pub fn run_tycho( @@ -33,8 +31,7 @@ impl TychoRunner { protocol_type_names: &[String], protocol_system: &str, ) -> miette::Result<()> { - // Expects a .env present in the same folder as package root (where Cargo.toml is) - dotenv().ok(); + info!("Running Tycho indexer from block {start_block} to {end_block}..."); let mut cmd = Command::new("tycho-indexer"); cmd.env("RUST_LOG", std::env::var("RUST_LOG").unwrap_or("tycho_indexer=info".to_string())) @@ -79,9 +76,7 @@ impl TychoRunner { .into_diagnostic() .wrap_err("Error running Tycho indexer")?; - if self.with_binary_logs { - Self::handle_process_output(&mut process); - } + Self::handle_process_output(&mut process); let status = process .wait() @@ -110,7 +105,6 @@ impl TychoRunner { { let (tx, rx): (Sender, Receiver) = mpsc::channel(); let db_url = self.db_url.clone(); - let with_binary_logs = self.with_binary_logs; // Start the RPC server in a separate thread let rpc_thread = thread::spawn(move || { @@ -126,9 +120,7 @@ impl TychoRunner { .spawn() .expect("Failed to start RPC server"); - if with_binary_logs { - Self::handle_process_output(&mut cmd); - } + Self::handle_process_output(&mut cmd); match rx.recv() { Ok(_) => { diff --git a/protocol-testing/src/utils.rs b/protocol-testing/src/utils.rs index 6f4a39c..1e5e2f0 100644 --- a/protocol-testing/src/utils.rs +++ b/protocol-testing/src/utils.rs @@ -86,6 +86,7 @@ pub fn build_spkg(yaml_file_path: &PathBuf, initial_block: u64) -> miette::Resul // Restore the original YAML from backup fs::copy(&backup_file_path, yaml_file_path).into_diagnostic()?; fs::remove_file(&backup_file_path).into_diagnostic()?; + info!("Spkg built successfully: {}", spkg_name); Ok(spkg_name) }