Skip to content

Commit

Permalink
Merge branch 'ec2/rayon' into ec2/mutex-wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ec2 committed Sep 23, 2024
2 parents 03fc5a1 + 20e1676 commit 478b4d6
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --all-targets -- -D warnings
args: --all --lib -- -D warnings
47 changes: 45 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 11 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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"
Expand All @@ -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" }
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 1 addition & 3 deletions examples/simple-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32> = Some(2577329);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 3 additions & 11 deletions src/wallet.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
};
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/message-board-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 3 additions & 13 deletions tests/simple-sync-and-send.rs
Original file line number Diff line number Diff line change
@@ -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<u32> = Some(2577329);
Expand All @@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 478b4d6

Please sign in to comment.