From 5ce1c866a97af2969a409953f881e4d0644f3543 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 22 Sep 2025 18:30:01 -0400 Subject: [PATCH 001/162] remove slow_sync --- zainod/src/config.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 2248ada37..19762062a 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -111,9 +111,6 @@ pub struct IndexerConfig { /// Used for testing. pub no_db: bool, /// When enabled Zaino syncs it DB in the background, fetching data from the validator. - /// - /// NOTE: Unimplemented. - pub slow_sync: bool, } impl IndexerConfig { From 4406a4acd4d5d915a5cce8378a0c8e15f998b9d9 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 22 Sep 2025 18:48:08 -0400 Subject: [PATCH 002/162] remove comment --- zainod/src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 19762062a..833a1a584 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -110,7 +110,6 @@ pub struct IndexerConfig { /// Disables FinalisedState. /// Used for testing. pub no_db: bool, - /// When enabled Zaino syncs it DB in the background, fetching data from the validator. } impl IndexerConfig { From 30dadf593bdf0d3feee7c29f63d7be1bfa813ae2 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 22 Sep 2025 19:07:55 -0400 Subject: [PATCH 003/162] remove ref to field --- zainod/src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 833a1a584..ad3e2da43 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -258,7 +258,6 @@ impl Default for IndexerConfig { network: Network::Testnet, no_sync: false, no_db: false, - slow_sync: false, } } } From 8a9fe567b36c65c5e0241f229e105c40fcf52207 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 22 Sep 2025 20:37:50 -0400 Subject: [PATCH 004/162] remove field from testutils --- zaino-testutils/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 2d3a44a65..c7fdafeca 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -463,7 +463,6 @@ impl TestManager { network: network.into(), no_sync: zaino_no_sync, no_db: zaino_no_db, - slow_sync: false, }; let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await @@ -646,7 +645,6 @@ impl TestManager { network: network.into(), no_sync: zaino_no_sync, no_db: zaino_no_db, - slow_sync: false, }; let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await From 956b5ca5480af22026fc6e8377e7d218c38a3e6a Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 22 Sep 2025 21:23:52 -0400 Subject: [PATCH 005/162] Removing slow_sync asserts from zainod tests --- zainod/tests/config.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 63a41e94c..59719172c 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -124,7 +124,6 @@ fn test_deserialize_full_valid_config() { ); assert!(!finalized_config.no_sync); assert!(!finalized_config.no_db); - assert!(!finalized_config.slow_sync); Ok(()) }); @@ -167,7 +166,6 @@ fn test_deserialize_optional_fields_missing() { ); assert_eq!(config.no_sync, default_values.no_sync); assert_eq!(config.no_db, default_values.no_db); - assert_eq!(config.slow_sync, default_values.slow_sync); Ok(()) }); } @@ -311,7 +309,6 @@ fn test_deserialize_empty_string_yields_default() { ); assert_eq!(config.no_sync, default_config.no_sync); assert_eq!(config.no_db, default_config.no_db); - assert_eq!(config.slow_sync, default_config.slow_sync); Ok(()) }); } From 39b0eb8b982a26642a26c3e4acf67162a05deb7b Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 23 Sep 2025 00:24:01 -0400 Subject: [PATCH 006/162] start to work with grpc_tls --- zaino-common/src/config.rs | 25 +++++++++++++++++++++++++ zaino-common/src/lib.rs | 4 ++++ 2 files changed, 29 insertions(+) create mode 100644 zaino-common/src/config.rs diff --git a/zaino-common/src/config.rs b/zaino-common/src/config.rs new file mode 100644 index 000000000..15fd6e804 --- /dev/null +++ b/zaino-common/src/config.rs @@ -0,0 +1,25 @@ +//! gRPC config settings + +use std::path::PathBuf; + +// #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] +/// gRPC TLS settings +pub struct GrpcZainoConfig { + /// wrapper for TLS config, optional + pub grpc_tls: Option, +} + +/// Inner type, when a Zaino is configured with gRPC tls, it has paths to key and certificate. +pub struct GrpcTlsConfig { + /// Path to the TLS certificate file. + pub tls_cert_path: PathBuf, + /// Path to the TLS private key file. + pub tls_key_path: PathBuf, +} + +impl Default for GrpcZainoConfig { + fn default() -> Self { + // TODO may be dangerous as a default. + Self { grpc_tls: None } + } +} diff --git a/zaino-common/src/lib.rs b/zaino-common/src/lib.rs index f90dd3e6f..8799d80c5 100644 --- a/zaino-common/src/lib.rs +++ b/zaino-common/src/lib.rs @@ -3,11 +3,15 @@ //! This crate provides shared configuration types, network abstractions, //! and common utilities used across the Zaino blockchain indexer ecosystem. +pub mod config; pub mod network; pub mod service; pub mod storage; // Re-export commonly used types for convenience + +// TODO is GrpcClientConfig better? Something else? +pub use config::GrpcZainoConfig; pub use network::Network; pub use service::ServiceConfig; pub use storage::{CacheConfig, DatabaseConfig, DatabaseSize, StorageConfig}; From 7f2df0f94dd5419a1bf96a97e4fe6d48e7296e52 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 23 Sep 2025 01:05:47 -0400 Subject: [PATCH 007/162] WIP converting grpc_tls to Option<> --- zaino-common/src/config.rs | 17 ++++++++--------- zaino-common/src/lib.rs | 4 ++-- zaino-testutils/src/lib.rs | 8 ++------ zainod/src/config.rs | 14 ++++++++------ zainod/src/indexer.rs | 1 + zainod/tests/config.rs | 6 ++++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/zaino-common/src/config.rs b/zaino-common/src/config.rs index 15fd6e804..2c4aa36cd 100644 --- a/zaino-common/src/config.rs +++ b/zaino-common/src/config.rs @@ -2,14 +2,9 @@ use std::path::PathBuf; -// #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] +/// when a Zaino is configured with gRPC tls, it has paths to key and certificate. /// gRPC TLS settings -pub struct GrpcZainoConfig { - /// wrapper for TLS config, optional - pub grpc_tls: Option, -} - -/// Inner type, when a Zaino is configured with gRPC tls, it has paths to key and certificate. +#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcTlsConfig { /// Path to the TLS certificate file. pub tls_cert_path: PathBuf, @@ -17,9 +12,13 @@ pub struct GrpcTlsConfig { pub tls_key_path: PathBuf, } -impl Default for GrpcZainoConfig { +// TODO do we need a default? +impl Default for GrpcTlsConfig { fn default() -> Self { // TODO may be dangerous as a default. - Self { grpc_tls: None } + Self { + tls_cert_path: "/".into(), + tls_key_path: "/".into(), + } } } diff --git a/zaino-common/src/lib.rs b/zaino-common/src/lib.rs index 8799d80c5..d50765739 100644 --- a/zaino-common/src/lib.rs +++ b/zaino-common/src/lib.rs @@ -10,8 +10,8 @@ pub mod storage; // Re-export commonly used types for convenience -// TODO is GrpcClientConfig better? Something else? -pub use config::GrpcZainoConfig; +// TODO is GrpcClientConfig a better name? Something else? +pub use config::GrpcTlsConfig; pub use network::Network; pub use service::ServiceConfig; pub use storage::{CacheConfig, DatabaseConfig, DatabaseSize, StorageConfig}; diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index c7fdafeca..a6a7873e4 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -442,9 +442,7 @@ impl TestManager { enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, cookie_dir: zaino_json_server_cookie_dir.clone(), grpc_listen_address: zaino_grpc_listen_address, - grpc_tls: false, - tls_cert_path: None, - tls_key_path: None, + grpc_tls: None, validator_listen_address: zebrad_rpc_listen_address, validator_grpc_listen_address: zebrad_grpc_listen_address, validator_cookie_auth: false, @@ -624,9 +622,7 @@ impl TestManager { enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, cookie_dir: zaino_json_server_cookie_dir.clone(), grpc_listen_address: zaino_grpc_listen_address, - grpc_tls: false, - tls_cert_path: None, - tls_key_path: None, + grpc_tls: None, validator_listen_address: zebrad_rpc_listen_address, validator_grpc_listen_address: zebrad_grpc_listen_address, validator_cookie_auth: false, diff --git a/zainod/src/config.rs b/zainod/src/config.rs index ad3e2da43..b7af054b8 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -19,7 +19,7 @@ use serde::{ use tracing::warn; use tracing::{error, info}; use zaino_common::{ - CacheConfig, DatabaseConfig, DatabaseSize, Network, ServiceConfig, StorageConfig, + CacheConfig, DatabaseConfig, DatabaseSize, GrpcTlsConfig, Network, ServiceConfig, StorageConfig, }; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; @@ -75,11 +75,13 @@ pub struct IndexerConfig { #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub grpc_listen_address: SocketAddr, /// Enables TLS. - pub grpc_tls: bool, + pub grpc_tls: Option, + /* /// Path to the TLS certificate file. pub tls_cert_path: Option, /// Path to the TLS private key file. pub tls_key_path: Option, + */ /// Full node / validator listen port. #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub validator_listen_address: SocketAddr, @@ -118,6 +120,7 @@ impl IndexerConfig { // Network type is validated at the type level via Network enum. // Check TLS settings. + // TODO refactor below for new gRPC config setup if self.grpc_tls { if let Some(ref cert_path) = self.tls_cert_path { if !std::path::Path::new(cert_path).exists() { @@ -178,7 +181,7 @@ impl IndexerConfig { #[cfg(not(feature = "no_tls_use_unencrypted_traffic"))] { // Ensure TLS is used when connecting to external addresses. - if !is_private_listen_addr(&grpc_addr) && !self.grpc_tls { + if !is_private_listen_addr(&grpc_addr) && self.grpc_tls.is_none() { return Err(IndexerError::ConfigError( "TLS required when connecting to external addresses.".to_string(), )); @@ -192,6 +195,7 @@ impl IndexerConfig { )); } } + // TODO insure this is activated or removed #[cfg(feature = "no_tls_use_unencrypted_traffic")] { warn!( @@ -237,9 +241,7 @@ impl Default for IndexerConfig { enable_cookie_auth: false, cookie_dir: None, grpc_listen_address: "127.0.0.1:8137".parse().unwrap(), - grpc_tls: false, - tls_cert_path: None, - tls_key_path: None, + grpc_tls: None, validator_listen_address: "127.0.0.1:18232".parse().unwrap(), validator_grpc_listen_address: "127.0.0.1:18230".parse().unwrap(), validator_cookie_auth: false, diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 9d0c110f8..c04220c08 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -113,6 +113,7 @@ where service.inner_ref().get_subscriber(), GrpcConfig { grpc_listen_address: indexer_config.grpc_listen_address, + // TODO indexer_config is passed in with spawn_inner tls: indexer_config.grpc_tls, tls_cert_path: indexer_config.tls_cert_path.clone(), tls_key_path: indexer_config.tls_key_path.clone(), diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 59719172c..8ddc5a14e 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -29,6 +29,7 @@ fn test_deserialize_full_valid_config() { jail.create_dir(zaino_db_dir_name)?; jail.create_dir(zebra_db_dir_name)?; + // TODO we are altering this TOML ... see {cert_file_name} etc // Use relative paths in the TOML string let toml_str = format!( r#" @@ -38,6 +39,7 @@ fn test_deserialize_full_valid_config() { enable_cookie_auth = true cookie_dir = "{zaino_cookie_dir_name}" grpc_listen_address = "0.0.0.0:9000" + // grpc_tls = Some(GrpcTlsConfig {tls_cert_path: "{cert_file_name}".into(), tls_key_path: "{key_file_name}".into()}) grpc_tls = true tls_cert_path = "{cert_file_name}" tls_key_path = "{key_file_name}" @@ -110,7 +112,7 @@ fn test_deserialize_full_valid_config() { finalized_config.grpc_listen_address, "0.0.0.0:9000".parse().unwrap() ); - assert!(finalized_config.grpc_tls); + assert!(finalized_config.grpc_tls.is_some()); assert_eq!(finalized_config.validator_user, Some("user".to_string())); assert_eq!( finalized_config.validator_password, @@ -396,7 +398,7 @@ fn test_figment_env_override_toml_and_defaults() { assert!(config.enable_json_server); assert_eq!(config.storage.cache.capacity, 12345); assert_eq!(config.cookie_dir, Some(PathBuf::from("/env/cookie/path"))); - assert_eq!(!config.grpc_tls, true); + assert_eq!(config.grpc_tls, None); Ok(()) }); } From d4cbeae95ef9dd0902762efd832e4ad8bfa5b604 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 27 Sep 2025 22:15:52 -0400 Subject: [PATCH 008/162] todos and notes --- zaino-common/src/config.rs | 2 ++ zainod/src/config.rs | 1 + zainod/src/indexer.rs | 1 + zainod/zindexer.toml | 1 + 4 files changed, 5 insertions(+) diff --git a/zaino-common/src/config.rs b/zaino-common/src/config.rs index 2c4aa36cd..825c7a11c 100644 --- a/zaino-common/src/config.rs +++ b/zaino-common/src/config.rs @@ -7,6 +7,8 @@ use std::path::PathBuf; #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcTlsConfig { /// Path to the TLS certificate file. + // TODO maybe these need to be options because of GrpcConfig type...? + // or.. I need to just load THAT type in here. pub tls_cert_path: PathBuf, /// Path to the TLS private key file. pub tls_key_path: PathBuf, diff --git a/zainod/src/config.rs b/zainod/src/config.rs index b7af054b8..9caa83232 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -75,6 +75,7 @@ pub struct IndexerConfig { #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub grpc_listen_address: SocketAddr, /// Enables TLS. + // TODO: in zaino-serve/src/server/config there is GrpcConfig pub grpc_tls: Option, /* /// Path to the TLS certificate file. diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index c04220c08..ba0288472 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -74,6 +74,7 @@ where IndexerError: From<::Error>, { /// Spawns a new Indexer server. + // TODO rename (sounds too much like spawn indexer) pub async fn spawn_inner( service_config: Service::Config, indexer_config: IndexerConfig, diff --git a/zainod/zindexer.toml b/zainod/zindexer.toml index 85679b4f7..30b6d009b 100644 --- a/zainod/zindexer.toml +++ b/zainod/zindexer.toml @@ -84,6 +84,7 @@ validator_cookie_auth = false # Zebra Block Cache database file path. # If omitted, this defaults to $HOME/.cache/zebra/ (platform dependent). # zebra_db_path = "/path/to/zebra_db" +zebra_db_path = "/home/o/.cache/zebra/state/v27/testnet" # Block Cache database maximum size in gb. # Only used by the FetchService. From 3f0cd5de613cdd83e13baa85b769577b72a56e21 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 28 Sep 2025 04:07:17 -0400 Subject: [PATCH 009/162] WIP move to incorporate existing GrpcConfig --- Cargo.lock | 1 + zaino-common/src/config.rs | 2 ++ zaino-serve/Cargo.toml | 1 + zaino-serve/src/server/config.rs | 7 +++++++ zainod/src/config.rs | 4 +++- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b70eebdc9..641d33fe4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5970,6 +5970,7 @@ version = "0.1.2" dependencies = [ "futures", "jsonrpsee", + "serde", "thiserror 1.0.69", "tokio", "tonic", diff --git a/zaino-common/src/config.rs b/zaino-common/src/config.rs index 825c7a11c..09281a756 100644 --- a/zaino-common/src/config.rs +++ b/zaino-common/src/config.rs @@ -5,6 +5,8 @@ use std::path::PathBuf; /// when a Zaino is configured with gRPC tls, it has paths to key and certificate. /// gRPC TLS settings #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] +// TODO there is a GrpcConfig that covers tls in zaino-serve/src/server/config.rs +// I feel like this might want to just become 're-eliminated' pub struct GrpcTlsConfig { /// Path to the TLS certificate file. // TODO maybe these need to be options because of GrpcConfig type...? diff --git a/zaino-serve/Cargo.toml b/zaino-serve/Cargo.toml index 404ce2ab7..b655084f2 100644 --- a/zaino-serve/Cargo.toml +++ b/zaino-serve/Cargo.toml @@ -29,6 +29,7 @@ tonic = { workspace = true, features = ["tls"] } thiserror = { workspace = true } futures = { workspace = true } jsonrpsee = { workspace = true, features = ["server", "macros"] } +serde = { workspace = true, features = ["derive"] } tower = { workspace = true } [build-dependencies] diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 240ccf0fc..5f09946a7 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -1,5 +1,10 @@ //! Server configuration data. +use serde::{ + de::{self, Deserializer}, + Deserialize, Serialize, +}; + use std::{net::SocketAddr, path::PathBuf}; use tonic::transport::{Identity, ServerTlsConfig}; @@ -7,8 +12,10 @@ use tonic::transport::{Identity, ServerTlsConfig}; use super::error::ServerError; /// Configuration data for Zaino's gRPC server. +// TODO : this is probably what we want to mess with. pub struct GrpcConfig { /// gRPC server bind addr. + #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub grpc_listen_address: SocketAddr, /// Enables TLS. pub tls: bool, diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 9caa83232..741bb6f1b 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -21,6 +21,7 @@ use tracing::{error, info}; use zaino_common::{ CacheConfig, DatabaseConfig, DatabaseSize, GrpcTlsConfig, Network, ServiceConfig, StorageConfig, }; +use zaino_serve::server::config::GrpcConfig; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; use crate::error::IndexerError; @@ -71,11 +72,12 @@ pub struct IndexerConfig { pub enable_cookie_auth: bool, /// Directory to store authentication cookie file. pub cookie_dir: Option, + // TODO: convert all to GrpcConfig + pub grpc_settings: GrpcConfig, /// gRPC server bind addr. #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub grpc_listen_address: SocketAddr, /// Enables TLS. - // TODO: in zaino-serve/src/server/config there is GrpcConfig pub grpc_tls: Option, /* /// Path to the TLS certificate file. From ca13fa4a71fdcc4680cc19eeeebadcfb24fd571d Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 28 Sep 2025 05:23:03 -0400 Subject: [PATCH 010/162] start overhaul GrpcConfig --- zaino-serve/src/server/config.rs | 96 ++++++++++++++++++++++---------- zainod/src/config.rs | 6 +- 2 files changed, 69 insertions(+), 33 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 5f09946a7..ebd72e7df 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -1,9 +1,12 @@ //! Server configuration data. +/* use serde::{ - de::{self, Deserializer}, - Deserialize, Serialize, + // de::{self, Deserializer}, + Deserialize, + Serialize, }; +*/ use std::{net::SocketAddr, path::PathBuf}; @@ -11,45 +14,78 @@ use tonic::transport::{Identity, ServerTlsConfig}; use super::error::ServerError; +/// when a Zaino is configured with gRPC tls, it has paths to key and certificate. +/// gRPC TLS settings +#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] +pub struct GrpcTls { + /// Path to the TLS certificate file. + // TODO maybe these need to be options because of GrpcConfig type...? + // or.. I need to just load THAT type in here. + /// Path to the TLS certificate file in PEM format. + pub tls_cert_path: PathBuf, + /// Path to the TLS private key file in PEM format. + pub tls_key_path: PathBuf, +} + +/* +// TODO do we need a default? +impl Default for GrpcTlsSettings { + fn default() -> Self { + // TODO may be dangerous as a default. + Self { + tls_cert_path: "/".into(), + tls_key_path: "/".into(), + } + } +} +*/ + /// Configuration data for Zaino's gRPC server. -// TODO : this is probably what we want to mess with. pub struct GrpcConfig { /// gRPC server bind addr. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + // TODO : commented this out because serde didn't want to be portable (orphan rule?) + // can we work aorund this, or do we have to wrap it or something + // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub grpc_listen_address: SocketAddr, /// Enables TLS. - pub tls: bool, - /// Path to the TLS certificate file in PEM format. - pub tls_cert_path: Option, - /// Path to the TLS private key file in PEM format. - pub tls_key_path: Option, + pub tls: Option, } impl GrpcConfig { /// If TLS is enabled, reads the certificate and key files and returns a valid /// `ServerTlsConfig`. If TLS is not enabled, returns `Ok(None)`. + // TODO now this return type is wrong, it used to get an Option<&str> IIUC pub async fn get_valid_tls(&self) -> Result, ServerError> { - if self.tls { - // Ensure the certificate and key paths are provided. - let cert_path = self.tls_cert_path.as_ref().ok_or_else(|| { - ServerError::ServerConfigError("TLS enabled but tls_cert_path not provided".into()) - })?; - let key_path = self.tls_key_path.as_ref().ok_or_else(|| { - ServerError::ServerConfigError("TLS enabled but tls_key_path not provided".into()) - })?; - // Read the certificate and key files asynchronously. - let cert = tokio::fs::read(cert_path).await.map_err(|e| { - ServerError::ServerConfigError(format!("Failed to read TLS certificate: {e}")) - })?; - let key = tokio::fs::read(key_path).await.map_err(|e| { - ServerError::ServerConfigError(format!("Failed to read TLS key: {e}")) - })?; - // Build the identity and TLS configuration. - let identity = Identity::from_pem(cert, key); - let tls_config = ServerTlsConfig::new().identity(identity); - Ok(Some(tls_config)) - } else { - Ok(None) + match self.tls.clone() { + Some(t) => { + if !t.tls_cert_path.exists() { + return Err(ServerError::ServerConfigError( + "TLS enabled but tls_cert_path does not exist".into(), + )); + } + let cert_path = t.tls_cert_path; + + if !t.tls_key_path.exists() { + return Err(ServerError::ServerConfigError( + "TLS enabled but tls_key_path does not exist".into(), + )); + } + let key_path = t.tls_key_path; + + // Read the certificate and key files asynchronously. + let cert = tokio::fs::read(cert_path).await.map_err(|e| { + ServerError::ServerConfigError(format!("Failed to read TLS certificate: {e}")) + })?; + let key = tokio::fs::read(key_path).await.map_err(|e| { + ServerError::ServerConfigError(format!("Failed to read TLS key: {e}")) + })?; + + // Build the identity and TLS configuration. + let tls_id = Identity::from_pem(cert, key); + let tls_config = ServerTlsConfig::new().identity(tls_id); + Ok(Some(tls_config)) + } + None => Ok(None), } } } diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 741bb6f1b..fddf02dec 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -75,10 +75,10 @@ pub struct IndexerConfig { // TODO: convert all to GrpcConfig pub grpc_settings: GrpcConfig, /// gRPC server bind addr. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub grpc_listen_address: SocketAddr, + // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + // pub grpc_listen_address: SocketAddr, /// Enables TLS. - pub grpc_tls: Option, + // pub grpc_tls: Option, /* /// Path to the TLS certificate file. pub tls_cert_path: Option, From 1b03fc34ec807c7bfbe51ad8564d50c8a6434771 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 28 Sep 2025 05:25:16 -0400 Subject: [PATCH 011/162] cleanup, continue overhaul GrpcConfig --- zaino-serve/src/server/config.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index ebd72e7df..fe17a94e0 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -18,9 +18,6 @@ use super::error::ServerError; /// gRPC TLS settings #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcTls { - /// Path to the TLS certificate file. - // TODO maybe these need to be options because of GrpcConfig type...? - // or.. I need to just load THAT type in here. /// Path to the TLS certificate file in PEM format. pub tls_cert_path: PathBuf, /// Path to the TLS private key file in PEM format. @@ -54,7 +51,6 @@ pub struct GrpcConfig { impl GrpcConfig { /// If TLS is enabled, reads the certificate and key files and returns a valid /// `ServerTlsConfig`. If TLS is not enabled, returns `Ok(None)`. - // TODO now this return type is wrong, it used to get an Option<&str> IIUC pub async fn get_valid_tls(&self) -> Result, ServerError> { match self.tls.clone() { Some(t) => { From e873f86545d173555f2a23386531509e2f315bec Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 28 Sep 2025 05:27:17 -0400 Subject: [PATCH 012/162] remove zaino-common config for GrpcTls --- zaino-common/src/config.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 zaino-common/src/config.rs diff --git a/zaino-common/src/config.rs b/zaino-common/src/config.rs deleted file mode 100644 index 09281a756..000000000 --- a/zaino-common/src/config.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! gRPC config settings - -use std::path::PathBuf; - -/// when a Zaino is configured with gRPC tls, it has paths to key and certificate. -/// gRPC TLS settings -#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] -// TODO there is a GrpcConfig that covers tls in zaino-serve/src/server/config.rs -// I feel like this might want to just become 're-eliminated' -pub struct GrpcTlsConfig { - /// Path to the TLS certificate file. - // TODO maybe these need to be options because of GrpcConfig type...? - // or.. I need to just load THAT type in here. - pub tls_cert_path: PathBuf, - /// Path to the TLS private key file. - pub tls_key_path: PathBuf, -} - -// TODO do we need a default? -impl Default for GrpcTlsConfig { - fn default() -> Self { - // TODO may be dangerous as a default. - Self { - tls_cert_path: "/".into(), - tls_key_path: "/".into(), - } - } -} From b8ca602963f547ddc4c1c06bb5864a8b1086616c Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 02:34:13 -0400 Subject: [PATCH 013/162] rename GrpcConfig fields --- zainod/src/indexer.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index ba0288472..6a88ed19e 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -113,11 +113,9 @@ where let grpc_server = TonicServer::spawn( service.inner_ref().get_subscriber(), GrpcConfig { - grpc_listen_address: indexer_config.grpc_listen_address, + listen_address: indexer_config.grpc_settings.listen_address, // TODO indexer_config is passed in with spawn_inner - tls: indexer_config.grpc_tls, - tls_cert_path: indexer_config.tls_cert_path.clone(), - tls_key_path: indexer_config.tls_key_path.clone(), + tls: indexer_config.grpc_settings.tls, }, ) .await From 0607848be78fe6b5e66ae3830ba5d845cb8f32b1 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 02:34:57 -0400 Subject: [PATCH 014/162] rename GrpcConfig fields --- zaino-serve/src/server/config.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index fe17a94e0..df150722f 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -19,9 +19,9 @@ use super::error::ServerError; #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcTls { /// Path to the TLS certificate file in PEM format. - pub tls_cert_path: PathBuf, + pub cert_path: PathBuf, /// Path to the TLS private key file in PEM format. - pub tls_key_path: PathBuf, + pub key_path: PathBuf, } /* @@ -38,12 +38,14 @@ impl Default for GrpcTlsSettings { */ /// Configuration data for Zaino's gRPC server. +// TODO add debug clone and serialise +#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcConfig { /// gRPC server bind addr. // TODO : commented this out because serde didn't want to be portable (orphan rule?) // can we work aorund this, or do we have to wrap it or something // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub grpc_listen_address: SocketAddr, + pub listen_address: SocketAddr, /// Enables TLS. pub tls: Option, } @@ -51,22 +53,25 @@ pub struct GrpcConfig { impl GrpcConfig { /// If TLS is enabled, reads the certificate and key files and returns a valid /// `ServerTlsConfig`. If TLS is not enabled, returns `Ok(None)`. + // TODO seemingly only used in one place, + // when starting gRPC Tonic server + // TODO : redundant? pub async fn get_valid_tls(&self) -> Result, ServerError> { match self.tls.clone() { - Some(t) => { - if !t.tls_cert_path.exists() { + Some(tls) => { + if !tls.cert_path.exists() { return Err(ServerError::ServerConfigError( "TLS enabled but tls_cert_path does not exist".into(), )); } - let cert_path = t.tls_cert_path; + let cert_path = tls.cert_path; - if !t.tls_key_path.exists() { + if !tls.key_path.exists() { return Err(ServerError::ServerConfigError( "TLS enabled but tls_key_path does not exist".into(), )); } - let key_path = t.tls_key_path; + let key_path = tls.key_path; // Read the certificate and key files asynchronously. let cert = tokio::fs::read(cert_path).await.map_err(|e| { From c2e12588bf40deae98c43b430aeff70cfdaf8233 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 02:36:02 -0400 Subject: [PATCH 015/162] rename GrpcConfig fields --- zaino-serve/src/server/grpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-serve/src/server/grpc.rs b/zaino-serve/src/server/grpc.rs index 37e2512d2..442ff64bf 100644 --- a/zaino-serve/src/server/grpc.rs +++ b/zaino-serve/src/server/grpc.rs @@ -56,7 +56,7 @@ impl TonicServer { }; let server_future = server_builder .add_service(svc) - .serve_with_shutdown(server_config.grpc_listen_address, shutdown_signal); + .serve_with_shutdown(server_config.listen_address, shutdown_signal); let task_status = status.clone(); let server_handle = tokio::task::spawn(async move { From e9fb7bf29efb9b788644294ae2bd782563717fbb Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 03:18:03 -0400 Subject: [PATCH 016/162] change zainod/config, path cert key checks adjusted --- zainod/src/config.rs | 68 +++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index fddf02dec..f9284648c 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -19,7 +19,7 @@ use serde::{ use tracing::warn; use tracing::{error, info}; use zaino_common::{ - CacheConfig, DatabaseConfig, DatabaseSize, GrpcTlsConfig, Network, ServiceConfig, StorageConfig, + CacheConfig, DatabaseConfig, DatabaseSize, Network, ServiceConfig, StorageConfig, }; use zaino_serve::server::config::GrpcConfig; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; @@ -72,9 +72,8 @@ pub struct IndexerConfig { pub enable_cookie_auth: bool, /// Directory to store authentication cookie file. pub cookie_dir: Option, - // TODO: convert all to GrpcConfig + /// gRPC server settings including listen addr, tls key and cert. pub grpc_settings: GrpcConfig, - /// gRPC server bind addr. // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] // pub grpc_listen_address: SocketAddr, /// Enables TLS. @@ -123,30 +122,32 @@ impl IndexerConfig { // Network type is validated at the type level via Network enum. // Check TLS settings. - // TODO refactor below for new gRPC config setup - if self.grpc_tls { - if let Some(ref cert_path) = self.tls_cert_path { - if !std::path::Path::new(cert_path).exists() { - return Err(IndexerError::ConfigError(format!( - "TLS is enabled, but certificate path '{cert_path}' does not exist." - ))); - } - } else { - return Err(IndexerError::ConfigError( - "TLS is enabled, but no certificate path is provided.".to_string(), - )); + if self.grpc_settings.tls.is_some() { + // then check if cert path exists or return error + let c_path = &self + .grpc_settings + .tls + .as_ref() + .expect("to be Some") + .cert_path; + if !std::path::Path::new(&c_path).exists() { + return Err(IndexerError::ConfigError(format!( + "TLS is enabled, but certificate path {:?} does not exist.", + c_path + ))); } - if let Some(ref key_path) = self.tls_key_path { - if !std::path::Path::new(key_path).exists() { - return Err(IndexerError::ConfigError(format!( - "TLS is enabled, but key path '{key_path}' does not exist." - ))); - } - } else { - return Err(IndexerError::ConfigError( - "TLS is enabled, but no key path is provided.".to_string(), - )); + let k_path = &self + .grpc_settings + .tls + .as_ref() + .expect("to be Some") + .key_path; + if !std::path::Path::new(&k_path).exists() { + return Err(IndexerError::ConfigError(format!( + "TLS is enabled, but key path {:?} does not exist.", + k_path + ))); } } @@ -167,9 +168,10 @@ impl IndexerConfig { } #[cfg(not(feature = "no_tls_use_unencrypted_traffic"))] - let grpc_addr = fetch_socket_addr_from_hostname(&self.grpc_listen_address.to_string())?; - #[cfg(feature = "no_tls_use_unencrypted_traffic")] - let _ = fetch_socket_addr_from_hostname(&self.grpc_listen_address.to_string())?; + let grpc_addr = + fetch_socket_addr_from_hostname(&self.grpc_settings.listen_address.to_string())?; + // #[cfg(feature = "no_tls_use_unencrypted_traffic")] + // let _ = fetch_socket_addr_from_hostname(&self.grpc_listen_address.to_string())?; let validator_addr = fetch_socket_addr_from_hostname(&self.validator_listen_address.to_string())?; @@ -184,7 +186,7 @@ impl IndexerConfig { #[cfg(not(feature = "no_tls_use_unencrypted_traffic"))] { // Ensure TLS is used when connecting to external addresses. - if !is_private_listen_addr(&grpc_addr) && self.grpc_tls.is_none() { + if !is_private_listen_addr(&grpc_addr) && self.grpc_settings.tls.is_none() { return Err(IndexerError::ConfigError( "TLS required when connecting to external addresses.".to_string(), )); @@ -207,7 +209,7 @@ impl IndexerConfig { } // Check gRPC and JsonRPC server are not listening on the same address. - if self.json_rpc_listen_address == self.grpc_listen_address { + if self.json_rpc_listen_address == self.grpc_settings.listen_address { return Err(IndexerError::ConfigError( "gRPC server and JsonRPC server must listen on different addresses.".to_string(), )); @@ -243,8 +245,10 @@ impl Default for IndexerConfig { json_rpc_listen_address: "127.0.0.1:8237".parse().unwrap(), enable_cookie_auth: false, cookie_dir: None, - grpc_listen_address: "127.0.0.1:8137".parse().unwrap(), - grpc_tls: None, + grpc_settings: GrpcConfig { + listen_address: "127.0.0.1:8137".parse().unwrap(), + tls: None, + }, validator_listen_address: "127.0.0.1:18232".parse().unwrap(), validator_grpc_listen_address: "127.0.0.1:18230".parse().unwrap(), validator_cookie_auth: false, From 67a5962b1f1b8afcfb0e5849c77ae834ece456df Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 03:26:42 -0400 Subject: [PATCH 017/162] rm common --- zaino-common/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zaino-common/src/lib.rs b/zaino-common/src/lib.rs index d50765739..5e7e264b4 100644 --- a/zaino-common/src/lib.rs +++ b/zaino-common/src/lib.rs @@ -3,15 +3,12 @@ //! This crate provides shared configuration types, network abstractions, //! and common utilities used across the Zaino blockchain indexer ecosystem. -pub mod config; pub mod network; pub mod service; pub mod storage; // Re-export commonly used types for convenience -// TODO is GrpcClientConfig a better name? Something else? -pub use config::GrpcTlsConfig; pub use network::Network; pub use service::ServiceConfig; pub use storage::{CacheConfig, DatabaseConfig, DatabaseSize, StorageConfig}; From 10dfb2d3ac31e3e424990f00d9d494fb8e913b74 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 03:49:40 -0400 Subject: [PATCH 018/162] change testutils grpc settings, add dependency zaino-serve --- Cargo.lock | 1 + zaino-testutils/Cargo.toml | 1 + zaino-testutils/src/lib.rs | 13 +++++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 641d33fe4..f18d6b9f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6049,6 +6049,7 @@ dependencies = [ "tonic", "tracing-subscriber", "zaino-common", + "zaino-serve", "zaino-state", "zaino-testvectors", "zainod", diff --git a/zaino-testutils/Cargo.toml b/zaino-testutils/Cargo.toml index 7c2b482b9..c78660e8d 100644 --- a/zaino-testutils/Cargo.toml +++ b/zaino-testutils/Cargo.toml @@ -11,6 +11,7 @@ publish = false [dependencies] zaino-state = { workspace = true, features = ["bench"] } +zaino-serve.workspace = true zaino-testvectors.workspace = true zaino-common.workspace = true diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index a6a7873e4..5e89ca265 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -17,6 +17,7 @@ use tempfile::TempDir; use testvectors::{seeds, REG_O_ADDR_FROM_ABANDONART}; use tracing_subscriber::EnvFilter; use zaino_common::{CacheConfig, DatabaseConfig, ServiceConfig, StorageConfig}; +use zaino_serve::server::config::GrpcConfig; use zaino_state::BackendType; use zainodlib::config::default_ephemeral_cookie_path; pub use zingo_infra_services as services; @@ -441,8 +442,10 @@ impl TestManager { json_rpc_listen_address: zaino_json_listen_address, enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, cookie_dir: zaino_json_server_cookie_dir.clone(), - grpc_listen_address: zaino_grpc_listen_address, - grpc_tls: None, + grpc_settings: GrpcConfig { + listen_address: zaino_grpc_listen_address, + tls: None, + }, validator_listen_address: zebrad_rpc_listen_address, validator_grpc_listen_address: zebrad_grpc_listen_address, validator_cookie_auth: false, @@ -621,8 +624,10 @@ impl TestManager { json_rpc_listen_address: zaino_json_listen_address, enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, cookie_dir: zaino_json_server_cookie_dir.clone(), - grpc_listen_address: zaino_grpc_listen_address, - grpc_tls: None, + grpc_settings: GrpcConfig { + listen_address: zaino_grpc_listen_address, + tls: None, + }, validator_listen_address: zebrad_rpc_listen_address, validator_grpc_listen_address: zebrad_grpc_listen_address, validator_cookie_auth: false, From 91b5010b870d7c01669948c8b80e16625c7f6f07 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 16:11:58 -0400 Subject: [PATCH 019/162] WIP, compiling, failing tests, raw string toml --- zainod/tests/config.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 8ddc5a14e..70ac3421f 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -38,11 +38,7 @@ fn test_deserialize_full_valid_config() { json_rpc_listen_address = "127.0.0.1:8000" enable_cookie_auth = true cookie_dir = "{zaino_cookie_dir_name}" - grpc_listen_address = "0.0.0.0:9000" - // grpc_tls = Some(GrpcTlsConfig {tls_cert_path: "{cert_file_name}".into(), tls_key_path: "{key_file_name}".into()}) - grpc_tls = true - tls_cert_path = "{cert_file_name}" - tls_key_path = "{key_file_name}" + grpc_settings: = {{ listen_address = "0.0.0.0:9000", tls = {{cert_path: "{cert_file_name}".into(), key_path: "{key_file_name}"}} }} validator_listen_address = "192.168.1.10:18232" validator_cookie_auth = true validator_cookie_path = "{validator_cookie_file_name}" @@ -88,12 +84,22 @@ fn test_deserialize_full_valid_config() { Some(PathBuf::from(zaino_cookie_dir_name)) ); assert_eq!( - finalized_config.tls_cert_path, - Some(cert_file_name.to_string()) + finalized_config + .clone() + .grpc_settings + .tls + .expect("tls to be Some in finalized conifg") + .cert_path, + PathBuf::from(cert_file_name) ); assert_eq!( - finalized_config.tls_key_path, - Some(key_file_name.to_string()) + finalized_config + .clone() + .grpc_settings + .tls + .expect("tls to be Some in finalized_conifg") + .key_path, + PathBuf::from(key_file_name) ); assert_eq!( finalized_config.validator_cookie_path, @@ -109,10 +115,10 @@ fn test_deserialize_full_valid_config() { ); assert_eq!(finalized_config.network, Network::Mainnet); assert_eq!( - finalized_config.grpc_listen_address, + finalized_config.grpc_settings.listen_address, "0.0.0.0:9000".parse().unwrap() ); - assert!(finalized_config.grpc_tls.is_some()); + assert!(finalized_config.grpc_settings.tls.is_some()); assert_eq!(finalized_config.validator_user, Some("user".to_string())); assert_eq!( finalized_config.validator_password, @@ -398,7 +404,7 @@ fn test_figment_env_override_toml_and_defaults() { assert!(config.enable_json_server); assert_eq!(config.storage.cache.capacity, 12345); assert_eq!(config.cookie_dir, Some(PathBuf::from("/env/cookie/path"))); - assert_eq!(config.grpc_tls, None); + assert!(config.grpc_settings.tls.is_none()); Ok(()) }); } From f0bee092a9307ca5964a0fc89a610743dc80202a Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 16:38:23 -0400 Subject: [PATCH 020/162] fix rawstring to TOML --- zainod/tests/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 70ac3421f..fac92ecfa 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -38,7 +38,7 @@ fn test_deserialize_full_valid_config() { json_rpc_listen_address = "127.0.0.1:8000" enable_cookie_auth = true cookie_dir = "{zaino_cookie_dir_name}" - grpc_settings: = {{ listen_address = "0.0.0.0:9000", tls = {{cert_path: "{cert_file_name}".into(), key_path: "{key_file_name}"}} }} + grpc_settings = {{ listen_address = "0.0.0.0:9000", tls = {{cert_path = "{cert_file_name}", key_path = "{key_file_name}" }} }} validator_listen_address = "192.168.1.10:18232" validator_cookie_auth = true validator_cookie_path = "{validator_cookie_file_name}" From 11818fed4280d4733eb2ee53e8e57280ba8f46b5 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 17:42:49 -0400 Subject: [PATCH 021/162] cleanup --- zaino-common/src/lib.rs | 1 - zainod/zindexer.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/zaino-common/src/lib.rs b/zaino-common/src/lib.rs index 5e7e264b4..f90dd3e6f 100644 --- a/zaino-common/src/lib.rs +++ b/zaino-common/src/lib.rs @@ -8,7 +8,6 @@ pub mod service; pub mod storage; // Re-export commonly used types for convenience - pub use network::Network; pub use service::ServiceConfig; pub use storage::{CacheConfig, DatabaseConfig, DatabaseSize, StorageConfig}; diff --git a/zainod/zindexer.toml b/zainod/zindexer.toml index 30b6d009b..85679b4f7 100644 --- a/zainod/zindexer.toml +++ b/zainod/zindexer.toml @@ -84,7 +84,6 @@ validator_cookie_auth = false # Zebra Block Cache database file path. # If omitted, this defaults to $HOME/.cache/zebra/ (platform dependent). # zebra_db_path = "/path/to/zebra_db" -zebra_db_path = "/home/o/.cache/zebra/state/v27/testnet" # Block Cache database maximum size in gb. # Only used by the FetchService. From 87d4f1d2f23f423aaad07a2731ad342a177ba1b3 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 17:43:04 -0400 Subject: [PATCH 022/162] cleanup --- zaino-serve/src/server/config.rs | 24 ------------------------ zainod/src/indexer.rs | 14 -------------- 2 files changed, 38 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index df150722f..3ebc1f8ca 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -1,13 +1,5 @@ //! Server configuration data. -/* -use serde::{ - // de::{self, Deserializer}, - Deserialize, - Serialize, -}; -*/ - use std::{net::SocketAddr, path::PathBuf}; use tonic::transport::{Identity, ServerTlsConfig}; @@ -24,21 +16,7 @@ pub struct GrpcTls { pub key_path: PathBuf, } -/* -// TODO do we need a default? -impl Default for GrpcTlsSettings { - fn default() -> Self { - // TODO may be dangerous as a default. - Self { - tls_cert_path: "/".into(), - tls_key_path: "/".into(), - } - } -} -*/ - /// Configuration data for Zaino's gRPC server. -// TODO add debug clone and serialise #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcConfig { /// gRPC server bind addr. @@ -53,8 +31,6 @@ pub struct GrpcConfig { impl GrpcConfig { /// If TLS is enabled, reads the certificate and key files and returns a valid /// `ServerTlsConfig`. If TLS is not enabled, returns `Ok(None)`. - // TODO seemingly only used in one place, - // when starting gRPC Tonic server // TODO : redundant? pub async fn get_valid_tls(&self) -> Result, ServerError> { match self.tls.clone() { diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 6a88ed19e..5a24e65e3 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -81,19 +81,6 @@ where ) -> Result>, IndexerError> { let service = IndexerService::::spawn(service_config).await?; - // let read_state_service = IndexerService::::spawn(StateServiceConfig::new( - // todo!("add zebra config to indexerconfig"), - // config.validator_listen_address, - // config.validator_cookie_auth, - // config.validator_cookie_path, - // config.validator_user, - // config.validator_password, - // None, - // None, - // config.get_network()?, - // )) - // .await?; - let json_server = match indexer_config.enable_json_server { true => Some( JsonRpcServer::spawn( @@ -114,7 +101,6 @@ where service.inner_ref().get_subscriber(), GrpcConfig { listen_address: indexer_config.grpc_settings.listen_address, - // TODO indexer_config is passed in with spawn_inner tls: indexer_config.grpc_settings.tls, }, ) From e469518a74025fa3f0073c6d74cc65aaf922ffdd Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 17:45:04 -0400 Subject: [PATCH 023/162] remove todo --- zaino-serve/src/server/config.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 3ebc1f8ca..9ba48fd98 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -20,9 +20,6 @@ pub struct GrpcTls { #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcConfig { /// gRPC server bind addr. - // TODO : commented this out because serde didn't want to be portable (orphan rule?) - // can we work aorund this, or do we have to wrap it or something - // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub listen_address: SocketAddr, /// Enables TLS. pub tls: Option, From 91fb5adc24dbe28a9ba9473a80cfdf8f440a0bd8 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 17:47:51 -0400 Subject: [PATCH 024/162] add todo, remove comments --- zaino-serve/src/server/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 9ba48fd98..518d9afbe 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -20,6 +20,7 @@ pub struct GrpcTls { #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcConfig { /// gRPC server bind addr. + // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub listen_address: SocketAddr, /// Enables TLS. pub tls: Option, From 668419986eebd9b6a5d6c1d15825a31b747da6e7 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 17:48:11 -0400 Subject: [PATCH 025/162] add todo, remove comments --- zainod/src/config.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index f9284648c..30391dfee 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -74,16 +74,6 @@ pub struct IndexerConfig { pub cookie_dir: Option, /// gRPC server settings including listen addr, tls key and cert. pub grpc_settings: GrpcConfig, - // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - // pub grpc_listen_address: SocketAddr, - /// Enables TLS. - // pub grpc_tls: Option, - /* - /// Path to the TLS certificate file. - pub tls_cert_path: Option, - /// Path to the TLS private key file. - pub tls_key_path: Option, - */ /// Full node / validator listen port. #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub validator_listen_address: SocketAddr, From 2452a54072755212cc30346c0a997ab88161a428 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 17:49:40 -0400 Subject: [PATCH 026/162] adjust comment --- zainod/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 30391dfee..06e3e5c81 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -72,7 +72,7 @@ pub struct IndexerConfig { pub enable_cookie_auth: bool, /// Directory to store authentication cookie file. pub cookie_dir: Option, - /// gRPC server settings including listen addr, tls key and cert. + /// gRPC server settings including listen addr, tls status, key and cert. pub grpc_settings: GrpcConfig, /// Full node / validator listen port. #[serde(deserialize_with = "deserialize_socketaddr_from_string")] From 06822d4219a5230a3c4b2dadbd9d0ff77449479c Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 18:08:35 -0400 Subject: [PATCH 027/162] rename spawn_inner() --- zainod/src/indexer.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 5a24e65e3..142d5c3c5 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -60,10 +60,10 @@ pub async fn spawn_indexer( ); match BackendConfig::try_from(config.clone()) { Ok(BackendConfig::State(state_service_config)) => { - Indexer::::spawn_inner(state_service_config, config).await + Indexer::::launch_inner(state_service_config, config).await } Ok(BackendConfig::Fetch(fetch_service_config)) => { - Indexer::::spawn_inner(fetch_service_config, config).await + Indexer::::launch_inner(fetch_service_config, config).await } Err(e) => Err(e), } @@ -74,8 +74,7 @@ where IndexerError: From<::Error>, { /// Spawns a new Indexer server. - // TODO rename (sounds too much like spawn indexer) - pub async fn spawn_inner( + pub async fn launch_inner( service_config: Service::Config, indexer_config: IndexerConfig, ) -> Result>, IndexerError> { From 57c8794f79faca4b685a884161b4d3aa77343e98 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 18:14:59 -0400 Subject: [PATCH 028/162] remove deadcode --- zainod/src/config.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 06e3e5c81..580095ac0 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -160,8 +160,6 @@ impl IndexerConfig { #[cfg(not(feature = "no_tls_use_unencrypted_traffic"))] let grpc_addr = fetch_socket_addr_from_hostname(&self.grpc_settings.listen_address.to_string())?; - // #[cfg(feature = "no_tls_use_unencrypted_traffic")] - // let _ = fetch_socket_addr_from_hostname(&self.grpc_listen_address.to_string())?; let validator_addr = fetch_socket_addr_from_hostname(&self.validator_listen_address.to_string())?; From 7420b9180c799fccf8cffcf3419e81a6b2da3f40 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 29 Sep 2025 18:23:16 -0400 Subject: [PATCH 029/162] remove comment --- zainod/tests/config.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index fac92ecfa..db9020744 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -29,7 +29,6 @@ fn test_deserialize_full_valid_config() { jail.create_dir(zaino_db_dir_name)?; jail.create_dir(zebra_db_dir_name)?; - // TODO we are altering this TOML ... see {cert_file_name} etc // Use relative paths in the TOML string let toml_str = format!( r#" @@ -51,8 +50,6 @@ fn test_deserialize_full_valid_config() { no_sync = false no_db = false slow_sync = false - - "# ); From 777ee38df83782bae86a4925862fee91c29005f6 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 4 Oct 2025 02:29:35 -0400 Subject: [PATCH 030/162] begin no_db removal, comment out code, add todos --- zaino-common/src/storage.rs | 3 ++ zaino-state/src/config.rs | 34 +++++++++---------- zaino-state/src/local_cache.rs | 2 ++ .../src/local_cache/non_finalised_state.rs | 4 +++ zaino-testutils/src/lib.rs | 4 +-- zainod/src/config.rs | 13 +++---- zainod/tests/config.rs | 9 +++-- 7 files changed, 41 insertions(+), 28 deletions(-) diff --git a/zaino-common/src/storage.rs b/zaino-common/src/storage.rs index ccfde0aa3..d26ef2a21 100644 --- a/zaino-common/src/storage.rs +++ b/zaino-common/src/storage.rs @@ -37,6 +37,7 @@ impl Default for CacheConfig { /// This enum provides a clean TOML interface and easy extensibility for different units. #[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "lowercase")] +// and here pub enum DatabaseSize { /// Limited to a specific size in GB Gb(usize), @@ -69,6 +70,7 @@ impl DatabaseSize { /// Configures the file path and size limits for persistent storage /// used by Zaino services. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] +// and here pub struct DatabaseConfig { /// Database file path. pub path: PathBuf, @@ -90,6 +92,7 @@ impl Default for DatabaseConfig { /// /// This is used by services that need both in-memory caching and persistent storage. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, Default)] +// via here pub struct StorageConfig { /// Cache configuration. Uses defaults if not specified in TOML. #[serde(default)] diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index b7402cf53..afb478380 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -47,9 +47,9 @@ pub struct StateServiceConfig { /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - /// Disables FinalisedState. - /// Used for testing. - pub no_db: bool, + // /// Disables FinalisedState. + // /// Used for testing. + // pub no_db: bool, } impl StateServiceConfig { @@ -68,7 +68,7 @@ impl StateServiceConfig { storage: StorageConfig, network: Network, no_sync: bool, - no_db: bool, + // no_db: bool, ) -> Self { StateServiceConfig { validator_config, @@ -82,7 +82,7 @@ impl StateServiceConfig { storage, network, no_sync, - no_db, + // no_db, } } } @@ -109,9 +109,9 @@ pub struct FetchServiceConfig { /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - /// Disables FinalisedState. - /// Used for testing. - pub no_db: bool, + // /// Disables FinalisedState. + // /// Used for testing. + // pub no_db: bool, } impl FetchServiceConfig { @@ -128,7 +128,7 @@ impl FetchServiceConfig { storage: StorageConfig, network: Network, no_sync: bool, - no_db: bool, + // no_db: bool, ) -> Self { FetchServiceConfig { validator_rpc_address, @@ -140,7 +140,7 @@ impl FetchServiceConfig { storage, network, no_sync, - no_db, + // no_db, } } } @@ -158,9 +158,9 @@ pub struct BlockCacheConfig { /// Stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - /// Disables FinalisedState. - /// Used for testing. - pub no_db: bool, + // /// Disables FinalisedState. + // /// Used for testing. + // pub no_db: bool, } impl BlockCacheConfig { @@ -171,14 +171,14 @@ impl BlockCacheConfig { db_version: u32, network: Network, no_sync: bool, - no_db: bool, + // no_db: bool, ) -> Self { BlockCacheConfig { storage, db_version, network, no_sync, - no_db, + // no_db, } } } @@ -191,7 +191,7 @@ impl From for BlockCacheConfig { db_version: 1, network: value.network, no_sync: value.no_sync, - no_db: value.no_db, + // no_db: value.no_db, } } } @@ -204,7 +204,7 @@ impl From for BlockCacheConfig { db_version: 1, network: value.network, no_sync: value.no_sync, - no_db: value.no_db, + // no_db: value.no_db, } } } diff --git a/zaino-state/src/local_cache.rs b/zaino-state/src/local_cache.rs index 13a8d3cdb..4369a18a6 100644 --- a/zaino-state/src/local_cache.rs +++ b/zaino-state/src/local_cache.rs @@ -57,6 +57,8 @@ impl BlockCache { info!("Launching Local Block Cache.."); let (channel_tx, channel_rx) = tokio::sync::mpsc::channel(100); + // TODO here + // no_db is used in non-test code let finalised_state = if !config.no_db { Some(FinalisedState::spawn(fetcher, state, channel_rx, config.clone()).await?) } else { diff --git a/zaino-state/src/local_cache/non_finalised_state.rs b/zaino-state/src/local_cache/non_finalised_state.rs index ed001a7b9..9b04ea3ef 100644 --- a/zaino-state/src/local_cache/non_finalised_state.rs +++ b/zaino-state/src/local_cache/non_finalised_state.rs @@ -314,6 +314,9 @@ impl NonFinalisedState { if pop_height.0 < (validator_height.saturating_sub(100)) { if let Some(hash) = self.heights_to_hashes.get(&pop_height) { // Send to FinalisedState if db is active. + // match to db = 0 + // TODO this seems to be non-test code where no_db is used + // ? if no_db is fasle, then there is some db size if !self.config.no_db { if let Some(block) = self.hashes_to_blocks.get(&hash) { if self @@ -369,6 +372,7 @@ impl NonFinalisedState { /// Waits for server to sync with p2p network. pub async fn wait_on_server(&self) -> Result<(), NonFinalisedStateError> { // If no_db is active wait for server to sync with p2p network. + // TODO here also no_db used if self.config.no_db && !self.config.network.to_zebra_network().is_regtest() && !self.config.no_sync diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 5e89ca265..1fb44ab84 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -463,7 +463,7 @@ impl TestManager { zebra_db_path, network: network.into(), no_sync: zaino_no_sync, - no_db: zaino_no_db, + // no_db: zaino_no_db, }; let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await @@ -645,7 +645,7 @@ impl TestManager { zebra_db_path, network: network.into(), no_sync: zaino_no_sync, - no_db: zaino_no_db, + // no_db: zaino_no_db, }; let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 580095ac0..a125c720b 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -91,6 +91,7 @@ pub struct IndexerConfig { /// Service-level configuration (timeout, channel size). pub service: ServiceConfig, /// Storage configuration (cache and database). + // this is it, in here pub storage: StorageConfig, /// Block Cache database file path. /// @@ -101,9 +102,9 @@ pub struct IndexerConfig { /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - /// Disables FinalisedState. - /// Used for testing. - pub no_db: bool, + // /// db size 0 = (no_db) - Disables FinalisedState. + // /// Used for testing. + // pub no_db: bool, } impl IndexerConfig { @@ -254,7 +255,7 @@ impl Default for IndexerConfig { zebra_db_path: default_zebra_db_path().unwrap(), network: Network::Testnet, no_sync: false, - no_db: false, + // no_db: false, } } } @@ -388,7 +389,7 @@ impl TryFrom for BackendConfig { storage: cfg.storage, network: cfg.network, no_sync: cfg.no_sync, - no_db: cfg.no_db, + // no_db: cfg.no_db, })), zaino_state::BackendType::Fetch => Ok(BackendConfig::Fetch(FetchServiceConfig { @@ -403,7 +404,7 @@ impl TryFrom for BackendConfig { storage: cfg.storage, network: cfg.network, no_sync: cfg.no_sync, - no_db: cfg.no_db, + // no_db: cfg.no_db, })), } } diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index db9020744..7e3d8cb0e 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -128,7 +128,8 @@ fn test_deserialize_full_valid_config() { 128 * 1024 * 1024 * 1024 ); assert!(!finalized_config.no_sync); - assert!(!finalized_config.no_db); + // assert finalized config > 0 + //assert!(!finalized_config.no_db); Ok(()) }); @@ -170,7 +171,8 @@ fn test_deserialize_optional_fields_missing() { default_values.storage.database.size ); assert_eq!(config.no_sync, default_values.no_sync); - assert_eq!(config.no_db, default_values.no_db); + // db = 0 + //assert_eq!(config.no_db, default_values.no_db); Ok(()) }); } @@ -313,7 +315,8 @@ fn test_deserialize_empty_string_yields_default() { default_config.storage.database.size ); assert_eq!(config.no_sync, default_config.no_sync); - assert_eq!(config.no_db, default_config.no_db); + // db = 0 + // assert_eq!(config.no_db, default_config.no_db); Ok(()) }); } From 3448dc4b7c65e188b3c3084082ffe0bf63f78222 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 4 Oct 2025 17:36:47 -0400 Subject: [PATCH 031/162] remove no_db from local_cache --- zaino-state/src/local_cache.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/zaino-state/src/local_cache.rs b/zaino-state/src/local_cache.rs index 4369a18a6..e24a68b7e 100644 --- a/zaino-state/src/local_cache.rs +++ b/zaino-state/src/local_cache.rs @@ -57,12 +57,12 @@ impl BlockCache { info!("Launching Local Block Cache.."); let (channel_tx, channel_rx) = tokio::sync::mpsc::channel(100); - // TODO here - // no_db is used in non-test code - let finalised_state = if !config.no_db { - Some(FinalisedState::spawn(fetcher, state, channel_rx, config.clone()).await?) - } else { - None + let db_size = config.storage.database.size; + let finalised_state = match db_size { + zaino_common::DatabaseSize::Gb(0) => None, + zaino_common::DatabaseSize::Gb(_) => { + Some(FinalisedState::spawn(fetcher, state, channel_rx, config.clone()).await?) + } }; let non_finalised_state = @@ -95,9 +95,9 @@ impl BlockCache { /// Returns the status of the block cache. pub fn status(&self) -> StatusType { let non_finalised_state_status = self.non_finalised_state.status(); - let finalised_state_status = match self.config.no_db { - true => StatusType::Ready, - false => match &self.finalised_state { + let finalised_state_status = match self.config.storage.database.size { + zaino_common::DatabaseSize::Gb(0) => StatusType::Ready, + zaino_common::DatabaseSize::Gb(_) => match &self.finalised_state { Some(finalised_state) => finalised_state.status(), None => return StatusType::Offline, }, @@ -196,9 +196,10 @@ impl BlockCacheSubscriber { /// Returns the status of the [`BlockCache`].. pub fn status(&self) -> StatusType { let non_finalised_state_status = self.non_finalised_state.status(); - let finalised_state_status = match self.config.no_db { - true => StatusType::Ready, - false => match &self.finalised_state { + // mathcing on no_db = 0 + let finalised_state_status = match self.config.storage.database.size { + zaino_common::DatabaseSize::Gb(0) => StatusType::Ready, + zaino_common::DatabaseSize::Gb(_) => match &self.finalised_state { Some(finalised_state) => finalised_state.status(), None => return StatusType::Offline, }, From dbd637247107ce400c994b2826b051c122c1540a Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 4 Oct 2025 18:22:48 -0400 Subject: [PATCH 032/162] remove no_db logic from local_cache non_finalised_state --- .../src/local_cache/non_finalised_state.rs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/zaino-state/src/local_cache/non_finalised_state.rs b/zaino-state/src/local_cache/non_finalised_state.rs index 9b04ea3ef..6dce31069 100644 --- a/zaino-state/src/local_cache/non_finalised_state.rs +++ b/zaino-state/src/local_cache/non_finalised_state.rs @@ -314,22 +314,22 @@ impl NonFinalisedState { if pop_height.0 < (validator_height.saturating_sub(100)) { if let Some(hash) = self.heights_to_hashes.get(&pop_height) { // Send to FinalisedState if db is active. - // match to db = 0 - // TODO this seems to be non-test code where no_db is used - // ? if no_db is fasle, then there is some db size - if !self.config.no_db { - if let Some(block) = self.hashes_to_blocks.get(&hash) { - if self - .block_sender - .send((pop_height, *hash, block.as_ref().clone())) - .await - .is_err() - { - self.status.store(StatusType::CriticalError); - return Err(NonFinalisedStateError::Critical( - "Critical error in database. Closing NonFinalisedState" - .to_string(), - )); + match self.config.storage.database.size { + zaino_common::DatabaseSize::Gb(0) => {} // do nothing + zaino_common::DatabaseSize::Gb(_) => { + if let Some(block) = self.hashes_to_blocks.get(&hash) { + if self + .block_sender + .send((pop_height, *hash, block.as_ref().clone())) + .await + .is_err() + { + self.status.store(StatusType::CriticalError); + return Err(NonFinalisedStateError::Critical( + "Critical error in database. Closing NonFinalisedState" + .to_string(), + )); + } } } } @@ -372,11 +372,11 @@ impl NonFinalisedState { /// Waits for server to sync with p2p network. pub async fn wait_on_server(&self) -> Result<(), NonFinalisedStateError> { // If no_db is active wait for server to sync with p2p network. - // TODO here also no_db used - if self.config.no_db - && !self.config.network.to_zebra_network().is_regtest() - && !self.config.no_sync - { + let mybool = match self.config.storage.database.size { + zaino_common::DatabaseSize::Gb(0) => true, + zaino_common::DatabaseSize::Gb(_) => false, + }; + if mybool && !self.config.network.to_zebra_network().is_regtest() && !self.config.no_sync { self.status.store(StatusType::Syncing); loop { let blockchain_info = self.fetcher.get_blockchain_info().await.map_err(|e| { From 3a42ad8e58f376897f688085d710416bef34ba60 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 4 Oct 2025 18:23:41 -0400 Subject: [PATCH 033/162] rm no_db from testutils --- zaino-testutils/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 1fb44ab84..f402124e7 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -353,7 +353,6 @@ impl TestManager { enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, - zaino_no_db: bool, enable_clients: bool, ) -> Result { if (validator == &ValidatorKind::Zcashd) && (backend == &BackendType::State) { @@ -463,7 +462,6 @@ impl TestManager { zebra_db_path, network: network.into(), no_sync: zaino_no_sync, - // no_db: zaino_no_db, }; let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await @@ -534,7 +532,6 @@ impl TestManager { enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, - zaino_no_db: bool, enable_clients: bool, ) -> Result { if (validator == &ValidatorKind::Zcashd) && (backend == &BackendType::State) { @@ -645,7 +642,6 @@ impl TestManager { zebra_db_path, network: network.into(), no_sync: zaino_no_sync, - // no_db: zaino_no_db, }; let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await From 0c03807afc54695aa214770c1ec3831c7f5aa72d Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 03:29:49 -0400 Subject: [PATCH 034/162] remove no_db across integration tests, zaino-state --- integration-tests/tests/chain_cache.rs | 55 ++++---------- integration-tests/tests/fetch_service.rs | 71 +++++++++---------- integration-tests/tests/json_server.rs | 3 - integration-tests/tests/local_cache.rs | 22 +++--- integration-tests/tests/state_service.rs | 3 - integration-tests/tests/test_vectors.rs | 2 - .../tests/wallet_to_validator.rs | 14 ++-- zaino-state/src/chain_index/tests.rs | 1 - .../tests/finalised_state/migrations.rs | 6 -- .../chain_index/tests/finalised_state/v0.rs | 2 - .../chain_index/tests/finalised_state/v1.rs | 3 - zaino-state/src/local_cache.rs | 1 - zaino-testutils/src/lib.rs | 22 ------ 13 files changed, 66 insertions(+), 139 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index 9054196d5..13cd0c8e2 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -7,7 +7,7 @@ async fn create_test_manager_and_connector( chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - zaino_no_db: bool, + // zaino_no_db: bool, enable_clients: bool, ) -> (TestManager, JsonRpSeeConnector) { let test_manager = TestManager::launch( @@ -19,7 +19,6 @@ async fn create_test_manager_and_connector( false, false, zaino_no_sync, - zaino_no_db, enable_clients, ) .await @@ -72,7 +71,7 @@ mod chain_query_interface { chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - zaino_no_db: bool, + // zaino_no_db: bool, enable_clients: bool, ) -> ( TestManager, @@ -85,7 +84,6 @@ mod chain_query_interface { chain_cache.clone(), enable_zaino, zaino_no_sync, - zaino_no_db, enable_clients, ) .await; @@ -144,7 +142,6 @@ mod chain_query_interface { }, network.into(), true, - true, )) .await .unwrap(); @@ -161,7 +158,7 @@ mod chain_query_interface { db_version: 1, network: zaino_common::Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, + // no_db: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::State(chain_index::source::State { @@ -187,7 +184,7 @@ mod chain_query_interface { None, true, false, - false, + // no_db = false, true, ) .await; @@ -223,15 +220,8 @@ mod chain_query_interface { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn find_fork_point() { let (test_manager, _json_service, _chain_index, indexer) = - create_test_manager_and_chain_index( - &ValidatorKind::Zebrad, - None, - true, - false, - false, - true, - ) - .await; + create_test_manager_and_chain_index(&ValidatorKind::Zebrad, None, true, false, true) + .await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -254,15 +244,8 @@ mod chain_query_interface { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_raw_transaction() { let (test_manager, _json_service, _chain_index, indexer) = - create_test_manager_and_chain_index( - &ValidatorKind::Zebrad, - None, - true, - false, - false, - true, - ) - .await; + create_test_manager_and_chain_index(&ValidatorKind::Zebrad, None, true, false, true) + .await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -303,15 +286,8 @@ mod chain_query_interface { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_transaction_status() { let (test_manager, _json_service, _chain_index, indexer) = - create_test_manager_and_chain_index( - &ValidatorKind::Zebrad, - None, - true, - false, - false, - true, - ) - .await; + create_test_manager_and_chain_index(&ValidatorKind::Zebrad, None, true, false, true) + .await; let snapshot = indexer.snapshot_nonfinalized_state(); // I don't know where this second block is generated. Somewhere in the // guts of create_test_manager_and_chain_index @@ -342,15 +318,8 @@ mod chain_query_interface { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn sync_large_chain() { let (test_manager, state_service, _chain_index, indexer) = - create_test_manager_and_chain_index( - &ValidatorKind::Zebrad, - None, - true, - false, - false, - true, - ) - .await; + create_test_manager_and_chain_index(&ValidatorKind::Zebrad, None, true, false, true) + .await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index d73d960e5..063de2a14 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -21,7 +21,7 @@ async fn create_test_manager_and_fetch_service( chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - zaino_no_db: bool, + //zaino_no_db: bool, enable_clients: bool, ) -> (TestManager, FetchService, FetchServiceSubscriber) { let test_manager = TestManager::launch( @@ -33,7 +33,7 @@ async fn create_test_manager_and_fetch_service( false, false, zaino_no_sync, - zaino_no_db, + //zaino_no_db, enable_clients, ) .await @@ -59,7 +59,7 @@ async fn create_test_manager_and_fetch_service( ..Default::default() }, Network::Regtest(ActivationHeights::default()), - true, + // true, true, )) .await @@ -70,8 +70,7 @@ async fn create_test_manager_and_fetch_service( async fn launch_fetch_service(validator: &ValidatorKind, chain_cache: Option) { let (mut test_manager, _fetch_service, fetch_service_subscriber) = - create_test_manager_and_fetch_service(validator, chain_cache, false, true, true, false) - .await; + create_test_manager_and_fetch_service(validator, chain_cache, false, true, false).await; assert_eq!(fetch_service_subscriber.status(), StatusType::Ready); dbg!(fetch_service_subscriber.data.clone()); dbg!(fetch_service_subscriber.get_info().await.unwrap()); @@ -86,7 +85,7 @@ async fn launch_fetch_service(validator: &ValidatorKind, chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - zaino_no_db: bool, + // TODO removed no_db here - what matters? enable_clients: bool, ) -> ( TestManager, @@ -32,7 +32,6 @@ async fn create_test_manager_and_block_cache( false, false, zaino_no_sync, - zaino_no_db, enable_clients, ) .await @@ -85,7 +84,6 @@ async fn create_test_manager_and_block_cache( db_version: 1, network: network.into(), no_sync: zaino_no_sync, - no_db: zaino_no_db, }; let block_cache = BlockCache::spawn(&json_service, None, block_cache_config) @@ -102,9 +100,9 @@ async fn create_test_manager_and_block_cache( ) } -async fn launch_local_cache(validator: &ValidatorKind, no_db: bool) { +async fn launch_local_cache(validator: &ValidatorKind) { let (_test_manager, _json_service, _block_cache, block_cache_subscriber) = - create_test_manager_and_block_cache(validator, None, false, true, no_db, false).await; + create_test_manager_and_block_cache(validator, None, false, true, false).await; dbg!(block_cache_subscriber.status()); } @@ -112,7 +110,7 @@ async fn launch_local_cache(validator: &ValidatorKind, no_db: bool) { /// Launches a testmanager and block cache and generates `n*100` blocks, checking blocks are stored and fetched correctly. async fn launch_local_cache_process_n_block_batches(validator: &ValidatorKind, batches: u32) { let (test_manager, json_service, mut block_cache, mut block_cache_subscriber) = - create_test_manager_and_block_cache(validator, None, false, true, false, false).await; + create_test_manager_and_block_cache(validator, None, false, true, false).await; let finalised_state = block_cache.finalised_state.take().unwrap(); let finalised_state_subscriber = block_cache_subscriber.finalised_state.take().unwrap(); @@ -178,12 +176,14 @@ mod zcashd { #[tokio::test] async fn launch_no_db() { - launch_local_cache(&ValidatorKind::Zcashd, true).await; + // TODO here explicitly launching with no_db true + launch_local_cache(&ValidatorKind::Zcashd).await; } #[tokio::test] async fn launch_with_db() { - launch_local_cache(&ValidatorKind::Zcashd, false).await; + // TODO here explicitly launching with no_db false + launch_local_cache(&ValidatorKind::Zcashd).await; } #[tokio::test] @@ -204,12 +204,14 @@ mod zebrad { #[tokio::test] async fn launch_no_db() { - launch_local_cache(&ValidatorKind::Zebrad, true).await; + // TODO here explicitly launching with no_db true + launch_local_cache(&ValidatorKind::Zebrad).await; } #[tokio::test] async fn launch_with_db() { - launch_local_cache(&ValidatorKind::Zebrad, false).await; + // TODO here explicitly launching with no_db false + launch_local_cache(&ValidatorKind::Zebrad).await; } #[tokio::test] diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index fe2e6a64c..2cff57678 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -34,7 +34,6 @@ async fn create_test_manager_and_services( false, false, true, - true, enable_clients, ) .await @@ -80,7 +79,6 @@ async fn create_test_manager_and_services( }, network_type, zaino_sync_bool, - true, )) .await .unwrap(); @@ -121,7 +119,6 @@ async fn create_test_manager_and_services( }, network_type, true, - true, )) .await .unwrap(); diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index d17839955..0f4e6ae34 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -63,7 +63,6 @@ async fn create_test_manager_and_services( false, false, true, - true, enable_clients, ) .await @@ -122,7 +121,6 @@ async fn create_test_manager_and_services( }, network_type, zaino_sync_bool, - true, )) .await .unwrap(); diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index d49035e56..64eb4f752 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -10,7 +10,7 @@ use zaino_testutils::ValidatorKind; async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -27,7 +27,7 @@ async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backe async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -68,7 +68,7 @@ async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -109,7 +109,7 @@ async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -211,7 +211,7 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -296,7 +296,7 @@ async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { async fn shield_for_validator(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -364,7 +364,7 @@ async fn monitor_unverified_mempool_for_validator( backend: &BackendType, ) { let mut test_manager = TestManager::launch( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); diff --git a/zaino-state/src/chain_index/tests.rs b/zaino-state/src/chain_index/tests.rs index 836c09561..a2079ee57 100644 --- a/zaino-state/src/chain_index/tests.rs +++ b/zaino-state/src/chain_index/tests.rs @@ -84,7 +84,6 @@ mod mockchain_tests { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let indexer = NodeBackedChainIndex::new(source.clone(), config) diff --git a/zaino-state/src/chain_index/tests/finalised_state/migrations.rs b/zaino-state/src/chain_index/tests/finalised_state/migrations.rs index c2a60ffba..a8d7d7266 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/migrations.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/migrations.rs @@ -33,7 +33,6 @@ async fn v0_to_v1_full() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -47,7 +46,6 @@ async fn v0_to_v1_full() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let source = build_mockchain_source(blocks.clone()); @@ -113,7 +111,6 @@ async fn v0_to_v1_interrupted() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -127,7 +124,6 @@ async fn v0_to_v1_interrupted() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let source = build_mockchain_source(blocks.clone()); @@ -240,7 +236,6 @@ async fn v0_to_v1_partial() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -254,7 +249,6 @@ async fn v0_to_v1_partial() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let source = build_mockchain_source(blocks.clone()); diff --git a/zaino-state/src/chain_index/tests/finalised_state/v0.rs b/zaino-state/src/chain_index/tests/finalised_state/v0.rs index e0bec1a00..9cf95aa2a 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/v0.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/v0.rs @@ -33,7 +33,6 @@ pub(crate) async fn spawn_v0_zaino_db( network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let zaino_db = ZainoDB::spawn(config, source).await.unwrap(); @@ -210,7 +209,6 @@ async fn save_db_to_file_and_reload() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let source = build_mockchain_source(blocks.clone()); diff --git a/zaino-state/src/chain_index/tests/finalised_state/v1.rs b/zaino-state/src/chain_index/tests/finalised_state/v1.rs index 5f0c91740..ca0e19153 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/v1.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/v1.rs @@ -36,7 +36,6 @@ pub(crate) async fn spawn_v1_zaino_db( network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let zaino_db = ZainoDB::spawn(config, source).await.unwrap(); @@ -215,7 +214,6 @@ async fn save_db_to_file_and_reload() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let source = build_mockchain_source(blocks.clone()); @@ -326,7 +324,6 @@ async fn load_db_backend_from_file() { network: Network::Regtest(ActivationHeights::default()), no_sync: false, - no_db: false, }; let finalized_state_backend = DbBackend::spawn_v1(&config).await.unwrap(); diff --git a/zaino-state/src/local_cache.rs b/zaino-state/src/local_cache.rs index e24a68b7e..0f0f801c5 100644 --- a/zaino-state/src/local_cache.rs +++ b/zaino-state/src/local_cache.rs @@ -196,7 +196,6 @@ impl BlockCacheSubscriber { /// Returns the status of the [`BlockCache`].. pub fn status(&self) -> StatusType { let non_finalised_state_status = self.non_finalised_state.status(); - // mathcing on no_db = 0 let finalised_state_status = match self.config.storage.database.size { zaino_common::DatabaseSize::Gb(0) => StatusType::Ready, zaino_common::DatabaseSize::Gb(_) => match &self.finalised_state { diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index f402124e7..941373249 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -747,7 +747,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -770,7 +769,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -799,7 +797,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -822,7 +819,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -856,7 +852,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -884,7 +879,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -927,7 +921,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -950,7 +943,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -979,7 +971,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -1002,7 +993,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -1036,7 +1026,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1064,7 +1053,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1103,7 +1091,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1187,7 +1174,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1216,7 +1202,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -1239,7 +1224,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -1268,7 +1252,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -1291,7 +1274,6 @@ mod launch_testmanager { false, false, true, - true, false, ) .await @@ -1325,7 +1307,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1354,7 +1335,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1395,7 +1375,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); @@ -1477,7 +1456,6 @@ mod launch_testmanager { false, true, true, - true, ) .await .unwrap(); From 99759f7124660d032562f8cf53b2f26ed09d7111 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 04:32:37 -0400 Subject: [PATCH 035/162] rm comments from storage.rs --- zaino-common/src/storage.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zaino-common/src/storage.rs b/zaino-common/src/storage.rs index d26ef2a21..ccfde0aa3 100644 --- a/zaino-common/src/storage.rs +++ b/zaino-common/src/storage.rs @@ -37,7 +37,6 @@ impl Default for CacheConfig { /// This enum provides a clean TOML interface and easy extensibility for different units. #[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "lowercase")] -// and here pub enum DatabaseSize { /// Limited to a specific size in GB Gb(usize), @@ -70,7 +69,6 @@ impl DatabaseSize { /// Configures the file path and size limits for persistent storage /// used by Zaino services. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] -// and here pub struct DatabaseConfig { /// Database file path. pub path: PathBuf, @@ -92,7 +90,6 @@ impl Default for DatabaseConfig { /// /// This is used by services that need both in-memory caching and persistent storage. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize, Default)] -// via here pub struct StorageConfig { /// Cache configuration. Uses defaults if not specified in TOML. #[serde(default)] From a9d46b952697083e8cd3918a24aa59f121b07103 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 04:38:12 -0400 Subject: [PATCH 036/162] remove comments from tests/chain_cache --- integration-tests/tests/chain_cache.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index 13cd0c8e2..27687080b 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -7,7 +7,6 @@ async fn create_test_manager_and_connector( chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - // zaino_no_db: bool, enable_clients: bool, ) -> (TestManager, JsonRpSeeConnector) { let test_manager = TestManager::launch( @@ -71,7 +70,6 @@ mod chain_query_interface { chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - // zaino_no_db: bool, enable_clients: bool, ) -> ( TestManager, @@ -158,7 +156,6 @@ mod chain_query_interface { db_version: 1, network: zaino_common::Network::Regtest(ActivationHeights::default()), no_sync: false, - // no_db: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::State(chain_index::source::State { @@ -179,15 +176,8 @@ mod chain_query_interface { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_block_range() { let (test_manager, _json_service, _chain_index, indexer) = - create_test_manager_and_chain_index( - &ValidatorKind::Zebrad, - None, - true, - false, - // no_db = false, - true, - ) - .await; + create_test_manager_and_chain_index(&ValidatorKind::Zebrad, None, true, false, true) + .await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; From 6d3d94541b036da773cabf3329987954e915ddde Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 18:00:50 -0400 Subject: [PATCH 037/162] remove commented no_db code --- zaino-state/src/config.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index afb478380..edd31f3d1 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -47,9 +47,6 @@ pub struct StateServiceConfig { /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - // /// Disables FinalisedState. - // /// Used for testing. - // pub no_db: bool, } impl StateServiceConfig { @@ -68,7 +65,6 @@ impl StateServiceConfig { storage: StorageConfig, network: Network, no_sync: bool, - // no_db: bool, ) -> Self { StateServiceConfig { validator_config, @@ -82,7 +78,6 @@ impl StateServiceConfig { storage, network, no_sync, - // no_db, } } } @@ -109,9 +104,6 @@ pub struct FetchServiceConfig { /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - // /// Disables FinalisedState. - // /// Used for testing. - // pub no_db: bool, } impl FetchServiceConfig { @@ -128,7 +120,6 @@ impl FetchServiceConfig { storage: StorageConfig, network: Network, no_sync: bool, - // no_db: bool, ) -> Self { FetchServiceConfig { validator_rpc_address, @@ -140,7 +131,6 @@ impl FetchServiceConfig { storage, network, no_sync, - // no_db, } } } From 975141b5d1dee8758d761b2ffb9cb205ca597d2d Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 18:10:56 -0400 Subject: [PATCH 038/162] trim local_cache integration tests --- integration-tests/tests/local_cache.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index 9ca4efa66..6e43d7bb6 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -15,7 +15,6 @@ async fn create_test_manager_and_block_cache( chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - // TODO removed no_db here - what matters? enable_clients: bool, ) -> ( TestManager, @@ -175,17 +174,11 @@ mod zcashd { use crate::{launch_local_cache, launch_local_cache_process_n_block_batches}; #[tokio::test] - async fn launch_no_db() { + async fn launch_local_cache_zcashd() { // TODO here explicitly launching with no_db true launch_local_cache(&ValidatorKind::Zcashd).await; } - #[tokio::test] - async fn launch_with_db() { - // TODO here explicitly launching with no_db false - launch_local_cache(&ValidatorKind::Zcashd).await; - } - #[tokio::test] async fn process_100_blocks() { launch_local_cache_process_n_block_batches(&ValidatorKind::Zcashd, 1).await; @@ -203,14 +196,7 @@ mod zebrad { use crate::{launch_local_cache, launch_local_cache_process_n_block_batches}; #[tokio::test] - async fn launch_no_db() { - // TODO here explicitly launching with no_db true - launch_local_cache(&ValidatorKind::Zebrad).await; - } - - #[tokio::test] - async fn launch_with_db() { - // TODO here explicitly launching with no_db false + async fn launch_local_cache_zebrad() { launch_local_cache(&ValidatorKind::Zebrad).await; } From df3105b943a63ec1f506e85ddfaf4eafbdce6741 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 18:19:38 -0400 Subject: [PATCH 039/162] remove commented code from state config --- zaino-state/src/config.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index edd31f3d1..af258a82c 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -148,27 +148,17 @@ pub struct BlockCacheConfig { /// Stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - // /// Disables FinalisedState. - // /// Used for testing. - // pub no_db: bool, } impl BlockCacheConfig { /// Returns a new instance of [`BlockCacheConfig`]. #[allow(dead_code)] - pub fn new( - storage: StorageConfig, - db_version: u32, - network: Network, - no_sync: bool, - // no_db: bool, - ) -> Self { + pub fn new(storage: StorageConfig, db_version: u32, network: Network, no_sync: bool) -> Self { BlockCacheConfig { storage, db_version, network, no_sync, - // no_db, } } } @@ -181,7 +171,6 @@ impl From for BlockCacheConfig { db_version: 1, network: value.network, no_sync: value.no_sync, - // no_db: value.no_db, } } } @@ -194,7 +183,6 @@ impl From for BlockCacheConfig { db_version: 1, network: value.network, no_sync: value.no_sync, - // no_db: value.no_db, } } } From e94e250e2d280dbc6e1c4a94508f22f7eafe15ae Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 18:41:57 -0400 Subject: [PATCH 040/162] cleanup local_cache tests module --- integration-tests/tests/local_cache.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index 6e43d7bb6..97997f6dd 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -62,7 +62,6 @@ async fn create_test_manager_and_block_cache( canopy: Some(1), nu5: Some(1), nu6: Some(1), - // TODO: What is network upgrade 6.1? What does a minor version NU mean? nu6_1: None, nu7: None, }, @@ -102,8 +101,6 @@ async fn create_test_manager_and_block_cache( async fn launch_local_cache(validator: &ValidatorKind) { let (_test_manager, _json_service, _block_cache, block_cache_subscriber) = create_test_manager_and_block_cache(validator, None, false, true, false).await; - - dbg!(block_cache_subscriber.status()); } /// Launches a testmanager and block cache and generates `n*100` blocks, checking blocks are stored and fetched correctly. @@ -175,7 +172,6 @@ mod zcashd { #[tokio::test] async fn launch_local_cache_zcashd() { - // TODO here explicitly launching with no_db true launch_local_cache(&ValidatorKind::Zcashd).await; } From f7542e75f1bb7e6dbe079b140cff6403f484ccf9 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 19:01:01 -0400 Subject: [PATCH 041/162] cleanup cache integration tests --- integration-tests/tests/local_cache.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index 97997f6dd..4d5d922b3 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -99,8 +99,7 @@ async fn create_test_manager_and_block_cache( } async fn launch_local_cache(validator: &ValidatorKind) { - let (_test_manager, _json_service, _block_cache, block_cache_subscriber) = - create_test_manager_and_block_cache(validator, None, false, true, false).await; + create_test_manager_and_block_cache(validator, None, false, true, false).await; } /// Launches a testmanager and block cache and generates `n*100` blocks, checking blocks are stored and fetched correctly. From 7497511ec32e2026d885969b71c25d501eb0dc81 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 21:25:09 -0400 Subject: [PATCH 042/162] removed commented code from zainod config --- zainod/src/config.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index a125c720b..92e46ffdc 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -102,9 +102,6 @@ pub struct IndexerConfig { /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. pub no_sync: bool, - // /// db size 0 = (no_db) - Disables FinalisedState. - // /// Used for testing. - // pub no_db: bool, } impl IndexerConfig { From 7a5e4843cdaa9ab73a2b221ecdfa5d07c45d2e02 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 5 Oct 2025 21:27:30 -0400 Subject: [PATCH 043/162] cleanup zainod config --- zainod/src/config.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 92e46ffdc..7aafe1161 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -91,7 +91,6 @@ pub struct IndexerConfig { /// Service-level configuration (timeout, channel size). pub service: ServiceConfig, /// Storage configuration (cache and database). - // this is it, in here pub storage: StorageConfig, /// Block Cache database file path. /// @@ -186,7 +185,7 @@ impl IndexerConfig { )); } } - // TODO insure this is activated or removed + #[cfg(feature = "no_tls_use_unencrypted_traffic")] { warn!( @@ -252,7 +251,6 @@ impl Default for IndexerConfig { zebra_db_path: default_zebra_db_path().unwrap(), network: Network::Testnet, no_sync: false, - // no_db: false, } } } @@ -386,7 +384,6 @@ impl TryFrom for BackendConfig { storage: cfg.storage, network: cfg.network, no_sync: cfg.no_sync, - // no_db: cfg.no_db, })), zaino_state::BackendType::Fetch => Ok(BackendConfig::Fetch(FetchServiceConfig { @@ -401,7 +398,6 @@ impl TryFrom for BackendConfig { storage: cfg.storage, network: cfg.network, no_sync: cfg.no_sync, - // no_db: cfg.no_db, })), } } From e5a702d46ab9296ac210725930bbb5e7e586e0cd Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 6 Oct 2025 01:29:18 -0400 Subject: [PATCH 044/162] begin refactoring json server settings for IndexerConfig --- zaino-serve/src/server/config.rs | 3 +++ zainod/src/config.rs | 42 ++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 518d9afbe..e76d85091 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -66,8 +66,11 @@ impl GrpcConfig { } /// Configuration data for Zaino's gRPC server. +// #[derive(Debug, Clone)] +#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcConfig { /// Server bind addr. + // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, /// Enable cookie-based authentication. diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 7aafe1161..28295c5ec 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -21,7 +21,7 @@ use tracing::{error, info}; use zaino_common::{ CacheConfig, DatabaseConfig, DatabaseSize, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::config::GrpcConfig; +use zaino_serve::server::config::{GrpcConfig, JsonRpcConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; use crate::error::IndexerError; @@ -63,15 +63,20 @@ pub struct IndexerConfig { #[serde(deserialize_with = "deserialize_backendtype_from_string")] #[serde(serialize_with = "serialize_backendtype_to_string")] pub backend: zaino_state::BackendType, + // TODO create a nested type, like ... the others /// Enable JsonRPC server. - pub enable_json_server: bool, - /// Server bind addr. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub json_rpc_listen_address: SocketAddr, - /// Enable cookie-based authentication. - pub enable_cookie_auth: bool, - /// Directory to store authentication cookie file. - pub cookie_dir: Option, + pub json_server_settings: Option, + // Some is true + // pub enable_json_server: bool, + // /// Server bind addr. + // TODO commenting out : for rpc listen #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + // pub json_rpc_listen_address: SocketAddr, + // /// Enable cookie-based authentication. + // pub enable_cookie_auth: bool, + // /// Directory to store authentication cookie file. + // pub cookie_dir: Option, + // TODO end here, I believe + // /// gRPC server settings including listen addr, tls status, key and cert. pub grpc_settings: GrpcConfig, /// Full node / validator listen port. @@ -107,7 +112,6 @@ impl IndexerConfig { /// Performs checks on config data. pub(crate) fn check_config(&self) -> Result<(), IndexerError> { // Network type is validated at the type level via Network enum. - // Check TLS settings. if self.grpc_settings.tls.is_some() { // then check if cert path exists or return error @@ -194,7 +198,14 @@ impl IndexerConfig { } // Check gRPC and JsonRPC server are not listening on the same address. - if self.json_rpc_listen_address == self.grpc_settings.listen_address { + if self.json_server_settings.is_some() + && self + .json_server_settings + .as_ref() + .expect("json_server_settings to be Some") + .json_rpc_listen_address + == self.grpc_settings.listen_address + { return Err(IndexerError::ConfigError( "gRPC server and JsonRPC server must listen on different addresses.".to_string(), )); @@ -226,10 +237,11 @@ impl Default for IndexerConfig { fn default() -> Self { Self { backend: zaino_state::BackendType::Fetch, - enable_json_server: false, - json_rpc_listen_address: "127.0.0.1:8237".parse().unwrap(), - enable_cookie_auth: false, - cookie_dir: None, + json_server_settings: None, + // enable_json_server: false, + // json_rpc_listen_address: "127.0.0.1:8237".parse().unwrap(), + // enable_cookie_auth: false, + // cookie_dir: None, grpc_settings: GrpcConfig { listen_address: "127.0.0.1:8137".parse().unwrap(), tls: None, From 597b612e10ee5bd911b5c107b702052cb2953692 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 6 Oct 2025 18:24:22 -0400 Subject: [PATCH 045/162] WIP json_server config --- zaino-serve/src/server/config.rs | 5 +++- zainod/src/config.rs | 47 +++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index e76d85091..68ae0ca72 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -65,14 +65,17 @@ impl GrpcConfig { } } +// TODO comment! :P /// Configuration data for Zaino's gRPC server. -// #[derive(Debug, Clone)] +// using this at all is an option. if it's on, we have a SocketAddr. +// If it's got a cookie dir... cookies are always on? #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcConfig { /// Server bind addr. // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, + // TODO : eliminate this - if we have a cookie dir, we're using cookies. /// Enable cookie-based authentication. pub enable_cookie_auth: bool, diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 28295c5ec..482cab8ad 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -219,8 +219,13 @@ impl IndexerConfig { Ok(self.network.to_zebra_network()) } - /// Finalizes the configuration after initial parsing, applying conditional defaults. + // /// Finalizes the configuration after initial parsing, applying conditional defaults. + /* fn finalize_config_logic(mut self) -> Self { + // ONLY used in one place, no need for helper fn + // just set default of cookie dir if cookie auth is true + // and make sure cookie dir is none if there is no cookie auth + if self.enable_cookie_auth { if self.cookie_dir.is_none() { self.cookie_dir = Some(default_ephemeral_cookie_path()); @@ -229,8 +234,10 @@ impl IndexerConfig { // If auth is not enabled, cookie_dir should be None, regardless of what was in the config. self.cookie_dir = None; } + self } + */ } impl Default for IndexerConfig { @@ -353,7 +360,45 @@ pub fn load_config(file_path: &PathBuf) -> Result { match figment.extract::() { Ok(parsed_config) => { + if parsed_config.json_server_settings.is_some() { + // if cookie auth is true + if parsed_config + .json_server_settings + .as_ref() + .expect("json_server_settings to be Some") + .enable_cookie_auth + && parsed_config + .json_server_settings + .as_ref() + .expect("json_server_settings to be Some") + .cookie_dir + .is_none() + { + + // apply default cookie dir default + + // parsed_config.json_server_settings.cookie_dir = Some(default_ephemeral_cookie_path()); + } + } + + // old way let finalized_config = parsed_config.finalize_config_logic(); + // only place for finalize_config_logic + // + // just set default of cookie dir if cookie auth is true + // and make sure cookie dir is none if there is no cookie auth + /* + if self.enable_cookie_auth { + if self.cookie_dir.is_none() { + self.cookie_dir = Some(default_ephemeral_cookie_path()); + } + } else { + // If auth is not enabled, cookie_dir should be None, regardless of what was in the config. + self.cookie_dir = None; + } + + self + */ finalized_config.check_config()?; info!( "Successfully loaded and validated config. Base TOML file checked: '{}'", From a76f7d954bd698cf912d47a570a014bd0645f270 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 7 Oct 2025 01:31:36 -0400 Subject: [PATCH 046/162] add and correct comments --- zaino-serve/src/server/config.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 68ae0ca72..906e2a339 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -65,20 +65,15 @@ impl GrpcConfig { } } -// TODO comment! :P -/// Configuration data for Zaino's gRPC server. -// using this at all is an option. if it's on, we have a SocketAddr. -// If it's got a cookie dir... cookies are always on? +/// Configuration data for Zaino's JSON RPC server. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcConfig { /// Server bind addr. // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, - // TODO : eliminate this - if we have a cookie dir, we're using cookies. - /// Enable cookie-based authentication. - pub enable_cookie_auth: bool, - + // If cookie_dir is Some, cookie auth is on. + // An empty PathBuf will have an emphemeral path assigned to it when zaino loads the config. /// Directory to store authentication cookie file. pub cookie_dir: Option, } From dfed34f265e6e03a0b25342cf75fa2a652e0a083 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 7 Oct 2025 01:35:19 -0400 Subject: [PATCH 047/162] refactor parsed_config, remove finalised_config helper fn --- zainod/src/config.rs | 82 ++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 61 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 482cab8ad..dd3950871 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -63,7 +63,7 @@ pub struct IndexerConfig { #[serde(deserialize_with = "deserialize_backendtype_from_string")] #[serde(serialize_with = "serialize_backendtype_to_string")] pub backend: zaino_state::BackendType, - // TODO create a nested type, like ... the others + // TODO later, create what were called "sections" /// Enable JsonRPC server. pub json_server_settings: Option, // Some is true @@ -218,26 +218,6 @@ impl IndexerConfig { pub fn get_network(&self) -> Result { Ok(self.network.to_zebra_network()) } - - // /// Finalizes the configuration after initial parsing, applying conditional defaults. - /* - fn finalize_config_logic(mut self) -> Self { - // ONLY used in one place, no need for helper fn - // just set default of cookie dir if cookie auth is true - // and make sure cookie dir is none if there is no cookie auth - - if self.enable_cookie_auth { - if self.cookie_dir.is_none() { - self.cookie_dir = Some(default_ephemeral_cookie_path()); - } - } else { - // If auth is not enabled, cookie_dir should be None, regardless of what was in the config. - self.cookie_dir = None; - } - - self - } - */ } impl Default for IndexerConfig { @@ -359,52 +339,32 @@ pub fn load_config(file_path: &PathBuf) -> Result { .merge(figment::providers::Env::prefixed("ZAINO_")); match figment.extract::() { - Ok(parsed_config) => { - if parsed_config.json_server_settings.is_some() { - // if cookie auth is true - if parsed_config - .json_server_settings - .as_ref() - .expect("json_server_settings to be Some") - .enable_cookie_auth - && parsed_config - .json_server_settings - .as_ref() - .expect("json_server_settings to be Some") - .cookie_dir - .is_none() - { - - // apply default cookie dir default - - // parsed_config.json_server_settings.cookie_dir = Some(default_ephemeral_cookie_path()); - } - } - - // old way - let finalized_config = parsed_config.finalize_config_logic(); - // only place for finalize_config_logic - // - // just set default of cookie dir if cookie auth is true - // and make sure cookie dir is none if there is no cookie auth - /* - if self.enable_cookie_auth { - if self.cookie_dir.is_none() { - self.cookie_dir = Some(default_ephemeral_cookie_path()); + Ok(mut parsed_config) => { + // Finalizes the configuration after initial parsing, applying conditional default to json rpc cookie dir, + // if the assigned pathbuf is empty (cookies enabled but no path defined). + if parsed_config + .json_server_settings + .clone() + .is_some_and(|json_settings| { + json_settings.cookie_dir.is_some() + && json_settings + .cookie_dir + .expect("cookie_dir to be Some") + .as_os_str() + .is_empty() + }) + { + if let Some(ref mut json_config) = parsed_config.json_server_settings { + json_config.cookie_dir = Some(default_ephemeral_cookie_path()); } - } else { - // If auth is not enabled, cookie_dir should be None, regardless of what was in the config. - self.cookie_dir = None; - } + }; - self - */ - finalized_config.check_config()?; + parsed_config.check_config()?; info!( "Successfully loaded and validated config. Base TOML file checked: '{}'", file_path.display() ); - Ok(finalized_config) + Ok(parsed_config) } Err(figment_error) => { error!("Failed to extract configuration: {}", figment_error); From 6536223c42e6f10c1b7d2de7b40e388473f58a9d Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 7 Oct 2025 01:36:21 -0400 Subject: [PATCH 048/162] update check for cookie auth in impl JsonRpcServer --- zaino-serve/src/server/jsonrpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-serve/src/server/jsonrpc.rs b/zaino-serve/src/server/jsonrpc.rs index 121e4b990..632659d24 100644 --- a/zaino-serve/src/server/jsonrpc.rs +++ b/zaino-serve/src/server/jsonrpc.rs @@ -45,7 +45,7 @@ impl JsonRpcServer { }; // Initialize Zebra-compatible cookie-based authentication if enabled. - let (cookie, cookie_dir) = if server_config.enable_cookie_auth { + let (cookie, cookie_dir) = if server_config.cookie_dir.is_some() { let cookie = Cookie::default(); if let Some(dir) = &server_config.cookie_dir { write_to_disk(&cookie, dir).map_err(|e| { From 1dd8545ebf99449d1f3b9bf6cd991d82e9b6da94 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 7 Oct 2025 01:38:12 -0400 Subject: [PATCH 049/162] adjust json rpc within impl Indexer launch_inner() --- zainod/src/indexer.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 142d5c3c5..b85c297b0 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -5,8 +5,10 @@ use tracing::info; use zaino_fetch::jsonrpsee::connector::test_node_and_return_url; use zaino_serve::server::{ - config::{GrpcConfig, JsonRpcConfig}, + // TODO see: config here + config::GrpcConfig, grpc::TonicServer, + // TODO vs Server here jsonrpc::JsonRpcServer, }; use zaino_state::{ @@ -79,21 +81,13 @@ where indexer_config: IndexerConfig, ) -> Result>, IndexerError> { let service = IndexerService::::spawn(service_config).await?; - - let json_server = match indexer_config.enable_json_server { - true => Some( - JsonRpcServer::spawn( - service.inner_ref().get_subscriber(), - JsonRpcConfig { - json_rpc_listen_address: indexer_config.json_rpc_listen_address, - enable_cookie_auth: indexer_config.enable_cookie_auth, - cookie_dir: indexer_config.cookie_dir, - }, - ) - .await - .unwrap(), + let json_server = match indexer_config.json_server_settings { + Some(json_server_config) => Some( + JsonRpcServer::spawn(service.inner_ref().get_subscriber(), json_server_config) + .await + .unwrap(), ), - false => None, + None => None, }; let grpc_server = TonicServer::spawn( From 2db0dad9a6b971bbe9f35a80c38662a2ca0d0664 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 8 Oct 2025 02:42:55 -0400 Subject: [PATCH 050/162] WIP heavy commenting --- zaino-serve/src/server/config.rs | 3 +++ zaino-serve/src/server/grpc.rs | 4 +++ zaino-testutils/src/lib.rs | 45 +++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 906e2a339..38b9321e6 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -70,8 +70,11 @@ impl GrpcConfig { pub struct JsonRpcConfig { /// Server bind addr. // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + // LISTENING address for incoming connections. Do we have a destination address, + // or is that simply a port for our full node? pub json_rpc_listen_address: SocketAddr, + // TODO this is the field that actually is the same in the server as the config. Should we these separate? // If cookie_dir is Some, cookie auth is on. // An empty PathBuf will have an emphemeral path assigned to it when zaino loads the config. /// Directory to store authentication cookie file. diff --git a/zaino-serve/src/server/grpc.rs b/zaino-serve/src/server/grpc.rs index 442ff64bf..3dfa55197 100644 --- a/zaino-serve/src/server/grpc.rs +++ b/zaino-serve/src/server/grpc.rs @@ -14,6 +14,9 @@ use crate::{ }; /// LightWallet server capable of servicing clients over TCP. +// TODO rename to gRPC server? +// also, why no listen address? +// below, it's taken straight from the config. pub struct TonicServer { /// Current status of the server. pub status: AtomicStatus, @@ -56,6 +59,7 @@ impl TonicServer { }; let server_future = server_builder .add_service(svc) + // here, it's taken straight from the config. .serve_with_shutdown(server_config.listen_address, shutdown_signal); let task_status = status.clone(); diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 941373249..c9ede1036 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -17,7 +17,7 @@ use tempfile::TempDir; use testvectors::{seeds, REG_O_ADDR_FROM_ABANDONART}; use tracing_subscriber::EnvFilter; use zaino_common::{CacheConfig, DatabaseConfig, ServiceConfig, StorageConfig}; -use zaino_serve::server::config::GrpcConfig; +use zaino_serve::server::{config::{GrpcConfig, JsonRpcConfig}, jsonrpc::JsonRpcServer}; use zaino_state::BackendType; use zainodlib::config::default_ephemeral_cookie_path; pub use zingo_infra_services as services; @@ -350,6 +350,7 @@ impl TestManager { network: Option, chain_cache: Option, enable_zaino: bool, + // TODO here enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, @@ -421,7 +422,13 @@ impl TestManager { // Launch Zaino: let ( zaino_grpc_listen_address, + + // TODO there is some mismatch between JsonRpcConfig/JsonRpcServer and GrpcConfig/GrpcServer + + // TODO this can be set to None [ an Option ]- which is different than our Config type representation + // ah! but we are _listening_ here, not serving I think. zaino_json_listen_address, + // Option - like our config. zaino_json_server_cookie_dir, zaino_handle, ) = if enable_zaino { @@ -429,18 +436,28 @@ impl TestManager { let zaino_grpc_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_grpc_listen_port); + // generating port on the spot let zaino_json_listen_port = portpicker::pick_unused_port().expect("No ports free"); + // set to localhost with the newly generated port let zaino_json_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_json_listen_port); + // this cookie dir is generated on the spot, whenever zaino is enabled let zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); + // then here we custom-set an entire, whole new config let indexer_config = zainodlib::config::IndexerConfig { // TODO: Make configurable. backend: *backend, - enable_json_server: enable_zaino_jsonrpc_server, + json_server_settings: Some(zaino_serve::server::config::JsonRpcConfig { + + // TODO + // this is the argument to launch, passed in: (meaning Some) +// enable_json_server: enable_zaino_jsonrpc_server, json_rpc_listen_address: zaino_json_listen_address, - enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, - cookie_dir: zaino_json_server_cookie_dir.clone(), + // this an the argument to launch, passed in: (meaning Some) +// enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, +// cookie_dir: zaino_json_server_cookie_dir.clone(), + }) grpc_settings: GrpcConfig { listen_address: zaino_grpc_listen_address, tls: None, @@ -463,21 +480,40 @@ impl TestManager { network: network.into(), no_sync: zaino_no_sync, }; + // TODO we create the handle here, with indexer_config. + // I think we could possibly ... spit out the indexer stuff if we need it later, piece by piece? + // ie, just return the handle and the config + // + // so... we need indexer_config to launch the handle. But maybe we should separate this out? + // step one, set config, step two spawn indexer let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await .unwrap(); // NOTE: This is required to give the server time to launch, this is not used in production code but could be rewritten to improve testing efficiency. + // TODO try decrementing to one? less? + // what about with the $(nproc) stuff? tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; ( Some(zaino_grpc_listen_address), + // this is also different than the conceived Some(zaino_json_listen_address), zaino_json_server_cookie_dir, Some(handle), ) } else { + // so we already have these types as None (None, None, None, None) }; + // TODO find out where the not-joinhandle config-stuff is needed. (two socketaddrs and an Option.. ) + // are all of these in the config? + + // TODO by here we've already generated a JoinHandle. + // pub zaino_handle: Option>>, + // along with two listen addresses and a cookie_dir. + // these should be separated out, I'm almost sure. + // + // Launch Zingolib Lightclients: let clients = if enable_clients { @@ -614,6 +650,7 @@ impl TestManager { SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_json_listen_port); let zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); + // TODO set this up for refurbish let indexer_config = zainodlib::config::IndexerConfig { // TODO: Make configurable. backend: *backend, From 63705614e8690faa72494d12fed7996657969cb1 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 02:15:52 -0400 Subject: [PATCH 051/162] post dev merge adjustments --- zaino-testutils/src/lib.rs | 51 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index f977463dc..b30e2fa7c 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -18,7 +18,10 @@ use tracing_subscriber::EnvFilter; use zaino_common::{ network::ActivationHeights, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::{config::{GrpcConfig, JsonRpcConfig}, jsonrpc::JsonRpcServer}; +use zaino_serve::server::{ + config::{GrpcConfig, JsonRpcConfig}, + jsonrpc::JsonRpcServer, +}; use zaino_state::BackendType; use zainodlib::config::default_ephemeral_cookie_path; pub use zcash_local_net as services; @@ -460,9 +463,8 @@ impl TestManager { // Launch Zaino: let ( zaino_grpc_listen_address, - // TODO there is some mismatch between JsonRpcConfig/JsonRpcServer and GrpcConfig/GrpcServer - + // TODO this can be set to None [ an Option ]- which is different than our Config type representation // ah! but we are _listening_ here, not serving I think. zaino_json_listen_address, @@ -487,15 +489,14 @@ impl TestManager { // TODO: Make configurable. backend: *backend, json_server_settings: Some(zaino_serve::server::config::JsonRpcConfig { - // TODO // this is the argument to launch, passed in: (meaning Some) -// enable_json_server: enable_zaino_jsonrpc_server, - json_rpc_listen_address: zaino_json_listen_address, + // enable_json_server: enable_zaino_jsonrpc_server, + json_rpc_listen_address: zaino_json_listen_address, // this an the argument to launch, passed in: (meaning Some) -// enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, -// cookie_dir: zaino_json_server_cookie_dir.clone(), - }) + // enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, + // cookie_dir: zaino_json_server_cookie_dir.clone(), + }), grpc_settings: GrpcConfig { listen_address: zaino_grpc_listen_address, tls: None, @@ -518,12 +519,12 @@ impl TestManager { network: zaino_network_kind, no_sync: zaino_no_sync, }; - // TODO we create the handle here, with indexer_config. - // I think we could possibly ... spit out the indexer stuff if we need it later, piece by piece? - // ie, just return the handle and the config - // - // so... we need indexer_config to launch the handle. But maybe we should separate this out? - // step one, set config, step two spawn indexer + // TODO we create the handle here, with indexer_config. + // I think we could possibly ... spit out the indexer stuff if we need it later, piece by piece? + // ie, just return the handle and the config + // + // so... we need indexer_config to launch the handle. But maybe we should separate this out? + // step one, set config, step two spawn indexer let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await .unwrap(); @@ -534,24 +535,23 @@ impl TestManager { tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; ( Some(zaino_grpc_listen_address), - // this is also different than the conceived + // this is also different than the conceived Some(zaino_json_listen_address), zaino_json_server_cookie_dir, Some(handle), ) } else { - // so we already have these types as None + // so we already have these types as None (None, None, None, None) }; - // TODO find out where the not-joinhandle config-stuff is needed. (two socketaddrs and an Option.. ) - // are all of these in the config? - - // TODO by here we've already generated a JoinHandle. - // pub zaino_handle: Option>>, - // along with two listen addresses and a cookie_dir. - // these should be separated out, I'm almost sure. - // + // TODO find out where the not-joinhandle config-stuff is needed. (two socketaddrs and an Option.. ) + // are all of these in the config? + // TODO by here we've already generated a JoinHandle. + // pub zaino_handle: Option>>, + // along with two listen addresses and a cookie_dir. + // these should be separated out, I'm almost sure. + // // Launch Zingolib Lightclients: let clients = if enable_clients { @@ -630,7 +630,6 @@ impl TestManager { enable_zaino_jsonrpc_server, enable_zaino_jsonrpc_server_cookie_auth, zaino_no_sync, - zaino_no_db, enable_clients, ) .await From 5f8bb1d89c4efbd56dea46f115ab85e94121e28e Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 02:33:28 -0400 Subject: [PATCH 052/162] add cookie_dir field --- zaino-testutils/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index b30e2fa7c..bbfaaf73e 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -493,6 +493,7 @@ impl TestManager { // this is the argument to launch, passed in: (meaning Some) // enable_json_server: enable_zaino_jsonrpc_server, json_rpc_listen_address: zaino_json_listen_address, + cookie_dir: zaino_json_server_cookie_dir.clone(), // this an the argument to launch, passed in: (meaning Some) // enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, // cookie_dir: zaino_json_server_cookie_dir.clone(), From df4fd2a7a05aad75300e830fcffe969aacdb9b0d Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 02:34:10 -0400 Subject: [PATCH 053/162] remove comments --- zaino-testutils/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index bbfaaf73e..e83ced3bc 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -489,14 +489,8 @@ impl TestManager { // TODO: Make configurable. backend: *backend, json_server_settings: Some(zaino_serve::server::config::JsonRpcConfig { - // TODO - // this is the argument to launch, passed in: (meaning Some) - // enable_json_server: enable_zaino_jsonrpc_server, json_rpc_listen_address: zaino_json_listen_address, cookie_dir: zaino_json_server_cookie_dir.clone(), - // this an the argument to launch, passed in: (meaning Some) - // enable_cookie_auth: enable_zaino_jsonrpc_server_cookie_auth, - // cookie_dir: zaino_json_server_cookie_dir.clone(), }), grpc_settings: GrpcConfig { listen_address: zaino_grpc_listen_address, From 4520739fd4475113ca08804a07cd6122d7b1724d Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 02:39:51 -0400 Subject: [PATCH 054/162] set cookie_dir without Some, remove comments --- zaino-testutils/src/lib.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index e83ced3bc..61676c7d3 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -482,7 +482,7 @@ impl TestManager { let zaino_json_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_json_listen_port); // this cookie dir is generated on the spot, whenever zaino is enabled - let zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); + let zaino_json_server_cookie_dir = default_ephemeral_cookie_path(); // then here we custom-set an entire, whole new config let indexer_config = zainodlib::config::IndexerConfig { @@ -490,7 +490,7 @@ impl TestManager { backend: *backend, json_server_settings: Some(zaino_serve::server::config::JsonRpcConfig { json_rpc_listen_address: zaino_json_listen_address, - cookie_dir: zaino_json_server_cookie_dir.clone(), + cookie_dir: Some(zaino_json_server_cookie_dir.clone()), }), grpc_settings: GrpcConfig { listen_address: zaino_grpc_listen_address, @@ -525,18 +525,14 @@ impl TestManager { .unwrap(); // NOTE: This is required to give the server time to launch, this is not used in production code but could be rewritten to improve testing efficiency. - // TODO try decrementing to one? less? - // what about with the $(nproc) stuff? tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; ( Some(zaino_grpc_listen_address), - // this is also different than the conceived Some(zaino_json_listen_address), - zaino_json_server_cookie_dir, + Some(zaino_json_server_cookie_dir), Some(handle), ) } else { - // so we already have these types as None (None, None, None, None) }; // TODO find out where the not-joinhandle config-stuff is needed. (two socketaddrs and an Option.. ) From 42458641c9b08f1408fb4e7cea710451cb87336d Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 02:56:36 -0400 Subject: [PATCH 055/162] update use, cleanup impl TestManager launch w/o jsonrpc args --- integration-tests/tests/local_cache.rs | 2 -- zaino-testutils/src/lib.rs | 11 ++--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index 5e66248af..bd806d537 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -33,8 +33,6 @@ async fn create_test_manager_and_block_cache( Some(activation_heights), chain_cache, enable_zaino, - false, - false, zaino_no_sync, enable_clients, ) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 61676c7d3..f842e81f7 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -18,10 +18,7 @@ use tracing_subscriber::EnvFilter; use zaino_common::{ network::ActivationHeights, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::{ - config::{GrpcConfig, JsonRpcConfig}, - jsonrpc::JsonRpcServer, -}; +use zaino_serve::server::config::{GrpcConfig, JsonRpcConfig}; use zaino_state::BackendType; use zainodlib::config::default_ephemeral_cookie_path; pub use zcash_local_net as services; @@ -396,8 +393,6 @@ impl TestManager { chain_cache: Option, enable_zaino: bool, // TODO here - enable_zaino_jsonrpc_server: bool, - enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, enable_clients: bool, ) -> Result { @@ -488,7 +483,7 @@ impl TestManager { let indexer_config = zainodlib::config::IndexerConfig { // TODO: Make configurable. backend: *backend, - json_server_settings: Some(zaino_serve::server::config::JsonRpcConfig { + json_server_settings: Some(JsonRpcConfig { json_rpc_listen_address: zaino_json_listen_address, cookie_dir: Some(zaino_json_server_cookie_dir.clone()), }), @@ -618,8 +613,6 @@ impl TestManager { Some(activation_heights), chain_cache, enable_zaino, - enable_zaino_jsonrpc_server, - enable_zaino_jsonrpc_server_cookie_auth, zaino_no_sync, enable_clients, ) From a0288a9ce31a85c2ab7b37630aa23342164794c5 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 03:19:04 -0400 Subject: [PATCH 056/162] underscore args for launch_w_activation_heights, update chain_cache test --- integration-tests/tests/chain_cache.rs | 2 -- zaino-testutils/src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index 663c92420..3f4befce8 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -18,8 +18,6 @@ async fn create_test_manager_and_connector( activation_heights, chain_cache, enable_zaino, - false, - false, zaino_no_sync, enable_clients, ) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index f842e81f7..b5f8b041b 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -596,8 +596,8 @@ impl TestManager { network: Option, chain_cache: Option, enable_zaino: bool, - enable_zaino_jsonrpc_server: bool, - enable_zaino_jsonrpc_server_cookie_auth: bool, + _enable_zaino_jsonrpc_server: bool, + _enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, enable_clients: bool, ) -> Result { From c33db6be8edb274f07c374d6513803f5434a5f37 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 03:45:26 -0400 Subject: [PATCH 057/162] update config tests --- zainod/tests/config.rs | 83 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 15 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 7e3d8cb0e..f7961aa83 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -70,14 +70,21 @@ fn test_deserialize_full_valid_config() { let finalized_config = config_result.unwrap(); assert_eq!(finalized_config.backend, ZainoBackendType::Fetch); - assert!(finalized_config.enable_json_server); + assert!(finalized_config.json_server_settings.is_some()); assert_eq!( - finalized_config.json_rpc_listen_address, + finalized_config + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .json_rpc_listen_address, "127.0.0.1:8000".parse().unwrap() ); - assert!(finalized_config.enable_cookie_auth); assert_eq!( - finalized_config.cookie_dir, + finalized_config + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .cookie_dir, Some(PathBuf::from(zaino_cookie_dir_name)) ); assert_eq!( @@ -155,7 +162,7 @@ fn test_deserialize_optional_fields_missing() { let default_values = IndexerConfig::default(); assert_eq!(config.backend, ZainoBackendType::State); - assert_eq!(config.enable_json_server, default_values.enable_json_server); + // assert_eq!(config.enable_json_server, default_values.enable_json_server); assert_eq!(config.validator_user, default_values.validator_user); assert_eq!(config.validator_password, default_values.validator_password); assert_eq!( @@ -199,7 +206,13 @@ fn test_cookie_dir_logic() { )?; let config1 = load_config(&s1_path).expect("Config S1 failed"); - assert!(config1.cookie_dir.is_some()); + assert!(config1.json_server_settings.is_some()); + assert!(config1 + .json_server_settings + .as_ref() + .expect("json settings is Some") + .cookie_dir + .is_some()); // Scenario 2: auth enabled, cookie_dir specified let s2_path = jail.directory().join("s2.toml"); @@ -218,7 +231,15 @@ fn test_cookie_dir_logic() { "#, )?; let config2 = load_config(&s2_path).expect("Config S2 failed"); - assert_eq!(config2.cookie_dir, Some(PathBuf::from("/my/cookie/path"))); + assert!(config2.json_server_settings.is_some()); + assert_eq!( + config2 + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .cookie_dir, + Some(PathBuf::from("/my/cookie/path")) + ); // Scenario 3: auth disabled, cookie_dir specified (should be None after finalize) let s3_path = jail.directory().join("s3.toml"); @@ -237,7 +258,15 @@ fn test_cookie_dir_logic() { "#, )?; let config3 = load_config(&s3_path).expect("Config S3 failed"); - assert_eq!(config3.cookie_dir, None); + assert!(config3.json_server_settings.is_some()); + assert_eq!( + config3 + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .cookie_dir, + None + ); Ok(()) }); } @@ -264,7 +293,15 @@ fn test_string_none_as_path_for_cookie_dir() { )?; let config_auth_enabled = load_config(&toml_auth_enabled_path).expect("Auth enabled failed"); - assert_eq!(config_auth_enabled.cookie_dir, Some(PathBuf::from("None"))); + assert!(config_auth_enabled.json_server_settings.is_some()); + assert_eq!( + config_auth_enabled + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .cookie_dir, + Some(PathBuf::from("None")) + ); let toml_auth_disabled_path = jail.directory().join("auth_disabled.toml"); jail.create_file( @@ -283,7 +320,15 @@ fn test_string_none_as_path_for_cookie_dir() { )?; let config_auth_disabled = load_config(&toml_auth_disabled_path).expect("Auth disabled failed"); - assert_eq!(config_auth_disabled.cookie_dir, None); + assert!(config_auth_disabled.json_server_settings.is_some()); + assert_eq!( + config_auth_disabled + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .cookie_dir, + None + ); Ok(()) }); } @@ -299,7 +344,7 @@ fn test_deserialize_empty_string_yields_default() { // Compare relevant fields that should come from default assert_eq!(config.network, default_config.network); assert_eq!(config.backend, default_config.backend); - assert_eq!(config.enable_json_server, default_config.enable_json_server); + // assert_eq!(config.enable_json_server, default_config.enable_json_server); assert_eq!(config.validator_user, default_config.validator_user); assert_eq!(config.validator_password, default_config.validator_password); assert_eq!( @@ -401,9 +446,17 @@ fn test_figment_env_override_toml_and_defaults() { let config = load_config(&temp_toml_path).expect("load_config should succeed"); assert_eq!(config.network, Network::Mainnet); - assert!(config.enable_json_server); + assert!(config.json_server_settings.is_some()); assert_eq!(config.storage.cache.capacity, 12345); - assert_eq!(config.cookie_dir, Some(PathBuf::from("/env/cookie/path"))); + assert!(config.json_server_settings.is_some()); + assert_eq!( + config + .json_server_settings + .as_ref() + .expect("json settings to be Some") + .cookie_dir, + Some(PathBuf::from("/env/cookie/path")) + ); assert!(config.grpc_settings.tls.is_none()); Ok(()) }); @@ -425,7 +478,7 @@ fn test_figment_toml_overrides_defaults() { config.network, Network::Regtest(ActivationHeights::default()) ); - assert!(config.enable_json_server); + assert!(config.json_server_settings.is_some()); Ok(()) }); } @@ -439,7 +492,7 @@ fn test_figment_all_defaults() { load_config(&temp_toml_path).expect("load_config should succeed with empty toml"); let defaults = IndexerConfig::default(); assert_eq!(config.network, defaults.network); - assert_eq!(config.enable_json_server, defaults.enable_json_server); + // assert_eq!(config.enable_json_server, defaults.enable_json_server); assert_eq!( config.storage.cache.capacity, defaults.storage.cache.capacity From ffef5433c038d2e7aa5c2a6d647023ac1b2174ca Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 04:41:27 -0400 Subject: [PATCH 058/162] update test fn args --- integration-tests/tests/chain_cache.rs | 13 +++++-------- integration-tests/tests/fetch_service.rs | 4 ++-- integration-tests/tests/wallet_to_validator.rs | 14 +++++++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index 3f4befce8..f38856f4c 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -163,7 +163,6 @@ mod chain_query_interface { }, network.into(), true, - true, )) .await .unwrap(); @@ -180,7 +179,6 @@ mod chain_query_interface { db_version: 1, network: zaino_common::Network::Regtest(activation_heights), no_sync: false, - no_db: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::State(chain_index::source::State { @@ -217,7 +215,6 @@ mod chain_query_interface { db_version: 1, network: zaino_common::Network::Regtest(activation_heights), no_sync: false, - no_db: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::Fetch(json_service.clone()), @@ -245,7 +242,7 @@ mod chain_query_interface { async fn get_block_range(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -287,7 +284,7 @@ mod chain_query_interface { async fn find_fork_point(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -319,7 +316,7 @@ mod chain_query_interface { async fn get_raw_transaction(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -373,7 +370,7 @@ mod chain_query_interface { async fn get_transaction_status(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false, false).await; let snapshot = indexer.snapshot_nonfinalized_state(); // I don't know where this second block is generated. Somewhere in the // guts of create_test_manager_and_chain_index @@ -413,7 +410,7 @@ mod chain_query_interface { async fn sync_large_chain(validator: &ValidatorKind) { let (test_manager, json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index b2e168353..b7e37fcb0 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -613,7 +613,7 @@ async fn assert_fetch_service_difficulty_matches_rpc(validator: &ValidatorKind) async fn assert_fetch_service_peerinfo_matches_rpc(validator: &ValidatorKind) { let (test_manager, _fetch_service, fetch_service_subscriber) = - create_test_manager_and_fetch_service(validator, None, true, true, true, true).await; + create_test_manager_and_fetch_service(validator, None, true, true, true).await; let fetch_service_get_peer_info = fetch_service_subscriber.get_peer_info().await.unwrap(); @@ -641,7 +641,7 @@ async fn assert_fetch_service_peerinfo_matches_rpc(validator: &ValidatorKind) { async fn fetch_service_get_block_subsidy(validator: &ValidatorKind) { let (test_manager, _fetch_service, fetch_service_subscriber) = - create_test_manager_and_fetch_service(validator, None, true, true, true, true).await; + create_test_manager_and_fetch_service(validator, None, true, true, true).await; const BLOCK_LIMIT: u32 = 10; diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index 34e75a3fd..b8f9ddb99 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -11,7 +11,7 @@ use zip32::AccountId; async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -28,7 +28,7 @@ async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backe async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -71,7 +71,7 @@ async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -114,7 +114,7 @@ async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -218,7 +218,7 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -309,7 +309,7 @@ async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { async fn shield_for_validator(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); @@ -385,7 +385,7 @@ async fn monitor_unverified_mempool_for_validator( backend: &BackendType, ) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, true, + validator, backend, None, None, true, false, false, true, true, ) .await .unwrap(); From 1fb8b1f0d4b15ae81766f66b99443418c8a844fc Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 16:01:26 -0400 Subject: [PATCH 059/162] WIP jsonrpc config tests --- zaino-serve/src/server/config.rs | 4 +++- zainod/src/config.rs | 1 + zainod/tests/config.rs | 39 ++++++++------------------------ 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 38b9321e6..f32bc63bf 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -69,14 +69,16 @@ impl GrpcConfig { #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcConfig { /// Server bind addr. - // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] // LISTENING address for incoming connections. Do we have a destination address, // or is that simply a port for our full node? + // TODO for this field, assess + // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, // TODO this is the field that actually is the same in the server as the config. Should we these separate? // If cookie_dir is Some, cookie auth is on. // An empty PathBuf will have an emphemeral path assigned to it when zaino loads the config. /// Directory to store authentication cookie file. + #[serde(default)] pub cookie_dir: Option, } diff --git a/zainod/src/config.rs b/zainod/src/config.rs index dd3950871..d05f1ee86 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -65,6 +65,7 @@ pub struct IndexerConfig { pub backend: zaino_state::BackendType, // TODO later, create what were called "sections" /// Enable JsonRPC server. + #[serde(default)] pub json_server_settings: Option, // Some is true // pub enable_json_server: bool, diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index f7961aa83..3ee11277b 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -193,15 +193,19 @@ fn test_cookie_dir_logic() { let s1_path = jail.directory().join("s1.toml"); jail.create_file( &s1_path, + // TODO check gRPC config as well r#" backend = "fetch" + + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" + cookie_dir = "" + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" zebra_db_path = "/zebra/db" network = "Testnet" - enable_cookie_auth = true "#, )?; @@ -218,16 +222,19 @@ fn test_cookie_dir_logic() { let s2_path = jail.directory().join("s2.toml"); jail.create_file( &s2_path, + // removed auth - now we handle this with Some / None r#" backend = "fetch" + + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" + cookie_dir = "/my/cookie/path" + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" zebra_db_path = "/zebra/db" network = "Testnet" - enable_cookie_auth = true - cookie_dir = "/my/cookie/path" "#, )?; let config2 = load_config(&s2_path).expect("Config S2 failed"); @@ -241,32 +248,6 @@ fn test_cookie_dir_logic() { Some(PathBuf::from("/my/cookie/path")) ); - // Scenario 3: auth disabled, cookie_dir specified (should be None after finalize) - let s3_path = jail.directory().join("s3.toml"); - jail.create_file( - &s3_path, - r#" - backend = "fetch" - json_rpc_listen_address = "127.0.0.1:8237" - grpc_listen_address = "127.0.0.1:8137" - validator_listen_address = "127.0.0.1:18232" - zaino_db_path = "/zaino/db" - zebra_db_path = "/zebra/db" - network = "Testnet" - enable_cookie_auth = false - cookie_dir = "/my/ignored/path" - "#, - )?; - let config3 = load_config(&s3_path).expect("Config S3 failed"); - assert!(config3.json_server_settings.is_some()); - assert_eq!( - config3 - .json_server_settings - .as_ref() - .expect("json settings to be Some") - .cookie_dir, - None - ); Ok(()) }); } From 3c22e01bbf942f8db6e09293bc8233cb32f9d55f Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 11 Oct 2025 18:50:13 -0400 Subject: [PATCH 060/162] WIP zainod config tests jsonrpc --- zainod/tests/config.rs | 80 +++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 3ee11277b..95f9e2613 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -2,7 +2,7 @@ use figment::Jail; use std::path::PathBuf; -use zaino_common::network::ActivationHeights; +// use zaino_common::network::ActivationHeights; use zaino_common::Network; // Use the explicit library name `zainodlib` as defined in Cargo.toml [lib] name. @@ -33,11 +33,18 @@ fn test_deserialize_full_valid_config() { let toml_str = format!( r#" backend = "fetch" - enable_json_server = true + + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8000" - enable_cookie_auth = true cookie_dir = "{zaino_cookie_dir_name}" - grpc_settings = {{ listen_address = "0.0.0.0:9000", tls = {{cert_path = "{cert_file_name}", key_path = "{key_file_name}" }} }} + + [grpc_settings] + listen_address = "0.0.0.0:9000" + + [grpc_settings.tls] + cert_path = "{cert_file_name}" + key_path = "{key_file_name}" + validator_listen_address = "192.168.1.10:18232" validator_cookie_auth = true validator_cookie_path = "{validator_cookie_file_name}" @@ -105,6 +112,7 @@ fn test_deserialize_full_valid_config() { .key_path, PathBuf::from(key_file_name) ); + // TODO how did I break this assert_eq!( finalized_config.validator_cookie_path, Some(validator_cookie_file_name.to_string()) @@ -247,7 +255,7 @@ fn test_cookie_dir_logic() { .cookie_dir, Some(PathBuf::from("/my/cookie/path")) ); - + // TODO you took out a whole test without switching it to expect to fail Ok(()) }); } @@ -258,13 +266,16 @@ fn test_cookie_dir_logic() { fn test_string_none_as_path_for_cookie_dir() { Jail::expect_with(|jail| { let toml_auth_enabled_path = jail.directory().join("auth_enabled.toml"); + // TODO first case is cookie auth on but no dir assigned jail.create_file( &toml_auth_enabled_path, r#" backend = "fetch" - enable_cookie_auth = true - cookie_dir = "None" + + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" + cookie_dir = "" + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" @@ -275,23 +286,27 @@ fn test_string_none_as_path_for_cookie_dir() { let config_auth_enabled = load_config(&toml_auth_enabled_path).expect("Auth enabled failed"); assert!(config_auth_enabled.json_server_settings.is_some()); - assert_eq!( - config_auth_enabled - .json_server_settings - .as_ref() - .expect("json settings to be Some") - .cookie_dir, - Some(PathBuf::from("None")) - ); + assert!(config_auth_enabled + .json_server_settings + .as_ref() + .expect("json settings to be Some") + // TODO default does add a cookie dir? + // I see "/run/user/1000/zaino/.cookie + // assigns cookie dir automatically + .cookie_dir + .is_some()); + // TODO this case is cookie auth off, no cookie dir let toml_auth_disabled_path = jail.directory().join("auth_disabled.toml"); jail.create_file( &toml_auth_disabled_path, r#" backend = "fetch" - enable_cookie_auth = false - cookie_dir = "None" + + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" + cookie_dir = "" + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" @@ -302,6 +317,7 @@ fn test_string_none_as_path_for_cookie_dir() { let config_auth_disabled = load_config(&toml_auth_disabled_path).expect("Auth disabled failed"); assert!(config_auth_disabled.json_server_settings.is_some()); + // TODO here we see there is an assignment happening somehow. I assume it because of a default assert_eq!( config_auth_disabled .json_server_settings @@ -369,12 +385,16 @@ fn test_deserialize_invalid_socket_address() { let invalid_toml_path = jail.directory().join("invalid_socket.toml"); jail.create_file( &invalid_toml_path, - r#"json_rpc_listen_address = "not-a-valid-address""#, + r#" + [json_server_settings] + json_rpc_listen_address = "not-a-valid-address" + cookie_dir = "" + "#, )?; let result = load_config(&invalid_toml_path); assert!(result.is_err()); if let Err(IndexerError::ConfigError(msg)) = result { - assert!(msg.contains("Invalid socket address string")); + assert!(msg.contains("invalid socket address syntax")); } Ok(()) }); @@ -414,14 +434,18 @@ fn test_figment_env_override_toml_and_defaults() { "test_config.toml", r#" network = "Testnet" - enable_json_server = false + json_server_settings = "" "#, )?; jail.set_env("ZAINO_NETWORK", "Mainnet"); + // TODO this: + // config intended to be no-json-server, testing env variables + // TODO these have to be used, somehow, somewhere? jail.set_env("ZAINO_ENABLE_JSON_SERVER", "true"); - jail.set_env("ZAINO_STORAGE.CACHE.CAPACITY", "12345"); jail.set_env("ZAINO_ENABLE_COOKIE_AUTH", "true"); jail.set_env("ZAINO_COOKIE_DIR", "/env/cookie/path"); + // TODO lacking default address + jail.set_env("ZAINO_STORAGE.CACHE.CAPACITY", "12345"); let temp_toml_path = jail.directory().join("test_config.toml"); let config = load_config(&temp_toml_path).expect("load_config should succeed"); @@ -450,16 +474,16 @@ fn test_figment_toml_overrides_defaults() { "test_config.toml", r#" network = "Regtest" - enable_json_server = true + + [json_server_settings] + json_rpc_listen_address = "" + cookie_dir = "" "#, )?; let temp_toml_path = jail.directory().join("test_config.toml"); - let config = load_config(&temp_toml_path).expect("load_config should succeed"); - assert_eq!( - config.network, - Network::Regtest(ActivationHeights::default()) - ); - assert!(config.json_server_settings.is_some()); + + // a json_server_setting without a listening address is forbidden + assert!(load_config(&temp_toml_path).is_err()); Ok(()) }); } From a377651ab742d217e7bc792855a3374cfc764e52 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 13 Oct 2025 01:05:13 -0400 Subject: [PATCH 061/162] no_db comment --- zaino-testutils/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index b5f8b041b..1fbfe93ab 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -599,6 +599,7 @@ impl TestManager { _enable_zaino_jsonrpc_server: bool, _enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, + // no db enable_clients: bool, ) -> Result { let activation_heights = match validator { From b74d5307e0f0aa03301012039b3fcd5b7fb87678 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 13 Oct 2025 20:59:51 -0400 Subject: [PATCH 062/162] remove no_db arg from test --- integration-tests/tests/fetch_service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 15b059c75..46aec2c0e 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -1413,7 +1413,7 @@ async fn fetch_service_get_lightd_info(validator: &ValidatorKind) { async fn assert_fetch_service_getnetworksols_matches_rpc(validator: &ValidatorKind) { let (test_manager, _fetch_service, fetch_service_subscriber) = - create_test_manager_and_fetch_service(validator, None, true, true, true, true).await; + create_test_manager_and_fetch_service(validator, None, true, true, true).await; let fetch_service_get_networksolps = fetch_service_subscriber .get_network_sol_ps(None, None) From ba0444401724be74a746976c5ac8536e46f28779 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 13 Oct 2025 21:23:04 -0400 Subject: [PATCH 063/162] trailing whitespace --- zainod/tests/config.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 95f9e2613..dcbf2e558 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -33,18 +33,18 @@ fn test_deserialize_full_valid_config() { let toml_str = format!( r#" backend = "fetch" - + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8000" cookie_dir = "{zaino_cookie_dir_name}" - + [grpc_settings] listen_address = "0.0.0.0:9000" [grpc_settings.tls] cert_path = "{cert_file_name}" key_path = "{key_file_name}" - + validator_listen_address = "192.168.1.10:18232" validator_cookie_auth = true validator_cookie_path = "{validator_cookie_file_name}" @@ -208,7 +208,7 @@ fn test_cookie_dir_logic() { [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" cookie_dir = "" - + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" @@ -233,11 +233,11 @@ fn test_cookie_dir_logic() { // removed auth - now we handle this with Some / None r#" backend = "fetch" - + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" cookie_dir = "/my/cookie/path" - + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" @@ -275,7 +275,7 @@ fn test_string_none_as_path_for_cookie_dir() { [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" cookie_dir = "" - + grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" From fb39c81ec1d90db63a65141513622a138e220d70 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 13 Oct 2025 22:25:44 -0400 Subject: [PATCH 064/162] update comments and field names of TestManager --- zaino-testutils/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 1fbfe93ab..c76930bd3 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -350,7 +350,7 @@ impl Clients { } } -/// Configuration data for Zingo-Indexer Tests. +/// Configuration data for Zaino Tests. pub struct TestManager { /// Zcash-local-net. pub local_net: LocalNet, @@ -359,14 +359,14 @@ pub struct TestManager { /// Network (chain) type: pub network: NetworkKind, /// Zebrad/Zcashd JsonRpc listen address. - pub zebrad_rpc_listen_address: SocketAddr, + pub full_node_rpc_listen_address: SocketAddr, /// Zebrad/Zcashd gRpc listen address. - pub zebrad_grpc_listen_address: SocketAddr, + pub full_node_grpc_listen_address: SocketAddr, /// Zaino Indexer JoinHandle. pub zaino_handle: Option>>, - /// Zingo-Indexer JsonRPC listen address. + /// Zaino JsonRPC listen address. pub zaino_json_rpc_listen_address: Option, - /// Zingo-Indexer gRPC listen address. + /// Zaino gRPC listen address. pub zaino_grpc_listen_address: Option, /// JsonRPC server cookie dir. pub json_server_cookie_dir: Option, @@ -423,9 +423,9 @@ impl TestManager { // Launch LocalNet: let rpc_listen_port = portpicker::pick_unused_port().expect("No ports free"); let grpc_listen_port = portpicker::pick_unused_port().expect("No ports free"); - let zebrad_rpc_listen_address = + let full_node_rpc_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), rpc_listen_port); - let zebrad_grpc_listen_address = + let full_node_grpc_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), grpc_listen_port); let validator_config = match validator { @@ -491,8 +491,8 @@ impl TestManager { listen_address: zaino_grpc_listen_address, tls: None, }, - validator_listen_address: zebrad_rpc_listen_address, - validator_grpc_listen_address: zebrad_grpc_listen_address, + validator_listen_address: full_node_rpc_listen_address, + validator_grpc_listen_address: full_node_grpc_listen_address, validator_cookie_auth: false, validator_cookie_path: None, validator_user: Some("xxxxxx".to_string()), @@ -572,8 +572,8 @@ impl TestManager { local_net, data_dir, network: network_kind, - zebrad_rpc_listen_address, - zebrad_grpc_listen_address, + full_node_rpc_listen_address, + full_node_grpc_listen_address, zaino_handle, zaino_json_rpc_listen_address: zaino_json_listen_address, zaino_grpc_listen_address, From 9bec21b32e56d1ccc5d649fa214a75f6f3e03d1f Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 13 Oct 2025 22:44:40 -0400 Subject: [PATCH 065/162] update field names of TestManager in tests --- integration-tests/tests/chain_cache.rs | 6 +++--- integration-tests/tests/fetch_service.rs | 14 +++++++------- integration-tests/tests/json_server.rs | 2 +- integration-tests/tests/local_cache.rs | 2 +- integration-tests/tests/state_service.rs | 6 +++--- integration-tests/tests/test_vectors.rs | 4 ++-- integration-tests/tests/wallet_to_validator.rs | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index f38856f4c..c38c5d406 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -26,7 +26,7 @@ async fn create_test_manager_and_connector( let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -142,8 +142,8 @@ mod chain_query_interface { debug_stop_at_height: None, debug_validity_check_interval: None, }, - test_manager.zebrad_rpc_listen_address, - test_manager.zebrad_grpc_listen_address, + test_manager.full_node_rpc_listen_address, + test_manager.full_node_grpc_listen_address, false, None, None, diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 46aec2c0e..308865607 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -43,7 +43,7 @@ async fn create_test_manager_and_fetch_service( .unwrap(); let fetch_service = FetchService::spawn(FetchServiceConfig::new( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, None, @@ -184,7 +184,7 @@ async fn fetch_service_get_raw_mempool(validator: &ValidatorKind) { let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -554,7 +554,7 @@ async fn fetch_service_get_latest_block(validator: &ValidatorKind) { let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -594,7 +594,7 @@ async fn assert_fetch_service_difficulty_matches_rpc(validator: &ValidatorKind) let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -619,7 +619,7 @@ async fn assert_fetch_service_peerinfo_matches_rpc(validator: &ValidatorKind) { let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -653,7 +653,7 @@ async fn fetch_service_get_block_subsidy(validator: &ValidatorKind) { let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -1422,7 +1422,7 @@ async fn assert_fetch_service_getnetworksols_matches_rpc(validator: &ValidatorKi let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 01805bb17..372ab8a43 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -40,7 +40,7 @@ async fn create_test_manager_and_fetch_services( println!("Launching zcashd fetch service.."); let zcashd_fetch_service = FetchService::spawn(FetchServiceConfig::new( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, None, diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index bd806d537..d2f074a7c 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -41,7 +41,7 @@ async fn create_test_manager_and_block_cache( let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index 8104641f1..8d73a450f 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -60,7 +60,7 @@ async fn create_test_manager_and_services( test_manager.local_net.print_stdout(); let fetch_service = FetchService::spawn(FetchServiceConfig::new( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, None, @@ -99,8 +99,8 @@ async fn create_test_manager_and_services( debug_stop_at_height: None, debug_validity_check_interval: None, }, - test_manager.zebrad_rpc_listen_address, - test_manager.zebrad_grpc_listen_address, + test_manager.full_node_rpc_listen_address, + test_manager.full_node_grpc_listen_address, false, None, None, diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index e2c50bedc..e38ee710c 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -100,8 +100,8 @@ async fn create_test_manager_and_services( debug_stop_at_height: None, debug_validity_check_interval: None, }, - test_manager.zebrad_rpc_listen_address, - test_manager.zebrad_grpc_listen_address, + test_manager.full_node_rpc_listen_address, + test_manager.full_node_grpc_listen_address, false, None, None, diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index b8f9ddb99..fb20af5d9 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -142,7 +142,7 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { let fetch_service = zaino_fetch::jsonrpsee::connector::JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), @@ -437,7 +437,7 @@ async fn monitor_unverified_mempool_for_validator( let fetch_service = zaino_fetch::jsonrpsee::connector::JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, + test_manager.full_node_rpc_listen_address, false, None, Some("xxxxxx".to_string()), From 44929832c0c566b8f74ffe5c13e6e6b4dd4186b8 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 00:55:59 -0400 Subject: [PATCH 066/162] reintroduce zaino_jsonrpc_server fields in TestManager, comments --- zaino-testutils/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index c76930bd3..91dc276fc 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -392,7 +392,9 @@ impl TestManager { activation_heights: Option, chain_cache: Option, enable_zaino: bool, - // TODO here + // TODO the following two fields involve zaino's json RPC server + enable_zaino_jsonrpc_server: bool, + enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, enable_clients: bool, ) -> Result { @@ -483,6 +485,8 @@ impl TestManager { let indexer_config = zainodlib::config::IndexerConfig { // TODO: Make configurable. backend: *backend, + // TODO this needs to be conditional + // use Builder pattern json_server_settings: Some(JsonRpcConfig { json_rpc_listen_address: zaino_json_listen_address, cookie_dir: Some(zaino_json_server_cookie_dir.clone()), @@ -497,11 +501,13 @@ impl TestManager { validator_cookie_path: None, validator_user: Some("xxxxxx".to_string()), validator_password: Some("xxxxxx".to_string()), + // TODO also deafault() by hazel a month ago service: ServiceConfig::default(), storage: StorageConfig { cache: CacheConfig::default(), database: DatabaseConfig { path: zaino_db_path, + // TODO this is using default pattern... by hazel a month ago.. ..Default::default() }, }, @@ -589,6 +595,7 @@ impl TestManager { } /// Helper function to support default test case. + // TODO this is impl TestManager #[allow(clippy::too_many_arguments)] pub async fn launch_with_default_activation_heights( validator: &ValidatorKind, From 39e10af78b5e665d4d530b9f4b8181dde98f01c9 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 00:57:07 -0400 Subject: [PATCH 067/162] impl Default for JsonRpcConfig --- zaino-serve/src/server/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index f32bc63bf..424e07b4e 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -82,3 +82,13 @@ pub struct JsonRpcConfig { #[serde(default)] pub cookie_dir: Option, } + +impl Default for JsonRpcConfig { + fn default() -> Self { + Self { + json_rpc_listen_address: + // Safe, minimally connectable default: loopback with ephemeral port + "127.0.0.1:0".parse().unwrap(), + cookie_dir: None } + } +} From 2eb4726f436f51a9c6899ba3fc1057b01fe89bd6 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 01:15:39 -0400 Subject: [PATCH 068/162] rename to JsonRpcServerConfig, update doc comments --- zaino-serve/src/lib.rs | 2 +- zaino-serve/src/rpc.rs | 2 +- zaino-serve/src/server/config.rs | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/zaino-serve/src/lib.rs b/zaino-serve/src/lib.rs index 9d3d28c14..df52dbd67 100644 --- a/zaino-serve/src/lib.rs +++ b/zaino-serve/src/lib.rs @@ -1,4 +1,4 @@ -//! Holds a gRPC server capable of servicing clients over TCP. +//! Holds gRPC and JSON RPC servers capable of servicing clients over TCP. //! //! - server::ingestor has been built so that other ingestors may be added that use different transport protocols (Nym, TOR). //! diff --git a/zaino-serve/src/rpc.rs b/zaino-serve/src/rpc.rs index bc8378494..2b1fd1e7e 100644 --- a/zaino-serve/src/rpc.rs +++ b/zaino-serve/src/rpc.rs @@ -13,7 +13,7 @@ pub struct GrpcClient { } #[derive(Clone)] -/// Zaino gRPC service. +/// Zaino JSONRPC service. pub struct JsonRpcClient { /// Chain fetch service subscriber. pub service_subscriber: IndexerSubscriber, diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 424e07b4e..16e3e338b 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -67,10 +67,9 @@ impl GrpcConfig { /// Configuration data for Zaino's JSON RPC server. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] -pub struct JsonRpcConfig { +pub struct JsonRpcServerConfig { /// Server bind addr. - // LISTENING address for incoming connections. Do we have a destination address, - // or is that simply a port for our full node? + // LISTENING address for incoming connections. // TODO for this field, assess // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, @@ -83,7 +82,7 @@ pub struct JsonRpcConfig { pub cookie_dir: Option, } -impl Default for JsonRpcConfig { +impl Default for JsonRpcServerConfig { fn default() -> Self { Self { json_rpc_listen_address: From 51deca35c28f94a340f8e710a6432d64c0dc34b1 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:00:21 -0400 Subject: [PATCH 069/162] MVP conditional JsonRpcConfig --- zaino-testutils/src/lib.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 91dc276fc..a2c3773f6 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -485,12 +485,18 @@ impl TestManager { let indexer_config = zainodlib::config::IndexerConfig { // TODO: Make configurable. backend: *backend, - // TODO this needs to be conditional - // use Builder pattern - json_server_settings: Some(JsonRpcConfig { - json_rpc_listen_address: zaino_json_listen_address, - cookie_dir: Some(zaino_json_server_cookie_dir.clone()), - }), + json_server_settings: if enable_zaino_jsonrpc_server { + Some(JsonRpcConfig { + json_rpc_listen_address: zaino_json_listen_address, + cookie_dir: if enable_zaino_jsonrpc_server_cookie_auth { + Some(zaino_json_server_cookie_dir.clone()) + } else { + None + }, + }) + } else { + None + }, grpc_settings: GrpcConfig { listen_address: zaino_grpc_listen_address, tls: None, @@ -501,13 +507,11 @@ impl TestManager { validator_cookie_path: None, validator_user: Some("xxxxxx".to_string()), validator_password: Some("xxxxxx".to_string()), - // TODO also deafault() by hazel a month ago service: ServiceConfig::default(), storage: StorageConfig { cache: CacheConfig::default(), database: DatabaseConfig { path: zaino_db_path, - // TODO this is using default pattern... by hazel a month ago.. ..Default::default() }, }, From 573c97938f57a503723625bee62c08da180d6cac Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:01:58 -0400 Subject: [PATCH 070/162] update name to JsonRpcServerConfig in lib --- zaino-testutils/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index a2c3773f6..d5c43ec03 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -18,7 +18,7 @@ use tracing_subscriber::EnvFilter; use zaino_common::{ network::ActivationHeights, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::config::{GrpcConfig, JsonRpcConfig}; +use zaino_serve::server::config::{GrpcConfig, JsonRpcServerConfig}; use zaino_state::BackendType; use zainodlib::config::default_ephemeral_cookie_path; pub use zcash_local_net as services; @@ -486,7 +486,7 @@ impl TestManager { // TODO: Make configurable. backend: *backend, json_server_settings: if enable_zaino_jsonrpc_server { - Some(JsonRpcConfig { + Some(JsonRpcServerConfig { json_rpc_listen_address: zaino_json_listen_address, cookie_dir: if enable_zaino_jsonrpc_server_cookie_auth { Some(zaino_json_server_cookie_dir.clone()) From d3443b2cf774b5f27d2495a470662a354ee329e9 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:24:53 -0400 Subject: [PATCH 071/162] rename JsonRpcServerConfig in zainod config --- zainod/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index d05f1ee86..68ec84e92 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -21,7 +21,7 @@ use tracing::{error, info}; use zaino_common::{ CacheConfig, DatabaseConfig, DatabaseSize, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::config::{GrpcConfig, JsonRpcConfig}; +use zaino_serve::server::config::{GrpcConfig, JsonRpcServerConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; use crate::error::IndexerError; @@ -66,7 +66,7 @@ pub struct IndexerConfig { // TODO later, create what were called "sections" /// Enable JsonRPC server. #[serde(default)] - pub json_server_settings: Option, + pub json_server_settings: Option, // Some is true // pub enable_json_server: bool, // /// Server bind addr. From 9d1297687fce64495ca9ed7d6198389eb56a332b Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:25:45 -0400 Subject: [PATCH 072/162] rename JsonRpcServerConfig in zaino-server --- zaino-serve/src/server/jsonrpc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zaino-serve/src/server/jsonrpc.rs b/zaino-serve/src/server/jsonrpc.rs index 632659d24..5ae65d076 100644 --- a/zaino-serve/src/server/jsonrpc.rs +++ b/zaino-serve/src/server/jsonrpc.rs @@ -2,7 +2,7 @@ use crate::{ rpc::{jsonrpc::service::ZcashIndexerRpcServer as _, JsonRpcClient}, - server::{config::JsonRpcConfig, error::ServerError}, + server::{config::JsonRpcServerConfig, error::ServerError}, }; use zaino_state::{AtomicStatus, IndexerSubscriber, LightWalletIndexer, StatusType, ZcashIndexer}; @@ -36,7 +36,7 @@ impl JsonRpcServer { /// - Checks for shutdown signal, shutting down server if received. pub async fn spawn( service_subscriber: IndexerSubscriber, - server_config: JsonRpcConfig, + server_config: JsonRpcServerConfig, ) -> Result { let status = AtomicStatus::new(StatusType::Spawning); From 98a7503e59b897916944abe8e746b957b0520fe4 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:26:36 -0400 Subject: [PATCH 073/162] update server config doc comment --- zaino-serve/src/server/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 16e3e338b..e2c063a65 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -65,7 +65,7 @@ impl GrpcConfig { } } -/// Configuration data for Zaino's JSON RPC server. +/// Configuration data for Zaino's JSON RPC server, capable of servicing clients over TCP. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcServerConfig { /// Server bind addr. From c5b215b5724922bd1a6864fa2e6d24bf0dbcea2e Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:27:12 -0400 Subject: [PATCH 074/162] re enable TestManger bools for zaino jsonrpc server --- zaino-testutils/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index d5c43ec03..2d803d12d 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -460,12 +460,8 @@ impl TestManager { // Launch Zaino: let ( zaino_grpc_listen_address, - // TODO there is some mismatch between JsonRpcConfig/JsonRpcServer and GrpcConfig/GrpcServer - - // TODO this can be set to None [ an Option ]- which is different than our Config type representation - // ah! but we are _listening_ here, not serving I think. + // TODO there is some mismatch between JsonRpcServerConfig/JsonRpcServer and GrpcConfig/GrpcServer zaino_json_listen_address, - // Option - like our config. zaino_json_server_cookie_dir, zaino_handle, ) = if enable_zaino { @@ -607,8 +603,8 @@ impl TestManager { network: Option, chain_cache: Option, enable_zaino: bool, - _enable_zaino_jsonrpc_server: bool, - _enable_zaino_jsonrpc_server_cookie_auth: bool, + enable_zaino_jsonrpc_server: bool, + enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, // no db enable_clients: bool, @@ -625,6 +621,8 @@ impl TestManager { Some(activation_heights), chain_cache, enable_zaino, + enable_zaino_jsonrpc_server, + enable_zaino_jsonrpc_server_cookie_auth, zaino_no_sync, enable_clients, ) From 918fc535f2ee07aff3a3a119edf5aabff9d12e82 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 02:34:37 -0400 Subject: [PATCH 075/162] reintroduce rpcserver bools into integration tests --- integration-tests/tests/chain_cache.rs | 2 ++ integration-tests/tests/local_cache.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index c38c5d406..0dfad5b0f 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -18,6 +18,8 @@ async fn create_test_manager_and_connector( activation_heights, chain_cache, enable_zaino, + false, //enable_zaino_jsonrpc_server: bool, + false, //enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync, enable_clients, ) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index d2f074a7c..782d86cd5 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -33,6 +33,8 @@ async fn create_test_manager_and_block_cache( Some(activation_heights), chain_cache, enable_zaino, + false, //enable_zaino_jsonrpc_server: bool, + false, //enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync, enable_clients, ) From e93c91ed265ac9c023c89f898cde75598169a714 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 14 Oct 2025 04:20:06 -0400 Subject: [PATCH 076/162] WIP zainod tests config --- zainod/tests/config.rs | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index dcbf2e558..c255edf40 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -33,18 +33,6 @@ fn test_deserialize_full_valid_config() { let toml_str = format!( r#" backend = "fetch" - - [json_server_settings] - json_rpc_listen_address = "127.0.0.1:8000" - cookie_dir = "{zaino_cookie_dir_name}" - - [grpc_settings] - listen_address = "0.0.0.0:9000" - - [grpc_settings.tls] - cert_path = "{cert_file_name}" - key_path = "{key_file_name}" - validator_listen_address = "192.168.1.10:18232" validator_cookie_auth = true validator_cookie_path = "{validator_cookie_file_name}" @@ -57,6 +45,17 @@ fn test_deserialize_full_valid_config() { no_sync = false no_db = false slow_sync = false + + [json_server_settings] + json_rpc_listen_address = "127.0.0.1:8000" + cookie_dir = "{zaino_cookie_dir_name}" + + [grpc_settings] + listen_address = "0.0.0.0:9000" + + [grpc_settings.tls] + cert_path = "{cert_file_name}" + key_path = "{key_file_name}" "# ); @@ -112,7 +111,6 @@ fn test_deserialize_full_valid_config() { .key_path, PathBuf::from(key_file_name) ); - // TODO how did I break this assert_eq!( finalized_config.validator_cookie_path, Some(validator_cookie_file_name.to_string()) @@ -143,7 +141,7 @@ fn test_deserialize_full_valid_config() { 128 * 1024 * 1024 * 1024 ); assert!(!finalized_config.no_sync); - // assert finalized config > 0 + // TODO assert finalized config > 0 //assert!(!finalized_config.no_db); Ok(()) @@ -271,16 +269,15 @@ fn test_string_none_as_path_for_cookie_dir() { &toml_auth_enabled_path, r#" backend = "fetch" - - [json_server_settings] - json_rpc_listen_address = "127.0.0.1:8237" - cookie_dir = "" - grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" zaino_db_path = "/zaino/db" zebra_db_path = "/zebra/db" network = "Testnet" + + [json_server_settings] + json_rpc_listen_address = "127.0.0.1:8237" + cookie_dir = "" "#, )?; let config_auth_enabled = @@ -434,7 +431,7 @@ fn test_figment_env_override_toml_and_defaults() { "test_config.toml", r#" network = "Testnet" - json_server_settings = "" + json_server_settings = "/replaceme" "#, )?; jail.set_env("ZAINO_NETWORK", "Mainnet"); From 5618fdf19e553436f1140d57d295a6b19bb1d8e1 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 05:52:58 -0400 Subject: [PATCH 077/162] update figment env vars in config tests --- zainod/tests/config.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index c255edf40..bcffa9332 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -2,7 +2,6 @@ use figment::Jail; use std::path::PathBuf; -// use zaino_common::network::ActivationHeights; use zaino_common::Network; // Use the explicit library name `zainodlib` as defined in Cargo.toml [lib] name. @@ -427,28 +426,34 @@ fn test_parse_zindexer_toml_integration() { #[test] fn test_figment_env_override_toml_and_defaults() { Jail::expect_with(|jail| { + // test will fail without a JsonRpcServerConfig being decleared (should default to None) + // valid socket also address (needed for JsonRpcServerConfig struct) + // and also a 'dummy' cookie path, as no mention of it makes the value None which cannot be updated via env var jail.create_file( "test_config.toml", r#" network = "Testnet" - json_server_settings = "/replaceme" "#, )?; jail.set_env("ZAINO_NETWORK", "Mainnet"); // TODO this: // config intended to be no-json-server, testing env variables // TODO these have to be used, somehow, somewhere? - jail.set_env("ZAINO_ENABLE_JSON_SERVER", "true"); - jail.set_env("ZAINO_ENABLE_COOKIE_AUTH", "true"); - jail.set_env("ZAINO_COOKIE_DIR", "/env/cookie/path"); - // TODO lacking default address + //jail.set_env("ZAINO_JSON_SERVER_SETTINGS", "some"); + jail.set_env( + "ZAINO_JSON_SERVER_SETTINGS-JSON_RPC_LISTEN_ADDRESS", + "127.0.0.1:0", + ); + // pub json_rpc_listen_address: SocketAddr, + //jail.set_env("ZAINO_ENABLE_COOKIE_AUTH", "true"); + jail.set_env("ZAINO_JSON_SERVER_SETTINGS-COOKIE_DIR", "/env/cookie/path"); + //jail.set_env("ZAINO_JSON_SERVER_SETTINGS_COOKIE_DIR", "/env/cookie/path"); jail.set_env("ZAINO_STORAGE.CACHE.CAPACITY", "12345"); let temp_toml_path = jail.directory().join("test_config.toml"); let config = load_config(&temp_toml_path).expect("load_config should succeed"); assert_eq!(config.network, Network::Mainnet); - assert!(config.json_server_settings.is_some()); assert_eq!(config.storage.cache.capacity, 12345); assert!(config.json_server_settings.is_some()); assert_eq!( From 39ce0a769bbee28c8300176748aa55f3ec3aba8f Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 05:55:46 -0400 Subject: [PATCH 078/162] add split to figment merge to allow nested structs with underscored named fields, clarify error messages --- zainod/src/config.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 68ec84e92..355d684f8 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -1,6 +1,7 @@ //! Zaino config. use std::{ + fmt::Display, net::{IpAddr, SocketAddr, ToSocketAddrs}, path::PathBuf, }; @@ -329,6 +330,8 @@ pub(crate) fn is_loopback_listen_addr(addr: &SocketAddr) -> bool { /// If the file cannot be read, or if its contents cannot be parsed into `IndexerConfig`, /// a warning is logged, and a default configuration is returned. /// The loaded or default configuration undergoes further checks and finalization. +// TODO my problems must be here, where configs read in as files are adapted based on env vars +// see step 3 below pub fn load_config(file_path: &PathBuf) -> Result { // Configuration sources are layered: Env > TOML > Defaults. let figment = Figment::new() @@ -337,7 +340,7 @@ pub fn load_config(file_path: &PathBuf) -> Result { // 2. Override with values from the TOML configuration file. .merge(Toml::file(file_path)) // 3. Override with values from environment variables prefixed with "ZAINO_". - .merge(figment::providers::Env::prefixed("ZAINO_")); + .merge(figment::providers::Env::prefixed("ZAINO_").split("-")); match figment.extract::() { Ok(mut parsed_config) => { @@ -368,9 +371,12 @@ pub fn load_config(file_path: &PathBuf) -> Result { Ok(parsed_config) } Err(figment_error) => { - error!("Failed to extract configuration: {}", figment_error); + error!( + "Failed to extract configuration using figment: {}", + figment_error + ); Err(IndexerError::ConfigError(format!( - "Configuration loading failed for TOML file '{}' (or environment variables). Details: {}", + "Zaino configuration loading failed during figment extract '{}' (could be TOML file or environment variables). Details: {}", file_path.display(), figment_error ))) } From 0e4f4d4dbd7effce6227476c2e5b3ec95da727d2 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 06:00:01 -0400 Subject: [PATCH 079/162] trim and clarify comments --- zainod/tests/config.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index bcffa9332..aacb7178a 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -252,7 +252,7 @@ fn test_cookie_dir_logic() { .cookie_dir, Some(PathBuf::from("/my/cookie/path")) ); - // TODO you took out a whole test without switching it to expect to fail + // TODO took out a whole test without switching it to expect to fail Ok(()) }); } @@ -426,9 +426,6 @@ fn test_parse_zindexer_toml_integration() { #[test] fn test_figment_env_override_toml_and_defaults() { Jail::expect_with(|jail| { - // test will fail without a JsonRpcServerConfig being decleared (should default to None) - // valid socket also address (needed for JsonRpcServerConfig struct) - // and also a 'dummy' cookie path, as no mention of it makes the value None which cannot be updated via env var jail.create_file( "test_config.toml", r#" @@ -436,18 +433,12 @@ fn test_figment_env_override_toml_and_defaults() { "#, )?; jail.set_env("ZAINO_NETWORK", "Mainnet"); - // TODO this: - // config intended to be no-json-server, testing env variables - // TODO these have to be used, somehow, somewhere? - //jail.set_env("ZAINO_JSON_SERVER_SETTINGS", "some"); + // valid socket address assigned with env var (needed for valid JsonRpcServerConfig struct) jail.set_env( "ZAINO_JSON_SERVER_SETTINGS-JSON_RPC_LISTEN_ADDRESS", "127.0.0.1:0", ); - // pub json_rpc_listen_address: SocketAddr, - //jail.set_env("ZAINO_ENABLE_COOKIE_AUTH", "true"); jail.set_env("ZAINO_JSON_SERVER_SETTINGS-COOKIE_DIR", "/env/cookie/path"); - //jail.set_env("ZAINO_JSON_SERVER_SETTINGS_COOKIE_DIR", "/env/cookie/path"); jail.set_env("ZAINO_STORAGE.CACHE.CAPACITY", "12345"); let temp_toml_path = jail.directory().join("test_config.toml"); From 4434ae3a7644a2aa18a51a6b43575ae9a45f9d4c Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 06:07:52 -0400 Subject: [PATCH 080/162] compact use statements for zainod config --- zainod/src/config.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 355d684f8..95e50a3d2 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -1,17 +1,14 @@ //! Zaino config. - -use std::{ - fmt::Display, - net::{IpAddr, SocketAddr, ToSocketAddrs}, - path::PathBuf, -}; - use figment::{ providers::{Format, Serialized, Toml}, Figment, }; - +use std::{ + net::{IpAddr, SocketAddr, ToSocketAddrs}, + path::PathBuf, +}; // Added for Serde deserialization helpers +use crate::error::IndexerError; use serde::{ de::{self, Deserializer}, Deserialize, Serialize, @@ -25,8 +22,6 @@ use zaino_common::{ use zaino_serve::server::config::{GrpcConfig, JsonRpcServerConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; -use crate::error::IndexerError; - /// Custom deserialization function for `SocketAddr` from a String. /// Used by Serde's `deserialize_with`. fn deserialize_socketaddr_from_string<'de, D>(deserializer: D) -> Result From bf93b010a49dd678643765e9de1eb52cf03b4ffd Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 06:08:21 -0400 Subject: [PATCH 081/162] cleanup comments in zaino-serve config --- zaino-serve/src/server/config.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index e2c063a65..2e90c002f 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -69,16 +69,15 @@ impl GrpcConfig { #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcServerConfig { /// Server bind addr. - // LISTENING address for incoming connections. // TODO for this field, assess // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, // TODO this is the field that actually is the same in the server as the config. Should we these separate? - // If cookie_dir is Some, cookie auth is on. - // An empty PathBuf will have an emphemeral path assigned to it when zaino loads the config. /// Directory to store authentication cookie file. + /// Enable cookie-based authentication with a valid Some() value. #[serde(default)] + // An empty PathBuf that is still Some will have an emphemeral path assigned to it when zaino loads the config. pub cookie_dir: Option, } @@ -86,7 +85,7 @@ impl Default for JsonRpcServerConfig { fn default() -> Self { Self { json_rpc_listen_address: - // Safe, minimally connectable default: loopback with ephemeral port + // minimally connectable default: loopback with ephemeral port "127.0.0.1:0".parse().unwrap(), cookie_dir: None } } From 944d8ae38209e6a5e97785bb9c31c33a62d3a4f7 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 06:17:29 -0400 Subject: [PATCH 082/162] fix test_string_none_as_path_for_cookie_dir, final config test --- zainod/tests/config.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index aacb7178a..d32ed2a0b 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -258,12 +258,11 @@ fn test_cookie_dir_logic() { } #[test] -// Tests how `load_config` handles literal string "None" for `cookie_dir` -// with varying `enable_cookie_auth` states. +// Tests how `load_config` handles varying `enable_cookie_auth` states. fn test_string_none_as_path_for_cookie_dir() { Jail::expect_with(|jail| { let toml_auth_enabled_path = jail.directory().join("auth_enabled.toml"); - // TODO first case is cookie auth on but no dir assigned + // cookie auth on but no dir assigned jail.create_file( &toml_auth_enabled_path, r#" @@ -286,13 +285,10 @@ fn test_string_none_as_path_for_cookie_dir() { .json_server_settings .as_ref() .expect("json settings to be Some") - // TODO default does add a cookie dir? - // I see "/run/user/1000/zaino/.cookie - // assigns cookie dir automatically .cookie_dir .is_some()); - // TODO this case is cookie auth off, no cookie dir + // omitting cookie_dir will set it to None let toml_auth_disabled_path = jail.directory().join("auth_disabled.toml"); jail.create_file( &toml_auth_disabled_path, @@ -301,7 +297,6 @@ fn test_string_none_as_path_for_cookie_dir() { [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" - cookie_dir = "" grpc_listen_address = "127.0.0.1:8137" validator_listen_address = "127.0.0.1:18232" @@ -313,7 +308,6 @@ fn test_string_none_as_path_for_cookie_dir() { let config_auth_disabled = load_config(&toml_auth_disabled_path).expect("Auth disabled failed"); assert!(config_auth_disabled.json_server_settings.is_some()); - // TODO here we see there is an assignment happening somehow. I assume it because of a default assert_eq!( config_auth_disabled .json_server_settings From ce26758f0217028a37c64c4c606585da4c27b64a Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 06:34:06 -0400 Subject: [PATCH 083/162] readd database size check --- zainod/tests/config.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index d32ed2a0b..87a900d7f 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -2,7 +2,7 @@ use figment::Jail; use std::path::PathBuf; -use zaino_common::Network; +use zaino_common::{DatabaseSize, Network}; // Use the explicit library name `zainodlib` as defined in Cargo.toml [lib] name. use zainodlib::config::{load_config, IndexerConfig}; @@ -140,8 +140,10 @@ fn test_deserialize_full_valid_config() { 128 * 1024 * 1024 * 1024 ); assert!(!finalized_config.no_sync); - // TODO assert finalized config > 0 - //assert!(!finalized_config.no_db); + assert!(match finalized_config.storage.database.size { + DatabaseSize::Gb(0) => false, + DatabaseSize::Gb(_) => true, + }); Ok(()) }); From 795c3ab12ff0361d44e97d17f469f1a1d3584807 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 15 Oct 2025 06:48:58 -0400 Subject: [PATCH 084/162] touchup doc comment --- zaino-serve/src/server/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 2e90c002f..71892aff8 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -75,7 +75,7 @@ pub struct JsonRpcServerConfig { // TODO this is the field that actually is the same in the server as the config. Should we these separate? /// Directory to store authentication cookie file. - /// Enable cookie-based authentication with a valid Some() value. + /// Enable cookie-based authentication with a valid `Some()` value. #[serde(default)] // An empty PathBuf that is still Some will have an emphemeral path assigned to it when zaino loads the config. pub cookie_dir: Option, From e635caa45f7f130dc9d565ffb075b504057928bf Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 00:53:23 -0400 Subject: [PATCH 085/162] rename GrpcConfig to GrpcServerConfig --- zaino-serve/src/server/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 71892aff8..992a7de25 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -18,7 +18,7 @@ pub struct GrpcTls { /// Configuration data for Zaino's gRPC server. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] -pub struct GrpcConfig { +pub struct GrpcServerConfig { /// gRPC server bind addr. // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub listen_address: SocketAddr, @@ -26,7 +26,7 @@ pub struct GrpcConfig { pub tls: Option, } -impl GrpcConfig { +impl GrpcServerConfig { /// If TLS is enabled, reads the certificate and key files and returns a valid /// `ServerTlsConfig`. If TLS is not enabled, returns `Ok(None)`. // TODO : redundant? From c4a8176a3c52fe0bc060dad4a40e020ef1a58dea Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 00:56:49 -0400 Subject: [PATCH 086/162] rename config field to validator_jsonrpc_listen_address, change names of references --- zaino-serve/src/server/grpc.rs | 4 ++-- zaino-testutils/src/lib.rs | 7 +++---- zainod/src/config.rs | 34 +++++++++++----------------------- zainod/src/indexer.rs | 6 +++--- 4 files changed, 19 insertions(+), 32 deletions(-) diff --git a/zaino-serve/src/server/grpc.rs b/zaino-serve/src/server/grpc.rs index 3dfa55197..386594b43 100644 --- a/zaino-serve/src/server/grpc.rs +++ b/zaino-serve/src/server/grpc.rs @@ -10,7 +10,7 @@ use zaino_state::{AtomicStatus, IndexerSubscriber, LightWalletIndexer, StatusTyp use crate::{ rpc::GrpcClient, - server::{config::GrpcConfig, error::ServerError}, + server::{config::GrpcServerConfig, error::ServerError}, }; /// LightWallet server capable of servicing clients over TCP. @@ -32,7 +32,7 @@ impl TonicServer { /// - Checks for shutdown signal, shutting down server if received. pub async fn spawn( service_subscriber: IndexerSubscriber, - server_config: GrpcConfig, + server_config: GrpcServerConfig, ) -> Result { let status = AtomicStatus::new(StatusType::Spawning); diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 2d803d12d..9f9f19ce6 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -18,7 +18,7 @@ use tracing_subscriber::EnvFilter; use zaino_common::{ network::ActivationHeights, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::config::{GrpcConfig, JsonRpcServerConfig}; +use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::BackendType; use zainodlib::config::default_ephemeral_cookie_path; pub use zcash_local_net as services; @@ -392,7 +392,6 @@ impl TestManager { activation_heights: Option, chain_cache: Option, enable_zaino: bool, - // TODO the following two fields involve zaino's json RPC server enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, @@ -493,11 +492,11 @@ impl TestManager { } else { None }, - grpc_settings: GrpcConfig { + grpc_settings: GrpcServerConfig { listen_address: zaino_grpc_listen_address, tls: None, }, - validator_listen_address: full_node_rpc_listen_address, + validator_jsonrpc_listen_address: full_node_rpc_listen_address, validator_grpc_listen_address: full_node_grpc_listen_address, validator_cookie_auth: false, validator_cookie_path: None, diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 95e50a3d2..8c061f2ae 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -19,7 +19,7 @@ use tracing::{error, info}; use zaino_common::{ CacheConfig, DatabaseConfig, DatabaseSize, Network, ServiceConfig, StorageConfig, }; -use zaino_serve::server::config::{GrpcConfig, JsonRpcServerConfig}; +use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; /// Custom deserialization function for `SocketAddr` from a String. @@ -60,25 +60,16 @@ pub struct IndexerConfig { #[serde(serialize_with = "serialize_backendtype_to_string")] pub backend: zaino_state::BackendType, // TODO later, create what were called "sections" - /// Enable JsonRPC server. + /// Enable JsonRPC server with a valid Some value. #[serde(default)] pub json_server_settings: Option, - // Some is true - // pub enable_json_server: bool, - // /// Server bind addr. // TODO commenting out : for rpc listen #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - // pub json_rpc_listen_address: SocketAddr, - // /// Enable cookie-based authentication. - // pub enable_cookie_auth: bool, - // /// Directory to store authentication cookie file. - // pub cookie_dir: Option, - // TODO end here, I believe - // /// gRPC server settings including listen addr, tls status, key and cert. - pub grpc_settings: GrpcConfig, + pub grpc_settings: GrpcServerConfig, + /// Full node / validator listen port. #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub validator_listen_address: SocketAddr, + pub validator_jsonrpc_listen_address: SocketAddr, /// Full node / validator gprc listen port. #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub validator_grpc_listen_address: SocketAddr, @@ -90,6 +81,7 @@ pub struct IndexerConfig { pub validator_user: Option, /// full node / validator Password. pub validator_password: Option, + /// Service-level configuration (timeout, channel size). pub service: ServiceConfig, /// Storage configuration (cache and database). @@ -160,7 +152,7 @@ impl IndexerConfig { fetch_socket_addr_from_hostname(&self.grpc_settings.listen_address.to_string())?; let validator_addr = - fetch_socket_addr_from_hostname(&self.validator_listen_address.to_string())?; + fetch_socket_addr_from_hostname(&self.validator_jsonrpc_listen_address.to_string())?; // Ensure validator listen address is private. if !is_private_listen_addr(&validator_addr) { @@ -222,15 +214,11 @@ impl Default for IndexerConfig { Self { backend: zaino_state::BackendType::Fetch, json_server_settings: None, - // enable_json_server: false, - // json_rpc_listen_address: "127.0.0.1:8237".parse().unwrap(), - // enable_cookie_auth: false, - // cookie_dir: None, - grpc_settings: GrpcConfig { + grpc_settings: GrpcServerConfig { listen_address: "127.0.0.1:8137".parse().unwrap(), tls: None, }, - validator_listen_address: "127.0.0.1:18232".parse().unwrap(), + validator_jsonrpc_listen_address: "127.0.0.1:18232".parse().unwrap(), validator_grpc_listen_address: "127.0.0.1:18230".parse().unwrap(), validator_cookie_auth: false, validator_cookie_path: None, @@ -391,7 +379,7 @@ impl TryFrom for BackendConfig { debug_stop_at_height: None, debug_validity_check_interval: None, }, - validator_rpc_address: cfg.validator_listen_address, + validator_rpc_address: cfg.validator_jsonrpc_listen_address, validator_indexer_rpc_address: cfg.validator_grpc_listen_address, validator_cookie_auth: cfg.validator_cookie_auth, validator_cookie_path: cfg.validator_cookie_path, @@ -406,7 +394,7 @@ impl TryFrom for BackendConfig { })), zaino_state::BackendType::Fetch => Ok(BackendConfig::Fetch(FetchServiceConfig { - validator_rpc_address: cfg.validator_listen_address, + validator_rpc_address: cfg.validator_jsonrpc_listen_address, validator_cookie_auth: cfg.validator_cookie_auth, validator_cookie_path: cfg.validator_cookie_path, validator_rpc_user: cfg.validator_user.unwrap_or_else(|| "xxxxxx".to_string()), diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index b85c297b0..d088bb126 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -6,7 +6,7 @@ use tracing::info; use zaino_fetch::jsonrpsee::connector::test_node_and_return_url; use zaino_serve::server::{ // TODO see: config here - config::GrpcConfig, + config::GrpcServerConfig, grpc::TonicServer, // TODO vs Server here jsonrpc::JsonRpcServer, @@ -48,7 +48,7 @@ pub async fn spawn_indexer( config.check_config()?; info!("Checking connection with node.."); let zebrad_uri = test_node_and_return_url( - config.validator_listen_address, + config.validator_jsonrpc_listen_address, config.validator_cookie_auth, config.validator_cookie_path.clone(), config.validator_user.clone(), @@ -92,7 +92,7 @@ where let grpc_server = TonicServer::spawn( service.inner_ref().get_subscriber(), - GrpcConfig { + GrpcServerConfig { listen_address: indexer_config.grpc_settings.listen_address, tls: indexer_config.grpc_settings.tls, }, From 6f3ffae68da0c378085bdd267ac9dbd427251bc1 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 00:57:37 -0400 Subject: [PATCH 087/162] add validator in zaino-common lib --- zaino-common/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zaino-common/src/lib.rs b/zaino-common/src/lib.rs index f90dd3e6f..7df3109b5 100644 --- a/zaino-common/src/lib.rs +++ b/zaino-common/src/lib.rs @@ -6,8 +6,10 @@ pub mod network; pub mod service; pub mod storage; +pub mod validator; // Re-export commonly used types for convenience pub use network::Network; pub use service::ServiceConfig; pub use storage::{CacheConfig, DatabaseConfig, DatabaseSize, StorageConfig}; +pub use validator::Validator; From 2318ecfbe273d474144ef150eefefce01905dfe4 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 04:28:02 -0400 Subject: [PATCH 088/162] update comments in zainod indexer --- zainod/src/indexer.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index d088bb126..41003eac4 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -1,16 +1,10 @@ -//! Zingo-Indexer implementation. +//! Zaino : Zingo-Indexer implementation. use tokio::time::Instant; use tracing::info; use zaino_fetch::jsonrpsee::connector::test_node_and_return_url; -use zaino_serve::server::{ - // TODO see: config here - config::GrpcServerConfig, - grpc::TonicServer, - // TODO vs Server here - jsonrpc::JsonRpcServer, -}; +use zaino_serve::server::{config::GrpcServerConfig, grpc::TonicServer, jsonrpc::JsonRpcServer}; use zaino_state::{ BackendConfig, FetchService, IndexerService, LightWalletService, StateService, StatusType, ZcashIndexer, ZcashService, @@ -18,7 +12,7 @@ use zaino_state::{ use crate::{config::IndexerConfig, error::IndexerError}; -/// Zingo-Indexer. +/// Zaino, the Zingo-Indexer. pub struct Indexer { /// JsonRPC server. /// From 81e805404a0cdba73ca70cab5075afbb23ad0279 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 04:45:06 -0400 Subject: [PATCH 089/162] change ValidatorConfig enum in testutils to ValidatorTestConfig --- zaino-testutils/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 9f9f19ce6..a29ce19e9 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -137,7 +137,7 @@ pub enum ValidatorKind { } /// Config for validators. -pub enum ValidatorConfig { +pub enum ValidatorTestConfig { /// Zcashd Config. ZcashdConfig(ZcashdConfig), /// Zebrad Config. @@ -170,7 +170,7 @@ impl zcash_local_net::validator::Validator for LocalNet { const CONFIG_FILENAME: &str = ""; const PROCESS: zcash_local_net::Process = zcash_local_net::Process::Empty; // todo - type Config = ValidatorConfig; + type Config = ValidatorTestConfig; fn default_test_config() -> Self::Config { todo!() @@ -194,7 +194,7 @@ impl zcash_local_net::validator::Validator for LocalNet { { async move { match config { - ValidatorConfig::ZcashdConfig(cfg) => { + ValidatorTestConfig::ZcashdConfig(cfg) => { let net = zcash_local_net::LocalNet::< zcash_local_net::indexer::Empty, zcash_local_net::validator::Zcashd, @@ -204,7 +204,7 @@ impl zcash_local_net::validator::Validator for LocalNet { .await; Ok(LocalNet::Zcashd(net)) } - ValidatorConfig::ZebradConfig(cfg) => { + ValidatorTestConfig::ZebradConfig(cfg) => { let net = zcash_local_net::LocalNet::< zcash_local_net::indexer::Empty, zcash_local_net::validator::Zebrad, @@ -435,7 +435,7 @@ impl TestManager { cfg.rpc_listen_port = Some(rpc_listen_port); cfg.configured_activation_heights = activation_heights.into(); cfg.chain_cache = chain_cache.clone(); - ValidatorConfig::ZcashdConfig(cfg) + ValidatorTestConfig::ZcashdConfig(cfg) } ValidatorKind::Zebrad => { let mut cfg = ZebradConfig::default_test(); @@ -444,7 +444,7 @@ impl TestManager { cfg.configured_activation_heights = activation_heights.into(); cfg.chain_cache = chain_cache.clone(); cfg.network = network_kind; - ValidatorConfig::ZebradConfig(cfg) + ValidatorTestConfig::ZebradConfig(cfg) } }; let local_net = LocalNet::launch(validator_config).await.unwrap(); @@ -496,6 +496,7 @@ impl TestManager { listen_address: zaino_grpc_listen_address, tls: None, }, + validator_settings: ValidatorTestConfig validator_jsonrpc_listen_address: full_node_rpc_listen_address, validator_grpc_listen_address: full_node_grpc_listen_address, validator_cookie_auth: false, From ac3b982c4c23132b1db155bced3f1f32b5f0c0e5 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 04:46:57 -0400 Subject: [PATCH 090/162] WIP change logic to ValidatorConfig in IndexerConfig declaration --- zaino-testutils/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index a29ce19e9..1411f6a91 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -496,7 +496,7 @@ impl TestManager { listen_address: zaino_grpc_listen_address, tls: None, }, - validator_settings: ValidatorTestConfig + validator_settings: ValidatorConfig {} validator_jsonrpc_listen_address: full_node_rpc_listen_address, validator_grpc_listen_address: full_node_grpc_listen_address, validator_cookie_auth: false, From d1b433851f2a7fe3363720e23a53e8ca6d8cba96 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 05:13:00 -0400 Subject: [PATCH 091/162] enable ValidatorConfig in IndexerConfig --- zainod/src/config.rs | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 8c061f2ae..6bdea45a6 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -18,6 +18,7 @@ use tracing::warn; use tracing::{error, info}; use zaino_common::{ CacheConfig, DatabaseConfig, DatabaseSize, Network, ServiceConfig, StorageConfig, + ValidatorConfig, }; use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; @@ -66,22 +67,25 @@ pub struct IndexerConfig { // TODO commenting out : for rpc listen #[serde(deserialize_with = "deserialize_socketaddr_from_string")] /// gRPC server settings including listen addr, tls status, key and cert. pub grpc_settings: GrpcServerConfig, + // TODO this should be an Option() + validator_settings: ValidatorConfig, - /// Full node / validator listen port. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub validator_jsonrpc_listen_address: SocketAddr, - /// Full node / validator gprc listen port. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub validator_grpc_listen_address: SocketAddr, - /// Enable validator rpc cookie authentification. - pub validator_cookie_auth: bool, - /// Path to the validator cookie file. - pub validator_cookie_path: Option, - /// Full node / validator Username. - pub validator_user: Option, - /// full node / validator Password. - pub validator_password: Option, - + /* + /// Full node / validator listen port. + #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + pub validator_jsonrpc_listen_address: SocketAddr, + /// Full node / validator gprc listen port. + #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + pub validator_grpc_listen_address: SocketAddr, + /// Enable validator rpc cookie authentification. + pub validator_cookie_auth: bool, + /// Path to the validator cookie file. + pub validator_cookie_path: Option, + /// Full node / validator Username. + pub validator_user: Option, + /// full node / validator Password. + pub validator_password: Option, + */ /// Service-level configuration (timeout, channel size). pub service: ServiceConfig, /// Storage configuration (cache and database). @@ -89,6 +93,7 @@ pub struct IndexerConfig { /// Block Cache database file path. /// /// ZebraDB location. + // TODO seems to overlap with Storageconfig pub zebra_db_path: PathBuf, /// Network chain type. pub network: Network, @@ -132,8 +137,8 @@ impl IndexerConfig { } // Check validator cookie authentication settings - if self.validator_cookie_auth { - if let Some(ref cookie_path) = self.validator_cookie_path { + if self.validator_settings.validator_cookie_path.is_some() { + if let Some(ref cookie_path) = self.validator_settings.validator_cookie_path { if !std::path::Path::new(cookie_path).exists() { return Err(IndexerError::ConfigError( format!("Validator cookie authentication is enabled, but cookie path '{cookie_path}' does not exist."), From 87a4aa39d5a051b58a1b9167e163c8b72311ff3e Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 05:13:37 -0400 Subject: [PATCH 092/162] update use in zaino-common lib --- zaino-common/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-common/src/lib.rs b/zaino-common/src/lib.rs index 7df3109b5..5ded4262b 100644 --- a/zaino-common/src/lib.rs +++ b/zaino-common/src/lib.rs @@ -12,4 +12,4 @@ pub mod validator; pub use network::Network; pub use service::ServiceConfig; pub use storage::{CacheConfig, DatabaseConfig, DatabaseSize, StorageConfig}; -pub use validator::Validator; +pub use validator::ValidatorConfig; From e597fa723d3799e1e031f1d5a8963e064aea6b9e Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 05:14:28 -0400 Subject: [PATCH 093/162] fill in ValidatorConfig in testutils --- zaino-testutils/src/lib.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 1411f6a91..c2125440e 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -16,7 +16,8 @@ use std::{ use tempfile::TempDir; use tracing_subscriber::EnvFilter; use zaino_common::{ - network::ActivationHeights, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, + network::ActivationHeights, validator::ValidatorConfig, CacheConfig, DatabaseConfig, Network, + ServiceConfig, StorageConfig, }; use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::BackendType; @@ -496,13 +497,13 @@ impl TestManager { listen_address: zaino_grpc_listen_address, tls: None, }, - validator_settings: ValidatorConfig {} - validator_jsonrpc_listen_address: full_node_rpc_listen_address, - validator_grpc_listen_address: full_node_grpc_listen_address, - validator_cookie_auth: false, - validator_cookie_path: None, - validator_user: Some("xxxxxx".to_string()), - validator_password: Some("xxxxxx".to_string()), + validator_settings: ValidatorConfig { + validator_jsonrpc_listen_address: full_node_rpc_listen_address, + validator_grpc_listen_address: full_node_grpc_listen_address, + validator_cookie_path: None, + validator_user: Some("xxxxxx".to_string()), + validator_password: Some("xxxxxx".to_string()), + }, service: ServiceConfig::default(), storage: StorageConfig { cache: CacheConfig::default(), From ce100b56e380b8db2a1cde7a7ec87713fca4efee Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 05:50:32 -0400 Subject: [PATCH 094/162] removing enable cookie auth --- integration-tests/tests/fetch_service.rs | 1 - integration-tests/tests/json_server.rs | 4 +--- integration-tests/tests/state_service.rs | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 308865607..77162721d 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -44,7 +44,6 @@ async fn create_test_manager_and_fetch_service( let fetch_service = FetchService::spawn(FetchServiceConfig::new( test_manager.full_node_rpc_listen_address, - false, None, None, None, diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 372ab8a43..a6cdab113 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -12,7 +12,7 @@ use zebra_chain::subtree::NoteCommitmentSubtreeIndex; use zebra_rpc::methods::{AddressStrings, GetAddressTxIdsRequest, GetInfo}; async fn create_test_manager_and_fetch_services( - enable_cookie_auth: bool, + _enable_cookie_auth: bool, clients: bool, ) -> ( TestManager, @@ -41,7 +41,6 @@ async fn create_test_manager_and_fetch_services( println!("Launching zcashd fetch service.."); let zcashd_fetch_service = FetchService::spawn(FetchServiceConfig::new( test_manager.full_node_rpc_listen_address, - false, None, None, None, @@ -71,7 +70,6 @@ async fn create_test_manager_and_fetch_services( let zaino_json_server_address = dbg!(test_manager.zaino_json_rpc_listen_address.unwrap()); let zaino_fetch_service = FetchService::spawn(FetchServiceConfig::new( zaino_json_server_address, - enable_cookie_auth, test_manager .json_server_cookie_dir .clone() diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index 8d73a450f..21977ed53 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -61,7 +61,6 @@ async fn create_test_manager_and_services( let fetch_service = FetchService::spawn(FetchServiceConfig::new( test_manager.full_node_rpc_listen_address, - false, None, None, None, From 850226d851d6ff096237065e590649a13a1e7fbd Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 05:51:23 -0400 Subject: [PATCH 095/162] renaming validator config in state to ValidatorStateConfig --- zaino-state/src/config.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index af258a82c..0716f2257 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -25,7 +25,7 @@ pub enum BackendConfig { #[derive(Debug, Clone)] pub struct StateServiceConfig { /// Zebra [`zebra_state::ReadStateService`] config data - pub validator_config: zebra_state::Config, + pub validator_state_config: zebra_state::Config, /// Validator JsonRPC address. pub validator_rpc_address: std::net::SocketAddr, /// Validator gRPC address. @@ -54,7 +54,7 @@ impl StateServiceConfig { #[allow(clippy::too_many_arguments)] // TODO: replace with struct-literal init only? pub fn new( - validator_config: zebra_state::Config, + validator_state_config: zebra_state::Config, validator_rpc_address: std::net::SocketAddr, validator_indexer_rpc_address: std::net::SocketAddr, validator_cookie_auth: bool, @@ -67,7 +67,7 @@ impl StateServiceConfig { no_sync: bool, ) -> Self { StateServiceConfig { - validator_config, + validator_state_config, validator_rpc_address, validator_indexer_rpc_address, validator_cookie_auth, @@ -87,9 +87,10 @@ impl StateServiceConfig { pub struct FetchServiceConfig { /// Validator JsonRPC address. pub validator_rpc_address: std::net::SocketAddr, - /// Enable validator rpc cookie authentification. - pub validator_cookie_auth: bool, + // pub validator_cookie_auth: bool, + /// Enable validator rpc cookie authentification with Some. /// Path to the validator cookie file. + // TODO change to PathBuf pub validator_cookie_path: Option, /// Validator JsonRPC user. pub validator_rpc_user: String, @@ -112,7 +113,6 @@ impl FetchServiceConfig { // TODO: replace with struct-literal init only? pub fn new( validator_rpc_address: std::net::SocketAddr, - validator_cookie_auth: bool, validator_cookie_path: Option, validator_rpc_user: Option, validator_rpc_password: Option, @@ -123,7 +123,6 @@ impl FetchServiceConfig { ) -> Self { FetchServiceConfig { validator_rpc_address, - validator_cookie_auth, validator_cookie_path, validator_rpc_user: validator_rpc_user.unwrap_or("xxxxxx".to_string()), validator_rpc_password: validator_rpc_password.unwrap_or("xxxxxx".to_string()), From e417b29fe73fd53f6a1dc4f11fdfeb5d79dde4d3 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 05:52:10 -0400 Subject: [PATCH 096/162] update zainod config with new ValidatorConfig --- zainod/src/config.rs | 51 +++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 6bdea45a6..630a3b3ca 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -156,8 +156,12 @@ impl IndexerConfig { let grpc_addr = fetch_socket_addr_from_hostname(&self.grpc_settings.listen_address.to_string())?; - let validator_addr = - fetch_socket_addr_from_hostname(&self.validator_jsonrpc_listen_address.to_string())?; + let validator_addr = fetch_socket_addr_from_hostname( + &self + .validator_settings + .validator_jsonrpc_listen_address + .to_string(), + )?; // Ensure validator listen address is private. if !is_private_listen_addr(&validator_addr) { @@ -176,7 +180,9 @@ impl IndexerConfig { } // Ensure validator rpc cookie authentication is used when connecting to non-loopback addresses. - if !is_loopback_listen_addr(&validator_addr) && !self.validator_cookie_auth { + if !is_loopback_listen_addr(&validator_addr) + && self.validator_settings.validator_cookie_path.is_none() + { return Err(IndexerError::ConfigError( "Validator listen address is not loopback, so cookie authentication must be enabled." .to_string(), @@ -223,12 +229,13 @@ impl Default for IndexerConfig { listen_address: "127.0.0.1:8137".parse().unwrap(), tls: None, }, - validator_jsonrpc_listen_address: "127.0.0.1:18232".parse().unwrap(), - validator_grpc_listen_address: "127.0.0.1:18230".parse().unwrap(), - validator_cookie_auth: false, - validator_cookie_path: None, - validator_user: Some("xxxxxx".to_string()), - validator_password: Some("xxxxxx".to_string()), + validator_settings: ValidatorConfig { + validator_grpc_listen_address: "127.0.0.1:18230".parse().unwrap(), + validator_jsonrpc_listen_address: "127.0.0.1:18232".parse().unwrap(), + validator_cookie_path: None, + validator_user: Some("xxxxxx".to_string()), + validator_password: Some("xxxxxx".to_string()), + }, service: ServiceConfig::default(), storage: StorageConfig { cache: CacheConfig::default(), @@ -377,19 +384,22 @@ impl TryFrom for BackendConfig { fn try_from(cfg: IndexerConfig) -> Result { match cfg.backend { zaino_state::BackendType::State => Ok(BackendConfig::State(StateServiceConfig { - validator_config: zebra_state::Config { + validator_state_config: zebra_state::Config { cache_dir: cfg.zebra_db_path.clone(), ephemeral: false, delete_old_database: true, debug_stop_at_height: None, debug_validity_check_interval: None, }, - validator_rpc_address: cfg.validator_jsonrpc_listen_address, - validator_indexer_rpc_address: cfg.validator_grpc_listen_address, - validator_cookie_auth: cfg.validator_cookie_auth, - validator_cookie_path: cfg.validator_cookie_path, - validator_rpc_user: cfg.validator_user.unwrap_or_else(|| "xxxxxx".to_string()), + validator_rpc_address: cfg.validator_settings.validator_jsonrpc_listen_address, + validator_indexer_rpc_address: cfg.validator_settings.validator_grpc_listen_address, + validator_cookie_path: cfg.validator_settings.validator_cookie_path, + validator_rpc_user: cfg + .validator_settings + .validator_user + .unwrap_or_else(|| "xxxxxx".to_string()), validator_rpc_password: cfg + .validator_settings .validator_password .unwrap_or_else(|| "xxxxxx".to_string()), service: cfg.service, @@ -399,11 +409,14 @@ impl TryFrom for BackendConfig { })), zaino_state::BackendType::Fetch => Ok(BackendConfig::Fetch(FetchServiceConfig { - validator_rpc_address: cfg.validator_jsonrpc_listen_address, - validator_cookie_auth: cfg.validator_cookie_auth, - validator_cookie_path: cfg.validator_cookie_path, - validator_rpc_user: cfg.validator_user.unwrap_or_else(|| "xxxxxx".to_string()), + validator_rpc_address: cfg.validator_settings.validator_jsonrpc_listen_address, + validator_cookie_path: cfg.validator_settings.validator_cookie_path, + validator_rpc_user: cfg + .validator_settings + .validator_user + .unwrap_or_else(|| "xxxxxx".to_string()), validator_rpc_password: cfg + .validator_settings .validator_password .unwrap_or_else(|| "xxxxxx".to_string()), service: cfg.service, From f31fbb9ed32086eaebc26df2317ffd87d00c5492 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 06:01:03 -0400 Subject: [PATCH 097/162] WIP removing cookie auth from stateservice --- zaino-state/src/backends/fetch.rs | 1 - zaino-state/src/backends/state.rs | 3 +-- zaino-state/src/config.rs | 6 ++---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/zaino-state/src/backends/fetch.rs b/zaino-state/src/backends/fetch.rs index 2bafd9d78..926b387e8 100644 --- a/zaino-state/src/backends/fetch.rs +++ b/zaino-state/src/backends/fetch.rs @@ -89,7 +89,6 @@ impl ZcashService for FetchService { info!("Launching Chain Fetch Service.."); let fetcher = JsonRpSeeConnector::new_from_config_parts( - config.validator_cookie_auth, config.validator_rpc_address, config.validator_rpc_user.clone(), config.validator_rpc_password.clone(), diff --git a/zaino-state/src/backends/state.rs b/zaino-state/src/backends/state.rs index 19b48f655..64665a64e 100644 --- a/zaino-state/src/backends/state.rs +++ b/zaino-state/src/backends/state.rs @@ -162,7 +162,6 @@ impl ZcashService for StateService { info!("Launching Chain Fetch Service.."); let rpc_client = JsonRpSeeConnector::new_from_config_parts( - config.validator_cookie_auth, config.validator_rpc_address, config.validator_rpc_user.clone(), config.validator_rpc_password.clone(), @@ -210,7 +209,7 @@ impl ZcashService for StateService { info!("Launching Chain Syncer.."); let (mut read_state_service, _latest_chain_tip, chain_tip_change, sync_task_handle) = init_read_state_with_syncer( - config.validator_config.clone(), + config.validator_state_config.clone(), &config.network.to_zebra_network(), config.validator_indexer_rpc_address, ) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index 0716f2257..a6475884c 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -30,8 +30,8 @@ pub struct StateServiceConfig { pub validator_rpc_address: std::net::SocketAddr, /// Validator gRPC address. pub validator_indexer_rpc_address: std::net::SocketAddr, - /// Enable validator rpc cookie authentification. - pub validator_cookie_auth: bool, + // pub validator_cookie_auth: bool, + /// Enable validator rpc cookie authentification with Some. /// Path to the validator cookie file. pub validator_cookie_path: Option, /// Validator JsonRPC user. @@ -57,7 +57,6 @@ impl StateServiceConfig { validator_state_config: zebra_state::Config, validator_rpc_address: std::net::SocketAddr, validator_indexer_rpc_address: std::net::SocketAddr, - validator_cookie_auth: bool, validator_cookie_path: Option, validator_rpc_user: Option, validator_rpc_password: Option, @@ -70,7 +69,6 @@ impl StateServiceConfig { validator_state_config, validator_rpc_address, validator_indexer_rpc_address, - validator_cookie_auth, validator_cookie_path, validator_rpc_user: validator_rpc_user.unwrap_or("xxxxxx".to_string()), validator_rpc_password: validator_rpc_password.unwrap_or("xxxxxx".to_string()), From a2c13aef9fbe066680869560940dfcfd05be1d37 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 06:10:58 -0400 Subject: [PATCH 098/162] WIP remove cookie bool from test_node_and_return_url() --- integration-tests/tests/chain_cache.rs | 1 - integration-tests/tests/fetch_service.rs | 6 ------ integration-tests/tests/local_cache.rs | 1 - integration-tests/tests/wallet_to_validator.rs | 2 -- zaino-fetch/src/jsonrpsee/connector.rs | 8 ++------ zainod/src/indexer.rs | 1 - 6 files changed, 2 insertions(+), 17 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index 0dfad5b0f..eec899262 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -29,7 +29,6 @@ async fn create_test_manager_and_connector( let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 77162721d..21f78a109 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -184,7 +184,6 @@ async fn fetch_service_get_raw_mempool(validator: &ValidatorKind) { let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), @@ -554,7 +553,6 @@ async fn fetch_service_get_latest_block(validator: &ValidatorKind) { let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), @@ -594,7 +592,6 @@ async fn assert_fetch_service_difficulty_matches_rpc(validator: &ValidatorKind) let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), @@ -619,7 +616,6 @@ async fn assert_fetch_service_peerinfo_matches_rpc(validator: &ValidatorKind) { let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), @@ -653,7 +649,6 @@ async fn fetch_service_get_block_subsidy(validator: &ValidatorKind) { let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), @@ -1422,7 +1417,6 @@ async fn assert_fetch_service_getnetworksols_matches_rpc(validator: &ValidatorKi let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index 782d86cd5..d3a3b15bc 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -44,7 +44,6 @@ async fn create_test_manager_and_block_cache( let json_service = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index fb20af5d9..1db6907f4 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -143,7 +143,6 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { let fetch_service = zaino_fetch::jsonrpsee::connector::JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), @@ -438,7 +437,6 @@ async fn monitor_unverified_mempool_for_validator( let fetch_service = zaino_fetch::jsonrpsee::connector::JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( test_manager.full_node_rpc_listen_address, - false, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), diff --git a/zaino-fetch/src/jsonrpsee/connector.rs b/zaino-fetch/src/jsonrpsee/connector.rs index 46ce0c999..28ea888c4 100644 --- a/zaino-fetch/src/jsonrpsee/connector.rs +++ b/zaino-fetch/src/jsonrpsee/connector.rs @@ -226,17 +226,15 @@ impl JsonRpSeeConnector { /// Helper function to create from parts of a StateServiceConfig or /// FetchServiceConfig pub async fn new_from_config_parts( - validator_cookie_auth: bool, validator_rpc_address: SocketAddr, validator_rpc_user: String, validator_rpc_password: String, validator_cookie_path: Option, ) -> Result { - match validator_cookie_auth { + match validator_cookie_path.is_some() { true => JsonRpSeeConnector::new_with_cookie_auth( test_node_and_return_url( validator_rpc_address, - validator_cookie_auth, validator_cookie_path.clone(), None, None, @@ -251,7 +249,6 @@ impl JsonRpSeeConnector { false => JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( validator_rpc_address, - false, None, Some(validator_rpc_user.clone()), Some(validator_rpc_password.clone()), @@ -807,12 +804,11 @@ async fn test_node_connection(url: Url, auth_method: AuthMethod) -> Result<(), T /// Tries to connect to zebrad/zcashd using the provided SocketAddr and returns the correct URL. pub async fn test_node_and_return_url( addr: SocketAddr, - rpc_cookie_auth: bool, cookie_path: Option, user: Option, password: Option, ) -> Result { - let auth_method = match rpc_cookie_auth { + let auth_method = match cookie_path.is_some() { true => { let cookie_file_path_str = cookie_path.expect("validator rpc cookie path missing"); let cookie_password = read_and_parse_cookie_token(Path::new(&cookie_file_path_str))?; diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 41003eac4..9c91f17b5 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -43,7 +43,6 @@ pub async fn spawn_indexer( info!("Checking connection with node.."); let zebrad_uri = test_node_and_return_url( config.validator_jsonrpc_listen_address, - config.validator_cookie_auth, config.validator_cookie_path.clone(), config.validator_user.clone(), config.validator_password.clone(), From 449a5797bc3f4d0489d6d3f32accf099e64156ac Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 06:12:55 -0400 Subject: [PATCH 099/162] WIP test_node_and_return_url --- zainod/src/indexer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 9c91f17b5..ee676c585 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -42,10 +42,10 @@ pub async fn spawn_indexer( config.check_config()?; info!("Checking connection with node.."); let zebrad_uri = test_node_and_return_url( - config.validator_jsonrpc_listen_address, - config.validator_cookie_path.clone(), - config.validator_user.clone(), - config.validator_password.clone(), + config.validator_settings.validator_jsonrpc_listen_address, + config.validator_settings.validator_cookie_path.clone(), + config.validator_settings.validator_user.clone(), + config.validator_settings.validator_password.clone(), ) .await?; From 09605657f2ffe8c2ad6aef5c5045876c4b25a4a2 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 06:14:00 -0400 Subject: [PATCH 100/162] pub validator_settings --- zainod/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 630a3b3ca..760ad8689 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -68,7 +68,7 @@ pub struct IndexerConfig { /// gRPC server settings including listen addr, tls status, key and cert. pub grpc_settings: GrpcServerConfig, // TODO this should be an Option() - validator_settings: ValidatorConfig, + pub validator_settings: ValidatorConfig, /* /// Full node / validator listen port. From 46c5132a72d1c6001db2c3ca3b8a9a6c08e05ac5 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 06:15:06 -0400 Subject: [PATCH 101/162] doc comment --- zainod/src/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 760ad8689..64587cdda 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -68,6 +68,7 @@ pub struct IndexerConfig { /// gRPC server settings including listen addr, tls status, key and cert. pub grpc_settings: GrpcServerConfig, // TODO this should be an Option() + /// Full node / validator configuration settings. pub validator_settings: ValidatorConfig, /* From 544379811c6d0bdc8da7535233573d1cddaf7740 Mon Sep 17 00:00:00 2001 From: al amoda Date: Thu, 16 Oct 2025 06:26:13 -0400 Subject: [PATCH 102/162] update tests with new ValidatorConfig --- zainod/tests/config.rs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 87a900d7f..09fb1e710 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -111,7 +111,7 @@ fn test_deserialize_full_valid_config() { PathBuf::from(key_file_name) ); assert_eq!( - finalized_config.validator_cookie_path, + finalized_config.validator_settings.validator_cookie_path, Some(validator_cookie_file_name.to_string()) ); assert_eq!( @@ -128,9 +128,12 @@ fn test_deserialize_full_valid_config() { "0.0.0.0:9000".parse().unwrap() ); assert!(finalized_config.grpc_settings.tls.is_some()); - assert_eq!(finalized_config.validator_user, Some("user".to_string())); assert_eq!( - finalized_config.validator_password, + finalized_config.validator_settings.validator_user, + Some("user".to_string()) + ); + assert_eq!( + finalized_config.validator_settings.validator_password, Some("password".to_string()) ); assert_eq!(finalized_config.storage.cache.capacity, 10000); @@ -170,8 +173,14 @@ fn test_deserialize_optional_fields_missing() { assert_eq!(config.backend, ZainoBackendType::State); // assert_eq!(config.enable_json_server, default_values.enable_json_server); - assert_eq!(config.validator_user, default_values.validator_user); - assert_eq!(config.validator_password, default_values.validator_password); + assert_eq!( + config.validator_settings.validator_user, + default_values.validator_settings.validator_user + ); + assert_eq!( + config.validator_settings.validator_password, + default_values.validator_settings.validator_password + ); assert_eq!( config.storage.cache.capacity, default_values.storage.cache.capacity @@ -334,8 +343,14 @@ fn test_deserialize_empty_string_yields_default() { assert_eq!(config.network, default_config.network); assert_eq!(config.backend, default_config.backend); // assert_eq!(config.enable_json_server, default_config.enable_json_server); - assert_eq!(config.validator_user, default_config.validator_user); - assert_eq!(config.validator_password, default_config.validator_password); + assert_eq!( + config.validator_settings.validator_user, + default_config.validator_settings.validator_user + ); + assert_eq!( + config.validator_settings.validator_password, + default_config.validator_settings.validator_password + ); assert_eq!( config.storage.cache.capacity, default_config.storage.cache.capacity @@ -412,7 +427,10 @@ fn test_parse_zindexer_toml_integration() { let defaults = IndexerConfig::default(); assert_eq!(config.backend, ZainoBackendType::Fetch); - assert_eq!(config.validator_user, defaults.validator_user); + assert_eq!( + config.validator_settings.validator_user, + defaults.validator_settings.validator_user + ); Ok(()) }); From 855ae3244c91ff716e6fcae67890adfd43ddf0e4 Mon Sep 17 00:00:00 2001 From: nachog00 Date: Thu, 16 Oct 2025 13:43:17 -0300 Subject: [PATCH 103/162] rename INdexerConfig -> ZainodConfig --- zaino-testutils/src/lib.rs | 2 +- zainod/src/config.rs | 16 ++++++++-------- zainod/src/indexer.rs | 8 ++++---- zainod/tests/config.rs | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index c2125440e..292f7bb14 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -478,7 +478,7 @@ impl TestManager { let zaino_json_server_cookie_dir = default_ephemeral_cookie_path(); // then here we custom-set an entire, whole new config - let indexer_config = zainodlib::config::IndexerConfig { + let indexer_config = zainodlib::config::ZainodConfig { // TODO: Make configurable. backend: *backend, json_server_settings: if enable_zaino_jsonrpc_server { diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 64587cdda..12363cb62 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -55,7 +55,7 @@ where /// Config information required for Zaino. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(default)] -pub struct IndexerConfig { +pub struct ZainodConfig { /// Type of backend to be used. #[serde(deserialize_with = "deserialize_backendtype_from_string")] #[serde(serialize_with = "serialize_backendtype_to_string")] @@ -103,7 +103,7 @@ pub struct IndexerConfig { pub no_sync: bool, } -impl IndexerConfig { +impl ZainodConfig { /// Performs checks on config data. pub(crate) fn check_config(&self) -> Result<(), IndexerError> { // Network type is validated at the type level via Network enum. @@ -221,7 +221,7 @@ impl IndexerConfig { } } -impl Default for IndexerConfig { +impl Default for ZainodConfig { fn default() -> Self { Self { backend: zaino_state::BackendType::Fetch, @@ -328,17 +328,17 @@ pub(crate) fn is_loopback_listen_addr(addr: &SocketAddr) -> bool { /// The loaded or default configuration undergoes further checks and finalization. // TODO my problems must be here, where configs read in as files are adapted based on env vars // see step 3 below -pub fn load_config(file_path: &PathBuf) -> Result { +pub fn load_config(file_path: &PathBuf) -> Result { // Configuration sources are layered: Env > TOML > Defaults. let figment = Figment::new() // 1. Base defaults from `IndexerConfig::default()`. - .merge(Serialized::defaults(IndexerConfig::default())) + .merge(Serialized::defaults(ZainodConfig::default())) // 2. Override with values from the TOML configuration file. .merge(Toml::file(file_path)) // 3. Override with values from environment variables prefixed with "ZAINO_". .merge(figment::providers::Env::prefixed("ZAINO_").split("-")); - match figment.extract::() { + match figment.extract::() { Ok(mut parsed_config) => { // Finalizes the configuration after initial parsing, applying conditional default to json rpc cookie dir, // if the assigned pathbuf is empty (cookies enabled but no path defined). @@ -379,10 +379,10 @@ pub fn load_config(file_path: &PathBuf) -> Result { } } -impl TryFrom for BackendConfig { +impl TryFrom for BackendConfig { type Error = IndexerError; - fn try_from(cfg: IndexerConfig) -> Result { + fn try_from(cfg: ZainodConfig) -> Result { match cfg.backend { zaino_state::BackendType::State => Ok(BackendConfig::State(StateServiceConfig { validator_state_config: zebra_state::Config { diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index ee676c585..a0c4ee22a 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -10,7 +10,7 @@ use zaino_state::{ ZcashIndexer, ZcashService, }; -use crate::{config::IndexerConfig, error::IndexerError}; +use crate::{config::ZainodConfig, error::IndexerError}; /// Zaino, the Zingo-Indexer. pub struct Indexer { @@ -28,7 +28,7 @@ pub struct Indexer { /// /// Currently only takes an IndexerConfig. pub async fn start_indexer( - config: IndexerConfig, + config: ZainodConfig, ) -> Result>, IndexerError> { startup_message(); info!("Starting Zaino.."); @@ -37,7 +37,7 @@ pub async fn start_indexer( /// Spawns a new Indexer server. pub async fn spawn_indexer( - config: IndexerConfig, + config: ZainodConfig, ) -> Result>, IndexerError> { config.check_config()?; info!("Checking connection with node.."); @@ -71,7 +71,7 @@ where /// Spawns a new Indexer server. pub async fn launch_inner( service_config: Service::Config, - indexer_config: IndexerConfig, + indexer_config: ZainodConfig, ) -> Result>, IndexerError> { let service = IndexerService::::spawn(service_config).await?; let json_server = match indexer_config.json_server_settings { diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 09fb1e710..ba08001c1 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use zaino_common::{DatabaseSize, Network}; // Use the explicit library name `zainodlib` as defined in Cargo.toml [lib] name. -use zainodlib::config::{load_config, IndexerConfig}; +use zainodlib::config::{load_config, ZainodConfig}; use zainodlib::error::IndexerError; // If BackendType is used directly in assertions beyond what IndexerConfig holds: use zaino_state::BackendType as ZainoBackendType; @@ -169,7 +169,7 @@ fn test_deserialize_optional_fields_missing() { jail.create_file(&temp_toml_path, toml_str)?; let config = load_config(&temp_toml_path).expect("load_config failed"); - let default_values = IndexerConfig::default(); + let default_values = ZainodConfig::default(); assert_eq!(config.backend, ZainoBackendType::State); // assert_eq!(config.enable_json_server, default_values.enable_json_server); @@ -338,7 +338,7 @@ fn test_deserialize_empty_string_yields_default() { let empty_toml_path = jail.directory().join("empty.toml"); jail.create_file(&empty_toml_path, "")?; let config = load_config(&empty_toml_path).expect("Empty TOML load failed"); - let default_config = IndexerConfig::default(); + let default_config = ZainodConfig::default(); // Compare relevant fields that should come from default assert_eq!(config.network, default_config.network); assert_eq!(config.backend, default_config.backend); @@ -424,7 +424,7 @@ fn test_parse_zindexer_toml_integration() { config_result.err() ); let config = config_result.unwrap(); - let defaults = IndexerConfig::default(); + let defaults = ZainodConfig::default(); assert_eq!(config.backend, ZainoBackendType::Fetch); assert_eq!( @@ -502,7 +502,7 @@ fn test_figment_all_defaults() { let temp_toml_path = jail.directory().join("empty_config.toml"); let config = load_config(&temp_toml_path).expect("load_config should succeed with empty toml"); - let defaults = IndexerConfig::default(); + let defaults = ZainodConfig::default(); assert_eq!(config.network, defaults.network); // assert_eq!(config.enable_json_server, defaults.enable_json_server); assert_eq!( From 6a56913afb41214143f497f0a41e7b9a89af01cc Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 19 Oct 2025 22:15:08 -0400 Subject: [PATCH 104/162] update zindexer config --- zainod/zindexer.toml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zainod/zindexer.toml b/zainod/zindexer.toml index 85679b4f7..f80a596ba 100644 --- a/zainod/zindexer.toml +++ b/zainod/zindexer.toml @@ -1,5 +1,7 @@ # Configuration for Zaino +# TODO this may break everything now. + # Backend: # Type of backend to use. Options are: @@ -10,13 +12,13 @@ backend = "fetch" # JsonRPC server config: # Enables JsonRPC server. -enable_json_server = false +# enable_json_server = false # JsonRPC server listen addr. json_rpc_listen_address = "127.0.0.1:8237" # Enables cookie-based authentication for JsonRPC server. -enable_cookie_auth = false +# enable_cookie_auth = false # Directory to store authentication cookie file. # If 'enable_cookie_auth' is true and this is omitted, a default ephemeral path (e.g., /tmp/zaino/.cookie or XDG_RUNTIME_DIR) will be used. @@ -31,7 +33,7 @@ enable_cookie_auth = false grpc_listen_address = "127.0.0.1:8137" # Enables TLS for the gRPC server. -grpc_tls = false +# grpc_tls = false # Path to the TLS certificate file in PEM format. # Required if `grpc_tls` is true. If omitted and grpc_tls is true, startup will fail. @@ -51,7 +53,7 @@ grpc_tls = false validator_listen_address = "127.0.0.1:18232" # Enable validator rpc cookie authentication. -validator_cookie_auth = false +# validator_cookie_auth = false # Path to the validator cookie file. # Required if `validator_cookie_auth` is true. If omitted and validator_cookie_auth is true, startup will fail. @@ -105,7 +107,7 @@ no_sync = false # # Only used by the FetchServic. # Used for testing. -no_db = false +# no_db = false # When enabled Zaino syncs it DB in the background, fetching data from the validator. # From 8841bee979f62c11522a95eecbe2bdf9c76f4124 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 00:53:38 -0400 Subject: [PATCH 105/162] zainod config test validator_settings toml update --- zainod/tests/config.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index ba08001c1..3d901aa1a 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -32,11 +32,6 @@ fn test_deserialize_full_valid_config() { let toml_str = format!( r#" backend = "fetch" - validator_listen_address = "192.168.1.10:18232" - validator_cookie_auth = true - validator_cookie_path = "{validator_cookie_file_name}" - validator_user = "user" - validator_password = "password" storage.database.path = "{zaino_db_dir_name}" zebra_db_path = "{zebra_db_dir_name}" db_size = 100 @@ -45,6 +40,12 @@ fn test_deserialize_full_valid_config() { no_db = false slow_sync = false + [validator_settings] + validator_jsonrpc_listen_address = "192.168.1.10:18232" + validator_cookie_path = "{validator_cookie_file_name}" + validator_user = "user" + validator_password = "password" + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8000" cookie_dir = "{zaino_cookie_dir_name}" @@ -112,7 +113,7 @@ fn test_deserialize_full_valid_config() { ); assert_eq!( finalized_config.validator_settings.validator_cookie_path, - Some(validator_cookie_file_name.to_string()) + Some(PathBuf::from(validator_cookie_file_name)) ); assert_eq!( finalized_config.storage.database.path, From df9928add485b7ecb55fa5cb4bf9480785e46e50 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 00:55:15 -0400 Subject: [PATCH 106/162] add zaino-common validator type for config --- zaino-common/src/validator.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 zaino-common/src/validator.rs diff --git a/zaino-common/src/validator.rs b/zaino-common/src/validator.rs new file mode 100644 index 000000000..5fd394cc2 --- /dev/null +++ b/zaino-common/src/validator.rs @@ -0,0 +1,29 @@ +//! Validator type for Zaino configuration. + +// use serde::{Deserialize, Serialize}; +// use zebra_chain::parameters::testnet::ConfiguredActivationHeights; +use std::net::SocketAddr; +use std::path::PathBuf; + +/// Validator (full-node) type for Zaino configuration. +#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)] +// #[serde(from = "ValidatorDeserialize")] +pub struct ValidatorConfig { + // jsonrpc and grpc addresses always known. + /// Full node / validator gprc listen port. + //#[serde(deserialize_with = "deserialize_socketaddr_from_string")] + pub validator_grpc_listen_address: SocketAddr, + + /// Full node / validator listen port. + // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] + pub validator_jsonrpc_listen_address: SocketAddr, + + /// Enable validator rpc cookie authentication with Some + /// Path to the validator cookie file. + // TODO changed to PathBuf + pub validator_cookie_path: Option, + /// Full node / validator Username. + pub validator_user: Option, + /// full node / validator Password. + pub validator_password: Option, +} From 87ae7db89f3003141d890f1965a04b8273809a18 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:02:26 -0400 Subject: [PATCH 107/162] zainod config validator logic, comment cleanup --- zainod/src/config.rs | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 12363cb62..b217a36c6 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -23,6 +23,7 @@ use zaino_common::{ use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; +/* /// Custom deserialization function for `SocketAddr` from a String. /// Used by Serde's `deserialize_with`. fn deserialize_socketaddr_from_string<'de, D>(deserializer: D) -> Result @@ -33,6 +34,7 @@ where fetch_socket_addr_from_hostname(&s) .map_err(|e| de::Error::custom(format!("Invalid socket address string '{s}': {e}"))) } +*/ /// Custom deserialization function for `BackendType` from a String. /// Used by Serde's `deserialize_with`. @@ -64,29 +66,10 @@ pub struct ZainodConfig { /// Enable JsonRPC server with a valid Some value. #[serde(default)] pub json_server_settings: Option, - // TODO commenting out : for rpc listen #[serde(deserialize_with = "deserialize_socketaddr_from_string")] /// gRPC server settings including listen addr, tls status, key and cert. pub grpc_settings: GrpcServerConfig, - // TODO this should be an Option() /// Full node / validator configuration settings. pub validator_settings: ValidatorConfig, - - /* - /// Full node / validator listen port. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub validator_jsonrpc_listen_address: SocketAddr, - /// Full node / validator gprc listen port. - #[serde(deserialize_with = "deserialize_socketaddr_from_string")] - pub validator_grpc_listen_address: SocketAddr, - /// Enable validator rpc cookie authentification. - pub validator_cookie_auth: bool, - /// Path to the validator cookie file. - pub validator_cookie_path: Option, - /// Full node / validator Username. - pub validator_user: Option, - /// full node / validator Password. - pub validator_password: Option, - */ /// Service-level configuration (timeout, channel size). pub service: ServiceConfig, /// Storage configuration (cache and database). @@ -94,7 +77,6 @@ pub struct ZainodConfig { /// Block Cache database file path. /// /// ZebraDB location. - // TODO seems to overlap with Storageconfig pub zebra_db_path: PathBuf, /// Network chain type. pub network: Network, @@ -142,7 +124,7 @@ impl ZainodConfig { if let Some(ref cookie_path) = self.validator_settings.validator_cookie_path { if !std::path::Path::new(cookie_path).exists() { return Err(IndexerError::ConfigError( - format!("Validator cookie authentication is enabled, but cookie path '{cookie_path}' does not exist."), + format!("Validator cookie authentication is enabled, but cookie path '{:?}' does not exist.", cookie_path), )); } } else { @@ -325,9 +307,8 @@ pub(crate) fn is_loopback_listen_addr(addr: &SocketAddr) -> bool { /// /// If the file cannot be read, or if its contents cannot be parsed into `IndexerConfig`, /// a warning is logged, and a default configuration is returned. +/// Finally there is an override of the config using environmental variables. /// The loaded or default configuration undergoes further checks and finalization. -// TODO my problems must be here, where configs read in as files are adapted based on env vars -// see step 3 below pub fn load_config(file_path: &PathBuf) -> Result { // Configuration sources are layered: Env > TOML > Defaults. let figment = Figment::new() @@ -393,7 +374,8 @@ impl TryFrom for BackendConfig { debug_validity_check_interval: None, }, validator_rpc_address: cfg.validator_settings.validator_jsonrpc_listen_address, - validator_indexer_rpc_address: cfg.validator_settings.validator_grpc_listen_address, + validator_grpc_address: cfg.validator_settings.validator_grpc_listen_address, + validator_cookie_auth: cfg.validator_settings.validator_cookie_path.is_some(), validator_cookie_path: cfg.validator_settings.validator_cookie_path, validator_rpc_user: cfg .validator_settings From 7ecafc7e145121483080884e1f0d3990a6faf57d Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:40:46 -0400 Subject: [PATCH 108/162] WIP for testmanager and related --- zaino-testutils/src/lib.rs | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 292f7bb14..1936256af 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -370,6 +370,8 @@ pub struct TestManager { /// Zaino gRPC listen address. pub zaino_grpc_listen_address: Option, /// JsonRPC server cookie dir. + // TODO ambiguity + // TODO PATH to validator cookie file!???! pub json_server_cookie_dir: Option, /// Zingolib lightclients. pub clients: Option, @@ -474,21 +476,25 @@ impl TestManager { // set to localhost with the newly generated port let zaino_json_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_json_listen_port); + // this cookie dir is generated on the spot, whenever zaino is enabled - let zaino_json_server_cookie_dir = default_ephemeral_cookie_path(); + let mut zaino_json_server_cookie_dir: Option = None; + if enable_zaino_jsonrpc_server_cookie_auth { + zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); + } + + dbg!( + "zaino_json_server_cookie_dir =========== {}", + &zaino_json_server_cookie_dir + ); - // then here we custom-set an entire, whole new config let indexer_config = zainodlib::config::ZainodConfig { // TODO: Make configurable. backend: *backend, json_server_settings: if enable_zaino_jsonrpc_server { Some(JsonRpcServerConfig { json_rpc_listen_address: zaino_json_listen_address, - cookie_dir: if enable_zaino_jsonrpc_server_cookie_auth { - Some(zaino_json_server_cookie_dir.clone()) - } else { - None - }, + cookie_dir: zaino_json_server_cookie_dir.clone(), }) } else { None @@ -531,20 +537,15 @@ impl TestManager { ( Some(zaino_grpc_listen_address), Some(zaino_json_listen_address), - Some(zaino_json_server_cookie_dir), + zaino_json_server_cookie_dir, Some(handle), ) } else { (None, None, None, None) }; - // TODO find out where the not-joinhandle config-stuff is needed. (two socketaddrs and an Option.. ) - // are all of these in the config? - // TODO by here we've already generated a JoinHandle. // pub zaino_handle: Option>>, // along with two listen addresses and a cookie_dir. - // these should be separated out, I'm almost sure. - // // Launch Zingolib Lightclients: let clients = if enable_clients { @@ -574,7 +575,10 @@ impl TestManager { } else { None }; - + dbg!( + "zaino_json_server_cookie_dir: {:?}", + zaino_json_server_cookie_dir.clone() + ); let test_manager = Self { local_net, data_dir, @@ -596,10 +600,9 @@ impl TestManager { } /// Helper function to support default test case. - // TODO this is impl TestManager #[allow(clippy::too_many_arguments)] pub async fn launch_with_default_activation_heights( - validator: &ValidatorKind, + validator_kind: &ValidatorKind, backend: &BackendType, network: Option, chain_cache: Option, @@ -607,22 +610,22 @@ impl TestManager { enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, zaino_no_sync: bool, - // no db enable_clients: bool, ) -> Result { - let activation_heights = match validator { + let activation_heights = match validator_kind { ValidatorKind::Zebrad => ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, ValidatorKind::Zcashd => ActivationHeights::default(), }; Self::launch( - validator, + validator_kind, backend, network, Some(activation_heights), chain_cache, enable_zaino, enable_zaino_jsonrpc_server, + // TODO : in our tests, is always set to false enable_zaino_jsonrpc_server_cookie_auth, zaino_no_sync, enable_clients, From afe6b36f865263beca1ca21c661df9e7e51580d2 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:43:14 -0400 Subject: [PATCH 109/162] update StateServiceConfig with new validator schemes --- zaino-state/src/config.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index a6475884c..1df02ab11 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -1,5 +1,6 @@ //! Holds config data for Zaino-State services. +use std::path::PathBuf; use zaino_common::{Network, ServiceConfig, StorageConfig}; #[derive(Debug, Clone, serde::Deserialize, PartialEq, Copy)] @@ -29,11 +30,12 @@ pub struct StateServiceConfig { /// Validator JsonRPC address. pub validator_rpc_address: std::net::SocketAddr, /// Validator gRPC address. - pub validator_indexer_rpc_address: std::net::SocketAddr, - // pub validator_cookie_auth: bool, - /// Enable validator rpc cookie authentification with Some. + pub validator_grpc_address: std::net::SocketAddr, + /// Validator cookie auth. + pub validator_cookie_auth: bool, /// Path to the validator cookie file. - pub validator_cookie_path: Option, + /// Enable validator rpc cookie authentification with Some. + pub validator_cookie_path: Option, /// Validator JsonRPC user. pub validator_rpc_user: String, /// Validator JsonRPC password. @@ -56,8 +58,9 @@ impl StateServiceConfig { pub fn new( validator_state_config: zebra_state::Config, validator_rpc_address: std::net::SocketAddr, - validator_indexer_rpc_address: std::net::SocketAddr, - validator_cookie_path: Option, + validator_grpc_address: std::net::SocketAddr, + validator_cookie_auth: bool, + validator_cookie_path: Option, validator_rpc_user: Option, validator_rpc_password: Option, service: ServiceConfig, @@ -68,7 +71,8 @@ impl StateServiceConfig { StateServiceConfig { validator_state_config, validator_rpc_address, - validator_indexer_rpc_address, + validator_grpc_address, + validator_cookie_auth, validator_cookie_path, validator_rpc_user: validator_rpc_user.unwrap_or("xxxxxx".to_string()), validator_rpc_password: validator_rpc_password.unwrap_or("xxxxxx".to_string()), @@ -88,8 +92,7 @@ pub struct FetchServiceConfig { // pub validator_cookie_auth: bool, /// Enable validator rpc cookie authentification with Some. /// Path to the validator cookie file. - // TODO change to PathBuf - pub validator_cookie_path: Option, + pub validator_cookie_path: Option, /// Validator JsonRPC user. pub validator_rpc_user: String, /// Validator JsonRPC password. @@ -111,7 +114,7 @@ impl FetchServiceConfig { // TODO: replace with struct-literal init only? pub fn new( validator_rpc_address: std::net::SocketAddr, - validator_cookie_path: Option, + validator_cookie_path: Option, validator_rpc_user: Option, validator_rpc_password: Option, service: ServiceConfig, From f0e4529342cadac12513c08c22c696fbdb8c8770 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:45:18 -0400 Subject: [PATCH 110/162] correct comment --- zaino-state/src/backends/fetch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-state/src/backends/fetch.rs b/zaino-state/src/backends/fetch.rs index 926b387e8..1b05a721d 100644 --- a/zaino-state/src/backends/fetch.rs +++ b/zaino-state/src/backends/fetch.rs @@ -84,7 +84,7 @@ pub struct FetchService { impl ZcashService for FetchService { type Subscriber = FetchServiceSubscriber; type Config = FetchServiceConfig; - /// Initializes a new StateService instance and starts sync process. + /// Initializes a new FetchService instance and starts sync process. async fn spawn(config: FetchServiceConfig) -> Result { info!("Launching Chain Fetch Service.."); From bddbd561e3ae42bcb3e2704e49d6aea4d3cdf160 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:46:50 -0400 Subject: [PATCH 111/162] updated StateService with new validator scheme, correct info!() --- zaino-state/src/backends/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zaino-state/src/backends/state.rs b/zaino-state/src/backends/state.rs index 64665a64e..8fc83aea4 100644 --- a/zaino-state/src/backends/state.rs +++ b/zaino-state/src/backends/state.rs @@ -159,7 +159,7 @@ impl ZcashService for StateService { /// Initializes a new StateService instance and starts sync process. async fn spawn(config: StateServiceConfig) -> Result { - info!("Launching Chain Fetch Service.."); + info!("Spawning State Service.."); let rpc_client = JsonRpSeeConnector::new_from_config_parts( config.validator_rpc_address, @@ -211,7 +211,7 @@ impl ZcashService for StateService { init_read_state_with_syncer( config.validator_state_config.clone(), &config.network.to_zebra_network(), - config.validator_indexer_rpc_address, + config.validator_grpc_address, ) .await??; From 6836a5bb41d087ac1f35174693e9db79b0a70675 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:50:21 -0400 Subject: [PATCH 112/162] update fetch rpsee connector with validator cookie_path --- zaino-fetch/src/jsonrpsee/connector.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zaino-fetch/src/jsonrpsee/connector.rs b/zaino-fetch/src/jsonrpsee/connector.rs index 28ea888c4..befca97a6 100644 --- a/zaino-fetch/src/jsonrpsee/connector.rs +++ b/zaino-fetch/src/jsonrpsee/connector.rs @@ -2,11 +2,11 @@ //! //! TODO: - Add option for http connector. //! - Refactor JsonRPSeecConnectorError into concrete error types and implement fmt::display []. - use base64::{engine::general_purpose, Engine}; use http::Uri; use reqwest::{Client, ClientBuilder, Url}; use serde::{Deserialize, Serialize}; +use std::path::PathBuf; use std::{ any::type_name, convert::Infallible, @@ -229,7 +229,7 @@ impl JsonRpSeeConnector { validator_rpc_address: SocketAddr, validator_rpc_user: String, validator_rpc_password: String, - validator_cookie_path: Option, + validator_cookie_path: Option, ) -> Result { match validator_cookie_path.is_some() { true => JsonRpSeeConnector::new_with_cookie_auth( @@ -804,13 +804,14 @@ async fn test_node_connection(url: Url, auth_method: AuthMethod) -> Result<(), T /// Tries to connect to zebrad/zcashd using the provided SocketAddr and returns the correct URL. pub async fn test_node_and_return_url( addr: SocketAddr, - cookie_path: Option, + cookie_path: Option, user: Option, password: Option, ) -> Result { let auth_method = match cookie_path.is_some() { true => { let cookie_file_path_str = cookie_path.expect("validator rpc cookie path missing"); + let cookie_password = read_and_parse_cookie_token(Path::new(&cookie_file_path_str))?; AuthMethod::Cookie { cookie: cookie_password, From d6382bbcb83d9d812433c4b6cf3f9a1834ba7bfc Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:51:17 -0400 Subject: [PATCH 113/162] rm comment --- zaino-common/src/validator.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/zaino-common/src/validator.rs b/zaino-common/src/validator.rs index 5fd394cc2..c9bae23e1 100644 --- a/zaino-common/src/validator.rs +++ b/zaino-common/src/validator.rs @@ -20,7 +20,6 @@ pub struct ValidatorConfig { /// Enable validator rpc cookie authentication with Some /// Path to the validator cookie file. - // TODO changed to PathBuf pub validator_cookie_path: Option, /// Full node / validator Username. pub validator_user: Option, From 7b1a3b03f38c08ebb5add28f4a4927a45f042f47 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 01:52:38 -0400 Subject: [PATCH 114/162] update integration tests with validator config, annotations --- integration-tests/tests/json_server.rs | 31 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index a6cdab113..f253a7841 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -11,8 +11,9 @@ use zaino_testutils::{TestManager, ValidatorKind}; use zebra_chain::subtree::NoteCommitmentSubtreeIndex; use zebra_rpc::methods::{AddressStrings, GetAddressTxIdsRequest, GetInfo}; +// TODO has many [17] references, in which enable_cookie_auth is ALWAYS false. async fn create_test_manager_and_fetch_services( - _enable_cookie_auth: bool, + enable_cookie_auth: bool, clients: bool, ) -> ( TestManager, @@ -29,6 +30,8 @@ async fn create_test_manager_and_fetch_services( None, true, true, + // enable_zaino_jsonrpc_server_cookie_auth: bool, + // TODO AFAIK, this is _always_ false enable_cookie_auth, true, clients, @@ -67,16 +70,19 @@ async fn create_test_manager_and_fetch_services( tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; println!("Launching zaino fetch service.."); - let zaino_json_server_address = dbg!(test_manager.zaino_json_rpc_listen_address.unwrap()); let zaino_fetch_service = FetchService::spawn(FetchServiceConfig::new( - zaino_json_server_address, - test_manager - .json_server_cookie_dir - .clone() - .map(|p| p.to_string_lossy().into_owned()), + // validator_rpc_address: std::net::SocketAddr, + test_manager.full_node_rpc_listen_address, + // zaino_json_server_address, + // validator_cookie_path: Option, + test_manager.json_server_cookie_dir.clone(), + // validator_rpc_user: Option, None, + // validator_rpc_password: Option, None, + // service: ServiceConfig, ServiceConfig::default(), + // storage: StorageConfig, StorageConfig { database: DatabaseConfig { path: test_manager @@ -89,7 +95,9 @@ async fn create_test_manager_and_fetch_services( }, ..Default::default() }, + // network: Network, zaino_common::Network::Regtest(ActivationHeights::default()), + // no_sync: bool, true, )) .await @@ -108,10 +116,9 @@ async fn create_test_manager_and_fetch_services( ) } -async fn launch_json_server_check_info(enable_cookie_auth: bool) { +async fn launch_json_server_check_info() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(enable_cookie_auth, false).await; - + create_test_manager_and_fetch_services(false, false).await; let zcashd_info = dbg!(zcashd_subscriber.get_info().await.unwrap()); let zcashd_blockchain_info = dbg!(zcashd_subscriber.get_blockchain_info().await.unwrap()); let zaino_info = dbg!(zaino_subscriber.get_info().await.unwrap()); @@ -670,12 +677,12 @@ mod zcashd { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn check_info_no_cookie() { - launch_json_server_check_info(false).await; + launch_json_server_check_info().await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn check_info_with_cookie() { - launch_json_server_check_info(false).await; + launch_json_server_check_info().await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] From 7889e40bc1d9a5be0c65c86fc879e8170423252f Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 03:05:40 -0400 Subject: [PATCH 115/162] remove bench feature from zaino-state --- zaino-testutils/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaino-testutils/Cargo.toml b/zaino-testutils/Cargo.toml index 7d3a0030c..9eaada7e1 100644 --- a/zaino-testutils/Cargo.toml +++ b/zaino-testutils/Cargo.toml @@ -11,7 +11,7 @@ publish = false [dependencies] # Zaino -zaino-state = { workspace = true, features = ["test_dependencies", "bench"] } +zaino-state = { workspace = true, features = ["test_dependencies"] } zaino-serve.workspace = true zaino-testvectors.workspace = true zaino-common.workspace = true From 6b13cb6d3d6b7487b5586f6597bfeb3ed2f50d3d Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 03:33:29 -0400 Subject: [PATCH 116/162] Removing custom deser for string and socketaddr --- zainod/src/config.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index b217a36c6..9574039d8 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -23,19 +23,6 @@ use zaino_common::{ use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::{BackendConfig, FetchServiceConfig, StateServiceConfig}; -/* -/// Custom deserialization function for `SocketAddr` from a String. -/// Used by Serde's `deserialize_with`. -fn deserialize_socketaddr_from_string<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - let s = String::deserialize(deserializer)?; - fetch_socket_addr_from_hostname(&s) - .map_err(|e| de::Error::custom(format!("Invalid socket address string '{s}': {e}"))) -} -*/ - /// Custom deserialization function for `BackendType` from a String. /// Used by Serde's `deserialize_with`. fn deserialize_backendtype_from_string<'de, D>( From 320cf5330876745e41d2002b4428df9d424d9ace Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 04:01:40 -0400 Subject: [PATCH 117/162] cleanup, note to rename no_sync --- integration-tests/tests/fetch_service.rs | 3 --- zainod/src/config.rs | 2 +- zainod/tests/config.rs | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 21f78a109..03b4cc496 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -24,7 +24,6 @@ async fn create_test_manager_and_fetch_service( chain_cache: Option, enable_zaino: bool, zaino_no_sync: bool, - //zaino_no_db: bool, enable_clients: bool, ) -> (TestManager, FetchService, FetchServiceSubscriber) { let test_manager = TestManager::launch_with_default_activation_heights( @@ -36,7 +35,6 @@ async fn create_test_manager_and_fetch_service( false, false, zaino_no_sync, - //zaino_no_db, enable_clients, ) .await @@ -61,7 +59,6 @@ async fn create_test_manager_and_fetch_service( ..Default::default() }, Network::Regtest(ActivationHeights::default()), - // true, true, )) .await diff --git a/zainod/src/config.rs b/zainod/src/config.rs index 9574039d8..b7493cc04 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -49,7 +49,6 @@ pub struct ZainodConfig { #[serde(deserialize_with = "deserialize_backendtype_from_string")] #[serde(serialize_with = "serialize_backendtype_to_string")] pub backend: zaino_state::BackendType, - // TODO later, create what were called "sections" /// Enable JsonRPC server with a valid Some value. #[serde(default)] pub json_server_settings: Option, @@ -69,6 +68,7 @@ pub struct ZainodConfig { pub network: Network, /// Disables internal sync and stops zaino waiting on server sync. /// Used for testing. + // TODO rename disable_internal_sync pub no_sync: bool, } diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 3d901aa1a..df2dfa46b 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -195,7 +195,7 @@ fn test_deserialize_optional_fields_missing() { default_values.storage.database.size ); assert_eq!(config.no_sync, default_values.no_sync); - // db = 0 + // TODO db = 0 //assert_eq!(config.no_db, default_values.no_db); Ok(()) }); From ffa492975c5f526bef5a18e4c593f8de98e7a624 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 20 Oct 2025 05:45:46 -0400 Subject: [PATCH 118/162] removing no_sync functionality and from ZainodConfig --- integration-tests/tests/chain_cache.rs | 24 ++++----- integration-tests/tests/fetch_service.rs | 6 +-- integration-tests/tests/json_server.rs | 7 +-- integration-tests/tests/local_cache.rs | 10 ++-- integration-tests/tests/state_service.rs | 8 +-- integration-tests/tests/test_vectors.rs | 6 +-- .../tests/wallet_to_validator.rs | 14 ++--- zaino-state/src/chain_index/tests.rs | 3 +- .../tests/finalised_state/migrations.rs | 18 +++---- .../chain_index/tests/finalised_state/v0.rs | 6 +-- .../chain_index/tests/finalised_state/v1.rs | 9 ++-- zaino-state/src/config.rs | 35 +++++++------ .../src/local_cache/finalised_state.rs | 3 +- .../src/local_cache/non_finalised_state.rs | 5 +- zaino-testutils/src/lib.rs | 52 +++++++++---------- zainod/src/config.rs | 14 ++--- zainod/tests/config.rs | 7 ++- 17 files changed, 109 insertions(+), 118 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index bc07061b6..e88b30321 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -8,7 +8,7 @@ async fn create_test_manager_and_connector( activation_heights: Option, chain_cache: Option, enable_zaino: bool, - zaino_no_sync: bool, + // zaino_no_sync: bool, enable_clients: bool, ) -> (TestManager, JsonRpSeeConnector) { let test_manager = TestManager::launch( @@ -20,7 +20,7 @@ async fn create_test_manager_and_connector( enable_zaino, false, //enable_zaino_jsonrpc_server: bool, false, //enable_zaino_jsonrpc_server_cookie_auth: bool, - zaino_no_sync, + // zaino_no_sync, enable_clients, ) .await @@ -74,7 +74,7 @@ mod chain_query_interface { validator: &ValidatorKind, chain_cache: Option, enable_zaino: bool, - zaino_no_sync: bool, + // no_sync enable_clients: bool, ) -> ( TestManager, @@ -117,7 +117,7 @@ mod chain_query_interface { Some(activation_heights), chain_cache.clone(), enable_zaino, - zaino_no_sync, + // zaino_no_sync, enable_clients, ) .await; @@ -163,7 +163,7 @@ mod chain_query_interface { }, }, network.into(), - true, + // true, )) .await .unwrap(); @@ -179,7 +179,7 @@ mod chain_query_interface { }, db_version: 1, network: zaino_common::Network::Regtest(activation_heights), - no_sync: false, + // no_sync: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::State(chain_index::source::State { @@ -215,7 +215,7 @@ mod chain_query_interface { }, db_version: 1, network: zaino_common::Network::Regtest(activation_heights), - no_sync: false, + // no_sync: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::Fetch(json_service.clone()), @@ -243,7 +243,7 @@ mod chain_query_interface { async fn get_block_range(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -285,7 +285,7 @@ mod chain_query_interface { async fn find_fork_point(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -317,7 +317,7 @@ mod chain_query_interface { async fn get_raw_transaction(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; @@ -371,7 +371,7 @@ mod chain_query_interface { async fn get_transaction_status(validator: &ValidatorKind) { let (test_manager, _json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false).await; let snapshot = indexer.snapshot_nonfinalized_state(); // I don't know where this second block is generated. Somewhere in the // guts of create_test_manager_and_chain_index @@ -411,7 +411,7 @@ mod chain_query_interface { async fn sync_large_chain(validator: &ValidatorKind) { let (test_manager, json_service, _option_state_service, _chain_index, indexer) = - create_test_manager_and_chain_index(validator, None, false, false, false).await; + create_test_manager_and_chain_index(validator, None, false, false).await; // this delay had to increase. Maybe we tweak sync loop rerun time? test_manager.generate_blocks_with_delay(5).await; diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 03b4cc496..12fe94a95 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -23,7 +23,7 @@ async fn create_test_manager_and_fetch_service( validator: &ValidatorKind, chain_cache: Option, enable_zaino: bool, - zaino_no_sync: bool, + _zaino_no_sync: bool, enable_clients: bool, ) -> (TestManager, FetchService, FetchServiceSubscriber) { let test_manager = TestManager::launch_with_default_activation_heights( @@ -34,7 +34,7 @@ async fn create_test_manager_and_fetch_service( enable_zaino, false, false, - zaino_no_sync, + // zaino_no_sync, enable_clients, ) .await @@ -59,7 +59,7 @@ async fn create_test_manager_and_fetch_service( ..Default::default() }, Network::Regtest(ActivationHeights::default()), - true, + // true, )) .await .unwrap(); diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index f253a7841..859fa9938 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -33,7 +33,7 @@ async fn create_test_manager_and_fetch_services( // enable_zaino_jsonrpc_server_cookie_auth: bool, // TODO AFAIK, this is _always_ false enable_cookie_auth, - true, + // true, clients, ) .await @@ -61,7 +61,7 @@ async fn create_test_manager_and_fetch_services( ..Default::default() }, zaino_common::Network::Regtest(ActivationHeights::default()), - true, + // true, )) .await .unwrap(); @@ -75,6 +75,7 @@ async fn create_test_manager_and_fetch_services( test_manager.full_node_rpc_listen_address, // zaino_json_server_address, // validator_cookie_path: Option, + // TODO this is suspect. test_manager.json_server_cookie_dir.clone(), // validator_rpc_user: Option, None, @@ -98,7 +99,7 @@ async fn create_test_manager_and_fetch_services( // network: Network, zaino_common::Network::Regtest(ActivationHeights::default()), // no_sync: bool, - true, + // true, )) .await .unwrap(); diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index d3a2da5c4..bd4c04914 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -13,7 +13,7 @@ async fn create_test_manager_and_block_cache( validator: &ValidatorKind, chain_cache: Option, enable_zaino: bool, - zaino_no_sync: bool, + // zaino_no_sync: bool, enable_clients: bool, ) -> ( TestManager, @@ -35,7 +35,7 @@ async fn create_test_manager_and_block_cache( enable_zaino, false, //enable_zaino_jsonrpc_server: bool, false, //enable_zaino_jsonrpc_server_cookie_auth: bool, - zaino_no_sync, + // zaino_no_sync, enable_clients, ) .await @@ -73,7 +73,7 @@ async fn create_test_manager_and_block_cache( }, db_version: 1, network: network.into(), - no_sync: zaino_no_sync, + // no_sync: zaino_no_sync, }; let block_cache = BlockCache::spawn(&json_service, None, block_cache_config) @@ -91,13 +91,13 @@ async fn create_test_manager_and_block_cache( } async fn launch_local_cache(validator: &ValidatorKind) { - create_test_manager_and_block_cache(validator, None, false, true, false).await; + create_test_manager_and_block_cache(validator, None, false, false).await; } /// Launches a testmanager and block cache and generates `n*100` blocks, checking blocks are stored and fetched correctly. async fn launch_local_cache_process_n_block_batches(validator: &ValidatorKind, batches: u32) { let (test_manager, json_service, mut block_cache, mut block_cache_subscriber) = - create_test_manager_and_block_cache(validator, None, false, true, false).await; + create_test_manager_and_block_cache(validator, None, false, false).await; let finalised_state = block_cache.finalised_state.take().unwrap(); let finalised_state_subscriber = block_cache_subscriber.finalised_state.take().unwrap(); diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index 21977ed53..a3c535515 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -34,13 +34,13 @@ async fn create_test_manager_and_services( enable_zaino, false, false, - true, + // true, enable_clients, ) .await .unwrap(); - let (network_type, zaino_sync_bool) = match network { + let (network_type, _zaino_sync_bool) = match network { Some(NetworkKind::Mainnet) => { println!("Waiting for validator to spawn.."); tokio::time::sleep(std::time::Duration::from_millis(5000)).await; @@ -78,7 +78,7 @@ async fn create_test_manager_and_services( ..Default::default() }, network_type, - zaino_sync_bool, + // zaino_sync_bool, )) .await .unwrap(); @@ -118,7 +118,7 @@ async fn create_test_manager_and_services( ..Default::default() }, network_type, - true, + // true, )) .await .unwrap(); diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index e38ee710c..d9aed1380 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -62,13 +62,13 @@ async fn create_test_manager_and_services( enable_zaino, false, false, - true, + // true, enable_clients, ) .await .unwrap(); - let (network_type, zaino_sync_bool) = match network { + let (network_type, _zaino_sync_bool) = match network { Some(NetworkKind::Mainnet) => { println!("Waiting for validator to spawn.."); tokio::time::sleep(std::time::Duration::from_millis(5000)).await; @@ -120,7 +120,7 @@ async fn create_test_manager_and_services( ..Default::default() }, network_type, - zaino_sync_bool, + // zaino_sync_bool, )) .await .unwrap(); diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index 1db6907f4..b49b2b77d 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -11,7 +11,7 @@ use zip32::AccountId; async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); @@ -28,7 +28,7 @@ async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backe async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); @@ -71,7 +71,7 @@ async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); @@ -114,7 +114,7 @@ async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); @@ -217,7 +217,7 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); @@ -308,7 +308,7 @@ async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { async fn shield_for_validator(validator: &ValidatorKind, backend: &BackendType) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); @@ -384,7 +384,7 @@ async fn monitor_unverified_mempool_for_validator( backend: &BackendType, ) { let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, true, + validator, backend, None, None, true, false, false, true, ) .await .unwrap(); diff --git a/zaino-state/src/chain_index/tests.rs b/zaino-state/src/chain_index/tests.rs index 7aaf5859c..713954cff 100644 --- a/zaino-state/src/chain_index/tests.rs +++ b/zaino-state/src/chain_index/tests.rs @@ -82,8 +82,7 @@ mod mockchain_tests { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let indexer = NodeBackedChainIndex::new(source.clone(), config) diff --git a/zaino-state/src/chain_index/tests/finalised_state/migrations.rs b/zaino-state/src/chain_index/tests/finalised_state/migrations.rs index 9bddf28e0..5ea68a73b 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/migrations.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/migrations.rs @@ -31,8 +31,7 @@ async fn v0_to_v1_full() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -44,8 +43,7 @@ async fn v0_to_v1_full() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); @@ -105,8 +103,7 @@ async fn v0_to_v1_interrupted() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -118,8 +115,7 @@ async fn v0_to_v1_interrupted() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); @@ -231,8 +227,7 @@ async fn v0_to_v1_partial() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -244,8 +239,7 @@ async fn v0_to_v1_partial() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); diff --git a/zaino-state/src/chain_index/tests/finalised_state/v0.rs b/zaino-state/src/chain_index/tests/finalised_state/v0.rs index e1fc62ddd..acac5335e 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/v0.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/v0.rs @@ -31,8 +31,7 @@ pub(crate) async fn spawn_v0_zaino_db( }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let zaino_db = ZainoDB::spawn(config, source).await.unwrap(); @@ -207,8 +206,7 @@ async fn save_db_to_file_and_reload() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); diff --git a/zaino-state/src/chain_index/tests/finalised_state/v1.rs b/zaino-state/src/chain_index/tests/finalised_state/v1.rs index e38ac2fe4..f830d4e16 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/v1.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/v1.rs @@ -37,8 +37,7 @@ pub(crate) async fn spawn_v1_zaino_db( }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let zaino_db = ZainoDB::spawn(config, source).await.unwrap(); @@ -216,8 +215,7 @@ async fn save_db_to_file_and_reload() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); @@ -327,8 +325,7 @@ async fn load_db_backend_from_file() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - - no_sync: false, + // no_sync: false, }; let finalized_state_backend = DbBackend::spawn_v1(&config).await.unwrap(); diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index 1df02ab11..3391193a7 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -46,9 +46,9 @@ pub struct StateServiceConfig { pub storage: StorageConfig, /// Network type. pub network: Network, - /// Disables internal sync and stops zaino waiting on server sync. - /// Used for testing. - pub no_sync: bool, + // /// Disables internal sync and stops zaino waiting on server sync. + // /// Used for testing. + // pub no_sync: bool, } impl StateServiceConfig { @@ -66,7 +66,7 @@ impl StateServiceConfig { service: ServiceConfig, storage: StorageConfig, network: Network, - no_sync: bool, + // no_sync: bool, ) -> Self { StateServiceConfig { validator_state_config, @@ -79,11 +79,12 @@ impl StateServiceConfig { service, storage, network, - no_sync, + // no_sync, } } } +// TODO should this live in another module? /// Holds config data for [crate::FetchService]. #[derive(Debug, Clone)] pub struct FetchServiceConfig { @@ -103,9 +104,9 @@ pub struct FetchServiceConfig { pub storage: StorageConfig, /// Network type. pub network: Network, - /// Disables internal sync and stops zaino waiting on server sync. - /// Used for testing. - pub no_sync: bool, + // /// Disables internal sync and stops zaino waiting on server sync. + // /// Used for testing. + // pub no_sync: bool, } impl FetchServiceConfig { @@ -120,7 +121,7 @@ impl FetchServiceConfig { service: ServiceConfig, storage: StorageConfig, network: Network, - no_sync: bool, + // no_sync: bool, ) -> Self { FetchServiceConfig { validator_rpc_address, @@ -130,7 +131,7 @@ impl FetchServiceConfig { service, storage, network, - no_sync, + // no_sync, } } } @@ -145,20 +146,20 @@ pub struct BlockCacheConfig { pub db_version: u32, /// Network type. pub network: Network, - /// Stops zaino waiting on server sync. - /// Used for testing. - pub no_sync: bool, + // /// Stops zaino waiting on server sync. + // /// Used for testing. + // pub no_sync: bool, } impl BlockCacheConfig { /// Returns a new instance of [`BlockCacheConfig`]. #[allow(dead_code)] - pub fn new(storage: StorageConfig, db_version: u32, network: Network, no_sync: bool) -> Self { + pub fn new(storage: StorageConfig, db_version: u32, network: Network, _no_sync: bool) -> Self { BlockCacheConfig { storage, db_version, network, - no_sync, + // no_sync, } } } @@ -170,7 +171,7 @@ impl From for BlockCacheConfig { // TODO: update zaino configs to include db version. db_version: 1, network: value.network, - no_sync: value.no_sync, + // no_sync: value.no_sync, } } } @@ -182,7 +183,7 @@ impl From for BlockCacheConfig { // TODO: update zaino configs to include db version. db_version: 1, network: value.network, - no_sync: value.no_sync, + // no_sync: value.no_sync, } } } diff --git a/zaino-state/src/local_cache/finalised_state.rs b/zaino-state/src/local_cache/finalised_state.rs index 249ed79b3..85d2c389f 100644 --- a/zaino-state/src/local_cache/finalised_state.rs +++ b/zaino-state/src/local_cache/finalised_state.rs @@ -476,7 +476,8 @@ impl FinalisedState { } // Wait for server to sync to with p2p network and sync new blocks. - if !self.config.network.to_zebra_network().is_regtest() && !self.config.no_sync { + if !self.config.network.to_zebra_network().is_regtest() { + // && !self.config.no_sync { self.status.store(StatusType::Syncing); loop { let blockchain_info = self.fetcher.get_blockchain_info().await?; diff --git a/zaino-state/src/local_cache/non_finalised_state.rs b/zaino-state/src/local_cache/non_finalised_state.rs index 6dce31069..b7cacadf8 100644 --- a/zaino-state/src/local_cache/non_finalised_state.rs +++ b/zaino-state/src/local_cache/non_finalised_state.rs @@ -372,11 +372,12 @@ impl NonFinalisedState { /// Waits for server to sync with p2p network. pub async fn wait_on_server(&self) -> Result<(), NonFinalisedStateError> { // If no_db is active wait for server to sync with p2p network. - let mybool = match self.config.storage.database.size { + let no_db = match self.config.storage.database.size { zaino_common::DatabaseSize::Gb(0) => true, zaino_common::DatabaseSize::Gb(_) => false, }; - if mybool && !self.config.network.to_zebra_network().is_regtest() && !self.config.no_sync { + if no_db && !self.config.network.to_zebra_network().is_regtest() { + // && !self.config.no_sync { self.status.store(StatusType::Syncing); loop { let blockchain_info = self.fetcher.get_blockchain_info().await.map_err(|e| { diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 1936256af..b6fdbf329 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -397,7 +397,7 @@ impl TestManager { enable_zaino: bool, enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, - zaino_no_sync: bool, + // zaino_no_sync: bool, enable_clients: bool, ) -> Result { if (validator == &ValidatorKind::Zcashd) && (backend == &BackendType::State) { @@ -520,7 +520,7 @@ impl TestManager { }, zebra_db_path, network: zaino_network_kind, - no_sync: zaino_no_sync, + // no_sync: zaino_no_sync, }; // TODO we create the handle here, with indexer_config. // I think we could possibly ... spit out the indexer stuff if we need it later, piece by piece? @@ -609,7 +609,7 @@ impl TestManager { enable_zaino: bool, enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, - zaino_no_sync: bool, + // zaino_no_sync: bool, enable_clients: bool, ) -> Result { let activation_heights = match validator_kind { @@ -627,7 +627,7 @@ impl TestManager { enable_zaino_jsonrpc_server, // TODO : in our tests, is always set to false enable_zaino_jsonrpc_server_cookie_auth, - zaino_no_sync, + // zaino_no_sync, enable_clients, ) .await @@ -687,7 +687,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -709,7 +709,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -737,7 +737,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -759,7 +759,7 @@ mod launch_testmanager { true, false, false, - true, + // true, false, ) .await @@ -785,7 +785,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -812,7 +812,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -861,7 +861,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -883,7 +883,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -911,7 +911,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -933,7 +933,7 @@ mod launch_testmanager { true, false, false, - true, + // true, false, ) .await @@ -959,7 +959,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -986,7 +986,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -1032,7 +1032,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -1133,7 +1133,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -1164,7 +1164,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -1186,7 +1186,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -1214,7 +1214,7 @@ mod launch_testmanager { false, false, false, - true, + // true, false, ) .await @@ -1236,7 +1236,7 @@ mod launch_testmanager { true, false, false, - true, + // true, false, ) .await @@ -1262,7 +1262,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -1289,7 +1289,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -1336,7 +1336,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await @@ -1435,7 +1435,7 @@ mod launch_testmanager { true, false, false, - true, + // true, true, ) .await diff --git a/zainod/src/config.rs b/zainod/src/config.rs index b7493cc04..ca2139f43 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -66,10 +66,10 @@ pub struct ZainodConfig { pub zebra_db_path: PathBuf, /// Network chain type. pub network: Network, - /// Disables internal sync and stops zaino waiting on server sync. - /// Used for testing. - // TODO rename disable_internal_sync - pub no_sync: bool, + // /// Disables internal sync and stops zaino waiting on server sync. + // /// Used for testing. + // // TODO rename disable_internal_sync + // pub no_sync: bool, } impl ZainodConfig { @@ -216,7 +216,7 @@ impl Default for ZainodConfig { }, zebra_db_path: default_zebra_db_path().unwrap(), network: Network::Testnet, - no_sync: false, + // no_sync: false, } } } @@ -375,7 +375,7 @@ impl TryFrom for BackendConfig { service: cfg.service, storage: cfg.storage, network: cfg.network, - no_sync: cfg.no_sync, + // no_sync: cfg.no_sync, })), zaino_state::BackendType::Fetch => Ok(BackendConfig::Fetch(FetchServiceConfig { @@ -392,7 +392,7 @@ impl TryFrom for BackendConfig { service: cfg.service, storage: cfg.storage, network: cfg.network, - no_sync: cfg.no_sync, + // no_sync: cfg.no_sync, })), } } diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index df2dfa46b..5aa98dbe0 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -36,7 +36,6 @@ fn test_deserialize_full_valid_config() { zebra_db_path = "{zebra_db_dir_name}" db_size = 100 network = "Mainnet" - no_sync = false no_db = false slow_sync = false @@ -143,7 +142,7 @@ fn test_deserialize_full_valid_config() { finalized_config.storage.database.size.to_byte_count(), 128 * 1024 * 1024 * 1024 ); - assert!(!finalized_config.no_sync); + // assert!(!finalized_config.no_sync); assert!(match finalized_config.storage.database.size { DatabaseSize::Gb(0) => false, DatabaseSize::Gb(_) => true, @@ -194,7 +193,7 @@ fn test_deserialize_optional_fields_missing() { config.storage.database.size, default_values.storage.database.size ); - assert_eq!(config.no_sync, default_values.no_sync); + // assert_eq!(config.no_sync, default_values.no_sync); // TODO db = 0 //assert_eq!(config.no_db, default_values.no_db); Ok(()) @@ -364,7 +363,7 @@ fn test_deserialize_empty_string_yields_default() { config.storage.database.size, default_config.storage.database.size ); - assert_eq!(config.no_sync, default_config.no_sync); + // assert_eq!(config.no_sync, default_config.no_sync); // db = 0 // assert_eq!(config.no_db, default_config.no_db); Ok(()) From 074545b42057d84a2318c414af546c50dcda0a08 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:13:11 -0400 Subject: [PATCH 119/162] update zindexer.toml --- zainod/zindexer.toml | 149 +++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 78 deletions(-) diff --git a/zainod/zindexer.toml b/zainod/zindexer.toml index f80a596ba..8e590df70 100644 --- a/zainod/zindexer.toml +++ b/zainod/zindexer.toml @@ -1,7 +1,5 @@ # Configuration for Zaino -# TODO this may break everything now. - # Backend: # Type of backend to use. Options are: @@ -9,63 +7,80 @@ # - "state" - Uses ReadStateService to fetch data (Zebrad). backend = "fetch" -# JsonRPC server config: - -# Enables JsonRPC server. -# enable_json_server = false - -# JsonRPC server listen addr. -json_rpc_listen_address = "127.0.0.1:8237" - -# Enables cookie-based authentication for JsonRPC server. -# enable_cookie_auth = false - -# Directory to store authentication cookie file. -# If 'enable_cookie_auth' is true and this is omitted, a default ephemeral path (e.g., /tmp/zaino/.cookie or XDG_RUNTIME_DIR) will be used. -# If 'enable_cookie_auth' is false, this setting is ignored and no cookie_dir is used. -# cookie_dir = "/path/to/cookie_dir" +# Zainod JsonRPC server config: +# Optional: Some enables Zaino's JsonRPC server. +[json_server_settings] + # JsonRPC server listen addr. Required if json_server_settings is Some. + json_rpc_listen_address = "127.0.0.1:8237" + + # Some enables cookie-based authentication for JsonRPC server. + # An empty PathBuf that is still Some will have a default emphemeral path assigned to it when zaino loads the config. + # (e.g., /tmp/zaino/.cookie or XDG_RUNTIME_DIR) will be used. + # Directory to store authentication cookie file. + # cookie_dir = "" + # cookie_dir = "/path/to/cookie_dir" # gRPC server config: - +# Required for valid zainod config. +[grpc_settings] # Zainod's gRPC server listen address. -# -# Must use TLS when connecting to non localhost addresses. -grpc_listen_address = "127.0.0.1:8137" - -# Enables TLS for the gRPC server. -# grpc_tls = false - -# Path to the TLS certificate file in PEM format. -# Required if `grpc_tls` is true. If omitted and grpc_tls is true, startup will fail. -# tls_cert_path = "/path/to/cert.pem" - -# Path to the TLS private key file in PEM format. -# Required if `grpc_tls` is true. If omitted and grpc_tls is true, startup will fail. -# tls_key_path = "/path/to/key.pem" - -# JsonRPC client config: - -# Full node / validator listen address. -# -# Must be a "private" address as defined in [IETF RFC 1918] for ipv4 addreses and [IETF RFC 4193] for ipv6 addreses. -# -# Must use validator rpc cookie authentication when connecting to non localhost addresses. -validator_listen_address = "127.0.0.1:18232" - -# Enable validator rpc cookie authentication. -# validator_cookie_auth = false - -# Path to the validator cookie file. -# Required if `validator_cookie_auth` is true. If omitted and validator_cookie_auth is true, startup will fail. -# validator_cookie_path = "/path/to/validator.cookie" - -# Optional full node / validator Username. -# validator_user = "xxxxxx" - -# Optional full node / validator Password. -# validator_password = "xxxxxx" - -# Mempool, Non-Finalised State and Finalised State config: + # SocketAddress, Required. + grpc_listen_address = "127.0.0.1:8137" + + # Some Enables TLS for the gRPC server. + # tls: Option, + # [tls] + # Path to the TLS certificate file in PEM format. + # cert_path: "" + # cert_path = "/path/to/cert.pem" + # Path to the TLS private key file in PEM format. + # key_path = "" + # key_path = "/path/to/key.pem" + +# Validator config: +# Required for valid zainod config. +[validator_settings] + # Full node / validator listen address. + # + # Must be a "private" address as defined in [IETF RFC 1918] for ipv4 addreses and [IETF RFC 4193] for ipv6 addreses. + # + # Must use validator rpc cookie authentication when connecting to non localhost addresses. + # Required + validator_grpc_listen_address = "127.0.0.1:18232" + + # SocketAddr, Required. + validator_jsonrpc_listen_address = "127.0.0.1:18230" + + # Optional. Enable validator rpc cookie authentication with Some. + # Path to the validator cookie file. + # validator_cookie_path = "/path/to/validator.cookie" + # validator_cookie_path = "" + # Optional. Enable user / pass authentication with Some. + # Full node / validator Username. + # validator_user = "" + # Optional. Enable user / pass authentication with Some + # full node / validator Password. + # validator_password: "" + # +# Service-level configuration (timeout, channel size). +# Required. +# [service] +# ... + +# Storage configuration (cache and database). +# Required. +# [storage] +# +# ZebraDB location. +# PathBuf, Required. +# zebra_db_path = "" +# +# Network chain type. +# Required. +# Network chain type (Mainnet, Testnet, Regtest). +# network = "Testnet" + +# ---- # Capacity of the Dashmaps used for the Mempool. # Also used by the BlockCache::NonFinalisedState when using the FetchService. @@ -91,25 +106,3 @@ validator_listen_address = "127.0.0.1:18232" # Only used by the FetchService. # If omitted, no specific limit may be enforced by Zaino for this setting initially. # db_size = 100 - -# Network: - -# Network chain type (Mainnet, Testnet, Regtest). -network = "Testnet" - -# Options: - -# Disables internal sync and stops zaino waiting on server to sync with p2p network. -# Useful for testing. -no_sync = false - -# Disables the FinalisedState in the BlockCache -# -# Only used by the FetchServic. -# Used for testing. -# no_db = false - -# When enabled Zaino syncs it DB in the background, fetching data from the validator. -# -# NOTE: Unimplemented. -slow_sync = false From ab13f953bba242ba3c3a9f12a42d9f2d8d69ae80 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:30:06 -0400 Subject: [PATCH 120/162] cleanup zainod config.rs --- zainod/src/config.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/zainod/src/config.rs b/zainod/src/config.rs index ca2139f43..e71d91beb 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -66,10 +66,6 @@ pub struct ZainodConfig { pub zebra_db_path: PathBuf, /// Network chain type. pub network: Network, - // /// Disables internal sync and stops zaino waiting on server sync. - // /// Used for testing. - // // TODO rename disable_internal_sync - // pub no_sync: bool, } impl ZainodConfig { @@ -216,7 +212,6 @@ impl Default for ZainodConfig { }, zebra_db_path: default_zebra_db_path().unwrap(), network: Network::Testnet, - // no_sync: false, } } } @@ -294,7 +289,7 @@ pub(crate) fn is_loopback_listen_addr(addr: &SocketAddr) -> bool { /// /// If the file cannot be read, or if its contents cannot be parsed into `IndexerConfig`, /// a warning is logged, and a default configuration is returned. -/// Finally there is an override of the config using environmental variables. +/// Finally, there is an override of the config using environmental variables. /// The loaded or default configuration undergoes further checks and finalization. pub fn load_config(file_path: &PathBuf) -> Result { // Configuration sources are layered: Env > TOML > Defaults. @@ -308,8 +303,6 @@ pub fn load_config(file_path: &PathBuf) -> Result { match figment.extract::() { Ok(mut parsed_config) => { - // Finalizes the configuration after initial parsing, applying conditional default to json rpc cookie dir, - // if the assigned pathbuf is empty (cookies enabled but no path defined). if parsed_config .json_server_settings .clone() @@ -319,6 +312,7 @@ pub fn load_config(file_path: &PathBuf) -> Result { .cookie_dir .expect("cookie_dir to be Some") .as_os_str() + // if the assigned pathbuf is empty (cookies enabled but no path defined). .is_empty() }) { @@ -375,7 +369,6 @@ impl TryFrom for BackendConfig { service: cfg.service, storage: cfg.storage, network: cfg.network, - // no_sync: cfg.no_sync, })), zaino_state::BackendType::Fetch => Ok(BackendConfig::Fetch(FetchServiceConfig { @@ -392,7 +385,6 @@ impl TryFrom for BackendConfig { service: cfg.service, storage: cfg.storage, network: cfg.network, - // no_sync: cfg.no_sync, })), } } From 7326961f35e4ebf8b2dd3ee0c28c9e12351eaa29 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:32:23 -0400 Subject: [PATCH 121/162] cleanup integration tests chain_cache --- integration-tests/tests/chain_cache.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index e88b30321..e9218b61a 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -8,7 +8,6 @@ async fn create_test_manager_and_connector( activation_heights: Option, chain_cache: Option, enable_zaino: bool, - // zaino_no_sync: bool, enable_clients: bool, ) -> (TestManager, JsonRpSeeConnector) { let test_manager = TestManager::launch( @@ -20,7 +19,6 @@ async fn create_test_manager_and_connector( enable_zaino, false, //enable_zaino_jsonrpc_server: bool, false, //enable_zaino_jsonrpc_server_cookie_auth: bool, - // zaino_no_sync, enable_clients, ) .await @@ -74,7 +72,6 @@ mod chain_query_interface { validator: &ValidatorKind, chain_cache: Option, enable_zaino: bool, - // no_sync enable_clients: bool, ) -> ( TestManager, @@ -117,7 +114,6 @@ mod chain_query_interface { Some(activation_heights), chain_cache.clone(), enable_zaino, - // zaino_no_sync, enable_clients, ) .await; @@ -163,7 +159,6 @@ mod chain_query_interface { }, }, network.into(), - // true, )) .await .unwrap(); From b88786bdcbbc3736dec97c9c5cc6d954ab952d79 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:34:24 -0400 Subject: [PATCH 122/162] cleaup integration tests fetch_service --- integration-tests/tests/fetch_service.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 12fe94a95..1736f5423 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -34,7 +34,6 @@ async fn create_test_manager_and_fetch_service( enable_zaino, false, false, - // zaino_no_sync, enable_clients, ) .await @@ -59,7 +58,6 @@ async fn create_test_manager_and_fetch_service( ..Default::default() }, Network::Regtest(ActivationHeights::default()), - // true, )) .await .unwrap(); From 362f28534c418e786828cee035c06bb59b6c50b9 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:36:22 -0400 Subject: [PATCH 123/162] cleaup integration tests json_server --- integration-tests/tests/json_server.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 859fa9938..cdad40fcd 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -33,7 +33,6 @@ async fn create_test_manager_and_fetch_services( // enable_zaino_jsonrpc_server_cookie_auth: bool, // TODO AFAIK, this is _always_ false enable_cookie_auth, - // true, clients, ) .await @@ -61,7 +60,6 @@ async fn create_test_manager_and_fetch_services( ..Default::default() }, zaino_common::Network::Regtest(ActivationHeights::default()), - // true, )) .await .unwrap(); @@ -96,10 +94,7 @@ async fn create_test_manager_and_fetch_services( }, ..Default::default() }, - // network: Network, zaino_common::Network::Regtest(ActivationHeights::default()), - // no_sync: bool, - // true, )) .await .unwrap(); From e4a8a5b287d1545ec3b80ed76dbc02a402271462 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:37:41 -0400 Subject: [PATCH 124/162] cleaup integration tests local_cache --- integration-tests/tests/local_cache.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index bd4c04914..ff3d9642a 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -13,7 +13,6 @@ async fn create_test_manager_and_block_cache( validator: &ValidatorKind, chain_cache: Option, enable_zaino: bool, - // zaino_no_sync: bool, enable_clients: bool, ) -> ( TestManager, @@ -35,7 +34,6 @@ async fn create_test_manager_and_block_cache( enable_zaino, false, //enable_zaino_jsonrpc_server: bool, false, //enable_zaino_jsonrpc_server_cookie_auth: bool, - // zaino_no_sync, enable_clients, ) .await @@ -73,7 +71,6 @@ async fn create_test_manager_and_block_cache( }, db_version: 1, network: network.into(), - // no_sync: zaino_no_sync, }; let block_cache = BlockCache::spawn(&json_service, None, block_cache_config) From 9ed6b1120825d275a2a7a701c98bdec67aeef3e2 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:39:06 -0400 Subject: [PATCH 125/162] cleaup integration tests state_service --- integration-tests/tests/state_service.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index a3c535515..4375189c6 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -34,7 +34,6 @@ async fn create_test_manager_and_services( enable_zaino, false, false, - // true, enable_clients, ) .await @@ -78,7 +77,6 @@ async fn create_test_manager_and_services( ..Default::default() }, network_type, - // zaino_sync_bool, )) .await .unwrap(); @@ -118,7 +116,6 @@ async fn create_test_manager_and_services( ..Default::default() }, network_type, - // true, )) .await .unwrap(); From de8f14bdc2b3b05b1926d64ff248df5e5a868d3c Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:50:59 -0400 Subject: [PATCH 126/162] remove unused variable --- integration-tests/tests/state_service.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index 4375189c6..9a1ace3c3 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -39,21 +39,18 @@ async fn create_test_manager_and_services( .await .unwrap(); - let (network_type, _zaino_sync_bool) = match network { + let network_type = match network { Some(NetworkKind::Mainnet) => { println!("Waiting for validator to spawn.."); tokio::time::sleep(std::time::Duration::from_millis(5000)).await; - (zaino_common::Network::Mainnet, false) + zaino_common::Network::Mainnet } Some(NetworkKind::Testnet) => { println!("Waiting for validator to spawn.."); tokio::time::sleep(std::time::Duration::from_millis(5000)).await; - (zaino_common::Network::Testnet, false) + zaino_common::Network::Testnet } - _ => ( - zaino_common::Network::Regtest(ActivationHeights::default()), - true, - ), + _ => zaino_common::Network::Regtest(ActivationHeights::default()), }; test_manager.local_net.print_stdout(); From 21de616aeb23f70daf361e739d1d044cd83fabad Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 03:52:51 -0400 Subject: [PATCH 127/162] clean tests chain_cache --- integration-tests/tests/chain_cache.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index e9218b61a..252ca8bbd 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -174,7 +174,6 @@ mod chain_query_interface { }, db_version: 1, network: zaino_common::Network::Regtest(activation_heights), - // no_sync: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::State(chain_index::source::State { @@ -210,7 +209,6 @@ mod chain_query_interface { }, db_version: 1, network: zaino_common::Network::Regtest(activation_heights), - // no_sync: false, }; let chain_index = NodeBackedChainIndex::new( ValidatorConnector::Fetch(json_service.clone()), From 7845d6bbd000db2ad632fd4158992d2efa3be18e Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 04:02:05 -0400 Subject: [PATCH 128/162] cleanup serve server config --- zaino-serve/src/server/config.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 992a7de25..92381bbac 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -69,24 +69,20 @@ impl GrpcServerConfig { #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct JsonRpcServerConfig { /// Server bind addr. - // TODO for this field, assess - // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub json_rpc_listen_address: SocketAddr, - // TODO this is the field that actually is the same in the server as the config. Should we these separate? /// Directory to store authentication cookie file. /// Enable cookie-based authentication with a valid `Some()` value. + /// An empty PathBuf that is still Some will have an emphemeral path assigned to it when zaino loads the config. #[serde(default)] - // An empty PathBuf that is still Some will have an emphemeral path assigned to it when zaino loads the config. pub cookie_dir: Option, } impl Default for JsonRpcServerConfig { fn default() -> Self { Self { - json_rpc_listen_address: - // minimally connectable default: loopback with ephemeral port - "127.0.0.1:0".parse().unwrap(), - cookie_dir: None } + json_rpc_listen_address: "127.0.0.1:0".parse().unwrap(), + cookie_dir: None, + } } } From 3caa10ebd5893b3e539bc7b14a816c702b3d0e71 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 04:09:20 -0400 Subject: [PATCH 129/162] cleanup serve server grpc --- zaino-serve/src/server/grpc.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zaino-serve/src/server/grpc.rs b/zaino-serve/src/server/grpc.rs index 386594b43..5199cd169 100644 --- a/zaino-serve/src/server/grpc.rs +++ b/zaino-serve/src/server/grpc.rs @@ -13,10 +13,7 @@ use crate::{ server::{config::GrpcServerConfig, error::ServerError}, }; -/// LightWallet server capable of servicing clients over TCP. -// TODO rename to gRPC server? -// also, why no listen address? -// below, it's taken straight from the config. +/// LightWallet gRPC server capable of servicing clients over TCP. pub struct TonicServer { /// Current status of the server. pub status: AtomicStatus, From 306abc7f58f6b255ef4da26fcbb962415b35b0e6 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 04:10:23 -0400 Subject: [PATCH 130/162] clean state chain_index tests --- zaino-state/src/chain_index/tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/zaino-state/src/chain_index/tests.rs b/zaino-state/src/chain_index/tests.rs index 713954cff..fd6f32462 100644 --- a/zaino-state/src/chain_index/tests.rs +++ b/zaino-state/src/chain_index/tests.rs @@ -82,7 +82,6 @@ mod mockchain_tests { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let indexer = NodeBackedChainIndex::new(source.clone(), config) From 5bd7cacf2271b60d7cfbbbccfdf08aa2490d9977 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 04:12:24 -0400 Subject: [PATCH 131/162] cleanup tests migrations --- .../src/chain_index/tests/finalised_state/migrations.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/zaino-state/src/chain_index/tests/finalised_state/migrations.rs b/zaino-state/src/chain_index/tests/finalised_state/migrations.rs index 5ea68a73b..691cdde70 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/migrations.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/migrations.rs @@ -31,7 +31,6 @@ async fn v0_to_v1_full() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -43,7 +42,6 @@ async fn v0_to_v1_full() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); @@ -103,7 +101,6 @@ async fn v0_to_v1_interrupted() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -115,7 +112,6 @@ async fn v0_to_v1_interrupted() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); @@ -227,7 +223,6 @@ async fn v0_to_v1_partial() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let v1_config = BlockCacheConfig { storage: StorageConfig { @@ -239,7 +234,6 @@ async fn v0_to_v1_partial() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); From 1842702b2a88c939e61f3376bbea2a8238e09e0d Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 04:15:28 -0400 Subject: [PATCH 132/162] clean state config --- zaino-state/src/config.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index 3391193a7..ecdc9c1cc 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -46,9 +46,6 @@ pub struct StateServiceConfig { pub storage: StorageConfig, /// Network type. pub network: Network, - // /// Disables internal sync and stops zaino waiting on server sync. - // /// Used for testing. - // pub no_sync: bool, } impl StateServiceConfig { @@ -66,7 +63,6 @@ impl StateServiceConfig { service: ServiceConfig, storage: StorageConfig, network: Network, - // no_sync: bool, ) -> Self { StateServiceConfig { validator_state_config, @@ -79,7 +75,6 @@ impl StateServiceConfig { service, storage, network, - // no_sync, } } } @@ -104,15 +99,11 @@ pub struct FetchServiceConfig { pub storage: StorageConfig, /// Network type. pub network: Network, - // /// Disables internal sync and stops zaino waiting on server sync. - // /// Used for testing. - // pub no_sync: bool, } impl FetchServiceConfig { /// Returns a new instance of [`FetchServiceConfig`]. #[allow(clippy::too_many_arguments)] - // TODO: replace with struct-literal init only? pub fn new( validator_rpc_address: std::net::SocketAddr, validator_cookie_path: Option, @@ -121,7 +112,6 @@ impl FetchServiceConfig { service: ServiceConfig, storage: StorageConfig, network: Network, - // no_sync: bool, ) -> Self { FetchServiceConfig { validator_rpc_address, @@ -131,7 +121,6 @@ impl FetchServiceConfig { service, storage, network, - // no_sync, } } } @@ -146,9 +135,6 @@ pub struct BlockCacheConfig { pub db_version: u32, /// Network type. pub network: Network, - // /// Stops zaino waiting on server sync. - // /// Used for testing. - // pub no_sync: bool, } impl BlockCacheConfig { @@ -159,7 +145,6 @@ impl BlockCacheConfig { storage, db_version, network, - // no_sync, } } } @@ -171,7 +156,6 @@ impl From for BlockCacheConfig { // TODO: update zaino configs to include db version. db_version: 1, network: value.network, - // no_sync: value.no_sync, } } } @@ -183,7 +167,6 @@ impl From for BlockCacheConfig { // TODO: update zaino configs to include db version. db_version: 1, network: value.network, - // no_sync: value.no_sync, } } } From 0d52ecf506f7162bb2f7bdcc57207000e48adda8 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 04:23:10 -0400 Subject: [PATCH 133/162] cleanup integration test vectors --- integration-tests/tests/test_vectors.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index d9aed1380..d5b981b6d 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -62,7 +62,6 @@ async fn create_test_manager_and_services( enable_zaino, false, false, - // true, enable_clients, ) .await @@ -120,7 +119,6 @@ async fn create_test_manager_and_services( ..Default::default() }, network_type, - // zaino_sync_bool, )) .await .unwrap(); From e8b29f5a3266c97c8190eac745feda8b4f4b8946 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 05:12:08 -0400 Subject: [PATCH 134/162] remove unused var test_vectors --- integration-tests/tests/test_vectors.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index d5b981b6d..117e59c49 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -67,21 +67,18 @@ async fn create_test_manager_and_services( .await .unwrap(); - let (network_type, _zaino_sync_bool) = match network { + let network_type = match network { Some(NetworkKind::Mainnet) => { println!("Waiting for validator to spawn.."); tokio::time::sleep(std::time::Duration::from_millis(5000)).await; - (zaino_common::Network::Mainnet, false) + zaino_common::Network::Mainnet } Some(NetworkKind::Testnet) => { println!("Waiting for validator to spawn.."); tokio::time::sleep(std::time::Duration::from_millis(5000)).await; - (zaino_common::Network::Testnet, false) + zaino_common::Network::Testnet } - _ => ( - zaino_common::Network::Regtest(ActivationHeights::default()), - true, - ), + _ => zaino_common::Network::Regtest(ActivationHeights::default()), }; test_manager.local_net.print_stdout(); From d342cf125efcb8d9bfdc1ebc61a660410b1090ec Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 05:19:07 -0400 Subject: [PATCH 135/162] clean fetch rpsee connector --- zaino-fetch/src/jsonrpsee/connector.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zaino-fetch/src/jsonrpsee/connector.rs b/zaino-fetch/src/jsonrpsee/connector.rs index befca97a6..a780fabad 100644 --- a/zaino-fetch/src/jsonrpsee/connector.rs +++ b/zaino-fetch/src/jsonrpsee/connector.rs @@ -223,8 +223,7 @@ impl JsonRpSeeConnector { }) } - /// Helper function to create from parts of a StateServiceConfig or - /// FetchServiceConfig + /// Helper function to create from parts of a StateServiceConfig or FetchServiceConfig pub async fn new_from_config_parts( validator_rpc_address: SocketAddr, validator_rpc_user: String, @@ -271,7 +270,6 @@ impl JsonRpSeeConnector { } /// Sends a jsonRPC request and returns the response. - /// /// NOTE: This function currently resends the call up to 5 times on a server response of "Work queue depth exceeded". /// This is because the node's queue can become overloaded and stop servicing RPCs. async fn send_request< @@ -811,7 +809,6 @@ pub async fn test_node_and_return_url( let auth_method = match cookie_path.is_some() { true => { let cookie_file_path_str = cookie_path.expect("validator rpc cookie path missing"); - let cookie_password = read_and_parse_cookie_token(Path::new(&cookie_file_path_str))?; AuthMethod::Cookie { cookie: cookie_password, From 7f97df9cf1a62e66bc64f326733886be110c428a Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 19:46:14 -0400 Subject: [PATCH 136/162] whitespace --- zainod/zindexer.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zainod/zindexer.toml b/zainod/zindexer.toml index 8e590df70..e856aa6a7 100644 --- a/zainod/zindexer.toml +++ b/zainod/zindexer.toml @@ -12,7 +12,7 @@ backend = "fetch" [json_server_settings] # JsonRPC server listen addr. Required if json_server_settings is Some. json_rpc_listen_address = "127.0.0.1:8237" - + # Some enables cookie-based authentication for JsonRPC server. # An empty PathBuf that is still Some will have a default emphemeral path assigned to it when zaino loads the config. # (e.g., /tmp/zaino/.cookie or XDG_RUNTIME_DIR) will be used. @@ -61,7 +61,7 @@ backend = "fetch" # Optional. Enable user / pass authentication with Some # full node / validator Password. # validator_password: "" - # + # # Service-level configuration (timeout, channel size). # Required. # [service] @@ -70,11 +70,11 @@ backend = "fetch" # Storage configuration (cache and database). # Required. # [storage] -# +# # ZebraDB location. # PathBuf, Required. # zebra_db_path = "" -# +# # Network chain type. # Required. # Network chain type (Mainnet, Testnet, Regtest). From 2a7ce22b4317a92712e0bd5d155b421617bd7f0b Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 22:54:43 -0400 Subject: [PATCH 137/162] add const to zaino_common network --- zaino-common/src/network.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/zaino-common/src/network.rs b/zaino-common/src/network.rs index d932c242a..bc756ab8b 100644 --- a/zaino-common/src/network.rs +++ b/zaino-common/src/network.rs @@ -3,6 +3,19 @@ use serde::{Deserialize, Serialize}; use zebra_chain::parameters::testnet::ConfiguredActivationHeights; +pub const ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS: ActivationHeights = ActivationHeights { + overwinter: Some(1), + before_overwinter: Some(1), + sapling: Some(1), + blossom: Some(1), + heartwood: Some(1), + canopy: Some(1), + nu5: Some(2), + nu6: Some(2), + nu6_1: Some(1000), + nu7: None, +}; + /// Network type for Zaino configuration. #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[serde(from = "NetworkDeserialize")] @@ -31,7 +44,7 @@ impl From for Network { match value { NetworkDeserialize::Mainnet => Network::Mainnet, NetworkDeserialize::Testnet => Network::Testnet, - NetworkDeserialize::Regtest => Network::Regtest(ActivationHeights::default()), + NetworkDeserialize::Regtest => Network::Regtest(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), } } } @@ -76,18 +89,7 @@ pub struct ActivationHeights { impl Default for ActivationHeights { fn default() -> Self { - ActivationHeights { - before_overwinter: Some(1), - overwinter: Some(1), - sapling: Some(1), - blossom: Some(1), - heartwood: Some(1), - canopy: Some(1), - nu5: Some(2), - nu6: Some(2), - nu6_1: Some(1000), - nu7: None, - } + ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS } } From aa0bdaea17ae0dd07fddd05a635fc9f8f5308145 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 22:55:29 -0400 Subject: [PATCH 138/162] const in integration tests state service, launch w/o helper start --- integration-tests/tests/state_service.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index b520b5672..3564a0eff 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -1,4 +1,4 @@ -use zaino_common::network::ActivationHeights; +use zaino_common::network::{ActivationHeights, ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS}; use zaino_common::{DatabaseConfig, ServiceConfig, StorageConfig}; use zaino_state::BackendType; use zaino_state::{ @@ -26,10 +26,11 @@ async fn create_test_manager_and_services( StateService, StateServiceSubscriber, ) { - let test_manager = TestManager::launch_with_default_activation_heights( + let test_manager = TestManager::launch( validator, &BackendType::Fetch, network, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), chain_cache.clone(), enable_zaino, false, From 2538c8cb2a4415f1e837d81debaede323371788e Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 22:59:58 -0400 Subject: [PATCH 139/162] testutils lib import const --- zaino-testutils/src/lib.rs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index b6fdbf329..3840185c8 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -16,8 +16,8 @@ use std::{ use tempfile::TempDir; use tracing_subscriber::EnvFilter; use zaino_common::{ - network::ActivationHeights, validator::ValidatorConfig, CacheConfig, DatabaseConfig, Network, - ServiceConfig, StorageConfig, + network::ActivationHeights, network::ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, + validator::ValidatorConfig, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, }; use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::BackendType; @@ -32,21 +32,6 @@ pub use zingolib::lightclient::LightClient; pub use zingolib::testutils::lightclient::from_inputs; use zingolib::testutils::scenarios::ClientBuilder; -// TODO: update zebra to allow full nu6.1 test support -/// Temporary default zebrad activation height until zaino is updated to next zebra release (or latest main). -pub const ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS: ActivationHeights = ActivationHeights { - overwinter: Some(1), - before_overwinter: Some(1), - sapling: Some(1), - blossom: Some(1), - heartwood: Some(1), - canopy: Some(1), - nu5: Some(2), - nu6: Some(2), - nu6_1: Some(1000), - nu7: None, -}; - /// Helper to get the test binary path from the TEST_BINARIES_DIR env var. fn binary_path(binary_name: &str) -> Option { std::env::var("TEST_BINARIES_DIR") @@ -601,6 +586,9 @@ impl TestManager { /// Helper function to support default test case. #[allow(clippy::too_many_arguments)] + // TODO it all comes through here.. to this to make a testmanager... + // and this is like a SHIM to account for different defaults, depending on which validtor_kind (full node) is being used. + // so really we only need this because the activation heights are (presumably) different!? pub async fn launch_with_default_activation_heights( validator_kind: &ValidatorKind, backend: &BackendType, @@ -612,6 +600,13 @@ impl TestManager { // zaino_no_sync: bool, enable_clients: bool, ) -> Result { + // These are the same lol + println!( + "CONST {:?} , default: {:?}", + ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, + ActivationHeights::default() + ); + // panic!("came to the wrong hood this time"); let activation_heights = match validator_kind { ValidatorKind::Zebrad => ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, ValidatorKind::Zcashd => ActivationHeights::default(), From 880f8384d7440219a66f7c345a2402b5e574b23c Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 23:01:22 -0400 Subject: [PATCH 140/162] testutils lib cleanup --- zaino-testutils/src/lib.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 3840185c8..d6354ba18 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -586,9 +586,6 @@ impl TestManager { /// Helper function to support default test case. #[allow(clippy::too_many_arguments)] - // TODO it all comes through here.. to this to make a testmanager... - // and this is like a SHIM to account for different defaults, depending on which validtor_kind (full node) is being used. - // so really we only need this because the activation heights are (presumably) different!? pub async fn launch_with_default_activation_heights( validator_kind: &ValidatorKind, backend: &BackendType, @@ -597,16 +594,8 @@ impl TestManager { enable_zaino: bool, enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, - // zaino_no_sync: bool, enable_clients: bool, ) -> Result { - // These are the same lol - println!( - "CONST {:?} , default: {:?}", - ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, - ActivationHeights::default() - ); - // panic!("came to the wrong hood this time"); let activation_heights = match validator_kind { ValidatorKind::Zebrad => ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, ValidatorKind::Zcashd => ActivationHeights::default(), @@ -622,7 +611,6 @@ impl TestManager { enable_zaino_jsonrpc_server, // TODO : in our tests, is always set to false enable_zaino_jsonrpc_server_cookie_auth, - // zaino_no_sync, enable_clients, ) .await From 6363d9ac751f17e3c72b0f57640fbc53f7751ef8 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 23:09:35 -0400 Subject: [PATCH 141/162] launching integration tests without extra helper fn --- integration-tests/tests/fetch_service.rs | 17 ++++++++++++----- integration-tests/tests/json_server.rs | 5 +++-- integration-tests/tests/local_cache.rs | 7 +++++-- integration-tests/tests/test_vectors.rs | 4 +++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 5f138e38d..de4f8c61e 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -1,7 +1,7 @@ //! These tests compare the output of `FetchService` with the output of `JsonRpcConnector`. use futures::StreamExt as _; -use zaino_common::network::ActivationHeights; +use zaino_common::network::{ActivationHeights, ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS}; use zaino_common::{DatabaseConfig, Network, ServiceConfig, StorageConfig}; use zaino_fetch::jsonrpsee::connector::{test_node_and_return_url, JsonRpSeeConnector}; use zaino_proto::proto::service::{ @@ -26,10 +26,15 @@ async fn create_test_manager_and_fetch_service( _zaino_no_sync: bool, enable_clients: bool, ) -> (TestManager, FetchService, FetchServiceSubscriber) { - let test_manager = TestManager::launch_with_default_activation_heights( + // TODO first in return is the testmanager, everything else depends on it + let test_manager = TestManager::launch( validator, &BackendType::Fetch, None, + // TODO just like launch, but w/o one var. + // between 3 + 4 are activation heights... + // Some(ZEBRAD_CONST) wherever this launch_with_default is used + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), chain_cache, enable_zaino, false, @@ -39,6 +44,7 @@ async fn create_test_manager_and_fetch_service( .await .unwrap(); + // TODO fetch_service leans on the established test manager to populate its fields. let fetch_service = FetchService::spawn(FetchServiceConfig::new( test_manager.full_node_rpc_listen_address, None, @@ -61,7 +67,9 @@ async fn create_test_manager_and_fetch_service( )) .await .unwrap(); + // TODO subscriber leans on the fetch service let subscriber = fetch_service.get_subscriber().inner(); + // TODO and here's the return (test_manager, fetch_service, subscriber) } @@ -604,14 +612,13 @@ async fn assert_fetch_service_difficulty_matches_rpc(validator: &ValidatorKind) async fn assert_fetch_service_mininginfo_matches_rpc(validator: &ValidatorKind) { let (test_manager, _fetch_service, fetch_service_subscriber) = - create_test_manager_and_fetch_service(validator, None, true, true, true, true).await; + create_test_manager_and_fetch_service(validator, None, true, true, true).await; let fetch_service_mining_info = fetch_service_subscriber.get_mining_info().await.unwrap(); let jsonrpc_client = JsonRpSeeConnector::new_with_basic_auth( test_node_and_return_url( - test_manager.zebrad_rpc_listen_address, - false, + test_manager.full_node_rpc_listen_address, None, Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 40c09d787..5173267bf 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -1,6 +1,6 @@ //! Tests that compare the output of both `zcashd` and `zainod` through `FetchService`. -use zaino_common::network::ActivationHeights; +use zaino_common::network::{ActivationHeights, ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS}; use zaino_common::{DatabaseConfig, ServiceConfig, StorageConfig}; use zaino_state::{ BackendType, FetchService, FetchServiceConfig, FetchServiceSubscriber, ZcashIndexer, @@ -23,10 +23,11 @@ async fn create_test_manager_and_fetch_services( FetchServiceSubscriber, ) { println!("Launching test manager.."); - let test_manager = TestManager::launch_with_default_activation_heights( + let test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, true, diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index ff3d9642a..cec8c47a4 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -1,11 +1,14 @@ -use zaino_common::{network::ActivationHeights, DatabaseConfig, StorageConfig}; +use zaino_common::{ + network::ActivationHeights, network::ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, DatabaseConfig, + StorageConfig, +}; use zaino_fetch::jsonrpsee::connector::{test_node_and_return_url, JsonRpSeeConnector}; use zaino_state::{ test_dependencies::{BlockCache, BlockCacheConfig, BlockCacheSubscriber}, BackendType, }; +use zaino_testutils::Validator; use zaino_testutils::{TestManager, ValidatorKind}; -use zaino_testutils::{Validator as _, ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS}; use zebra_chain::{block::Height, parameters::NetworkKind}; use zebra_state::HashOrHeight; diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index 117e59c49..d46f10e63 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -11,6 +11,7 @@ use std::path::Path; use std::sync::Arc; use tower::{Service, ServiceExt as _}; use zaino_common::network::ActivationHeights; +use zaino_common::network::ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS; use zaino_common::DatabaseConfig; use zaino_common::ServiceConfig; use zaino_common::StorageConfig; @@ -54,10 +55,11 @@ async fn create_test_manager_and_services( enable_clients: bool, network: Option, ) -> (TestManager, StateService, StateServiceSubscriber) { - let test_manager = TestManager::launch_with_default_activation_heights( + let test_manager = TestManager::launch( validator, &BackendType::Fetch, network, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), chain_cache.clone(), enable_zaino, false, From 8b184259316a8befe0ff0f683ddbf60ae77ac815 Mon Sep 17 00:00:00 2001 From: al amoda Date: Tue, 21 Oct 2025 23:24:52 -0400 Subject: [PATCH 142/162] launching wallet_to_validator tests without extra helper fn --- .../tests/wallet_to_validator.rs | 85 ++++++++++++++++--- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index b49b2b77d..0051ca89f 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -2,6 +2,7 @@ #![forbid(unsafe_code)] +use zaino_common::network::{ActivationHeights, ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS}; use zaino_fetch::jsonrpsee::connector::test_node_and_return_url; use zaino_state::BackendType; use zaino_testutils::from_inputs; @@ -10,8 +11,16 @@ use zaino_testutils::ValidatorKind; use zip32::AccountId; async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backend: &BackendType) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); @@ -27,8 +36,16 @@ async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backe } async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); @@ -70,8 +87,16 @@ async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { } async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); @@ -113,8 +138,16 @@ async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { } async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); @@ -216,8 +249,16 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { } async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); @@ -307,8 +348,16 @@ async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { } async fn shield_for_validator(validator: &ValidatorKind, backend: &BackendType) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); @@ -383,8 +432,16 @@ async fn monitor_unverified_mempool_for_validator( validator: &ValidatorKind, backend: &BackendType, ) { - let mut test_manager = TestManager::launch_with_default_activation_heights( - validator, backend, None, None, true, false, false, true, + let mut test_manager = TestManager::launch( + validator, + backend, + None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), + None, + true, + false, + false, + true, ) .await .unwrap(); From ad48dc5fa759a7aa9c682935f48e6cc298af6fbd Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 22 Oct 2025 01:03:36 -0400 Subject: [PATCH 143/162] cleanup wallet_to_validator --- integration-tests/tests/wallet_to_validator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index 0051ca89f..95c69e0f1 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -2,7 +2,7 @@ #![forbid(unsafe_code)] -use zaino_common::network::{ActivationHeights, ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS}; +use zaino_common::network::ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS; use zaino_fetch::jsonrpsee::connector::test_node_and_return_url; use zaino_state::BackendType; use zaino_testutils::from_inputs; From 6a6112e0e96d732153daf10de32ef9c409431a92 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 22 Oct 2025 01:04:21 -0400 Subject: [PATCH 144/162] change testutils lib launch_with to launch --- zaino-testutils/src/lib.rs | 66 +++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index d6354ba18..db7cd5c38 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -662,10 +662,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn basic() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, false, false, @@ -684,10 +685,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn generate_blocks() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, false, false, @@ -712,10 +714,11 @@ mod launch_testmanager { #[ignore = "chain cache needs development"] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn with_chain() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), ZCASHD_CHAIN_CACHE_DIR.clone(), false, false, @@ -734,10 +737,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -760,10 +764,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -787,10 +792,11 @@ mod launch_testmanager { /// Even if rewards need 100 confirmations these blocks should not have to be mined at the same time. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients_receive_mining_reward() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zcashd, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -836,10 +842,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn basic() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, false, false, @@ -858,10 +865,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn generate_blocks() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, false, false, @@ -886,10 +894,11 @@ mod launch_testmanager { #[ignore = "chain cache needs development"] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn with_chain() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), ZEBRAD_CHAIN_CACHE_DIR.clone(), false, false, @@ -908,10 +917,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -934,10 +944,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -961,10 +972,11 @@ mod launch_testmanager { /// Even if rewards need 100 confirmations these blocks should not have to be mined at the same time. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients_receive_mining_reward() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -1007,10 +1019,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients_receive_mining_reward_and_send() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -1108,10 +1121,11 @@ mod launch_testmanager { #[ignore = "requires fully synced testnet."] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_testnet() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::Fetch, Some(NetworkKind::Testnet), + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), ZEBRAD_TESTNET_CACHE_DIR.clone(), true, false, @@ -1139,10 +1153,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn basic() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, false, false, @@ -1161,10 +1176,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn generate_blocks() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, false, false, @@ -1189,10 +1205,11 @@ mod launch_testmanager { #[ignore = "chain cache needs development"] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn with_chain() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), ZEBRAD_CHAIN_CACHE_DIR.clone(), false, false, @@ -1211,10 +1228,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -1237,10 +1255,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -1264,10 +1283,11 @@ mod launch_testmanager { /// Even if rewards need 100 confirmations these blocks should not have to be mined at the same time. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients_receive_mining_reward() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -1311,10 +1331,11 @@ mod launch_testmanager { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_clients_receive_mining_reward_and_send() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, None, + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, false, @@ -1410,10 +1431,11 @@ mod launch_testmanager { #[ignore = "requires fully synced testnet."] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] pub(crate) async fn zaino_testnet() { - let mut test_manager = TestManager::launch_with_default_activation_heights( + let mut test_manager = TestManager::launch( &ValidatorKind::Zebrad, &BackendType::State, Some(NetworkKind::Testnet), + Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), ZEBRAD_TESTNET_CACHE_DIR.clone(), true, false, From fa1e38a14e08ba68c17d0c2757f8c6bf8a3e6f06 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 22 Oct 2025 02:28:59 -0400 Subject: [PATCH 145/162] remove launch_with_default, mv const, cleanup --- zaino-testutils/src/lib.rs | 40 ++++---------------------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index db7cd5c38..1e95b55b2 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -16,8 +16,8 @@ use std::{ use tempfile::TempDir; use tracing_subscriber::EnvFilter; use zaino_common::{ - network::ActivationHeights, network::ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, - validator::ValidatorConfig, CacheConfig, DatabaseConfig, Network, ServiceConfig, StorageConfig, + network::ActivationHeights, validator::ValidatorConfig, CacheConfig, DatabaseConfig, Network, + ServiceConfig, StorageConfig, }; use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::BackendType; @@ -250,6 +250,7 @@ impl zcash_local_net::validator::Validator for LocalNet { } fn config_dir(&self) -> &TempDir { + // TODO crufty match self { LocalNet::Zcashd(net) => net.validator().config_dir(), LocalNet::Zebrad(net) => net.validator().config_dir(), @@ -382,7 +383,6 @@ impl TestManager { enable_zaino: bool, enable_zaino_jsonrpc_server: bool, enable_zaino_jsonrpc_server_cookie_auth: bool, - // zaino_no_sync: bool, enable_clients: bool, ) -> Result { if (validator == &ValidatorKind::Zcashd) && (backend == &BackendType::State) { @@ -505,7 +505,6 @@ impl TestManager { }, zebra_db_path, network: zaino_network_kind, - // no_sync: zaino_no_sync, }; // TODO we create the handle here, with indexer_config. // I think we could possibly ... spit out the indexer stuff if we need it later, piece by piece? @@ -584,38 +583,6 @@ impl TestManager { Ok(test_manager) } - /// Helper function to support default test case. - #[allow(clippy::too_many_arguments)] - pub async fn launch_with_default_activation_heights( - validator_kind: &ValidatorKind, - backend: &BackendType, - network: Option, - chain_cache: Option, - enable_zaino: bool, - enable_zaino_jsonrpc_server: bool, - enable_zaino_jsonrpc_server_cookie_auth: bool, - enable_clients: bool, - ) -> Result { - let activation_heights = match validator_kind { - ValidatorKind::Zebrad => ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS, - ValidatorKind::Zcashd => ActivationHeights::default(), - }; - - Self::launch( - validator_kind, - backend, - network, - Some(activation_heights), - chain_cache, - enable_zaino, - enable_zaino_jsonrpc_server, - // TODO : in our tests, is always set to false - enable_zaino_jsonrpc_server_cookie_auth, - enable_clients, - ) - .await - } - /// Generates `blocks` regtest blocks. /// Adds a delay between blocks to allow zaino / zebra to catch up with test. pub async fn generate_blocks_with_delay(&self, blocks: u32) { @@ -644,6 +611,7 @@ impl Drop for TestManager { #[cfg(test)] mod launch_testmanager { + use zaino_common::network::ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS; use zcash_client_backend::proto::service::compact_tx_streamer_client::CompactTxStreamerClient; use zingo_netutils::{GetClientError, GrpcConnector, UnderlyingService}; From 54f1001af093fcac9c6c1b8b563a513adf208f97 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 22 Oct 2025 02:34:44 -0400 Subject: [PATCH 146/162] cleanup integration tests fetch service --- integration-tests/tests/fetch_service.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index de4f8c61e..726237345 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -31,9 +31,6 @@ async fn create_test_manager_and_fetch_service( validator, &BackendType::Fetch, None, - // TODO just like launch, but w/o one var. - // between 3 + 4 are activation heights... - // Some(ZEBRAD_CONST) wherever this launch_with_default is used Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), chain_cache, enable_zaino, From ae2e009c2763f5fbd322cba26361be2889301b77 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 22 Oct 2025 02:51:06 -0400 Subject: [PATCH 147/162] testutils lib cleanup --- zaino-testutils/src/lib.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 1e95b55b2..5b5b6a6c6 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -162,6 +162,7 @@ impl zcash_local_net::validator::Validator for LocalNet { todo!() } + // TODO many of these matches could be less verbose, perhaps by defining a into-inner kind of fuction. fn get_activation_heights( &self, ) -> zebra_chain::parameters::testnet::ConfiguredActivationHeights { @@ -639,7 +640,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -662,7 +662,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -691,7 +690,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -714,7 +712,6 @@ mod launch_testmanager { true, false, false, - // true, false, ) .await @@ -741,7 +738,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -769,7 +765,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -819,7 +814,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -842,7 +836,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -871,7 +864,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -894,7 +886,6 @@ mod launch_testmanager { true, false, false, - // true, false, ) .await @@ -921,7 +912,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -949,7 +939,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -996,7 +985,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -1098,7 +1086,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -1130,7 +1117,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -1153,7 +1139,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -1182,7 +1167,6 @@ mod launch_testmanager { false, false, false, - // true, false, ) .await @@ -1205,7 +1189,6 @@ mod launch_testmanager { true, false, false, - // true, false, ) .await @@ -1232,7 +1215,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -1260,7 +1242,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -1308,7 +1289,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await @@ -1408,7 +1388,6 @@ mod launch_testmanager { true, false, false, - // true, true, ) .await From b320bdf4a3be3ba873bbc787fc1848c2a26e7847 Mon Sep 17 00:00:00 2001 From: al amoda Date: Wed, 22 Oct 2025 02:58:56 -0400 Subject: [PATCH 148/162] cleanup, notes --- integration-tests/tests/fetch_service.rs | 3 ++- zaino-state/src/chain_index/tests/finalised_state/v1.rs | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 726237345..27cb35412 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -19,6 +19,7 @@ use zebra_rpc::client::ValidateAddressResponse; use zebra_rpc::methods::{AddressStrings, GetAddressTxIdsRequest, GetBlock, GetBlockHash}; use zip32::AccountId; +// TODO one unused var in tuple across 47 uses. async fn create_test_manager_and_fetch_service( validator: &ValidatorKind, chain_cache: Option, @@ -26,7 +27,7 @@ async fn create_test_manager_and_fetch_service( _zaino_no_sync: bool, enable_clients: bool, ) -> (TestManager, FetchService, FetchServiceSubscriber) { - // TODO first in return is the testmanager, everything else depends on it + // TODO launch sets us up for subsequent steps let test_manager = TestManager::launch( validator, &BackendType::Fetch, diff --git a/zaino-state/src/chain_index/tests/finalised_state/v1.rs b/zaino-state/src/chain_index/tests/finalised_state/v1.rs index f830d4e16..79b88d3e6 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/v1.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/v1.rs @@ -37,7 +37,6 @@ pub(crate) async fn spawn_v1_zaino_db( }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let zaino_db = ZainoDB::spawn(config, source).await.unwrap(); @@ -215,7 +214,6 @@ async fn save_db_to_file_and_reload() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); @@ -325,7 +323,6 @@ async fn load_db_backend_from_file() { }, db_version: 1, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let finalized_state_backend = DbBackend::spawn_v1(&config).await.unwrap(); From e5b0c239d5a3e2f727454def8b383747b06d0be1 Mon Sep 17 00:00:00 2001 From: al amoda Date: Fri, 24 Oct 2025 17:11:36 -0400 Subject: [PATCH 149/162] begin cleanup --- zaino-state/src/config.rs | 1 - zaino-testutils/src/lib.rs | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index ecdc9c1cc..d2626846b 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -85,7 +85,6 @@ impl StateServiceConfig { pub struct FetchServiceConfig { /// Validator JsonRPC address. pub validator_rpc_address: std::net::SocketAddr, - // pub validator_cookie_auth: bool, /// Enable validator rpc cookie authentification with Some. /// Path to the validator cookie file. pub validator_cookie_path: Option, diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 5b5b6a6c6..5e33b56b7 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -358,7 +358,12 @@ pub struct TestManager { pub zaino_grpc_listen_address: Option, /// JsonRPC server cookie dir. // TODO ambiguity + // TODO + // looking for: + // test_manager.json_server_cookie_dir.clone(), + // is it a validator cookie path?! // TODO PATH to validator cookie file!???! + // this really seems like a ZAINO server system piece. pub json_server_cookie_dir: Option, /// Zingolib lightclients. pub clients: Option, @@ -456,14 +461,9 @@ impl TestManager { let zaino_grpc_listen_port = portpicker::pick_unused_port().expect("No ports free"); let zaino_grpc_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_grpc_listen_port); - - // generating port on the spot let zaino_json_listen_port = portpicker::pick_unused_port().expect("No ports free"); - // set to localhost with the newly generated port let zaino_json_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_json_listen_port); - - // this cookie dir is generated on the spot, whenever zaino is enabled let mut zaino_json_server_cookie_dir: Option = None; if enable_zaino_jsonrpc_server_cookie_auth { zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); @@ -573,6 +573,7 @@ impl TestManager { zaino_handle, zaino_json_rpc_listen_address: zaino_json_listen_address, zaino_grpc_listen_address, + // TODO here, it's defined as zaino json server cookie dir... json_server_cookie_dir: zaino_json_server_cookie_dir, clients, }; From 9cd9049427d4f9c2ec9cec454806239cfa835647 Mon Sep 17 00:00:00 2001 From: al amoda Date: Fri, 24 Oct 2025 17:19:29 -0400 Subject: [PATCH 150/162] cleanup --- integration-tests/tests/json_server.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 5173267bf..4fa4e1966 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -69,20 +69,13 @@ async fn create_test_manager_and_fetch_services( tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; println!("Launching zaino fetch service.."); + let zaino_fetch_service = FetchService::spawn(FetchServiceConfig::new( - // validator_rpc_address: std::net::SocketAddr, test_manager.full_node_rpc_listen_address, - // zaino_json_server_address, - // validator_cookie_path: Option, - // TODO this is suspect. test_manager.json_server_cookie_dir.clone(), - // validator_rpc_user: Option, None, - // validator_rpc_password: Option, None, - // service: ServiceConfig, ServiceConfig::default(), - // storage: StorageConfig, StorageConfig { database: DatabaseConfig { path: test_manager From e5af10f0fb6903a85291667022486de24bf84d3f Mon Sep 17 00:00:00 2001 From: al amoda Date: Fri, 24 Oct 2025 17:50:16 -0400 Subject: [PATCH 151/162] cleanup --- integration-tests/tests/chain_cache.rs | 4 +-- integration-tests/tests/fetch_service.rs | 4 --- integration-tests/tests/json_server.rs | 1 - integration-tests/tests/local_cache.rs | 4 +-- zaino-common/src/validator.rs | 9 +----- zaino-serve/src/server/config.rs | 12 ++----- zaino-serve/src/server/grpc.rs | 1 - .../chain_index/tests/finalised_state/v0.rs | 2 -- zaino-state/src/config.rs | 7 ++--- .../src/local_cache/finalised_state.rs | 1 - .../src/local_cache/non_finalised_state.rs | 1 - zaino-testutils/src/lib.rs | 31 ------------------- 12 files changed, 9 insertions(+), 68 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index 252ca8bbd..c14e0c964 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -17,8 +17,8 @@ async fn create_test_manager_and_connector( activation_heights, chain_cache, enable_zaino, - false, //enable_zaino_jsonrpc_server: bool, - false, //enable_zaino_jsonrpc_server_cookie_auth: bool, + false, + false, enable_clients, ) .await diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 27cb35412..89797dd34 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -27,7 +27,6 @@ async fn create_test_manager_and_fetch_service( _zaino_no_sync: bool, enable_clients: bool, ) -> (TestManager, FetchService, FetchServiceSubscriber) { - // TODO launch sets us up for subsequent steps let test_manager = TestManager::launch( validator, &BackendType::Fetch, @@ -42,7 +41,6 @@ async fn create_test_manager_and_fetch_service( .await .unwrap(); - // TODO fetch_service leans on the established test manager to populate its fields. let fetch_service = FetchService::spawn(FetchServiceConfig::new( test_manager.full_node_rpc_listen_address, None, @@ -65,9 +63,7 @@ async fn create_test_manager_and_fetch_service( )) .await .unwrap(); - // TODO subscriber leans on the fetch service let subscriber = fetch_service.get_subscriber().inner(); - // TODO and here's the return (test_manager, fetch_service, subscriber) } diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 4fa4e1966..ced471ca0 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -69,7 +69,6 @@ async fn create_test_manager_and_fetch_services( tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; println!("Launching zaino fetch service.."); - let zaino_fetch_service = FetchService::spawn(FetchServiceConfig::new( test_manager.full_node_rpc_listen_address, test_manager.json_server_cookie_dir.clone(), diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index cec8c47a4..a2bdc4293 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -35,8 +35,8 @@ async fn create_test_manager_and_block_cache( Some(activation_heights), chain_cache, enable_zaino, - false, //enable_zaino_jsonrpc_server: bool, - false, //enable_zaino_jsonrpc_server_cookie_auth: bool, + false, + false, enable_clients, ) .await diff --git a/zaino-common/src/validator.rs b/zaino-common/src/validator.rs index c9bae23e1..c2839bcc3 100644 --- a/zaino-common/src/validator.rs +++ b/zaino-common/src/validator.rs @@ -7,19 +7,12 @@ use std::path::PathBuf; /// Validator (full-node) type for Zaino configuration. #[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)] -// #[serde(from = "ValidatorDeserialize")] pub struct ValidatorConfig { - // jsonrpc and grpc addresses always known. /// Full node / validator gprc listen port. - //#[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub validator_grpc_listen_address: SocketAddr, - /// Full node / validator listen port. - // #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub validator_jsonrpc_listen_address: SocketAddr, - - /// Enable validator rpc cookie authentication with Some - /// Path to the validator cookie file. + /// Path to the validator cookie file. Enable validator rpc cookie authentication with Some. pub validator_cookie_path: Option, /// Full node / validator Username. pub validator_user: Option, diff --git a/zaino-serve/src/server/config.rs b/zaino-serve/src/server/config.rs index 92381bbac..03a1e244a 100644 --- a/zaino-serve/src/server/config.rs +++ b/zaino-serve/src/server/config.rs @@ -6,8 +6,7 @@ use tonic::transport::{Identity, ServerTlsConfig}; use super::error::ServerError; -/// when a Zaino is configured with gRPC tls, it has paths to key and certificate. -/// gRPC TLS settings +/// Settings for a Zaino configured with gRPC TLS: paths to key and certificate. #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcTls { /// Path to the TLS certificate file in PEM format. @@ -20,7 +19,6 @@ pub struct GrpcTls { #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct GrpcServerConfig { /// gRPC server bind addr. - // TODO for this field, assess #[serde(deserialize_with = "deserialize_socketaddr_from_string")] pub listen_address: SocketAddr, /// Enables TLS. pub tls: Option, @@ -29,7 +27,6 @@ pub struct GrpcServerConfig { impl GrpcServerConfig { /// If TLS is enabled, reads the certificate and key files and returns a valid /// `ServerTlsConfig`. If TLS is not enabled, returns `Ok(None)`. - // TODO : redundant? pub async fn get_valid_tls(&self) -> Result, ServerError> { match self.tls.clone() { Some(tls) => { @@ -46,16 +43,12 @@ impl GrpcServerConfig { )); } let key_path = tls.key_path; - - // Read the certificate and key files asynchronously. let cert = tokio::fs::read(cert_path).await.map_err(|e| { ServerError::ServerConfigError(format!("Failed to read TLS certificate: {e}")) })?; let key = tokio::fs::read(key_path).await.map_err(|e| { ServerError::ServerConfigError(format!("Failed to read TLS key: {e}")) })?; - - // Build the identity and TLS configuration. let tls_id = Identity::from_pem(cert, key); let tls_config = ServerTlsConfig::new().identity(tls_id); Ok(Some(tls_config)) @@ -71,8 +64,7 @@ pub struct JsonRpcServerConfig { /// Server bind addr. pub json_rpc_listen_address: SocketAddr, - /// Directory to store authentication cookie file. - /// Enable cookie-based authentication with a valid `Some()` value. + /// Enable cookie-based authentication with a valid `Some()` value: Directory to store authentication cookie file. /// An empty PathBuf that is still Some will have an emphemeral path assigned to it when zaino loads the config. #[serde(default)] pub cookie_dir: Option, diff --git a/zaino-serve/src/server/grpc.rs b/zaino-serve/src/server/grpc.rs index 5199cd169..fb6ec0559 100644 --- a/zaino-serve/src/server/grpc.rs +++ b/zaino-serve/src/server/grpc.rs @@ -56,7 +56,6 @@ impl TonicServer { }; let server_future = server_builder .add_service(svc) - // here, it's taken straight from the config. .serve_with_shutdown(server_config.listen_address, shutdown_signal); let task_status = status.clone(); diff --git a/zaino-state/src/chain_index/tests/finalised_state/v0.rs b/zaino-state/src/chain_index/tests/finalised_state/v0.rs index acac5335e..08f1a2387 100644 --- a/zaino-state/src/chain_index/tests/finalised_state/v0.rs +++ b/zaino-state/src/chain_index/tests/finalised_state/v0.rs @@ -31,7 +31,6 @@ pub(crate) async fn spawn_v0_zaino_db( }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let zaino_db = ZainoDB::spawn(config, source).await.unwrap(); @@ -206,7 +205,6 @@ async fn save_db_to_file_and_reload() { }, db_version: 0, network: Network::Regtest(ActivationHeights::default()), - // no_sync: false, }; let source = build_mockchain_source(blocks.clone()); diff --git a/zaino-state/src/config.rs b/zaino-state/src/config.rs index d2626846b..e5b6ec301 100644 --- a/zaino-state/src/config.rs +++ b/zaino-state/src/config.rs @@ -33,8 +33,7 @@ pub struct StateServiceConfig { pub validator_grpc_address: std::net::SocketAddr, /// Validator cookie auth. pub validator_cookie_auth: bool, - /// Path to the validator cookie file. - /// Enable validator rpc cookie authentification with Some. + /// Enable validator rpc cookie authentification with Some: Path to the validator cookie file. pub validator_cookie_path: Option, /// Validator JsonRPC user. pub validator_rpc_user: String, @@ -79,14 +78,12 @@ impl StateServiceConfig { } } -// TODO should this live in another module? /// Holds config data for [crate::FetchService]. #[derive(Debug, Clone)] pub struct FetchServiceConfig { /// Validator JsonRPC address. pub validator_rpc_address: std::net::SocketAddr, - /// Enable validator rpc cookie authentification with Some. - /// Path to the validator cookie file. + /// Enable validator rpc cookie authentification with Some: path to the validator cookie file. pub validator_cookie_path: Option, /// Validator JsonRPC user. pub validator_rpc_user: String, diff --git a/zaino-state/src/local_cache/finalised_state.rs b/zaino-state/src/local_cache/finalised_state.rs index 85d2c389f..85b0ed591 100644 --- a/zaino-state/src/local_cache/finalised_state.rs +++ b/zaino-state/src/local_cache/finalised_state.rs @@ -477,7 +477,6 @@ impl FinalisedState { // Wait for server to sync to with p2p network and sync new blocks. if !self.config.network.to_zebra_network().is_regtest() { - // && !self.config.no_sync { self.status.store(StatusType::Syncing); loop { let blockchain_info = self.fetcher.get_blockchain_info().await?; diff --git a/zaino-state/src/local_cache/non_finalised_state.rs b/zaino-state/src/local_cache/non_finalised_state.rs index b7cacadf8..aebabd388 100644 --- a/zaino-state/src/local_cache/non_finalised_state.rs +++ b/zaino-state/src/local_cache/non_finalised_state.rs @@ -377,7 +377,6 @@ impl NonFinalisedState { zaino_common::DatabaseSize::Gb(_) => false, }; if no_db && !self.config.network.to_zebra_network().is_regtest() { - // && !self.config.no_sync { self.status.store(StatusType::Syncing); loop { let blockchain_info = self.fetcher.get_blockchain_info().await.map_err(|e| { diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 5e33b56b7..9746909ee 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -162,7 +162,6 @@ impl zcash_local_net::validator::Validator for LocalNet { todo!() } - // TODO many of these matches could be less verbose, perhaps by defining a into-inner kind of fuction. fn get_activation_heights( &self, ) -> zebra_chain::parameters::testnet::ConfiguredActivationHeights { @@ -251,7 +250,6 @@ impl zcash_local_net::validator::Validator for LocalNet { } fn config_dir(&self) -> &TempDir { - // TODO crufty match self { LocalNet::Zcashd(net) => net.validator().config_dir(), LocalNet::Zebrad(net) => net.validator().config_dir(), @@ -357,13 +355,6 @@ pub struct TestManager { /// Zaino gRPC listen address. pub zaino_grpc_listen_address: Option, /// JsonRPC server cookie dir. - // TODO ambiguity - // TODO - // looking for: - // test_manager.json_server_cookie_dir.clone(), - // is it a validator cookie path?! - // TODO PATH to validator cookie file!???! - // this really seems like a ZAINO server system piece. pub json_server_cookie_dir: Option, /// Zingolib lightclients. pub clients: Option, @@ -453,7 +444,6 @@ impl TestManager { // Launch Zaino: let ( zaino_grpc_listen_address, - // TODO there is some mismatch between JsonRpcServerConfig/JsonRpcServer and GrpcConfig/GrpcServer zaino_json_listen_address, zaino_json_server_cookie_dir, zaino_handle, @@ -468,12 +458,6 @@ impl TestManager { if enable_zaino_jsonrpc_server_cookie_auth { zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); } - - dbg!( - "zaino_json_server_cookie_dir =========== {}", - &zaino_json_server_cookie_dir - ); - let indexer_config = zainodlib::config::ZainodConfig { // TODO: Make configurable. backend: *backend, @@ -507,12 +491,6 @@ impl TestManager { zebra_db_path, network: zaino_network_kind, }; - // TODO we create the handle here, with indexer_config. - // I think we could possibly ... spit out the indexer stuff if we need it later, piece by piece? - // ie, just return the handle and the config - // - // so... we need indexer_config to launch the handle. But maybe we should separate this out? - // step one, set config, step two spawn indexer let handle = zainodlib::indexer::spawn_indexer(indexer_config) .await .unwrap(); @@ -528,10 +506,6 @@ impl TestManager { } else { (None, None, None, None) }; - // TODO by here we've already generated a JoinHandle. - // pub zaino_handle: Option>>, - // along with two listen addresses and a cookie_dir. - // Launch Zingolib Lightclients: let clients = if enable_clients { let mut client_builder = ClientBuilder::new( @@ -560,10 +534,6 @@ impl TestManager { } else { None }; - dbg!( - "zaino_json_server_cookie_dir: {:?}", - zaino_json_server_cookie_dir.clone() - ); let test_manager = Self { local_net, data_dir, @@ -573,7 +543,6 @@ impl TestManager { zaino_handle, zaino_json_rpc_listen_address: zaino_json_listen_address, zaino_grpc_listen_address, - // TODO here, it's defined as zaino json server cookie dir... json_server_cookie_dir: zaino_json_server_cookie_dir, clients, }; From 190a89f4e3e65dddbacf1738e3e1be9d667a93e6 Mon Sep 17 00:00:00 2001 From: al amoda Date: Fri, 24 Oct 2025 18:03:31 -0400 Subject: [PATCH 152/162] readd asserts to zainod tests config, cleanup --- zainod/tests/config.rs | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 5aa98dbe0..4a5aefd43 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -142,7 +142,6 @@ fn test_deserialize_full_valid_config() { finalized_config.storage.database.size.to_byte_count(), 128 * 1024 * 1024 * 1024 ); - // assert!(!finalized_config.no_sync); assert!(match finalized_config.storage.database.size { DatabaseSize::Gb(0) => false, DatabaseSize::Gb(_) => true, @@ -172,7 +171,10 @@ fn test_deserialize_optional_fields_missing() { let default_values = ZainodConfig::default(); assert_eq!(config.backend, ZainoBackendType::State); - // assert_eq!(config.enable_json_server, default_values.enable_json_server); + assert_eq!( + config.json_server_settings.is_some(), + default_values.json_server_settings.is_some() + ); assert_eq!( config.validator_settings.validator_user, default_values.validator_settings.validator_user @@ -193,9 +195,10 @@ fn test_deserialize_optional_fields_missing() { config.storage.database.size, default_values.storage.database.size ); - // assert_eq!(config.no_sync, default_values.no_sync); - // TODO db = 0 - //assert_eq!(config.no_db, default_values.no_db); + assert_eq!( + config.storage.database.size.to_byte_count(), + default_values.storage.database.size.to_byte_count() + ); Ok(()) }); } @@ -209,7 +212,6 @@ fn test_cookie_dir_logic() { let s1_path = jail.directory().join("s1.toml"); jail.create_file( &s1_path, - // TODO check gRPC config as well r#" backend = "fetch" @@ -238,7 +240,6 @@ fn test_cookie_dir_logic() { let s2_path = jail.directory().join("s2.toml"); jail.create_file( &s2_path, - // removed auth - now we handle this with Some / None r#" backend = "fetch" @@ -263,13 +264,17 @@ fn test_cookie_dir_logic() { .cookie_dir, Some(PathBuf::from("/my/cookie/path")) ); - // TODO took out a whole test without switching it to expect to fail + let config3 = load_config(&s3_path).expect("Config S3 failed"); + assert!(config3 + .json_server_settings + .expect("json server settings to unwrap in config S3") + .cookie_dir + .is_none()); Ok(()) }); } #[test] -// Tests how `load_config` handles varying `enable_cookie_auth` states. fn test_string_none_as_path_for_cookie_dir() { Jail::expect_with(|jail| { let toml_auth_enabled_path = jail.directory().join("auth_enabled.toml"); @@ -342,7 +347,10 @@ fn test_deserialize_empty_string_yields_default() { // Compare relevant fields that should come from default assert_eq!(config.network, default_config.network); assert_eq!(config.backend, default_config.backend); - // assert_eq!(config.enable_json_server, default_config.enable_json_server); + assert_eq!( + config.json_server_settings.is_some(), + default_config.json_server_settings.is_some() + ); assert_eq!( config.validator_settings.validator_user, default_config.validator_settings.validator_user @@ -363,9 +371,10 @@ fn test_deserialize_empty_string_yields_default() { config.storage.database.size, default_config.storage.database.size ); - // assert_eq!(config.no_sync, default_config.no_sync); - // db = 0 - // assert_eq!(config.no_db, default_config.no_db); + assert_eq!( + config.storage.database.size.to_byte_count(), + default_config.storage.database.size.to_byte_count() + ); Ok(()) }); } @@ -447,7 +456,6 @@ fn test_figment_env_override_toml_and_defaults() { "#, )?; jail.set_env("ZAINO_NETWORK", "Mainnet"); - // valid socket address assigned with env var (needed for valid JsonRpcServerConfig struct) jail.set_env( "ZAINO_JSON_SERVER_SETTINGS-JSON_RPC_LISTEN_ADDRESS", "127.0.0.1:0", @@ -488,7 +496,6 @@ fn test_figment_toml_overrides_defaults() { "#, )?; let temp_toml_path = jail.directory().join("test_config.toml"); - // a json_server_setting without a listening address is forbidden assert!(load_config(&temp_toml_path).is_err()); Ok(()) @@ -504,7 +511,10 @@ fn test_figment_all_defaults() { load_config(&temp_toml_path).expect("load_config should succeed with empty toml"); let defaults = ZainodConfig::default(); assert_eq!(config.network, defaults.network); - // assert_eq!(config.enable_json_server, defaults.enable_json_server); + assert_eq!( + config.json_server_settings.is_some(), + defaults.json_server_settings.is_some() + ); assert_eq!( config.storage.cache.capacity, defaults.storage.cache.capacity From 2b607691acf88551a1a31b006bc7b2111c1c9eb4 Mon Sep 17 00:00:00 2001 From: al amoda Date: Fri, 24 Oct 2025 19:16:52 -0400 Subject: [PATCH 153/162] re-add cookie jrpc test --- zainod/tests/config.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index 4a5aefd43..a68dab838 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -264,6 +264,22 @@ fn test_cookie_dir_logic() { .cookie_dir, Some(PathBuf::from("/my/cookie/path")) ); + let s3_path = jail.directory().join("s3.toml"); + jail.create_file( + &s3_path, + r#" + backend = "fetch" + + [json_server_settings] + json_rpc_listen_address = "127.0.0.1:8237" + + grpc_listen_address = "127.0.0.1:8137" + validator_listen_address = "127.0.0.1:18232" + zaino_db_path = "/zaino/db" + zebra_db_path = "/zebra/db" + network = "Testnet" + "#, + )?; let config3 = load_config(&s3_path).expect("Config S3 failed"); assert!(config3 .json_server_settings From b662636f307982698618a8f1fa1ab71cce14c353 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 25 Oct 2025 05:58:50 -0400 Subject: [PATCH 154/162] rm comments tests json_server --- integration-tests/tests/json_server.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index ced471ca0..16269eff8 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -11,7 +11,6 @@ use zaino_testutils::{TestManager, ValidatorKind}; use zebra_chain::subtree::NoteCommitmentSubtreeIndex; use zebra_rpc::methods::{AddressStrings, GetAddressTxIdsRequest, GetInfo}; -// TODO has many [17] references, in which enable_cookie_auth is ALWAYS false. async fn create_test_manager_and_fetch_services( enable_cookie_auth: bool, clients: bool, @@ -31,8 +30,6 @@ async fn create_test_manager_and_fetch_services( None, true, true, - // enable_zaino_jsonrpc_server_cookie_auth: bool, - // TODO AFAIK, this is _always_ false enable_cookie_auth, clients, ) From fb1286f81e30e2d7b660e79c1374631539e616c4 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sat, 25 Oct 2025 06:06:32 -0400 Subject: [PATCH 155/162] whitespace --- zainod/tests/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zainod/tests/config.rs b/zainod/tests/config.rs index a68dab838..9a79aee01 100644 --- a/zainod/tests/config.rs +++ b/zainod/tests/config.rs @@ -269,7 +269,7 @@ fn test_cookie_dir_logic() { &s3_path, r#" backend = "fetch" - + [json_server_settings] json_rpc_listen_address = "127.0.0.1:8237" From 91b0521c3447143e2f2b17a960723088ae251fd9 Mon Sep 17 00:00:00 2001 From: al amoda Date: Sun, 26 Oct 2025 04:29:07 -0400 Subject: [PATCH 156/162] rm create_test_manager_and_fetch_services arg, comments --- integration-tests/tests/json_server.rs | 41 ++++++++++++++------------ zaino-testutils/src/lib.rs | 2 ++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 16269eff8..04ed99b29 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -12,7 +12,6 @@ use zebra_chain::subtree::NoteCommitmentSubtreeIndex; use zebra_rpc::methods::{AddressStrings, GetAddressTxIdsRequest, GetInfo}; async fn create_test_manager_and_fetch_services( - enable_cookie_auth: bool, clients: bool, ) -> ( TestManager, @@ -29,8 +28,12 @@ async fn create_test_manager_and_fetch_services( Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, + // TODO this is the only place enable_zaino_jsonrpc_server: bool, is true + // test_manger used throughout integration tests json_servers true, - enable_cookie_auth, + // TODO this is the only place where this is not hard-coded false with launch() + // but is always false because it is always set as false above with create_test_manager_and_fetch_services() ! + false, clients, ) .await @@ -104,7 +107,7 @@ async fn create_test_manager_and_fetch_services( async fn launch_json_server_check_info() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, false).await; + create_test_manager_and_fetch_services(false).await; let zcashd_info = dbg!(zcashd_subscriber.get_info().await.unwrap()); let zcashd_blockchain_info = dbg!(zcashd_subscriber.get_blockchain_info().await.unwrap()); let zaino_info = dbg!(zaino_subscriber.get_info().await.unwrap()); @@ -209,7 +212,7 @@ async fn launch_json_server_check_info() { async fn get_best_blockhash_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, false).await; + create_test_manager_and_fetch_services(false).await; let zcashd_bbh = dbg!(zcashd_subscriber.get_best_blockhash().await.unwrap()); let zaino_bbh = dbg!(zaino_subscriber.get_best_blockhash().await.unwrap()); @@ -221,7 +224,7 @@ async fn get_best_blockhash_inner() { async fn get_block_count_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, false).await; + create_test_manager_and_fetch_services(false).await; let zcashd_block_count = dbg!(zcashd_subscriber.get_block_count().await.unwrap()); let zaino_block_count = dbg!(zaino_subscriber.get_block_count().await.unwrap()); @@ -233,7 +236,7 @@ async fn get_block_count_inner() { async fn validate_address_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, false).await; + create_test_manager_and_fetch_services(false).await; // Using a testnet transparent address let address_string = "tmHMBeeYRuc2eVicLNfP15YLxbQsooCA6jb"; @@ -272,7 +275,7 @@ async fn validate_address_inner() { async fn z_get_address_balance_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -333,7 +336,7 @@ async fn z_get_address_balance_inner() { async fn z_get_block_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, false).await; + create_test_manager_and_fetch_services(false).await; let zcashd_block_raw = dbg!(zcashd_subscriber .z_get_block("1".to_string(), Some(0)) @@ -374,7 +377,7 @@ async fn z_get_block_inner() { async fn get_raw_mempool_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -413,7 +416,7 @@ async fn get_raw_mempool_inner() { async fn get_mempool_info_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -449,7 +452,7 @@ async fn get_mempool_info_inner() { async fn z_get_treestate_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -483,7 +486,7 @@ async fn z_get_treestate_inner() { async fn z_get_subtrees_by_index_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -517,7 +520,7 @@ async fn z_get_subtrees_by_index_inner() { async fn get_raw_transaction_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -553,7 +556,7 @@ async fn get_raw_transaction_inner() { async fn get_address_tx_ids_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -610,7 +613,7 @@ async fn get_address_tx_ids_inner() { async fn z_get_address_utxos_inner() { let (mut test_manager, _zcashd_service, zcashd_subscriber, _zaino_service, zaino_subscriber) = - create_test_manager_and_fetch_services(false, true).await; + create_test_manager_and_fetch_services(true).await; let mut clients = test_manager .clients @@ -698,7 +701,7 @@ mod zcashd { zcashd_subscriber, _zaino_service, zaino_subscriber, - ) = create_test_manager_and_fetch_services(false, false).await; + ) = create_test_manager_and_fetch_services(false).await; const BLOCK_LIMIT: i32 = 10; @@ -722,7 +725,7 @@ mod zcashd { zcashd_subscriber, _zaino_service, zaino_subscriber, - ) = create_test_manager_and_fetch_services(false, false).await; + ) = create_test_manager_and_fetch_services(false).await; const BLOCK_LIMIT: i32 = 10; @@ -746,7 +749,7 @@ mod zcashd { zcashd_subscriber, _zaino_service, zaino_subscriber, - ) = create_test_manager_and_fetch_services(false, false).await; + ) = create_test_manager_and_fetch_services(false).await; let zcashd_peer_info = zcashd_subscriber.get_peer_info().await.unwrap(); let zaino_peer_info = zaino_subscriber.get_peer_info().await.unwrap(); @@ -766,7 +769,7 @@ mod zcashd { zcashd_subscriber, _zaino_service, zaino_subscriber, - ) = create_test_manager_and_fetch_services(false, false).await; + ) = create_test_manager_and_fetch_services(false).await; test_manager.local_net.generate_blocks(1).await.unwrap(); diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 9746909ee..55e9f8f7f 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -378,7 +378,9 @@ impl TestManager { activation_heights: Option, chain_cache: Option, enable_zaino: bool, + // targeting enable_zaino_jsonrpc_server: bool, + // this is also always false, except one (tests json_server) enable_zaino_jsonrpc_server_cookie_auth: bool, enable_clients: bool, ) -> Result { From adf7537c8c3ee995db2055d6393d0d87c51b2fd3 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 27 Oct 2025 04:15:44 -0400 Subject: [PATCH 157/162] remove enable_zaino_jsonrpc_server_cookie_auth --- zaino-testutils/src/lib.rs | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 55e9f8f7f..937b5ca74 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -21,7 +21,6 @@ use zaino_common::{ }; use zaino_serve::server::config::{GrpcServerConfig, JsonRpcServerConfig}; use zaino_state::BackendType; -use zainodlib::config::default_ephemeral_cookie_path; pub use zcash_local_net as services; pub use zcash_local_net::validator::Validator; use zcash_local_net::validator::{ZcashdConfig, ZebradConfig}; @@ -378,10 +377,7 @@ impl TestManager { activation_heights: Option, chain_cache: Option, enable_zaino: bool, - // targeting enable_zaino_jsonrpc_server: bool, - // this is also always false, except one (tests json_server) - enable_zaino_jsonrpc_server_cookie_auth: bool, enable_clients: bool, ) -> Result { if (validator == &ValidatorKind::Zcashd) && (backend == &BackendType::State) { @@ -456,10 +452,7 @@ impl TestManager { let zaino_json_listen_port = portpicker::pick_unused_port().expect("No ports free"); let zaino_json_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), zaino_json_listen_port); - let mut zaino_json_server_cookie_dir: Option = None; - if enable_zaino_jsonrpc_server_cookie_auth { - zaino_json_server_cookie_dir = Some(default_ephemeral_cookie_path()); - } + let zaino_json_server_cookie_dir: Option = None; let indexer_config = zainodlib::config::ZainodConfig { // TODO: Make configurable. backend: *backend, @@ -612,7 +605,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -634,7 +626,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -662,7 +653,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -684,7 +674,6 @@ mod launch_testmanager { true, false, false, - false, ) .await .unwrap(); @@ -709,7 +698,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -736,7 +724,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -786,7 +773,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -808,7 +794,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -836,7 +821,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -858,7 +842,6 @@ mod launch_testmanager { true, false, false, - false, ) .await .unwrap(); @@ -883,7 +866,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -910,7 +892,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -956,7 +937,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -1057,7 +1037,6 @@ mod launch_testmanager { ZEBRAD_TESTNET_CACHE_DIR.clone(), true, false, - false, true, ) .await @@ -1089,7 +1068,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -1111,7 +1089,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -1139,7 +1116,6 @@ mod launch_testmanager { false, false, false, - false, ) .await .unwrap(); @@ -1161,7 +1137,6 @@ mod launch_testmanager { true, false, false, - false, ) .await .unwrap(); @@ -1186,7 +1161,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -1213,7 +1187,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -1260,7 +1233,6 @@ mod launch_testmanager { None, true, false, - false, true, ) .await @@ -1359,7 +1331,6 @@ mod launch_testmanager { ZEBRAD_TESTNET_CACHE_DIR.clone(), true, false, - false, true, ) .await From 97c1771aadc710fc98539a83f598ac1567114040 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 27 Oct 2025 04:16:57 -0400 Subject: [PATCH 158/162] remove args from wallet_to_validator --- integration-tests/tests/wallet_to_validator.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/integration-tests/tests/wallet_to_validator.rs b/integration-tests/tests/wallet_to_validator.rs index 95c69e0f1..6481134c5 100644 --- a/integration-tests/tests/wallet_to_validator.rs +++ b/integration-tests/tests/wallet_to_validator.rs @@ -19,7 +19,6 @@ async fn connect_to_node_get_info_for_validator(validator: &ValidatorKind, backe None, true, false, - false, true, ) .await @@ -44,7 +43,6 @@ async fn send_to_orchard(validator: &ValidatorKind, backend: &BackendType) { None, true, false, - false, true, ) .await @@ -95,7 +93,6 @@ async fn send_to_sapling(validator: &ValidatorKind, backend: &BackendType) { None, true, false, - false, true, ) .await @@ -146,7 +143,6 @@ async fn send_to_transparent(validator: &ValidatorKind, backend: &BackendType) { None, true, false, - false, true, ) .await @@ -257,7 +253,6 @@ async fn send_to_all(validator: &ValidatorKind, backend: &BackendType) { None, true, false, - false, true, ) .await @@ -356,7 +351,6 @@ async fn shield_for_validator(validator: &ValidatorKind, backend: &BackendType) None, true, false, - false, true, ) .await @@ -440,7 +434,6 @@ async fn monitor_unverified_mempool_for_validator( None, true, false, - false, true, ) .await From 22d51cafe5315e7615c99160deadc612ccc8c68b Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 27 Oct 2025 04:17:19 -0400 Subject: [PATCH 159/162] remove arg from integration-tests test_vectors --- integration-tests/tests/test_vectors.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/tests/test_vectors.rs b/integration-tests/tests/test_vectors.rs index d46f10e63..6a0e65365 100644 --- a/integration-tests/tests/test_vectors.rs +++ b/integration-tests/tests/test_vectors.rs @@ -63,7 +63,6 @@ async fn create_test_manager_and_services( chain_cache.clone(), enable_zaino, false, - false, enable_clients, ) .await From bcee723754ba6c7dff6ef603b56a3a829918fc91 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 27 Oct 2025 04:17:51 -0400 Subject: [PATCH 160/162] removed argb from local_cache and state_service --- integration-tests/tests/local_cache.rs | 1 - integration-tests/tests/state_service.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/integration-tests/tests/local_cache.rs b/integration-tests/tests/local_cache.rs index a2bdc4293..fe91d8b53 100644 --- a/integration-tests/tests/local_cache.rs +++ b/integration-tests/tests/local_cache.rs @@ -36,7 +36,6 @@ async fn create_test_manager_and_block_cache( chain_cache, enable_zaino, false, - false, enable_clients, ) .await diff --git a/integration-tests/tests/state_service.rs b/integration-tests/tests/state_service.rs index 3564a0eff..174a22404 100644 --- a/integration-tests/tests/state_service.rs +++ b/integration-tests/tests/state_service.rs @@ -34,7 +34,6 @@ async fn create_test_manager_and_services( chain_cache.clone(), enable_zaino, false, - false, enable_clients, ) .await From 60b27b0a900c6446cd83079bdc36ffe79fa7cebb Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 27 Oct 2025 04:18:21 -0400 Subject: [PATCH 161/162] remove arg from chain_cache and fetch_service --- integration-tests/tests/chain_cache.rs | 1 - integration-tests/tests/fetch_service.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/integration-tests/tests/chain_cache.rs b/integration-tests/tests/chain_cache.rs index c14e0c964..12c49b008 100644 --- a/integration-tests/tests/chain_cache.rs +++ b/integration-tests/tests/chain_cache.rs @@ -18,7 +18,6 @@ async fn create_test_manager_and_connector( chain_cache, enable_zaino, false, - false, enable_clients, ) .await diff --git a/integration-tests/tests/fetch_service.rs b/integration-tests/tests/fetch_service.rs index 89797dd34..800666297 100644 --- a/integration-tests/tests/fetch_service.rs +++ b/integration-tests/tests/fetch_service.rs @@ -35,7 +35,6 @@ async fn create_test_manager_and_fetch_service( chain_cache, enable_zaino, false, - false, enable_clients, ) .await From 0d01e06cada819437e0dea62be8e697be1f74683 Mon Sep 17 00:00:00 2001 From: al amoda Date: Mon, 27 Oct 2025 04:19:15 -0400 Subject: [PATCH 162/162] remove comments --- integration-tests/tests/json_server.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/integration-tests/tests/json_server.rs b/integration-tests/tests/json_server.rs index 04ed99b29..6c119f629 100644 --- a/integration-tests/tests/json_server.rs +++ b/integration-tests/tests/json_server.rs @@ -28,12 +28,7 @@ async fn create_test_manager_and_fetch_services( Some(ZEBRAD_DEFAULT_ACTIVATION_HEIGHTS), None, true, - // TODO this is the only place enable_zaino_jsonrpc_server: bool, is true - // test_manger used throughout integration tests json_servers true, - // TODO this is the only place where this is not hard-coded false with launch() - // but is always false because it is always set as false above with create_test_manager_and_fetch_services() ! - false, clients, ) .await