diff --git a/Cargo.toml b/Cargo.toml index 91796fc107..0ddd568e43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,4 +21,3 @@ codegen-units = 1 [patch.crates-io] zcash_encoding = { path = "components/zcash_encoding" } zcash_note_encryption = { path = "components/zcash_note_encryption" } -orchard = { git = "https://github.com/zcash/orchard.git", rev = "bdcf15ba2141f94f031c195140219a99335d96d5" } diff --git a/components/zcash_address/Cargo.toml b/components/zcash_address/Cargo.toml index f7342307a0..37bb36c173 100644 --- a/components/zcash_address/Cargo.toml +++ b/components/zcash_address/Cargo.toml @@ -15,7 +15,7 @@ categories = ["cryptography::cryptocurrencies", "encoding"] keywords = ["zcash", "address", "sapling", "unified"] [dependencies] -bech32 = "0.8" +bech32 = "0.9" bs58 = { version = "0.4", features = ["check"] } f4jumble = { version = "0.1", path = "../f4jumble" } zcash_encoding = { version = "0.2", path = "../zcash_encoding" } diff --git a/zcash_client_backend/CHANGELOG.md b/zcash_client_backend/CHANGELOG.md index 873f6a4467..c1e4a6bfaf 100644 --- a/zcash_client_backend/CHANGELOG.md +++ b/zcash_client_backend/CHANGELOG.md @@ -8,7 +8,8 @@ and this library adheres to Rust's notion of ## [Unreleased] ### Changed -- Bumped dependencies to `bls12_381 0.8`, `group 0.13`, +- Bumped dependencies to `bls12_381 0.8`, `group 0.13`, `orchard 0.4`, + `tonic 0.9`, `base64 0.21`, `bech32 0.9`. - The dependency on `zcash_primitives` no longer enables the `multicore` feature by default in order to support compilation under `wasm32-wasi`. Users of other platforms may need to include an explicit dependency on `zcash_primitives` diff --git a/zcash_client_backend/Cargo.toml b/zcash_client_backend/Cargo.toml index 1bdb36705e..01e6949796 100644 --- a/zcash_client_backend/Cargo.toml +++ b/zcash_client_backend/Cargo.toml @@ -31,8 +31,8 @@ zcash_primitives = { version = "0.10", path = "../zcash_primitives", default-fea time = "0.2" # - Encodings -base64 = "0.13" -bech32 = "0.8" +base64 = "0.21" +bech32 = "0.9" bs58 = { version = "0.4", features = ["check"] } # - Errors @@ -44,7 +44,7 @@ tracing = "0.1" # - Protobuf interfaces and gRPC bindings prost = "0.11" -tonic = { version = "0.8", optional = true } +tonic = { version = "0.9", optional = true } # - Secret management secrecy = "0.8" @@ -53,7 +53,7 @@ subtle = "2.2.3" # - Shielded protocols bls12_381 = "0.8" group = "0.13" -orchard = { version = "0.3", default-features = false } +orchard = { version = "0.4", default-features = false } # - Test dependencies proptest = { version = "1.0.0", optional = true } @@ -72,7 +72,7 @@ crossbeam-channel = "0.5" rayon = "1.5" [build-dependencies] -tonic-build = "0.8" +tonic-build = "0.9" which = "4" [dev-dependencies] diff --git a/zcash_client_backend/src/proto/service.rs b/zcash_client_backend/src/proto/service.rs index 9db625ab10..38b15abdbf 100644 --- a/zcash_client_backend/src/proto/service.rs +++ b/zcash_client_backend/src/proto/service.rs @@ -235,7 +235,7 @@ pub mod compact_tx_streamer_client { /// Attempt to create a new client by connecting to a given endpoint. pub async fn connect(dst: D) -> Result where - D: std::convert::TryInto, + D: TryInto, D::Error: Into, { let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; @@ -291,11 +291,27 @@ pub mod compact_tx_streamer_client { self.inner = self.inner.accept_compressed(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } /// Return the height of the tip of the best chain pub async fn get_latest_block( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -309,13 +325,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLatestBlock", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetLatestBlock", + ), + ); + self.inner.unary(req, path, codec).await } /// Return the compact block corresponding to the given block identifier pub async fn get_block( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response, tonic::Status, > { @@ -332,13 +356,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlock", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetBlock", + ), + ); + self.inner.unary(req, path, codec).await } /// Return a list of consecutive compact blocks pub async fn get_block_range( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response< tonic::codec::Streaming, >, @@ -357,13 +389,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlockRange", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetBlockRange", + ), + ); + self.inner.server_streaming(req, path, codec).await } /// Return the requested full (not compact) transaction (as from zcashd) pub async fn get_transaction( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -377,13 +417,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTransaction", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetTransaction", + ), + ); + self.inner.unary(req, path, codec).await } /// Submit the given transaction to the Zcash network pub async fn send_transaction( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -397,13 +445,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/SendTransaction", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "SendTransaction", + ), + ); + self.inner.unary(req, path, codec).await } /// Return the txids corresponding to the given t-address within the given block range pub async fn get_taddress_txids( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -420,12 +476,20 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTaddressTxids", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetTaddressTxids", + ), + ); + self.inner.server_streaming(req, path, codec).await } pub async fn get_taddress_balance( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -439,12 +503,20 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTaddressBalance", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetTaddressBalance", + ), + ); + self.inner.unary(req, path, codec).await } pub async fn get_taddress_balance_stream( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -458,9 +530,15 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTaddressBalanceStream", ); - self.inner - .client_streaming(request.into_streaming_request(), path, codec) - .await + let mut req = request.into_streaming_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetTaddressBalanceStream", + ), + ); + self.inner.client_streaming(req, path, codec).await } /// Return the compact transactions currently in the mempool; the results /// can be a few seconds out of date. If the Exclude list is empty, return @@ -474,7 +552,7 @@ pub mod compact_tx_streamer_client { pub async fn get_mempool_tx( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response< tonic::codec::Streaming, >, @@ -493,14 +571,22 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetMempoolTx", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetMempoolTx", + ), + ); + self.inner.server_streaming(req, path, codec).await } /// 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. pub async fn get_mempool_stream( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -517,7 +603,15 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetMempoolStream", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetMempoolStream", + ), + ); + self.inner.server_streaming(req, path, codec).await } /// GetTreeState returns the note commitment tree state corresponding to the given block. /// See section 3.7 of the Zcash protocol specification. It returns several other useful @@ -526,7 +620,7 @@ pub mod compact_tx_streamer_client { pub async fn get_tree_state( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -540,12 +634,20 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTreeState", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetTreeState", + ), + ); + self.inner.unary(req, path, codec).await } pub async fn get_latest_tree_state( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -559,12 +661,23 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLatestTreeState", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetLatestTreeState", + ), + ); + self.inner.unary(req, path, codec).await } pub async fn get_address_utxos( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await @@ -578,12 +691,20 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetAddressUtxos", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetAddressUtxos", + ), + ); + self.inner.unary(req, path, codec).await } pub async fn get_address_utxos_stream( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -600,13 +721,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetAddressUtxosStream", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetAddressUtxosStream", + ), + ); + self.inner.server_streaming(req, path, codec).await } /// Return information about this lightwalletd instance and the blockchain pub async fn get_lightd_info( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -620,13 +749,21 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLightdInfo", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cash.z.wallet.sdk.rpc.CompactTxStreamer", + "GetLightdInfo", + ), + ); + self.inner.unary(req, path, codec).await } /// Testing-only, requires lightwalletd --ping-very-insecure (do not enable in production) pub async fn ping( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -640,7 +777,12 @@ pub mod compact_tx_streamer_client { let path = http::uri::PathAndQuery::from_static( "/cash.z.wallet.sdk.rpc.CompactTxStreamer/Ping", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("cash.z.wallet.sdk.rpc.CompactTxStreamer", "Ping"), + ); + self.inner.unary(req, path, codec).await } } } diff --git a/zcash_client_backend/src/zip321.rs b/zcash_client_backend/src/zip321.rs index 33b0d5c668..46f979d80e 100644 --- a/zcash_client_backend/src/zip321.rs +++ b/zcash_client_backend/src/zip321.rs @@ -7,6 +7,7 @@ use core::fmt::Debug; use std::collections::HashMap; +use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine}; use nom::{ character::complete::char, combinator::all_consuming, multi::separated_list0, sequence::preceded, @@ -38,14 +39,15 @@ pub enum Zip321Error { /// /// [`MemoBytes`]: zcash_primitives::memo::MemoBytes pub fn memo_to_base64(memo: &MemoBytes) -> String { - base64::encode_config(memo.as_slice(), base64::URL_SAFE_NO_PAD) + BASE64_URL_SAFE_NO_PAD.encode(memo.as_slice()) } /// Parse a [`MemoBytes`] value from a ZIP 321 compatible base64-encoded string. /// /// [`MemoBytes`]: zcash_primitives::memo::MemoBytes pub fn memo_from_base64(s: &str) -> Result { - base64::decode_config(s, base64::URL_SAFE_NO_PAD) + BASE64_URL_SAFE_NO_PAD + .decode(s) .map_err(Zip321Error::InvalidBase64) .and_then(|b| MemoBytes::from_bytes(&b).map_err(Zip321Error::MemoBytesError)) } diff --git a/zcash_primitives/CHANGELOG.md b/zcash_primitives/CHANGELOG.md index 32da73c5e7..7bb2298778 100644 --- a/zcash_primitives/CHANGELOG.md +++ b/zcash_primitives/CHANGELOG.md @@ -8,7 +8,8 @@ and this library adheres to Rust's notion of ## [Unreleased] ### Changed -- Bumped dependencies to `bls12_381 0.8`, `ff 0.13`, `group 0.13`, `jubjub 0.10` +- Bumped dependencies to `bls12_381 0.8`, `ff 0.13`, `group 0.13`, + `jubjub 0.10`, `orchard 0.4`, `sha2 0.10`, `bip0039 0.11`. ## [0.10.2] - 2023-03-16 ### Added diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml index 8bd7d6af38..e75f326fcc 100644 --- a/zcash_primitives/Cargo.toml +++ b/zcash_primitives/Cargo.toml @@ -30,7 +30,7 @@ rand_core = "0.6" # - Digests (output types exposed) blake2b_simd = "1" -sha2 = "0.9" +sha2 = "0.10" # - Metrics memuse = "0.2.1" @@ -45,7 +45,7 @@ group = { version = "0.13", features = ["wnaf-memuse"] } incrementalmerkletree = "0.3" jubjub = "0.10" nonempty = "0.7" -orchard = { version = "0.3", default-features = false } +orchard = { version = "0.4", default-features = false } # - Static constants lazy_static = "1" @@ -60,7 +60,7 @@ hdwallet = { version = "0.3.1", optional = true } secp256k1 = { version = "0.21", optional = true } # - ZIP 339 -bip0039 = { version = "0.9", features = ["std", "all-languages"] } +bip0039 = { version = "0.11", features = ["std", "all-languages"] } # Dependencies used internally: # (Breaking upgrades to these are usually backwards-compatible, but check MSRVs.) @@ -76,8 +76,8 @@ blake2s_simd = "1" ripemd = { version = "0.1", optional = true } # - ZIP 32 -aes = "0.7" -fpe = "0.5" +aes = "0.8" +fpe = "0.6" [dependencies.zcash_note_encryption] version = "0.3" @@ -89,7 +89,7 @@ criterion = "0.4" proptest = "1.0.0" assert_matches = "1.3.0" rand_xorshift = "0.3" -orchard = { version = "0.3", default-features = false, features = ["test-dependencies"] } +orchard = { version = "0.4", default-features = false, features = ["test-dependencies"] } [target.'cfg(unix)'.dev-dependencies] pprof = { version = "0.11", features = ["criterion", "flamegraph"] } # MSRV 1.56 diff --git a/zcash_primitives/src/legacy/keys.rs b/zcash_primitives/src/legacy/keys.rs index 483003437e..6423b1fdad 100644 --- a/zcash_primitives/src/legacy/keys.rs +++ b/zcash_primitives/src/legacy/keys.rs @@ -2,9 +2,8 @@ use hdwallet::{ traits::{Deserialize, Serialize}, ExtendedPrivKey, ExtendedPubKey, KeyIndex, }; -use ripemd::Digest as RipemdDigest; use secp256k1::PublicKey; -use sha2::{Digest as Sha2Digest, Sha256}; +use sha2::{Digest, Sha256}; use crate::{consensus, keys::prf_expand_vec, zip32::AccountId}; diff --git a/zcash_primitives/src/transaction/components/transparent/builder.rs b/zcash_primitives/src/transaction/components/transparent/builder.rs index b36b1c7f8e..3a2e20b6af 100644 --- a/zcash_primitives/src/transaction/components/transparent/builder.rs +++ b/zcash_primitives/src/transaction/components/transparent/builder.rs @@ -22,7 +22,7 @@ use { TransactionData, TxDigests, }, blake2b_simd::Hash as Blake2bHash, - ripemd::Digest, + sha2::Digest, }; #[derive(Debug, PartialEq, Eq)] @@ -144,7 +144,7 @@ impl TransparentBuilder { match coin.script_pubkey.address() { Some(TransparentAddress::PublicKey(hash)) => { use ripemd::Ripemd160; - use sha2::{Digest, Sha256}; + use sha2::Sha256; if hash[..] != Ripemd160::digest(Sha256::digest(&pubkey))[..] { return Err(Error::InvalidAddress); diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index 99d12da36d..ed87c7a0c4 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -33,7 +33,7 @@ tracing = "0.1" # Dependencies used internally: # (Breaking upgrades to these are usually backwards-compatible, but check MSRVs.) blake2b_simd = "1" -directories = { version = "4", optional = true } +directories = { version = "5", optional = true } redjubjub = "0.7" wagyu-zcash-parameters = { version = "0.2", optional = true }