diff --git a/Cargo.lock b/Cargo.lock index 60a4fd5..dcfe009 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2556,7 +2556,7 @@ name = "integration-tests" version = "0.1.0" dependencies = [ "tokio", - "zingoproxy-testutils", + "zingoindexer-testutils", ] [[package]] @@ -7159,6 +7159,22 @@ dependencies = [ "syn 2.0.49", ] +[[package]] +name = "zingo-indexerd" +version = "0.1.0" +dependencies = [ + "ctrlc", + "http", + "nym-bin-common", + "nym-sdk", + "nym-sphinx-anonymous-replies", + "tokio", + "tonic", + "zcash_client_backend", + "zingo-netutils", + "zingo-rpc", +] + [[package]] name = "zingo-memo" version = "0.1.0" @@ -7189,22 +7205,6 @@ dependencies = [ "zcash_client_backend", ] -[[package]] -name = "zingo-proxyd" -version = "0.1.0" -dependencies = [ - "ctrlc", - "http", - "nym-bin-common", - "nym-sdk", - "nym-sphinx-anonymous-replies", - "tokio", - "tonic", - "zcash_client_backend", - "zingo-netutils", - "zingo-rpc", -] - [[package]] name = "zingo-rpc" version = "0.1.0" @@ -7296,6 +7296,23 @@ dependencies = [ "zcash_primitives", ] +[[package]] +name = "zingoindexer-testutils" +version = "0.1.0" +dependencies = [ + "ctrlc", + "http", + "portpicker", + "tempfile", + "tokio", + "tonic", + "zingo-indexerd", + "zingo-rpc", + "zingo-testutils", + "zingoconfig", + "zingolib", +] + [[package]] name = "zingolib" version = "0.2.0" @@ -7363,20 +7380,3 @@ dependencies = [ "zingo-testvectors", "zingoconfig", ] - -[[package]] -name = "zingoproxy-testutils" -version = "0.1.0" -dependencies = [ - "ctrlc", - "http", - "portpicker", - "tempfile", - "tokio", - "tonic", - "zingo-proxyd", - "zingo-rpc", - "zingo-testutils", - "zingoconfig", - "zingolib", -] diff --git a/Cargo.toml b/Cargo.toml index b4b991c..2f24486 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [workspace] members = [ "integration-tests", - "zingoproxy-testutils", - "zingo-proxyd", + "zingoindexer-testutils", + "zingo-indexerd", "zingo-rpc", ] @@ -10,7 +10,7 @@ members = [ resolver = "2" [workspace.package] -authors = ["Zingolabs Viridian"] +authors = ["Zingo Lab Cyan"] repository = "https://github.com/zingolabs" homepage = "https://www.zingolabs.org/" edition = "2021" diff --git a/README.md b/README.md index e69464d..c0c8916 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -# Zingo-Proxy -A rust implemented, nym enhanced, lightwalletd for Zcash. +# Zingo-Indexer +A rust implemented, nym enhanced, indexer for Zcash. A note to developers/consumers/contributers: The end goal is not an exact one-to-one port of all existing lwd functionaliy. We currently plan to hold the Service and Darkside RPC implementations, along with a Nym counterpart to the service RPCs for sending and recieving currency over the Nym Mixnet. +The zingo-indexer is intended to provide all necessary funtionality for clients, including "standalone" (formerly "light") clients/wallets and integrated (formerly "full") client/wallets. + # Security Vulnerability Disclosure If you believe you have discovered a security issue, please contact us at: @@ -12,18 +14,18 @@ zingodisclosure@proton.me # Zingo-RPC Will eventually hold the rust implementations of the LightWallet Service and Darkside RPCs, along with the wallet-side and server-side Nym Service implementations. -# Zingo-ProxyD -Currently a lightweight gRPC server for testing and development. Zingo-ProxyD also has a basic nym server, currently only receives send_transaction and get_lightd_info commands send over the mixnet. +# Zingo-IndexerD +Currently a lightweight gRPC server for testing and development. Zingo-IndexerD also has a basic nym server, currently only receives send_transaction and get_lightd_info commands send over the mixnet. This should not be used to run mainnet nodes in its current form as it lacks the queueing and error checking logic necessary. -Under the "nym_poc" feature flag Zingo-ProxyD can also act as a Nym powered proxy between zcash wallets and Zingo-ProxyD, capable of sending zcash transactions over the Nym Mixnet. +Under the "nym_poc" feature flag Zingo-IndexerD can also act as a Nym powered indexer between zcash wallets and Zingo-IndexerD, capable of sending zcash transactions over the Nym Mixnet. Note: The wallet-side nym service RPC implementations are moving to CompactTxStreamerClient for easier consumption by wallets. Functionality under the "nym_poc" feature flag will be removed once a working example has been implemented directly in zingolib. This is the POC and initial work on enabling zcash infrastructure to use the nym mixnet. [Nym_POC](./docs/nym_poc.pdf) shows the current state of this work ands our vision for the future. -Our plan is to first enable wallets to send and recieve transactions via a nym powered proxy between wallets and a lightwalletd/zebrad before looking at the wider zcash ecosystem. +Our plan is to first enable wallets to send and receive transactions via a nym powered indexer between wallets and a lightwalletd/zebrad before looking at the wider zcash ecosystem. # Dependencies @@ -35,11 +37,11 @@ Our plan is to first enable wallets to send and recieve transactions via a nym p # Testing - To run tests: -1) Simlink or copy compiled `zcashd`, `zcash-cli` and `lightwalletd` binaries to `$ zingo-proxy/zingo-testutils/test_binaries/bins/` +1) Simlink or copy compiled `zcashd`, `zcash-cli` and `lightwalletd` binaries to `$ zingo-indexer/zingo-testutils/test_binaries/bins/` 3) Run `$ cargo nextest run` or `$ cargo test` -# zingoproxyd -- To run zingo-cli through zingo-proxy, connecting to lightwalletd/zebrad locally: +# zingoindexerd +- To run zingo-cli through zingo-indexer, connecting to lightwalletd/zebrad locally: 1) Run `$ zebrad --config #PATH_TO_ZINGO_PROXY/zebrad.toml start` 3) Run `$ cargo run` diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 8fc2e0a..8f7ee3c 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "integration-tests" version = "0.1.0" -description = "Crate containing Zingo-Proxy 'Wallet-to-Node' tests." +description = "Crate containing Zingo-Indexer 'Wallet-to-Node' tests." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } @@ -13,7 +13,7 @@ repository = { workspace = true } nym_poc = [] [dependencies] -zingoproxy-testutils = { path = "../zingoproxy-testutils" } +zingoindexer-testutils = { path = "../zingoindexer-testutils" } # Miscellaneous Workspace tokio = { workspace = true } diff --git a/integration-tests/tests/integrations.rs b/integration-tests/tests/integrations.rs index 068fbfc..525a16d 100644 --- a/integration-tests/tests/integrations.rs +++ b/integration-tests/tests/integrations.rs @@ -4,7 +4,7 @@ #![forbid(unsafe_code)] use std::sync::{atomic::AtomicBool, Arc}; -use zingoproxy_testutils::{ +use zingoindexer_testutils::{ drop_test_manager, get_zingo_address, start_zingo_mempool_monitor, ProxyPool, TestManager, }; @@ -14,13 +14,13 @@ mod wallet_basic { #[tokio::test] async fn connect_to_node_get_info() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; let lightd_info = zingo_client.do_info().await; println!( - "@zingoproxytest: Lightd_info response:\n{:#?}.", + "@zingoindexertest: Lightd_info response:\n{:#?}.", lightd_info ); @@ -35,7 +35,7 @@ mod wallet_basic { #[tokio::test] async fn send_to_orchard() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -53,7 +53,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.orchard_balance.unwrap(), 1_875_000_000); drop_test_manager( @@ -67,7 +67,7 @@ mod wallet_basic { #[tokio::test] async fn send_to_sapling() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -85,7 +85,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.sapling_balance.unwrap(), 250_000); drop_test_manager( @@ -99,7 +99,7 @@ mod wallet_basic { #[tokio::test] async fn send_to_transparent() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -117,7 +117,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.transparent_balance.unwrap(), 250_000); drop_test_manager( @@ -131,7 +131,7 @@ mod wallet_basic { #[tokio::test] async fn send_to_multiple() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -165,7 +165,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.orchard_balance.unwrap(), 2_499_500_000); assert_eq!(balance.sapling_balance.unwrap(), 250_000); assert_eq!(balance.transparent_balance.unwrap(), 250_000); @@ -181,7 +181,7 @@ mod wallet_basic { #[tokio::test] async fn shield_from_sapling() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -199,7 +199,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.sapling_balance.unwrap(), 250_000); zingo_client @@ -210,7 +210,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.sapling_balance.unwrap(), 0); assert_eq!(balance.orchard_balance.unwrap(), 2_500_000_000); @@ -225,7 +225,7 @@ mod wallet_basic { #[tokio::test] async fn shield_from_transparent() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -243,7 +243,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.transparent_balance.unwrap(), 250_000); zingo_client @@ -254,7 +254,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.transparent_balance.unwrap(), 0); assert_eq!(balance.orchard_balance.unwrap(), 2_500_000_000); @@ -269,7 +269,7 @@ mod wallet_basic { #[tokio::test] async fn shield_from_multiple() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -295,7 +295,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.sapling_balance.unwrap(), 250_000); assert_eq!(balance.transparent_balance.unwrap(), 250_000); @@ -310,7 +310,7 @@ mod wallet_basic { zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.sapling_balance.unwrap(), 0); assert_eq!(balance.transparent_balance.unwrap(), 0); assert_eq!(balance.orchard_balance.unwrap(), 2_500_000_000); @@ -326,7 +326,7 @@ mod wallet_basic { #[tokio::test] async fn sync_full_batch() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -362,11 +362,11 @@ mod wallet_basic { .unwrap(); test_manager.regtest_manager.generate_n_blocks(30).unwrap(); - println!("@zingoproxytest: syncing full batch."); + println!("@zingoindexertest: syncing full batch."); zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.orchard_balance.unwrap(), 76_874_500_000); assert_eq!(balance.sapling_balance.unwrap(), 250_000); assert_eq!(balance.transparent_balance.unwrap(), 250_000); @@ -382,7 +382,7 @@ mod wallet_basic { #[tokio::test] async fn monitor_unverified_mempool() { let online = Arc::new(AtomicBool::new(true)); - let (test_manager, regtest_handler, _proxy_handler) = + let (test_manager, regtest_handler, _indexer_handler) = TestManager::launch(online.clone()).await; let zingo_client = test_manager.build_lightclient().await; @@ -408,13 +408,13 @@ mod wallet_basic { start_zingo_mempool_monitor(&zingo_client).await; let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.unverified_sapling_balance.unwrap(), 500_000); test_manager.regtest_manager.generate_n_blocks(1).unwrap(); zingo_client.do_sync(false).await.unwrap(); let balance = zingo_client.do_balance().await; - println!("@zingoproxytest: zingo_client balance: \n{:#?}.", balance); + println!("@zingoindexertest: zingo_client balance: \n{:#?}.", balance); assert_eq!(balance.verified_sapling_balance.unwrap(), 500_000); drop_test_manager( diff --git a/zingo-proxyd/Cargo.toml b/zingo-indexerd/Cargo.toml similarity index 81% rename from zingo-proxyd/Cargo.toml rename to zingo-indexerd/Cargo.toml index 385250c..cc3e942 100644 --- a/zingo-proxyd/Cargo.toml +++ b/zingo-indexerd/Cargo.toml @@ -1,18 +1,18 @@ [package] -name = "zingo-proxyd" +name = "zingo-indexerd" version = "0.1.0" -description = "Crate containing the Zingo-Proxy LightWallet server binary." +description = "Crate containing the Zingo-Indexer LightWallet server binary." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } repository = { workspace = true } [[bin]] -name = "zingoproxyd" -path = "src/bin/zingoproxyd.rs" +name = "zingoindexerd" +path = "src/bin/zingoindexerd.rs" [lib] -name = "zingoproxylib" +name = "zingoindexerlib" path = "src/lib.rs" [features] @@ -24,7 +24,7 @@ nym_poc = ["zingo-netutils", "zcash_client_backend"] # # Only used in original nym_poc code, to be removed with creation of nym enhanced zingolib build. # -# Not to be used in production code as zingo-rpc will become a dep of zingolib and zingo-proxy now builds its onw CompactTxStreamer. +# Not to be used in production code as zingo-rpc will become a dep of zingolib and zingo-indexer now builds its onw CompactTxStreamer. zingo-netutils = { git = "https://github.com/zingolabs/zingolib.git", branch = "nym_integration", optional = true } zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", branch = "nym_integration", features = ["lightwalletd-tonic"], optional = true } diff --git a/zingo-proxyd/src/bin/zingoproxyd.rs b/zingo-indexerd/src/bin/zingoindexerd.rs similarity index 77% rename from zingo-proxyd/src/bin/zingoproxyd.rs rename to zingo-indexerd/src/bin/zingoindexerd.rs index 0de3374..308d8a0 100644 --- a/zingo-proxyd/src/bin/zingoproxyd.rs +++ b/zingo-indexerd/src/bin/zingoindexerd.rs @@ -1,4 +1,4 @@ -//! Zingo-Proxy daemon +//! Zingo-Indexer daemon use std::{ process, @@ -7,14 +7,14 @@ use std::{ Arc, }, }; -use zingoproxylib::proxy::spawn_proxy; +use zingoindexerlib::indexer::spawn_indexer; #[tokio::main] async fn main() { let online = Arc::new(AtomicBool::new(true)); let online_ctrlc = online.clone(); ctrlc::set_handler(move || { - println!("@zingoproxyd: Received Ctrl+C, exiting."); + println!("@zingoindexerd: Received Ctrl+C, exiting."); online_ctrlc.store(false, Ordering::SeqCst); process::exit(0); }) @@ -23,10 +23,10 @@ async fn main() { nym_bin_common::logging::setup_logging(); #[allow(unused_mut)] - let mut proxy_port: u16 = 8080; + let mut indexer_port: u16 = 8080; #[cfg(feature = "nym_poc")] { - proxy_port = 8088; + indexer_port = 8088; } #[allow(unused_mut)] @@ -38,8 +38,8 @@ async fn main() { let zcashd_port: u16 = 18232; - let (_handles, _nym_address) = spawn_proxy( - &proxy_port, + let (_handles, _nym_address) = spawn_indexer( + &indexer_port, &lwd_port, &zcashd_port, "/tmp/nym_server", diff --git a/zingo-proxyd/src/proxy.rs b/zingo-indexerd/src/indexer.rs similarity index 85% rename from zingo-proxyd/src/proxy.rs rename to zingo-indexerd/src/indexer.rs index 2b07d37..c3c588a 100644 --- a/zingo-proxyd/src/proxy.rs +++ b/zingo-indexerd/src/indexer.rs @@ -1,4 +1,4 @@ -//! Zingo-Proxy server implementation. +//! Zingo-Indexer server implementation. //! //! TODO: - Add ProxyServerError error type and rewrite functions to return >, propagating internal errors. //! - Update spawn_server and nym_spawn to return > and > and use here. @@ -14,8 +14,8 @@ use std::sync::Arc; use tokio::task::JoinHandle; /// Launches test Zingo_Proxy server. -pub async fn spawn_proxy( - proxy_port: &u16, +pub async fn spawn_indexer( + indexer_port: &u16, lwd_port: &u16, zebrad_port: &u16, nym_conf_path: &str, @@ -28,7 +28,9 @@ pub async fn spawn_proxy( let nym_addr_out: Option; startup_message(); - println!("@zingoproxyd: Launching Zingo-Proxy!\n@zingoproxyd: Checking connection with node.."); + println!( + "@zingoindexerd: Launching Zingo-Indexer!\n@zingoindexerd: Checking connection with node.." + ); // TODO Add user and password fields. let _zebrad_uri = test_node_and_return_uri( zebrad_port, @@ -38,13 +40,14 @@ pub async fn spawn_proxy( .await .unwrap(); - println!("@zingoproxyd: Launching gRPC Server.."); - let proxy_handle = spawn_grpc_server(proxy_port, lwd_port, zebrad_port, online.clone()).await; - handles.push(proxy_handle); + println!("@zingoindexerd: Launching gRPC Server.."); + let indexer_handle = + spawn_grpc_server(indexer_port, lwd_port, zebrad_port, online.clone()).await; + handles.push(indexer_handle); #[cfg(not(feature = "nym_poc"))] { - wait_on_grpc_startup(proxy_port, online.clone()).await; + wait_on_grpc_startup(indexer_port, online.clone()).await; } #[cfg(feature = "nym_poc")] { @@ -53,16 +56,16 @@ pub async fn spawn_proxy( #[cfg(not(feature = "nym_poc"))] { - println!("@zingoproxyd[nym]: Launching Nym Server.."); + println!("@zingoindexerd[nym]: Launching Nym Server.."); // let nym_server: NymServer = NymServer(NymClient::nym_spawn(nym_conf_path).await); // nym_addr_out = Some(nym_server.0 .0.nym_address().to_string()); - // let nym_proxy_handle = nym_server.serve(online).await; + // let nym_indexer_handle = nym_server.serve(online).await; let nym_server = NymServer::new(nym_conf_path, online).await; nym_addr_out = Some(nym_server.nym_addr.clone()); - let nym_proxy_handle = nym_server.serve().await; + let nym_indexer_handle = nym_server.serve().await; - handles.push(nym_proxy_handle); + handles.push(nym_indexer_handle); // TODO: Add wait_on_nym_startup(nym_addr_out, online.clone()) function to test nym server. tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; } @@ -74,16 +77,16 @@ pub async fn spawn_proxy( (handles, nym_addr_out) } -/// Closes test Zingo-Proxy servers currently active. -pub async fn close_proxy(online: Arc) { +/// Closes test Zingo-Indexer servers currently active. +pub async fn close_indexer(online: Arc) { online.store(false, Ordering::SeqCst); } /// Tries to connect to the gRPC server and retruns if connection established. Shuts down with error message if connection with server cannot be established after 3 attempts. -async fn wait_on_grpc_startup(proxy_port: &u16, online: Arc) { - let proxy_uri = http::Uri::builder() +async fn wait_on_grpc_startup(indexer_port: &u16, online: Arc) { + let indexer_uri = http::Uri::builder() .scheme("http") - .authority(format!("localhost:{proxy_port}")) + .authority(format!("localhost:{indexer_port}")) .path_and_query("/") .build() .unwrap(); @@ -91,14 +94,14 @@ async fn wait_on_grpc_startup(proxy_port: &u16, online: Arc) { let mut interval = tokio::time::interval(tokio::time::Duration::from_millis(500)); interval.tick().await; while attempts < 3 { - match CompactTxStreamerClient::connect(proxy_uri.clone()).await { + match CompactTxStreamerClient::connect(indexer_uri.clone()).await { Ok(mut client) => match client.get_lightd_info(tonic::Request::new(Empty {})).await { Ok(_) => { return; } Err(e) => { println!( - "@zingoproxyd: GRPC server connection attempt {} failed with error: {}. Re", + "@zingoindexerd: GRPC server connection attempt {} failed with error: {}. Re", attempts + 1, e ); @@ -106,7 +109,7 @@ async fn wait_on_grpc_startup(proxy_port: &u16, online: Arc) { }, Err(e) => { println!( - "@zingoproxyd: GRPC server attempt {} failed to connect with error: {}", + "@zingoindexerd: GRPC server attempt {} failed to connect with error: {}", attempts + 1, e ); @@ -115,7 +118,7 @@ async fn wait_on_grpc_startup(proxy_port: &u16, online: Arc) { attempts += 1; interval.tick().await; } - println!("@zingoproxyd: Failed to start gRPC server, please check system config. Exiting Zingo-Proxy..."); + println!("@zingoindexerd: Failed to start gRPC server, please check system config. Exiting Zingo-Indexer..."); online.store(false, Ordering::SeqCst); std::process::exit(1); } @@ -170,11 +173,11 @@ fn startup_message() { &&&&&&&&&&&&&&@& .@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&& &&&&&&&&&&&&&&&&@@#, ,#@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&&&& -Thank you for using ZingoLabs ZingoProxyD! +Thank you for using ZingoLabs ZingoIndexerD! - Donate to us at https://free2z.cash/zingolabs. - Submit any security conserns to us at zingodisclosure@proton.me. -****** Please note ZingoProxyD is currently in development and should not be used to run mainnet nodes. ****** +****** Please note ZingoIndexerD is currently in development and should not be used to run mainnet nodes. ****** ****** Currently LightwalletD is required for full functionality. ****** "#; diff --git a/zingo-proxyd/src/lib.rs b/zingo-indexerd/src/lib.rs similarity index 83% rename from zingo-proxyd/src/lib.rs rename to zingo-indexerd/src/lib.rs index 54ae008..a763060 100644 --- a/zingo-proxyd/src/lib.rs +++ b/zingo-indexerd/src/lib.rs @@ -1,9 +1,9 @@ -//! Zingo-Proxy gRPC Server. +//! Zingo-Indexer gRPC Server. //! NOTE: This is currently a very simple implementation meant only for development and testing, and in its current form should not be used to run mainnet nodes. #![warn(missing_docs)] #![forbid(unsafe_code)] +pub mod indexer; pub mod nym_server; -pub mod proxy; pub mod server; diff --git a/zingo-proxyd/src/nym_server.rs b/zingo-indexerd/src/nym_server.rs similarity index 89% rename from zingo-proxyd/src/nym_server.rs rename to zingo-indexerd/src/nym_server.rs index 6b8c92c..a531739 100644 --- a/zingo-proxyd/src/nym_server.rs +++ b/zingo-indexerd/src/nym_server.rs @@ -2,7 +2,7 @@ //! //! TODO: - Add NymServerError error type and rewrite functions to return >, propagating internal errors. Include NymClientError from zingo-rpc::nym::utils. //! - Update NymServer to handle all service RPCs (currently only accepts send_command). [Return "Not Yet Implemented" for unimplemented RPC's?] -//! - Update NymServer to handle multiple requests, from multiple clients, simultaniously. [Combine with zingoproxyd "queue" logic when implemented?] +//! - Update NymServer to handle multiple requests, from multiple clients, simultaniously. [Combine with zingoindexerd "queue" logic when implemented?] use std::sync::{ atomic::{AtomicBool, Ordering}, @@ -14,7 +14,7 @@ use nym_sphinx_anonymous_replies::requests::AnonymousSenderTag; use zingo_rpc::{ primitives::client::{NymClient, ProxyClient}, - queue::request::ZingoProxyRequest, + queue::request::ZingoIndexerRequest, }; /// Wrapper struct for a Nym client. @@ -38,7 +38,7 @@ impl NymServer { // NOTE: the following should be removed with the addition of the queue and worker pool. let lwd_port = 8080; let zebrad_port = 18232; - let proxy_client = ProxyClient { + let indexer_client = ProxyClient { lightwalletd_uri: http::Uri::builder() .scheme("http") .authority(format!("localhost:{lwd_port}")) @@ -79,27 +79,27 @@ impl NymServer { request_in[0].sender_tag.unwrap().to_base58_string(), ) .unwrap(); - // --- build ZingoProxyRequest - let zingo_proxy_request = - ZingoProxyRequest::new_from_nym(return_recipient, request_vu8.as_ref()) + // --- build ZingoIndexerRequest + let zingo_indexer_request = + ZingoIndexerRequest::new_from_nym(return_recipient, request_vu8.as_ref()) .unwrap(); // print request for testing // println!( - // "@zingoproxyd[nym][TEST]: ZingoProxyRequest recieved: {:?}.", - // zingo_proxy_request + // "@zingoindexerd[nym][TEST]: ZingoIndexerRequest recieved: {:?}.", + // zingo_indexer_request // ); // --- process request // NOTE: when the queue is added requests will not be processed here but by the queue! - let response = proxy_client - .process_nym_request(&zingo_proxy_request) + let response = indexer_client + .process_nym_request(&zingo_indexer_request) .await .unwrap(); // print response for testing // println!( - // "@zingoproxyd[nym][TEST]: Response sent: {:?}.", + // "@zingoindexerd[nym][TEST]: Response sent: {:?}.", // &response[..], // ); @@ -163,7 +163,7 @@ impl NymServer { // // --- print request for testing // println!( -// "@zingoproxyd[nym]: request received: {:?} - request length: {}", +// "@zingoindexerd[nym]: request received: {:?} - request length: {}", // &request_vu8[..], // &request_vu8[..].len() // ); @@ -180,7 +180,7 @@ impl NymServer { // //print response for testing // println!( -// "@zingoproxyd[nym]: response sent: {:?} - response length: {}", +// "@zingoindexerd[nym]: response sent: {:?} - response length: {}", // &response_vu8[..], // &response_vu8[..].len() // ); diff --git a/zingo-proxyd/src/server.rs b/zingo-indexerd/src/server.rs similarity index 88% rename from zingo-proxyd/src/server.rs rename to zingo-indexerd/src/server.rs index 17ed5ca..3760c84 100644 --- a/zingo-proxyd/src/server.rs +++ b/zingo-indexerd/src/server.rs @@ -32,7 +32,7 @@ impl ProxyServer { tokio::task::spawn(async move { let svc = CompactTxStreamerServer::new(self.0); let sockaddr = SocketAddr::new(std::net::IpAddr::V4(Ipv4Addr::LOCALHOST), port.into()); - println!("@zingoproxyd: gRPC server listening on: {sockaddr}"); + println!("@zingoindexerd: gRPC server listening on: {sockaddr}"); let server = tonic::transport::Server::builder() .add_service(svc.clone()) @@ -44,12 +44,12 @@ impl ProxyServer { match result { Ok(_) => { // TODO: Gracefully restart gRPC server. - println!("@zingoproxyd: gRPC Server closed early. Restart required"); + println!("@zingoindexerd: gRPC Server closed early. Restart required"); Ok(()) } Err(e) => { // TODO: restart server or set online to false and exit - println!("@zingoproxyd: gRPC Server closed with error: {}. Restart required", e); + println!("@zingoindexerd: gRPC Server closed with error: {}. Restart required", e); Err(e) } } @@ -59,7 +59,7 @@ impl ProxyServer { interval.tick().await; } } => { - println!("@zingoproxyd: gRPC server shutting down."); + println!("@zingoindexerd: gRPC server shutting down."); Ok(()) } } @@ -78,7 +78,7 @@ impl ProxyServer { /// Spawns a gRPC server. pub async fn spawn_grpc_server( - proxy_port: &u16, + indexer_port: &u16, lwd_port: &u16, zebrad_port: &u16, online: Arc, @@ -100,5 +100,5 @@ pub async fn spawn_grpc_server( .unwrap(); let server = ProxyServer::new(lwd_uri, zebra_uri); - server.serve(*proxy_port, online) + server.serve(*indexer_port, online) } diff --git a/zingo-proxyd/zcash.conf b/zingo-indexerd/zcash.conf similarity index 100% rename from zingo-proxyd/zcash.conf rename to zingo-indexerd/zcash.conf diff --git a/zingo-proxyd/zebrad.toml b/zingo-indexerd/zebrad.toml similarity index 100% rename from zingo-proxyd/zebrad.toml rename to zingo-indexerd/zebrad.toml diff --git a/zingo-rpc/Cargo.toml b/zingo-rpc/Cargo.toml index be83311..8221136 100644 --- a/zingo-rpc/Cargo.toml +++ b/zingo-rpc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zingo-rpc" version = "0.1.0" -description = "Crate containing the Zingo-Proxy LightWallet server library." +description = "Crate containing the Zingo-Indexer LightWallet server library." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } @@ -16,7 +16,7 @@ nym_poc = ["zingo-netutils", "zcash_client_backend"] # # Only used in original nym_poc code, to be removed with creation of nym enhanced zingolib build. # -# Not to be used in production code as zingo-rpc will become a dep of zingolib and zingo-proxy now builds its onw CompactTxStreamer. +# Not to be used in production code as zingo-rpc will become a dep of zingolib and zingo-indexer now builds its onw CompactTxStreamer. zingo-netutils = { git = "https://github.com/zingolabs/zingolib.git", branch = "nym_integration", optional = true } zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", branch = "nym_integration", features = ["lightwalletd-tonic"], optional = true } diff --git a/zingo-rpc/src/blockcache.rs b/zingo-rpc/src/blockcache.rs index cc42278..3d96d32 100644 --- a/zingo-rpc/src/blockcache.rs +++ b/zingo-rpc/src/blockcache.rs @@ -1,4 +1,4 @@ -//! Zingo-Proxy Block Cache and Mempool State Engine. +//! Zingo-Indexer Block Cache and Mempool State Engine. pub mod block; pub mod error; diff --git a/zingo-rpc/src/blockcache/block.rs b/zingo-rpc/src/blockcache/block.rs index 0265404..ed55a30 100644 --- a/zingo-rpc/src/blockcache/block.rs +++ b/zingo-rpc/src/blockcache/block.rs @@ -206,7 +206,7 @@ pub struct FullBlockHeader { pub cached_hash: Vec, } -/// Zingo-Proxy Block. +/// Zingo-Indexer Block. #[derive(Debug)] pub struct FullBlock { /// The block header, containing block metadata. diff --git a/zingo-rpc/src/blockcache/mempool.rs b/zingo-rpc/src/blockcache/mempool.rs index 62fa5c3..e89949f 100644 --- a/zingo-rpc/src/blockcache/mempool.rs +++ b/zingo-rpc/src/blockcache/mempool.rs @@ -1,4 +1,4 @@ -//! Zingo-Proxy mempool state functionality. +//! Zingo-Indexer mempool state functionality. use std::{collections::HashSet, time::SystemTime}; use tokio::sync::{Mutex, RwLock}; @@ -12,7 +12,7 @@ use crate::{ pub struct Mempool { /// Txids currently in the mempool. txids: RwLock>, - /// Txids that have already been added to Zingo-Proxy's mempool. + /// Txids that have already been added to Zingo-Indexer's mempool. txids_seen: Mutex>, /// System time when the mempool was last updated. last_sync_time: Mutex, diff --git a/zingo-rpc/src/blockcache/transaction.rs b/zingo-rpc/src/blockcache/transaction.rs index cc762e5..812909f 100644 --- a/zingo-rpc/src/blockcache/transaction.rs +++ b/zingo-rpc/src/blockcache/transaction.rs @@ -655,7 +655,7 @@ impl TransactionData { } } -/// Zingo-Proxy struct for a full zcash transaction. +/// Zingo-Indexer struct for a full zcash transaction. #[derive(Debug)] pub struct FullTransaction { /// Full transaction data. @@ -734,7 +734,7 @@ impl FullTransaction { pub fn to_compact(self, index: u64) -> Result { let hash = self.tx_id; - // NOTE: LightWalletD currently does not return a fee and is not currently priority here. Please open an Issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy) if you require this functionality. + // NOTE: LightWalletD currently does not return a fee and is not currently priority here. Please open an Issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer) if you require this functionality. let fee = 0; let spends = self diff --git a/zingo-rpc/src/jsonrpc/connector.rs b/zingo-rpc/src/jsonrpc/connector.rs index 8a9ce22..541f6ee 100644 --- a/zingo-rpc/src/jsonrpc/connector.rs +++ b/zingo-rpc/src/jsonrpc/connector.rs @@ -69,7 +69,7 @@ impl JsonRpcConnector { /// /// TODO: 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. - /// This functionality is weak and should be incorporated in Zingo-Proxy's queue mechanism [WIP] that handles various errors appropriately. + /// This functionality is weak and should be incorporated in Zingo-Indexer's queue mechanism [WIP] that handles various errors appropriately. pub async fn send_request Deserialize<'de>>( &self, method: &str, @@ -164,7 +164,7 @@ impl JsonRpcConnector { /// - `address_strings`: (object, example={"addresses": ["tmYXBYJj1K7vhejSec5osXK2QsGa5MTisUQ"]}) A JSON map with a single entry /// - `addresses`: (array of strings) A list of base-58 encoded addresses. /// - /// NOTE: Currently unused by Zingo-Proxy and untested! + /// NOTE: Currently unused by Zingo-Indexer and untested! pub async fn get_address_balance( &self, addresses: Vec, @@ -227,7 +227,7 @@ impl JsonRpcConnector { /// method: post /// tags: blockchain /// - /// NOTE: Currently unused by Zingo-Proxy and untested! + /// NOTE: Currently unused by Zingo-Indexer and untested! pub async fn get_best_block_hash( &self, ) -> Result { @@ -274,7 +274,7 @@ impl JsonRpcConnector { /// - `start_index`: (number, required) The index of the first 2^16-leaf subtree to return. /// - `limit`: (number, optional) The maximum number of subtree values to return. /// - /// NOTE: Currently unused by Zingo-Proxy and untested! + /// NOTE: Currently unused by Zingo-Indexer and untested! pub async fn get_subtrees_by_index( &self, pool: String, @@ -355,7 +355,7 @@ impl JsonRpcConnector { /// /// - `addresses`: (array, required, example={\"addresses\": [\"tmYXBYJj1K7vhejSec5osXK2QsGa5MTisUQ\"]}) The addresses to get outputs from. /// - /// NOTE: Currently unused by Zingo-Proxy and untested! + /// NOTE: Currently unused by Zingo-Indexer and untested! pub async fn get_address_utxos( &self, addresses: Vec, @@ -412,27 +412,27 @@ pub async fn test_node_and_return_uri( .map_err(JsonRpcConnectorError::InvalidUriError)?; let mut interval = tokio::time::interval(tokio::time::Duration::from_millis(500)); for _ in 0..3 { - println!("@zingoproxyd: Trying connection on IPv4."); + println!("@zingoindexerd: Trying connection on IPv4."); match test_node_connection(ipv4_uri.clone(), user.clone(), password.clone()).await { Ok(_) => { println!( - "@zingoproxyd: Connected to node using IPv4 at address {}.", + "@zingoindexerd: Connected to node using IPv4 at address {}.", ipv4_uri ); return Ok(ipv4_uri); } Err(e_ipv4) => { - eprintln!("@zingoproxyd: Failed to connect to node using IPv4 with error: {}\n@zingoproxyd: Trying connection on IPv6.", e_ipv4); + eprintln!("@zingoindexerd: Failed to connect to node using IPv4 with error: {}\n@zingoindexerd: Trying connection on IPv6.", e_ipv4); match test_node_connection(ipv6_uri.clone(), user.clone(), password.clone()).await { Ok(_) => { println!( - "@zingoproxyd: Connected to node using IPv6 at address {}.", + "@zingoindexerd: Connected to node using IPv6 at address {}.", ipv6_uri ); return Ok(ipv6_uri); } Err(e_ipv6) => { - eprintln!("@zingoproxyd: Failed to connect to node using IPv6 with error: {}.\n@zingoproxyd: Connection not established. Retrying..", e_ipv6); + eprintln!("@zingoindexerd: Failed to connect to node using IPv6 with error: {}.\n@zingoindexerd: Connection not established. Retrying..", e_ipv6); tokio::time::sleep(std::time::Duration::from_secs(3)).await; } } @@ -440,6 +440,6 @@ pub async fn test_node_and_return_uri( } interval.tick().await; } - eprintln!("@zingoproxyd: Could not establish connection with node. \n@zingoproxyd: Please check config and confirm node is listening at the correct address and the correct authorisation details have been entered. \n@zingoproxyd: Exiting.."); + eprintln!("@zingoindexerd: Could not establish connection with node. \n@zingoindexerd: Please check config and confirm node is listening at the correct address and the correct authorisation details have been entered. \n@zingoindexerd: Exiting.."); std::process::exit(1); } diff --git a/zingo-rpc/src/jsonrpc/error.rs b/zingo-rpc/src/jsonrpc/error.rs index 0dd3c74..8ac27a3 100644 --- a/zingo-rpc/src/jsonrpc/error.rs +++ b/zingo-rpc/src/jsonrpc/error.rs @@ -40,7 +40,7 @@ impl JsonRpcConnectorError { /// Maps JsonRpcConnectorError to tonic::Status pub fn to_grpc_status(&self) -> tonic::Status { - eprintln!("@zingoproxyd: Error occurred: {}.", self); + eprintln!("@zingoindexerd: Error occurred: {}.", self); match self { JsonRpcConnectorError::SerdeJsonError(_) => { diff --git a/zingo-rpc/src/nym/client.rs b/zingo-rpc/src/nym/client.rs index 6a8e458..aadb9d9 100644 --- a/zingo-rpc/src/nym/client.rs +++ b/zingo-rpc/src/nym/client.rs @@ -22,7 +22,7 @@ impl NymClient { .await?; let nym_addr = client.nym_address().to_string(); - println!("@zingoproxyd[nym]: Nym server listening on: {nym_addr}."); + println!("@zingoindexerd[nym]: Nym server listening on: {nym_addr}."); Ok(Self(client)) } diff --git a/zingo-rpc/src/primitives.rs b/zingo-rpc/src/primitives.rs index 9aabb09..7673035 100644 --- a/zingo-rpc/src/primitives.rs +++ b/zingo-rpc/src/primitives.rs @@ -1,6 +1,6 @@ -//! ZingoProxy and Zcash primitives. +//! ZingoIndexer and Zcash primitives. //! -//! This is not an exaustive source of zcash primitives, only what Zingo-Proxy and consuming wallets [ZngoLib] require for their functionality. +//! This is not an exaustive source of zcash primitives, only what Zingo-Indexer and consuming wallets [ZngoLib] require for their functionality. pub mod address; pub mod block; diff --git a/zingo-rpc/src/primitives/client.rs b/zingo-rpc/src/primitives/client.rs index 6ad8e7a..62f0214 100644 --- a/zingo-rpc/src/primitives/client.rs +++ b/zingo-rpc/src/primitives/client.rs @@ -1,4 +1,4 @@ -//! Holds primitive structs for ZingoProxy network clients. +//! Holds primitive structs for ZingoIndexer network clients. use nym_sdk::mixnet::MixnetClient; use std::sync::{atomic::AtomicBool, Arc}; diff --git a/zingo-rpc/src/primitives/transaction.rs b/zingo-rpc/src/primitives/transaction.rs index 7ec7634..cfc2d6e 100644 --- a/zingo-rpc/src/primitives/transaction.rs +++ b/zingo-rpc/src/primitives/transaction.rs @@ -22,7 +22,7 @@ pub struct BlockCommitmentTreeSize { pub orchard: CommitmentTreeSize, } -/// Zingo-Proxy commitment tree structure replicating functionality in Zebra. +/// Zingo-Indexer commitment tree structure replicating functionality in Zebra. /// /// A wrapper that contains either an Orchard or Sapling note commitment tree. #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] @@ -31,7 +31,7 @@ pub struct CommitmentTreestate { pub final_state: String, } -/// Zingo-Proxy sapling treestate. +/// Zingo-Indexer sapling treestate. /// /// A treestate that is included in the [`z_gettreestate`][1] RPC response. #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] @@ -40,7 +40,7 @@ pub struct SaplingTreestate { pub commitments: CommitmentTreestate, } -/// Zingo-Proxy orchard treestate. +/// Zingo-Indexer orchard treestate. /// /// A treestate that is included in the [`z_gettreestate`][1] RPC response. #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] @@ -311,7 +311,7 @@ impl hex::FromHex for SubtreeRpcData { } } -/// Zingo-Proxy encoding of a Bitcoin script. +/// Zingo-Indexer encoding of a Bitcoin script. /// /// *** UNTESTED - TEST BEFORE USE *** #[derive(Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] diff --git a/zingo-rpc/src/queue.rs b/zingo-rpc/src/queue.rs index 6c82246..98ba53f 100644 --- a/zingo-rpc/src/queue.rs +++ b/zingo-rpc/src/queue.rs @@ -1,4 +1,4 @@ -//! Zingo-Proxy request queue. +//! Zingo-Indexer request queue. pub mod error; pub mod request; diff --git a/zingo-rpc/src/queue/error.rs b/zingo-rpc/src/queue/error.rs index 697eb62..f71ae1a 100644 --- a/zingo-rpc/src/queue/error.rs +++ b/zingo-rpc/src/queue/error.rs @@ -2,7 +2,7 @@ use crate::nym::error::NymError; -/// Zingo-Proxy request errors. +/// Zingo-Indexer request errors. #[derive(Debug, thiserror::Error)] pub enum RequestError { /// Errors originating from incorrect enum types being called. diff --git a/zingo-rpc/src/queue/request.rs b/zingo-rpc/src/queue/request.rs index 9a3a8e6..ac50deb 100644 --- a/zingo-rpc/src/queue/request.rs +++ b/zingo-rpc/src/queue/request.rs @@ -107,20 +107,20 @@ pub struct GrpcServerRequest { request: GrpcRequest, } -/// Zingo-Proxy request, used by request queue. +/// Zingo-Indexer request, used by request queue. #[derive(Debug)] -pub enum ZingoProxyRequest { +pub enum ZingoIndexerRequest { /// Requests originating from the Nym server. NymServerRequest(NymServerRequest), /// Requests originating from the gRPC server. GrpcServerRequest(GrpcServerRequest), } -impl ZingoProxyRequest { - /// Creates a ZingoProxyRequest from an encoded gRPC service call, recieved by the Nym server. +impl ZingoIndexerRequest { + /// Creates a ZingoIndexerRequest from an encoded gRPC service call, recieved by the Nym server. pub fn new_from_nym(metadata: AnonymousSenderTag, bytes: &[u8]) -> Result { let (id, method, body) = read_nym_request_data(bytes)?; - Ok(ZingoProxyRequest::NymServerRequest(NymServerRequest { + Ok(ZingoIndexerRequest::NymServerRequest(NymServerRequest { queuedata: QueueData::new(), request: NymRequest { id, @@ -131,11 +131,11 @@ impl ZingoProxyRequest { })) } - /// Creates a ZingoProxyRequest from a gRPC service call, recieved by the gRPC server. + /// Creates a ZingoIndexerRequest from a gRPC service call, recieved by the gRPC server. /// /// TODO: implement proper functionality along with queue. pub fn new_from_grpc(metadata: MetadataMap, bytes: &[u8]) -> Self { - ZingoProxyRequest::GrpcServerRequest(GrpcServerRequest { + ZingoIndexerRequest::GrpcServerRequest(GrpcServerRequest { queuedata: QueueData::new(), request: GrpcRequest { id: 0, // TODO @@ -149,56 +149,58 @@ impl ZingoProxyRequest { /// Increases the requeue attempts for the request. pub fn increase_requeues(&mut self) { match self { - ZingoProxyRequest::NymServerRequest(ref mut req) => req.queuedata.increase_requeues(), - ZingoProxyRequest::GrpcServerRequest(ref mut req) => req.queuedata.increase_requeues(), + ZingoIndexerRequest::NymServerRequest(ref mut req) => req.queuedata.increase_requeues(), + ZingoIndexerRequest::GrpcServerRequest(ref mut req) => { + req.queuedata.increase_requeues() + } } } /// Returns the duration sunce the request was received. pub fn duration(&self) -> Result { match self { - ZingoProxyRequest::NymServerRequest(ref req) => req.queuedata.duration(), - ZingoProxyRequest::GrpcServerRequest(ref req) => req.queuedata.duration(), + ZingoIndexerRequest::NymServerRequest(ref req) => req.queuedata.duration(), + ZingoIndexerRequest::GrpcServerRequest(ref req) => req.queuedata.duration(), } } /// Returns the number of times the request has been requeued. pub fn requeues(&self) -> u32 { match self { - ZingoProxyRequest::NymServerRequest(ref req) => req.queuedata.requeues(), - ZingoProxyRequest::GrpcServerRequest(ref req) => req.queuedata.requeues(), + ZingoIndexerRequest::NymServerRequest(ref req) => req.queuedata.requeues(), + ZingoIndexerRequest::GrpcServerRequest(ref req) => req.queuedata.requeues(), } } /// Returns the client assigned id for this request, only used to construct response. pub fn client_id(&self) -> u64 { match self { - ZingoProxyRequest::NymServerRequest(ref req) => req.request.id, - ZingoProxyRequest::GrpcServerRequest(ref req) => req.request.id, + ZingoIndexerRequest::NymServerRequest(ref req) => req.request.id, + ZingoIndexerRequest::GrpcServerRequest(ref req) => req.request.id, } } /// Returns the RPC being called by the request. pub fn method(&self) -> String { match self { - ZingoProxyRequest::NymServerRequest(ref req) => req.request.method.clone(), - ZingoProxyRequest::GrpcServerRequest(ref req) => req.request.method.clone(), + ZingoIndexerRequest::NymServerRequest(ref req) => req.request.method.clone(), + ZingoIndexerRequest::GrpcServerRequest(ref req) => req.request.method.clone(), } } /// Returns request metadata including sender data. pub fn metadata(&self) -> RequestMetaData { match self { - ZingoProxyRequest::NymServerRequest(ref req) => req.request.metadata.clone(), - ZingoProxyRequest::GrpcServerRequest(ref req) => req.request.metadata.clone(), + ZingoIndexerRequest::NymServerRequest(ref req) => req.request.metadata.clone(), + ZingoIndexerRequest::GrpcServerRequest(ref req) => req.request.metadata.clone(), } } /// Returns the number of times the request has been requeued. pub fn body(&self) -> Vec { match self { - ZingoProxyRequest::NymServerRequest(ref req) => req.request.body.clone(), - ZingoProxyRequest::GrpcServerRequest(ref req) => req.request.body.clone(), + ZingoIndexerRequest::NymServerRequest(ref req) => req.request.body.clone(), + ZingoIndexerRequest::GrpcServerRequest(ref req) => req.request.body.clone(), } } } diff --git a/zingo-rpc/src/rpc/nymservice.rs b/zingo-rpc/src/rpc/nymservice.rs index b9b3f17..5e4f3ad 100644 --- a/zingo-rpc/src/rpc/nymservice.rs +++ b/zingo-rpc/src/rpc/nymservice.rs @@ -2,7 +2,7 @@ use prost::Message; -use crate::{primitives::client::ProxyClient, queue::request::ZingoProxyRequest}; +use crate::{primitives::client::ProxyClient, queue::request::ZingoIndexerRequest}; #[cfg(not(feature = "nym_poc"))] use crate::proto::service::compact_tx_streamer_server::CompactTxStreamer; @@ -14,10 +14,10 @@ impl ProxyClient { /// Processes gRPC requests coming from the nym server. pub async fn process_nym_request( &self, - request: &ZingoProxyRequest, + request: &ZingoIndexerRequest, ) -> Result, tonic::Status> { match request { - ZingoProxyRequest::NymServerRequest(_) => match request.method().as_str() { + ZingoIndexerRequest::NymServerRequest(_) => match request.method().as_str() { "GetLightdInfo" => match prost::Message::decode(&request.body()[..]) { Ok(input) => { let tonic_request = tonic::Request::new(input); @@ -75,7 +75,7 @@ impl ProxyClient { "get_address_utxos" | "get_address_utxos_stream" | "ping" => { - Err(tonic::Status::unimplemented("RPC not yet implemented over nym. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("RPC not yet implemented over nym. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }, _ => Err(tonic::Status::invalid_argument("Incorrect Method String")), }, diff --git a/zingo-rpc/src/rpc/nymwalletservice.rs b/zingo-rpc/src/rpc/nymwalletservice.rs index c1c7c97..128981f 100644 --- a/zingo-rpc/src/rpc/nymwalletservice.rs +++ b/zingo-rpc/src/rpc/nymwalletservice.rs @@ -40,7 +40,7 @@ macro_rules! define_grpc_passthrough { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of {}.", stringify!($name)); + println!("@zingoindexerd: Received call of {}.", stringify!($name)); Box::pin(async { ::zingo_netutils::GrpcConnector::new($self.lightwalletd_uri.clone()) .get_client() @@ -90,7 +90,7 @@ impl CompactTxStreamer for ProxyClient { &self, request: Request, ) -> Result, Status> { - println!("@zingoproxyd[nym_poc]: Received call of send_transaction."); + println!("@zingoindexerd[nym_poc]: Received call of send_transaction."); // -- serialize RawTransaction let serialized_request = match serialize_request(&request.into_inner()).await { Ok(data) => data, @@ -101,7 +101,7 @@ impl CompactTxStreamer for ProxyClient { ))) } }; - // -- create ZingoProxyRequest + // -- create ZingoIndexerRequest let nym_request = match write_nym_request_data( 0, "SendTransaction".to_string(), @@ -228,7 +228,7 @@ impl CompactTxStreamer for ProxyClient { &self, request: Request, ) -> Result, Status> { - println!("@zingoproxyd[nym_poc]: Received call of get_lightd_info."); + println!("@zingoindexerd[nym_poc]: Received call of get_lightd_info."); // -- serialize Empty let serialized_request = match serialize_request(&request.into_inner()).await { Ok(data) => data, @@ -239,7 +239,7 @@ impl CompactTxStreamer for ProxyClient { ))) } }; - // -- create ZingoProxyRequest + // -- create ZingoIndexerRequest let nym_request = match write_nym_request_data( 0, "GetLightdInfo".to_string(), diff --git a/zingo-rpc/src/rpc/service.rs b/zingo-rpc/src/rpc/service.rs index aa85627..4d65063 100644 --- a/zingo-rpc/src/rpc/service.rs +++ b/zingo-rpc/src/rpc/service.rs @@ -104,7 +104,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_latest_block."); + println!("@zingoindexerd: Received call of get_latest_block."); Box::pin(async { let blockchain_info = JsonRpcConnector::new( self.zebrad_uri.clone(), @@ -128,7 +128,7 @@ impl CompactTxStreamer for ProxyClient { /// Return the compact block corresponding to the given block identifier. /// /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). /// /// TODO: This RPC should be implemented alongside the block cache. fn get_block<'life0, 'async_trait>( @@ -146,16 +146,16 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_block."); + println!("@zingoindexerd: Received call of get_block."); Box::pin(async { - Err(tonic::Status::unimplemented("get_block not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_block not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } /// Same as GetBlock except actions contain only nullifiers. /// /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_block_nullifiers<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -171,9 +171,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_block_nullifiers."); + println!("@zingoindexerd: Received call of get_block_nullifiers."); Box::pin(async { - Err(tonic::Status::unimplemented("get_block_nullifiers not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_block_nullifiers not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -203,7 +203,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_block_range."); + println!("@zingoindexerd: Received call of get_block_range."); let zebrad_uri = self.zebrad_uri.clone(); Box::pin(async move { let blockrange = request.into_inner(); @@ -219,7 +219,7 @@ impl CompactTxStreamer for ProxyClient { (start, end) = (end, start); } println!( - "@zingoproxytest: Fetching blocks in range: {}-{}.", + "@zingoindexertest: Fetching blocks in range: {}-{}.", start, end ); let (channel_tx, channel_rx) = tokio::sync::mpsc::channel(32); @@ -227,7 +227,7 @@ impl CompactTxStreamer for ProxyClient { // NOTE: This timeout is so slow due to the blockcache not being implemented. This should be reduced to 30s once functionality is in place. let timeout = timeout(std::time::Duration::from_secs(120), async { for height in (start..=end).rev() { - println!("@zingoproxytest: Fetching block at height: {}.", height); + println!("@zingoindexertest: Fetching block at height: {}.", height); let compact_block = get_block_from_node(&zebrad_uri, &height).await; match compact_block { Ok(block) => { @@ -273,7 +273,7 @@ impl CompactTxStreamer for ProxyClient { /// Same as GetBlockRange except actions contain only nullifiers. /// /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_block_range_nullifiers<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -292,9 +292,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_block_range_nullifiers."); + println!("@zingoindexerd: Received call of get_block_range_nullifiers."); Box::pin(async { - Err(tonic::Status::unimplemented("get_block_range_nullifiers not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_block_range_nullifiers not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -314,7 +314,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_transaction."); + println!("@zingoindexerd: Received call of get_transaction."); Box::pin(async { let hash = request.into_inner().hash; if hash.len() == 32 { @@ -369,7 +369,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of send_transaction."); + println!("@zingoindexerd: Received call of send_transaction."); Box::pin(async { let hex_tx = hex::encode(request.into_inner().data); let tx_output = JsonRpcConnector::new( @@ -412,7 +412,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_taddress_txids."); + println!("@zingoindexerd: Received call of get_taddress_txids."); Box::pin(async move { let block_filter = request.into_inner(); let address = block_filter.address; @@ -500,7 +500,7 @@ impl CompactTxStreamer for ProxyClient { } /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_taddress_balance<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -516,14 +516,14 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_taddress_balance."); + println!("@zingoindexerd: Received call of get_taddress_balance."); Box::pin(async { - Err(tonic::Status::unimplemented("get_taddress_balance not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_taddress_balance not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). #[must_use] #[allow(clippy::type_complexity, clippy::type_repetition_in_bounds)] fn get_taddress_balance_stream<'life0, 'async_trait>( @@ -540,9 +540,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_taddress_balance_stream."); + println!("@zingoindexerd: Received call of get_taddress_balance_stream."); Box::pin(async { - Err(tonic::Status::unimplemented("get_taddress_balance_stream not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_taddress_balance_stream not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -561,7 +561,7 @@ impl CompactTxStreamer for ProxyClient { /// in the exclude list that don't exist in the mempool are ignored. /// /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_mempool_tx<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -580,9 +580,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_mempool_tx."); + println!("@zingoindexerd: Received call of get_mempool_tx."); Box::pin(async { - Err(tonic::Status::unimplemented("get_mempool_tx not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_mempool_tx not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -593,8 +593,8 @@ impl CompactTxStreamer for ProxyClient { /// Return a stream of current Mempool transactions. This will keep the output stream open while /// there are mempool transactions. It will close the returned stream when a new block is mined. /// - /// TODO: This implementation is slow. Zingo-Proxy's blockcache state engine should keep its own internal mempool state. - /// - This RPC should query Zingo-Proxy's internal mempool state rather than creating its own mempool and directly querying zebrad. + /// TODO: This implementation is slow. Zingo-Indexer's blockcache state engine should keep its own internal mempool state. + /// - This RPC should query Zingo-Indexer's internal mempool state rather than creating its own mempool and directly querying zebrad. fn get_mempool_stream<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -613,7 +613,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_mempool_stream."); + println!("@zingoindexerd: Received call of get_mempool_stream."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( self.zebrad_uri.clone(), @@ -738,7 +738,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_tree_state."); + println!("@zingoindexerd: Received call of get_tree_state."); Box::pin(async { let block_id = request.into_inner(); let hash_or_height = if block_id.height != 0 { @@ -776,7 +776,7 @@ impl CompactTxStreamer for ProxyClient { } /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_latest_tree_state<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -792,9 +792,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_latest_tree_state."); + println!("@zingoindexerd: Received call of get_latest_tree_state."); Box::pin(async { - Err(tonic::Status::unimplemented("get_latest_tree_state not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_latest_tree_state not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -806,7 +806,7 @@ impl CompactTxStreamer for ProxyClient { /// note commitment trees. /// /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_subtree_roots<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -825,14 +825,14 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_subtree_roots."); + println!("@zingoindexerd: Received call of get_subtree_roots."); Box::pin(async { - Err(tonic::Status::unimplemented("get_subtree_roots not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_subtree_roots not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_address_utxos<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -851,9 +851,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_address_utxos."); + println!("@zingoindexerd: Received call of get_address_utxos."); Box::pin(async { - Err(tonic::Status::unimplemented("get_address_utxos not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_address_utxos not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -862,7 +862,7 @@ impl CompactTxStreamer for ProxyClient { type GetAddressUtxosStreamStream = tonic::Streaming; /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn get_address_utxos_stream<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -881,9 +881,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_address_utxos_stream."); + println!("@zingoindexerd: Received call of get_address_utxos_stream."); Box::pin(async { - Err(tonic::Status::unimplemented("get_address_utxos_stream not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("get_address_utxos_stream not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } @@ -903,7 +903,7 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of get_lightd_info."); + println!("@zingoindexerd: Received call of get_lightd_info."); // TODO: Add user and password as fields of ProxyClient and use here. // TODO: Return Nym_Address in get_lightd_info response, for use by wallets. Box::pin(async { @@ -942,7 +942,7 @@ impl CompactTxStreamer for ProxyClient { let lightd_info = LightdInfo { version: build_info.version, - vendor: "ZingoLabs ZingoProxyD".to_string(), + vendor: "ZingoLabs ZingoIndexerD".to_string(), taddr_support: true, chain_name: blockchain_info.chain, sapling_activation_height: sapling_height.0 as u64, @@ -963,7 +963,7 @@ impl CompactTxStreamer for ProxyClient { // /// Testing-only, requires lightwalletd --ping-very-insecure (do not enable in production) [from zebrad] /// This RPC has not been implemented as it is not currently used by zingolib. - /// If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy). + /// If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer). fn ping<'life0, 'async_trait>( &'life0 self, _request: tonic::Request, @@ -979,9 +979,9 @@ impl CompactTxStreamer for ProxyClient { 'life0: 'async_trait, Self: 'async_trait, { - println!("@zingoproxyd: Received call of ping."); + println!("@zingoindexerd: Received call of ping."); Box::pin(async { - Err(tonic::Status::unimplemented("ping not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Proxy github (https://github.com/zingolabs/zingo-proxy).")) + Err(tonic::Status::unimplemented("ping not yet implemented. If you require this RPC please open an issue or PR at the Zingo-Indexer github (https://github.com/zingolabs/zingo-indexer).")) }) } } diff --git a/zingo-rpc/src/utils.rs b/zingo-rpc/src/utils.rs index 4a50027..d520bf1 100644 --- a/zingo-rpc/src/utils.rs +++ b/zingo-rpc/src/utils.rs @@ -1,6 +1,6 @@ //! Utility functions for Zingo-RPC. -/// Zingo-Proxy build info. +/// Zingo-Indexer build info. pub struct BuildInfo { /// Git commit hash. pub commit_hash: String, @@ -10,11 +10,11 @@ pub struct BuildInfo { pub build_date: String, /// Build user. pub build_user: String, - /// Zingo-Proxy version. + /// Zingo-Indexer version. pub version: String, } -/// Returns build info for Zingo-Proxy. +/// Returns build info for Zingo-Indexer. pub fn get_build_info() -> BuildInfo { BuildInfo { commit_hash: env!("GIT_COMMIT").to_string(), diff --git a/zingoproxy-testutils/Cargo.toml b/zingoindexer-testutils/Cargo.toml similarity index 87% rename from zingoproxy-testutils/Cargo.toml rename to zingoindexer-testutils/Cargo.toml index 65daed5..e00e073 100644 --- a/zingoproxy-testutils/Cargo.toml +++ b/zingoindexer-testutils/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "zingoproxy-testutils" +name = "zingoindexer-testutils" version = "0.1.0" -description = "Crate containing Zingo-Proxy test specific functionality." +description = "Crate containing Zingo-Indexer test specific functionality." edition = { workspace = true } authors = { workspace = true } license = { workspace = true } @@ -13,7 +13,7 @@ nym_poc = [] [dependencies] zingo-rpc = { path = "../zingo-rpc" } -zingo-proxyd = { path = "../zingo-proxyd" } +zingo-indexerd = { path = "../zingo-indexerd" } # ZingoLib zingo-testutils = { git = "https://github.com/zingolabs/zingolib.git", branch = "nym_integration" } diff --git a/zingoproxy-testutils/src/lib.rs b/zingoindexer-testutils/src/lib.rs similarity index 87% rename from zingoproxy-testutils/src/lib.rs rename to zingoindexer-testutils/src/lib.rs index 0190a14..16891da 100644 --- a/zingoproxy-testutils/src/lib.rs +++ b/zingoindexer-testutils/src/lib.rs @@ -1,4 +1,4 @@ -//! Utility functions for Zingo-Proxy Testing. +//! Utility functions for Zingo-Indexer Testing. #![warn(missing_docs)] #![forbid(unsafe_code)] @@ -7,7 +7,7 @@ use std::io::Write; static CTRL_C_ONCE: std::sync::Once = std::sync::Once::new(); -/// Configuration data for Zingo-Proxy Tests. +/// Configuration data for Zingo-Indexer Tests. pub struct TestManager { /// Temporary Directory for nym, zcashd and lightwalletd configuration and regtest data. pub temp_conf_dir: tempfile::TempDir, @@ -16,18 +16,18 @@ pub struct TestManager { pub regtest_manager: zingo_testutils::regtest::RegtestManager, /// Zingolib regtest network. pub regtest_network: zingoconfig::RegtestNetwork, - /// Zingo-Proxy gRPC listen port. - pub proxy_port: u16, - /// Zingo-Proxy Nym listen address. + /// Zingo-Indexer gRPC listen port. + pub indexer_port: u16, + /// Zingo-Indexer Nym listen address. pub nym_addr: Option, /// Zebrad/Zcashd JsonRpc listen port. pub zebrad_port: u16, - /// Online status of Zingo-Proxy. + /// Online status of Zingo-Indexer. pub online: std::sync::Arc, } impl TestManager { - /// Launches a zingo regtest manager and zingo-proxy, created TempDir for configuration and log files. + /// Launches a zingo regtest manager and zingo-indexer, created TempDir for configuration and log files. pub async fn launch( online: std::sync::Arc, ) -> ( @@ -37,7 +37,7 @@ impl TestManager { ) { let lwd_port = portpicker::pick_unused_port().expect("No ports free"); let zebrad_port = portpicker::pick_unused_port().expect("No ports free"); - let proxy_port = portpicker::pick_unused_port().expect("No ports free"); + let indexer_port = portpicker::pick_unused_port().expect("No ports free"); let temp_conf_dir = create_temp_conf_files(lwd_port, zebrad_port).unwrap(); let temp_conf_path = temp_conf_dir.path().to_path_buf(); @@ -52,8 +52,8 @@ impl TestManager { .launch(true) .expect("Failed to start regtest services"); - let (proxy_handler, nym_addr) = zingoproxylib::proxy::spawn_proxy( - &proxy_port, + let (indexer_handler, nym_addr) = zingoindexerlib::indexer::spawn_indexer( + &indexer_port, &lwd_port, &zebrad_port, nym_conf_path.to_str().unwrap(), @@ -66,21 +66,21 @@ impl TestManager { temp_conf_dir, regtest_manager, regtest_network, - proxy_port, + indexer_port, nym_addr, zebrad_port, online, }, regtest_handler, - proxy_handler, + indexer_handler, ) } - /// Returns zingo-proxy listen address. - pub fn get_proxy_uri(&self) -> http::Uri { + /// Returns zingo-indexer listen address. + pub fn get_indexer_uri(&self) -> http::Uri { http::Uri::builder() .scheme("http") - .authority(format!("127.0.0.1:{0}", self.proxy_port)) + .authority(format!("127.0.0.1:{0}", self.indexer_port)) .path_and_query("") .build() .unwrap() @@ -100,7 +100,7 @@ impl TestManager { /// Builds aand returns Zingolib lightclient. pub async fn build_lightclient(&self) -> zingolib::lightclient::LightClient { let mut client_builder = zingo_testutils::scenarios::setup::ClientBuilder::new( - self.get_proxy_uri(), + self.get_indexer_uri(), self.temp_conf_dir.path().to_path_buf(), ); client_builder @@ -127,7 +127,7 @@ pub async fn drop_test_manager( if let Some(ref path) = temp_conf_path { if let Err(e) = std::fs::remove_dir_all(path) { eprintln!( - "@zingoproxyd: Failed to delete temporary regtest configuration directory: {:?}.", + "@zingoindexerd: Failed to delete temporary regtest configuration directory: {:?}.", e ); } @@ -135,7 +135,7 @@ pub async fn drop_test_manager( if let Some(ref path) = Some(temp_wallet_path) { if let Err(e) = std::fs::remove_dir_all(path) { eprintln!( - "@zingoproxyd: Failed to delete temporary directory: {:?}.", + "@zingoindexerd: Failed to delete temporary directory: {:?}.", e ); } @@ -167,7 +167,7 @@ fn set_custom_drops( if let Some(ref path) = temp_conf_path_panic { if let Err(e) = std::fs::remove_dir_all(path) { eprintln!( - "@zingoproxyd: Failed to delete temporary regtest config directory: {:?}.", + "@zingoindexerd: Failed to delete temporary regtest config directory: {:?}.", e ); } @@ -175,7 +175,7 @@ fn set_custom_drops( if let Some(ref path) = temp_wallet_path_panic { if let Err(e) = std::fs::remove_dir_all(path) { eprintln!( - "@zingoproxyd: Failed to delete temporary wallet directory: {:?}.", + "@zingoindexerd: Failed to delete temporary wallet directory: {:?}.", e ); } @@ -187,12 +187,12 @@ fn set_custom_drops( CTRL_C_ONCE.call_once(|| { ctrlc::set_handler(move || { - println!("@zingoproxyd: Received Ctrl+C, exiting."); + println!("@zingoindexerd: Received Ctrl+C, exiting."); online_ctrlc.store(false, std::sync::atomic::Ordering::SeqCst); if let Some(ref path) = temp_conf_path_ctrlc { if let Err(e) = std::fs::remove_dir_all(path) { eprintln!( - "@zingoproxyd: Failed to delete temporary regtest config directory: {:?}.", + "@zingoindexerd: Failed to delete temporary regtest config directory: {:?}.", e ); } @@ -200,7 +200,7 @@ fn set_custom_drops( if let Some(ref path) = temp_wallet_path_ctrlc { if let Err(e) = std::fs::remove_dir_all(path) { eprintln!( - "@zingoproxyd: Failed to delete temporary wallet directory: {:?}.", + "@zingoindexerd: Failed to delete temporary wallet directory: {:?}.", e ); } @@ -257,7 +257,7 @@ fn create_temp_conf_files( rpcport: u16, ) -> Result> { let temp_dir = tempfile::Builder::new() - .prefix("zingoproxytest") + .prefix("zingoindexertest") .tempdir()?; let conf_dir = temp_dir.path().join("conf"); std::fs::create_dir(&conf_dir)?; @@ -290,7 +290,7 @@ pub async fn start_zingo_mempool_monitor(zingo_client: &zingolib::lightclient::L tokio::time::sleep(std::time::Duration::from_secs(5)).await; } -/// Zingo-Proxy wrapper for Zingolib's Pool Enum. +/// Zingo-Indexer wrapper for Zingolib's Pool Enum. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ProxyPool { /// Orchard pool.