Skip to content

Commit

Permalink
Merge branch 'main' into add_block_cache_trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar-Pepper committed Feb 28, 2024
2 parents f60cfc1 + 5ed788d commit e7003ee
Show file tree
Hide file tree
Showing 11 changed files with 625 additions and 443 deletions.
246 changes: 124 additions & 122 deletions zcash_client_backend/CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
zcash_address.workspace = true
zcash_encoding.workspace = true
zcash_keys.workspace = true
zcash_keys = { workspace = true, features = ["sapling"] }
zcash_note_encryption.workspace = true
zcash_primitives.workspace = true
zip32.workspace = true
Expand Down Expand Up @@ -105,6 +105,7 @@ rand_core.workspace = true
shardtree = { workspace = true, features = ["test-dependencies"] }
zcash_proofs.workspace = true
zcash_address = { workspace = true, features = ["test-dependencies"] }
zcash_keys = { workspace = true, features = ["test-dependencies"] }

time = ">=0.3.22, <0.3.24" # time 0.3.24 has MSRV 1.67

Expand Down
5 changes: 3 additions & 2 deletions zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where
/// };
/// use zcash_proofs::prover::LocalTxProver;
/// use zcash_client_backend::{
/// keys::UnifiedSpendingKey,
/// keys::{UnifiedSpendingKey, UnifiedAddressRequest},
/// data_api::{wallet::create_spend_to_address, error::Error, testing},
/// wallet::OvkPolicy,
/// };
Expand All @@ -166,8 +166,9 @@ where
/// };
///
/// let account = AccountId::from(0);
/// let req = UnifiedAddressRequest::new(false, true, true);
/// let usk = UnifiedSpendingKey::from_seed(&Network::TestNetwork, &[0; 32][..], account).unwrap();
/// let to = usk.to_unified_full_viewing_key().default_address().0.into();
/// let to = usk.to_unified_full_viewing_key().default_address(req).0.into();
///
/// let mut db_read = testing::MockWalletDb {
/// network: Network::TestNetwork
Expand Down
26 changes: 9 additions & 17 deletions zcash_client_backend/src/zip321.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl TransactionRequest {

/// A utility for use in tests to help check round-trip serialization properties.
/// by comparing a two transaction requests for equality after normalization.
#[cfg(all(test, feature = "test-dependencies"))]
#[cfg(test)]
pub(in crate::zip321) fn normalize_and_eq(
a: &mut TransactionRequest,
b: &mut TransactionRequest,
Expand Down Expand Up @@ -735,7 +735,7 @@ mod parse {
}
}

#[cfg(feature = "test-dependencies")]
#[cfg(any(test, feature = "test-dependencies"))]
pub mod testing {
use proptest::collection::btree_map;
use proptest::collection::vec;
Expand Down Expand Up @@ -825,12 +825,16 @@ pub mod testing {

#[cfg(test)]
mod tests {
use proptest::prelude::{any, proptest};
use std::str::FromStr;

use zcash_keys::address::testing::arb_addr;
use zcash_primitives::{
consensus::{Parameters, TEST_NETWORK},
memo::Memo,
transaction::components::amount::{Amount, NonNegativeAmount},
transaction::components::amount::{
testing::arb_nonnegative_amount, Amount, NonNegativeAmount,
},
};

#[cfg(feature = "local-consensus")]
Expand All @@ -841,20 +845,9 @@ mod tests {
use super::{
memo_from_base64, memo_to_base64,
parse::{parse_amount, zcashparam, Param},
render::amount_str,
MemoBytes, Payment, TransactionRequest,
};

#[cfg(all(test, feature = "test-dependencies"))]
use proptest::prelude::{any, proptest};

#[cfg(all(test, feature = "test-dependencies"))]
use zcash_primitives::transaction::components::amount::testing::arb_nonnegative_amount;

#[cfg(all(test, feature = "test-dependencies"))]
use super::{
render::{memo_param, str_param},
render::{amount_str, memo_param, str_param},
testing::{arb_addr_str, arb_valid_memo, arb_zip321_request, arb_zip321_uri},
MemoBytes, Payment, TransactionRequest,
};

fn check_roundtrip(req: TransactionRequest) {
Expand Down Expand Up @@ -1099,7 +1092,6 @@ mod tests {
assert!(i10r.is_err());
}

#[cfg(all(test, feature = "test-dependencies"))]
proptest! {
#[test]
fn prop_zip321_roundtrip_address(addr in arb_addr(UA_REQUEST)) {
Expand Down
12 changes: 8 additions & 4 deletions zcash_client_sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rustdoc-args = ["--cfg", "docsrs"]
zcash_address.workspace = true
zcash_client_backend = { workspace = true, features = ["unstable-serialization", "unstable-spanning-tree"] }
zcash_encoding.workspace = true
zcash_keys = { workspace = true, features = ["orchard"] }
zcash_keys = { workspace = true, features = ["orchard", "sapling"] }
zcash_primitives.workspace = true

# Dependencies exposed in a public API:
Expand Down Expand Up @@ -90,7 +90,7 @@ multicore = ["maybe-rayon/threads", "zcash_primitives/multicore"]

## Enables support for storing data related to the sending and receiving of
## Orchard funds.
orchard = ["dep:orchard", "zcash_client_backend/orchard"]
orchard = ["dep:orchard", "zcash_client_backend/orchard", "zcash_keys/orchard"]

## Exposes APIs that are useful for testing, such as `proptest` strategies.
test-dependencies = [
Expand All @@ -100,8 +100,12 @@ test-dependencies = [
"incrementalmerkletree/test-dependencies",
]

## Enables receiving transparent funds and shielding them.
transparent-inputs = ["dep:hdwallet", "zcash_client_backend/transparent-inputs"]
## Enables receiving transparent funds and sending to transparent recipients
transparent-inputs = [
"dep:hdwallet",
"zcash_keys/transparent-inputs",
"zcash_client_backend/transparent-inputs"
]

#! ### Experimental features

Expand Down
36 changes: 17 additions & 19 deletions zcash_keys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,41 @@ The entries below are relative to the `zcash_client_backend` crate as of
`zcash_client_backend 0.10.0`.

### Added
- The following modules have been extracted from `zcash_client_backend` and
moved to this crate:
- `address`
- `encoding`
- `keys`
- `zcash_keys::address::UnifiedAddress::{unknown, has_orchard, has_sapling,
has_transparent, receiver_types}`:
- `zcash_keys::keys`:
- `zcash_keys::address` (moved from `zcash_client_backend::address`). Further
additions to this module:
- `UnifiedAddress::{has_orchard, has_sapling, has_transparent}`
- `UnifiedAddress::receiver_types`
- `UnifiedAddress::unknown`
- `zcash_keys::encoding` (moved from `zcash_client_backend::encoding`).
- `zcash_keys::keys` (moved from `zcash_client_backend::keys`). Further
additions to this module:
- `AddressGenerationError`
- `UnifiedAddressRequest`
- A new `orchard` feature flag has been added to make it possible to
build client code without `orchard` dependendencies.

### Changed
- The following methods and enum variants have been placed behind an `orchard`
feature flag:
- `zcash_keys::address::UnifiedAddress::orchard`
- `zcash_keys::keys::DerivationError::Orchard`
- `zcash_keys::keys::UnifiedSpendingKey::orchard`
- `zcash_keys::address`:
- `RecipientAddress` has been renamed to `Address`
- `Address::Shielded` has been renamed to `Address::Sapling`
- `RecipientAddress` has been renamed to `Address`.
- `Address::Shielded` has been renamed to `Address::Sapling`.
- `UnifiedAddress::from_receivers` no longer takes an Orchard receiver
argument unless the `orchard` feature is enabled.
- `UnifiedAddress::orchard` is now only available when the `orchard` feature
is enabled.

- `zcash_keys::keys`:
- `DerivationError::Orchard` is now only available when the `orchard` feature
is enabled.
- `UnifiedSpendingKey::address` now takes an argument that specifies the
receivers to be generated in the resulting address. Also, it now returns
`Result<UnifiedAddress, AddressGenerationError>` instead of
`Option<UnifiedAddress>` so that we may better report to the user how
address generation has failed.
- `UnifiedSpendingKey::orchard` is now only available when the `orchard`
feature is enabled.
- `UnifiedSpendingKey::transparent` is now only available when the
`transparent-inputs` feature is enabled.
- `UnifiedFullViewingKey::new` no longer takes an Orchard full viewing key
argument unless the `orchard` feature is enabled.

### Removed
- `zcash_keys::address::AddressMetadata` has been moved to
`zcash_client_backend::data_api::TransparentAddressMetadata` and fields changed.
- `zcash_keys::address::AddressMetadata`
(use `zcash_client_backend::data_api::TransparentAddressMetadata` instead).
5 changes: 4 additions & 1 deletion zcash_keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ subtle.workspace = true
bls12_381.workspace = true
group.workspace = true
orchard = { workspace = true, optional = true }
sapling.workspace = true
sapling = { workspace = true, optional = true }

# - Test dependencies
proptest = { workspace = true, optional = true }
Expand All @@ -75,6 +75,9 @@ transparent-inputs = ["dep:hdwallet", "zcash_primitives/transparent-inputs"]
## Enables use of Orchard key parts and addresses
orchard = ["dep:orchard"]

## Enables use of Sapling key parts and addresses
sapling = ["dep:sapling"]

## Exposes APIs that are useful for testing, such as `proptest` strategies.
test-dependencies = [
"dep:proptest",
Expand Down
Loading

0 comments on commit e7003ee

Please sign in to comment.