Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Zebra compatibility: re-enable and fix zcash_client_backend, update prost dependency version #75

Merged
merged 16 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ runs:
transparent-inputs
sapling
unstable
unstable-spanning-tree
${{ inputs.extra-features }}
${{ steps.test.outputs.feature }}
'" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ members = [
"components/zcash_encoding",
"components/zcash_protocol",
"components/zip321",
# "zcash_client_backend",
# zcash_client_backend and zcash_client_sqlite are not compatible with OrchardZSA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also commented in CI workflows. Specifically - workflows/ci.yml:L196-198

Shall we ucomment there too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks @alexeykoren, I just fixed it and commited the change.

"zcash_client_backend",
# "zcash_client_sqlite",
Comment on lines +10 to 11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment above line 9
# zcash_client_backend and zcash_client_sqlite are not compatible with OrchardZSA

"zcash_extensions",
"zcash_history",
Expand Down
2 changes: 2 additions & 0 deletions zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ where
orchard_external_ovk.clone(),
*ua.orchard().expect("The mapping between payment pool and receiver is checked in step construction"),
payment.amount().into(),
orchard::note::AssetBase::native(),
memo.clone(),
)?;
orchard_output_meta.push((
Expand Down Expand Up @@ -1081,6 +1082,7 @@ where
orchard_internal_ovk(),
orchard_fvk.address_at(0u32, orchard::keys::Scope::Internal),
change_value.value().into(),
orchard::note::AssetBase::native(),
memo.clone(),
)?;
orchard_output_meta.push((
Expand Down
6 changes: 3 additions & 3 deletions zcash_client_backend/src/data_api/wallet/input_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ where
),
#[cfg(feature = "orchard")]
&(
::orchard::builder::BundleType::DEFAULT,
::orchard::builder::BundleType::DEFAULT_VANILLA,
&orchard_inputs[..],
&orchard_outputs[..],
),
Expand Down Expand Up @@ -594,7 +594,7 @@ where
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&Vec::<Infallible>::new()[..],
),
Expand All @@ -619,7 +619,7 @@ where
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&Vec::<Infallible>::new()[..],
),
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_backend/src/fees/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod tests {
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&[] as &[Infallible],
&[] as &[Infallible],
),
Expand Down Expand Up @@ -180,7 +180,7 @@ mod tests {
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&[] as &[Infallible],
&[] as &[Infallible],
),
Expand Down
10 changes: 5 additions & 5 deletions zcash_client_backend/src/fees/zip317.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ mod tests {
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&Vec::<Infallible>::new()[..],
),
Expand Down Expand Up @@ -309,7 +309,7 @@ mod tests {
&Vec::<Infallible>::new()[..],
),
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&[OrchardPayment::new(NonNegativeAmount::const_from_u64(
30000,
Expand Down Expand Up @@ -355,7 +355,7 @@ mod tests {
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&Vec::<Infallible>::new()[..],
),
Expand Down Expand Up @@ -403,7 +403,7 @@ mod tests {
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&Vec::<Infallible>::new()[..],
),
Expand Down Expand Up @@ -455,7 +455,7 @@ mod tests {
),
#[cfg(feature = "orchard")]
&(
orchard::builder::BundleType::DEFAULT,
orchard::builder::BundleType::DEFAULT_VANILLA,
&Vec::<Infallible>::new()[..],
&Vec::<Infallible>::new()[..],
),
Expand Down
25 changes: 17 additions & 8 deletions zcash_client_backend/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{
io,
};

use sapling::{self, note::ExtractedNoteCommitment, Node};
use zcash_note_encryption::{EphemeralKeyBytes, COMPACT_NOTE_SIZE};
use sapling::{self, note::ExtractedNoteCommitment, note_encryption::COMPACT_NOTE_SIZE, Node};
use zcash_note_encryption::EphemeralKeyBytes;
use zcash_primitives::{
block::{BlockHash, BlockHeader},
consensus::BlockHeight,
Expand Down Expand Up @@ -150,7 +150,7 @@ impl<Proof> From<&sapling::bundle::OutputDescription<Proof>>
compact_formats::CompactSaplingOutput {
cmu: out.cmu().to_bytes().to_vec(),
ephemeral_key: out.ephemeral_key().as_ref().to_vec(),
ciphertext: out.enc_ciphertext()[..COMPACT_NOTE_SIZE].to_vec(),
ciphertext: out.enc_ciphertext().as_ref()[..COMPACT_NOTE_SIZE].to_vec(),
}
}
}
Expand Down Expand Up @@ -186,15 +186,19 @@ impl compact_formats::CompactSaplingSpend {
}

#[cfg(feature = "orchard")]
impl TryFrom<&compact_formats::CompactOrchardAction> for orchard::note_encryption::CompactAction {
impl TryFrom<&compact_formats::CompactOrchardAction>
for orchard::note_encryption::CompactAction<orchard::orchard_flavor::OrchardVanilla>
{
type Error = ();

fn try_from(value: &compact_formats::CompactOrchardAction) -> Result<Self, Self::Error> {
Ok(orchard::note_encryption::CompactAction::from_parts(
value.nf()?,
value.cmx()?,
value.ephemeral_key()?,
value.ciphertext[..].try_into().map_err(|_| ())?,
zcash_note_encryption::note_bytes::NoteBytesData(
value.ciphertext[..].try_into().map_err(|_| ())?,
),
))
}
}
Expand Down Expand Up @@ -247,13 +251,18 @@ impl<A: sapling::bundle::Authorization> From<&sapling::bundle::SpendDescription<
}

#[cfg(feature = "orchard")]
impl<SpendAuth> From<&orchard::Action<SpendAuth>> for compact_formats::CompactOrchardAction {
fn from(action: &orchard::Action<SpendAuth>) -> compact_formats::CompactOrchardAction {
impl<SpendAuth> From<&orchard::Action<SpendAuth, orchard::orchard_flavor::OrchardVanilla>>
for compact_formats::CompactOrchardAction
{
fn from(
action: &orchard::Action<SpendAuth, orchard::orchard_flavor::OrchardVanilla>,
) -> compact_formats::CompactOrchardAction {
compact_formats::CompactOrchardAction {
nullifier: action.nullifier().to_bytes().to_vec(),
cmx: action.cmx().to_bytes().to_vec(),
ephemeral_key: action.encrypted_note().epk_bytes.to_vec(),
ciphertext: action.encrypted_note().enc_ciphertext[..COMPACT_NOTE_SIZE].to_vec(),
ciphertext: action.encrypted_note().enc_ciphertext.as_ref()[..COMPACT_NOTE_SIZE]
.to_vec(),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion zcash_client_backend/src/proto/compact_formats.rs

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

1 change: 0 additions & 1 deletion zcash_client_backend/src/proto/proposal.rs

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

1 change: 0 additions & 1 deletion zcash_client_backend/src/proto/service.rs

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

12 changes: 3 additions & 9 deletions zcash_client_backend/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use std::sync::{
};

use memuse::DynamicUsage;
use zcash_note_encryption::{
batch, BatchDomain, Domain, ShieldedOutput,
};
use zcash_note_encryption::{batch, BatchDomain, Domain, ShieldedOutput};
use zcash_primitives::{block::BlockHash, transaction::TxId};

/// A decrypted transaction output.
Expand Down Expand Up @@ -58,9 +56,7 @@ pub(crate) trait Decryptor<D: BatchDomain, Output> {
/// A decryptor of outputs as encoded in transactions.
pub(crate) struct FullDecryptor;

impl<D: BatchDomain, Output: ShieldedOutput<D>> Decryptor<D, Output>
for FullDecryptor
{
impl<D: BatchDomain, Output: ShieldedOutput<D>> Decryptor<D, Output> for FullDecryptor {
type Memo = D::Memo;

fn batch_decrypt<IvkTag: Clone>(
Expand All @@ -85,9 +81,7 @@ impl<D: BatchDomain, Output: ShieldedOutput<D>> Decryptor<D, Output>
/// A decryptor of outputs as encoded in compact blocks.
pub(crate) struct CompactDecryptor;

impl<D: BatchDomain, Output: ShieldedOutput<D>> Decryptor<D, Output>
for CompactDecryptor
{
impl<D: BatchDomain, Output: ShieldedOutput<D>> Decryptor<D, Output> for CompactDecryptor {
type Memo = ();

fn batch_decrypt<IvkTag: Clone>(
Expand Down
45 changes: 32 additions & 13 deletions zcash_client_backend/src/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::{
#[cfg(feature = "orchard")]
use orchard::{
note_encryption::{CompactAction, OrchardDomain},
orchard_flavor::OrchardVanilla,
tree::MerkleHashOrchard,
};

Expand Down Expand Up @@ -161,7 +162,7 @@ impl<AccountId> ScanningKeyOps<SaplingDomain, AccountId, sapling::Nullifier>
}

#[cfg(feature = "orchard")]
impl<AccountId> ScanningKeyOps<OrchardDomain, AccountId, orchard::note::Nullifier>
impl<AccountId> ScanningKeyOps<OrchardDomain<OrchardVanilla>, AccountId, orchard::note::Nullifier>
for ScanningKey<orchard::keys::IncomingViewingKey, orchard::keys::FullViewingKey, AccountId>
{
fn prepare(&self) -> orchard::keys::PreparedIncomingViewingKey {
Expand Down Expand Up @@ -191,7 +192,7 @@ pub struct ScanningKeys<AccountId, IvkTag> {
#[cfg(feature = "orchard")]
orchard: HashMap<
IvkTag,
Box<dyn ScanningKeyOps<OrchardDomain, AccountId, orchard::note::Nullifier>>,
Box<dyn ScanningKeyOps<OrchardDomain<OrchardVanilla>, AccountId, orchard::note::Nullifier>>,
>,
}

Expand All @@ -204,7 +205,13 @@ impl<AccountId, IvkTag> ScanningKeys<AccountId, IvkTag> {
>,
#[cfg(feature = "orchard")] orchard: HashMap<
IvkTag,
Box<dyn ScanningKeyOps<OrchardDomain, AccountId, orchard::note::Nullifier>>,
Box<
dyn ScanningKeyOps<
OrchardDomain<OrchardVanilla>,
AccountId,
orchard::note::Nullifier,
>,
>,
>,
) -> Self {
Self {
Expand Down Expand Up @@ -235,8 +242,10 @@ impl<AccountId, IvkTag> ScanningKeys<AccountId, IvkTag> {
#[cfg(feature = "orchard")]
pub fn orchard(
&self,
) -> &HashMap<IvkTag, Box<dyn ScanningKeyOps<OrchardDomain, AccountId, orchard::note::Nullifier>>>
{
) -> &HashMap<
IvkTag,
Box<dyn ScanningKeyOps<OrchardDomain<OrchardVanilla>, AccountId, orchard::note::Nullifier>>,
> {
&self.orchard
}
}
Expand All @@ -256,7 +265,13 @@ impl<AccountId: Copy + Eq + Hash + 'static> ScanningKeys<AccountId, (AccountId,
#[cfg(feature = "orchard")]
let mut orchard: HashMap<
(AccountId, Scope),
Box<dyn ScanningKeyOps<OrchardDomain, AccountId, orchard::note::Nullifier>>,
Box<
dyn ScanningKeyOps<
OrchardDomain<OrchardVanilla>,
AccountId,
orchard::note::Nullifier,
>,
>,
> = HashMap::new();

for (account_id, ufvk) in ufvks {
Expand Down Expand Up @@ -519,13 +534,17 @@ type TaggedSaplingBatchRunner<IvkTag, Tasks> = BatchRunner<
>;

#[cfg(feature = "orchard")]
type TaggedOrchardBatch<IvkTag> =
Batch<IvkTag, OrchardDomain, orchard::note_encryption::CompactAction, CompactDecryptor>;
type TaggedOrchardBatch<IvkTag> = Batch<
IvkTag,
OrchardDomain<OrchardVanilla>,
orchard::note_encryption::CompactAction<OrchardVanilla>,
CompactDecryptor,
>;
#[cfg(feature = "orchard")]
type TaggedOrchardBatchRunner<IvkTag, Tasks> = BatchRunner<
IvkTag,
OrchardDomain,
orchard::note_encryption::CompactAction,
OrchardDomain<OrchardVanilla>,
orchard::note_encryption::CompactAction<OrchardVanilla>,
CompactDecryptor,
Tasks,
>;
Expand Down Expand Up @@ -1038,7 +1057,7 @@ fn find_received<
Nf,
IvkTag: Copy + std::hash::Hash + Eq + Send + 'static,
SK: ScanningKeyOps<D, AccountId, Nf>,
Output: ShieldedOutput<D, COMPACT_NOTE_SIZE>,
Output: ShieldedOutput<D>,
NoteCommitment,
>(
block_height: BlockHeight,
Expand Down Expand Up @@ -1155,13 +1174,13 @@ pub mod testing {
use rand_core::{OsRng, RngCore};
use sapling::{
constants::SPENDING_KEY_GENERATOR,
note_encryption::{sapling_note_encryption, SaplingDomain},
note_encryption::{sapling_note_encryption, SaplingDomain, COMPACT_NOTE_SIZE},
util::generate_random_rseed,
value::NoteValue,
zip32::DiversifiableFullViewingKey,
Nullifier,
};
use zcash_note_encryption::{Domain, COMPACT_NOTE_SIZE};
use zcash_note_encryption::Domain;
use zcash_primitives::{
block::BlockHash,
consensus::{BlockHeight, Network},
Expand Down
Loading