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/Cargo.lock b/Cargo.lock index b37faa8..2c1b543 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -812,6 +812,7 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "equihash" version = "0.2.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "blake2b_simd", "byteorder", @@ -863,6 +864,7 @@ dependencies = [ [[package]] name = "f4jumble" version = "0.1.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "blake2b_simd", ] @@ -1812,6 +1814,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" @@ -2198,6 +2223,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" @@ -3640,6 +3674,7 @@ dependencies = [ [[package]] name = "zcash_address" version = "0.5.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bech32", "bs58", @@ -3651,6 +3686,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", @@ -3696,8 +3732,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", @@ -3705,6 +3741,7 @@ dependencies = [ "jubjub", "nonempty", "orchard", + "parking_lot", "prost 0.13.2", "rayon", "sapling-crypto", @@ -3717,7 +3754,6 @@ dependencies = [ "thiserror", "tokio", "tracing", - "wasm_sync", "zcash_address", "zcash_client_backend", "zcash_encoding", @@ -3730,6 +3766,7 @@ dependencies = [ [[package]] name = "zcash_client_sqlite" version = "0.11.2" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bs58", "byteorder", @@ -3765,6 +3802,7 @@ dependencies = [ [[package]] name = "zcash_encoding" version = "0.2.1" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "byteorder", "nonempty", @@ -3773,6 +3811,7 @@ dependencies = [ [[package]] name = "zcash_keys" version = "0.3.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bech32", "bip32", @@ -3813,6 +3852,7 @@ dependencies = [ [[package]] name = "zcash_primitives" version = "0.17.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "aes", "bip32", @@ -3850,6 +3890,7 @@ dependencies = [ [[package]] name = "zcash_proofs" version = "0.17.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "bellman", "blake2b_simd", @@ -3869,6 +3910,7 @@ dependencies = [ [[package]] name = "zcash_protocol" version = "0.3.0" +source = "git+https://github.com/ChainSafe/librustzcash?rev=0fdd2fbb992a6f84eba45f488ee74a75d08d449b#0fdd2fbb992a6f84eba45f488ee74a75d08d449b" dependencies = [ "document-features", "memuse", @@ -3937,6 +3979,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 f0167d9..f921f66 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" @@ -131,16 +118,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" } 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 cba257b..940b555 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/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 1277f9f..6145b7d 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -1,28 +1,23 @@ 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 std::borrow::BorrowMut; 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 serde::{Serialize, Serializer}; use std::fmt::Debug; use std::hash::Hash; -use std::ops::DerefMut; use std::sync::Arc; use subtle::ConditionallySelectable; -use tokio::sync::{Mutex, RwLock}; +use tokio::sync::RwLock; use zcash_address::ZcashAddress; use zcash_client_backend::data_api::wallet::{ create_proposed_transactions, input_selection::GreedyInputSelector, propose_transfer, @@ -34,7 +29,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, }; @@ -51,8 +45,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 diff --git a/tests/message-board-sync.rs b/tests/message-board-sync.rs index 67e8fa5..4b779b2 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 6a1783f..aef7aaa 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); @@ -33,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 { 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