From bb027f133e4b7d57994de68b4572914b1681f719 Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Mon, 23 Sep 2024 18:04:25 -0400 Subject: [PATCH 1/5] clean up cargo toml --- Cargo.lock | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 37 ++++++++++---------------------- 2 files changed, 72 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3229b8..cd868d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -705,6 +705,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "equihash" version = "0.2.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "blake2b_simd", "byteorder", @@ -756,6 +757,7 @@ dependencies = [ [[package]] name = "f4jumble" version = "0.1.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "blake2b_simd", ] @@ -1393,6 +1395,16 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.22" @@ -1669,6 +1681,29 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + [[package]] name = "password-hash" version = "0.5.0" @@ -1990,6 +2025,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "redox_syscall" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" version = "1.10.6" @@ -2210,6 +2254,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "secp256k1" version = "0.27.0" @@ -3278,6 +3328,7 @@ dependencies = [ [[package]] name = "zcash_address" version = "0.5.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bech32", "bs58", @@ -3289,6 +3340,7 @@ dependencies = [ [[package]] name = "zcash_client_backend" version = "0.13.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "async-trait", "base64 0.21.7", @@ -3334,8 +3386,8 @@ dependencies = [ [[package]] name = "zcash_client_memory" version = "0.1.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ - "async-trait", "bs58", "byteorder", "group", @@ -3343,6 +3395,7 @@ dependencies = [ "jubjub", "nonempty", "orchard", + "parking_lot", "prost 0.13.2", "rayon", "sapling-crypto", @@ -3355,7 +3408,6 @@ dependencies = [ "thiserror", "tokio", "tracing", - "wasm_sync", "zcash_address", "zcash_client_backend", "zcash_encoding", @@ -3368,6 +3420,7 @@ dependencies = [ [[package]] name = "zcash_client_sqlite" version = "0.11.2" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bs58", "byteorder", @@ -3403,6 +3456,7 @@ dependencies = [ [[package]] name = "zcash_encoding" version = "0.2.1" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "byteorder", "nonempty", @@ -3411,6 +3465,7 @@ dependencies = [ [[package]] name = "zcash_keys" version = "0.3.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bech32", "bip32", @@ -3451,6 +3506,7 @@ dependencies = [ [[package]] name = "zcash_primitives" version = "0.17.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "aes", "bip32", @@ -3488,6 +3544,7 @@ dependencies = [ [[package]] name = "zcash_proofs" version = "0.17.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bellman", "blake2b_simd", @@ -3507,6 +3564,7 @@ dependencies = [ [[package]] name = "zcash_protocol" version = "0.3.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "document-features", "memuse", @@ -3575,6 +3633,7 @@ dependencies = [ [[package]] name = "zip321" version = "0.1.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "base64 0.21.7", "nom", diff --git a/Cargo.toml b/Cargo.toml index 0957d59..7dd43e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,18 +52,6 @@ js-sys = "0.3.70" wasm-bindgen-futures = "0.4.43" web-sys = { version = "0.3.70", features = [ "console", - "Headers", - "ReadableStream", - "ReferrerPolicy", - "Request", - "RequestCache", - "RequestCredentials", - "RequestInit", - "RequestMode", - "RequestRedirect", - "Response", - "ServiceWorkerGlobalScope", - "WorkerGlobalScope", ] } wasm-bindgen-rayon = { version = "1.2.1", optional = true } @@ -107,7 +95,6 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing = "0.1.40" rayon = { version = "1.8", features = ["web_spin_lock"] } subtle = "2.6.1" -#wasm_thread = { version = "0.3.0" } wasm_thread = { git = "https://github.com/WilsonGramer/wasm_thread.git", rev = "eb41bcc0d98ce0620a313687c0344341391b9d78", features = ["keep_worker_alive"] } wasm_sync = "0.1.2" @@ -127,16 +114,14 @@ wasm-bindgen-rayon = { git = "https://github.com/9SMTM6/wasm-bindgen-rayon", rev # TODO: Remove these once the PRs are merged shardtree = { git = "https://github.com/ec2/incrementalmerkletree.git", rev = "16eff253ad2575d48feec04f7387e6507a7dd698" } incrementalmerkletree = { git = "https://github.com/ec2/incrementalmerkletree.git", rev = "16eff253ad2575d48feec04f7387e6507a7dd698" } -#tonic-web-wasm-client = { path = "../tonic-web-wasm-client" } - -#wasm_thread = { git = "https://github.com/WilsonGramer/wasm_thread.git", rev = "eb41bcc0d98ce0620a313687c0344341391b9d78" } - -[patch.'https://github.com/chainsafe/librustzcash'] -zcash_address = { path = "../librustzcash/components/zcash_address" } -zcash_client_backend = { path = "../librustzcash/zcash_client_backend" } -zcash_client_sqlite = { path = "../librustzcash/zcash_client_sqlite" } -zcash_client_memory = { path = "../librustzcash/zcash_client_memory" } -zcash_keys = { path = "../librustzcash/zcash_keys" } -zcash_primitives = { path = "../librustzcash/zcash_primitives" } -zcash_proofs = { path = "../librustzcash/zcash_proofs" } -zcash_protocol = { path = "../librustzcash/components/zcash_protocol" } + + +#[patch.'https://github.com/chainsafe/librustzcash'] +#zcash_address = { path = "../librustzcash/components/zcash_address" } +#zcash_client_backend = { path = "../librustzcash/zcash_client_backend" } +#zcash_client_sqlite = { path = "../librustzcash/zcash_client_sqlite" } +#zcash_client_memory = { path = "../librustzcash/zcash_client_memory" } +#zcash_keys = { path = "../librustzcash/zcash_keys" } +#zcash_primitives = { path = "../librustzcash/zcash_primitives" } +#zcash_proofs = { path = "../librustzcash/zcash_proofs" } +#zcash_protocol = { path = "../librustzcash/components/zcash_protocol" } From 9dae234b17a30e6eb73449e4712eac990a4f5c4c Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Mon, 23 Sep 2024 18:05:45 -0400 Subject: [PATCH 2/5] clippy --- src/lib.rs | 2 +- src/wallet.rs | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7dcc67a..a2d8e1f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ use zcash_primitives::consensus; /// The maximum number of checkpoints to store in each shard-tree pub const PRUNING_DEPTH: usize = 100; -#[cfg(all(feature = "wasm-parallel"))] +#[cfg(feature = "wasm-parallel")] pub use wasm_bindgen_rayon::init_thread_pool; #[wasm_bindgen] diff --git a/src/wallet.rs b/src/wallet.rs index f6023dd..bc85a09 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -1,20 +1,16 @@ use std::num::NonZeroU32; use bip0039::{English, Mnemonic}; -use futures_util::{Stream, StreamExt, TryStreamExt}; +use futures_util::{StreamExt, TryStreamExt}; use nonempty::NonEmpty; use secrecy::{ExposeSecret, SecretVec, Zeroize}; use tonic::{ client::GrpcService, codegen::{Body, Bytes, StdError}, - Status, Streaming, }; use crate::error::Error; use crate::BlockRange; -use rayon::iter::IntoParallelIterator; -use rayon::iter::IntoParallelRefIterator; -use rayon::iter::ParallelIterator; use std::fmt::Debug; use std::hash::Hash; use subtle::ConditionallySelectable; @@ -29,7 +25,6 @@ use zcash_client_backend::data_api::{ }; use zcash_client_backend::fees::zip317::SingleOutputChangeStrategy; use zcash_client_backend::proposal::Proposal; -use zcash_client_backend::proto::compact_formats::CompactBlock; use zcash_client_backend::proto::service::{ self, compact_tx_streamer_client::CompactTxStreamerClient, }; @@ -46,8 +41,6 @@ use zcash_primitives::transaction::TxId; use zcash_proofs::prover::LocalTxProver; use zcash_client_backend::sync::run; -/// The maximum number of checkpoints to store in each shard-tree -const PRUNING_DEPTH: usize = 100; const BATCH_SIZE: u32 = 10000; /// # A Zcash wallet From 5103268056cacdc962b24ede24570a51efec628e Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Mon, 23 Sep 2024 18:08:18 -0400 Subject: [PATCH 3/5] move traefik configs into own folder --- docker-compose.yml | 4 ++-- examples/simple-sync.rs | 4 +--- dynamic.yml => traefik/dynamic.yml | 0 traefik.yml => traefik/traefik.yml | 0 4 files changed, 3 insertions(+), 5 deletions(-) rename dynamic.yml => traefik/dynamic.yml (100%) rename traefik.yml => traefik/traefik.yml (100%) diff --git a/docker-compose.yml b/docker-compose.yml index feed3b7..19dc3c0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,5 +9,5 @@ services: - "8080:8080" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro" - - "./dynamic.yml:/etc/traefik/dynamic.yml:ro" - - "./traefik.yml:/etc/traefik/traefik.yml:ro" + - "./traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro" + - "./traefik/traefik.yml:/etc/traefik/traefik.yml:ro" diff --git a/examples/simple-sync.rs b/examples/simple-sync.rs index 0273512..deb6a3a 100644 --- a/examples/simple-sync.rs +++ b/examples/simple-sync.rs @@ -6,9 +6,7 @@ use zcash_address::ZcashAddress; use zcash_primitives::consensus::Network; wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); -macro_rules! console_log { - ($($t:tt)*) => (web_sys::console::log_1(&format!($($t)*).into())) -} + const SEED: &str = "visit armed kite pen cradle toward reward clay marble oil write dove blind oyster silk oyster original message skate bench tone enable stadium element"; const HD_INDEX: u32 = 0; const BIRTHDAY: Option = Some(2577329); diff --git a/dynamic.yml b/traefik/dynamic.yml similarity index 100% rename from dynamic.yml rename to traefik/dynamic.yml diff --git a/traefik.yml b/traefik/traefik.yml similarity index 100% rename from traefik.yml rename to traefik/traefik.yml From bbf019255580fc3add348a84e7883f465f68b8aa Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Mon, 23 Sep 2024 18:10:08 -0400 Subject: [PATCH 4/5] remove unused imports in web test --- tests/simple-sync-and-send.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/simple-sync-and-send.rs b/tests/simple-sync-and-send.rs index fd71411..511c238 100644 --- a/tests/simple-sync-and-send.rs +++ b/tests/simple-sync-and-send.rs @@ -1,23 +1,13 @@ use wasm_bindgen_test::*; wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); -use http::Uri; -use js_sys::Promise; use std::sync::Once; use webz_core::bindgen::wallet::WebWallet; -use tokio_with_wasm::alias as tokio; -use tonic::{Request, Status}; -use tonic_web_wasm_client::options::{Credentials, FetchOptions, Mode, ReferrerPolicy}; -use tonic_web_wasm_client::Client; -use wasm_bindgen::prelude::wasm_bindgen; -use wasm_bindgen::{JsCast, UnwrapThrowExt}; -use wasm_bindgen_futures::{spawn_local, JsFuture}; +use wasm_bindgen::UnwrapThrowExt; +use wasm_bindgen_futures::JsFuture; use wasm_thread as thread; -use zcash_client_backend::proto::service::compact_tx_streamer_client::CompactTxStreamerClient; -use zcash_client_backend::proto::service::ChainSpec; - const SEED: &str = "visit armed kite pen cradle toward reward clay marble oil write dove blind oyster silk oyster original message skate bench tone enable stadium element"; const HD_INDEX: u32 = 0; const BIRTHDAY: Option = Some(2577329); From 20e16761ad4d850bb66d2e0beb3454e80951fe5d Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Mon, 23 Sep 2024 18:22:25 -0400 Subject: [PATCH 5/5] make clippy only run on library --- .github/workflows/rust-checks.yml | 2 +- tests/message-board-sync.rs | 2 +- tests/simple-sync-and-send.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust-checks.yml b/.github/workflows/rust-checks.yml index 1b5fb2d..2612753 100644 --- a/.github/workflows/rust-checks.yml +++ b/.github/workflows/rust-checks.yml @@ -36,4 +36,4 @@ jobs: - uses: actions-rs/cargo@v1 with: command: clippy - args: --all --all-targets -- -D warnings + args: --all --lib -- -D warnings diff --git a/tests/message-board-sync.rs b/tests/message-board-sync.rs index 4160a44..a1ec7eb 100644 --- a/tests/message-board-sync.rs +++ b/tests/message-board-sync.rs @@ -21,7 +21,7 @@ const SAPLING_EFVK: &str = "zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfa #[wasm_bindgen_test] async fn test_message_board() { initialize(); - #[cfg(all(feature = "wasm-parallel"))] + #[cfg(feature = "wasm-parallel")] let _ = wasm_bindgen_futures::JsFuture::from(wasm_bindgen_rayon::init_thread_pool(10)).await; let main_handler = thread::Builder::new() .spawn_async(|| async { diff --git a/tests/simple-sync-and-send.rs b/tests/simple-sync-and-send.rs index 511c238..9b493fa 100644 --- a/tests/simple-sync-and-send.rs +++ b/tests/simple-sync-and-send.rs @@ -23,7 +23,7 @@ pub fn initialize() { #[wasm_bindgen_test] async fn test_get_and_scan_range() { initialize(); - #[cfg(all(feature = "wasm-parallel"))] + #[cfg(feature = "wasm-parallel")] let _ = JsFuture::from(wasm_bindgen_rayon::init_thread_pool(10)).await; assert!(!thread::is_web_worker_thread()); let main_handler = thread::Builder::new().spawn_async(|| async {