From 1da25a07b3b3a4f4d1aa6a88ec9cee6ee5133e94 Mon Sep 17 00:00:00 2001 From: alexeykoren <2365507+alexeykoren@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:47:35 +0100 Subject: [PATCH] Fix clippy warnings --- zcash_primitives/src/transaction/builder.rs | 34 ++++++++++--------- .../src/transaction/components/orchard.rs | 12 +++---- zcash_primitives/src/transaction/mod.rs | 18 +++++----- zcash_primitives/src/transaction/txid.rs | 4 +-- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index 22ca15cdd..4af2205ac 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -877,7 +877,7 @@ impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder< .map_err(Error::OrchardBuild)? .unwrap(); - unproven_orchard_bundle = Some(OrchardBundle::OrchardZSA(bundle)); + unproven_orchard_bundle = Some(OrchardBundle::OrchardZSA(Box::new(bundle))); orchard_meta = meta; } } else { @@ -885,7 +885,7 @@ impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder< .build(&mut rng) .map_err(Error::OrchardBuild)? .unwrap(); - unproven_orchard_bundle = Some(OrchardBundle::OrchardVanilla(bundle)); + unproven_orchard_bundle = Some(OrchardBundle::OrchardVanilla(Box::new(bundle))); orchard_meta = meta; } }; @@ -949,24 +949,26 @@ impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder< .map_err(Error::SaplingBuild)?; let orchard_bundle: Option> = match unauthed_tx.orchard_bundle { - Some(OrchardBundle::OrchardVanilla(b)) => Some(OrchardBundle::OrchardVanilla( - b.create_proof( - &orchard::circuit::ProvingKey::build::(), - &mut rng, - ) - .and_then(|b| { - b.apply_signatures( + Some(OrchardBundle::OrchardVanilla(b)) => { + Some(OrchardBundle::OrchardVanilla(Box::new( + b.create_proof( + &orchard::circuit::ProvingKey::build::(), &mut rng, - *shielded_sig_commitment.as_ref(), - &self.orchard_saks, ) - }) - .unwrap(), - )), + .and_then(|b| { + b.apply_signatures( + &mut rng, + *shielded_sig_commitment.as_ref(), + &self.orchard_saks, + ) + }) + .unwrap(), + ))) + } #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] Some(OrchardBundle::OrchardZSA(b)) => Some(OrchardBundle::OrchardZSA( - b.create_proof( + Box::new(b.create_proof( &orchard::circuit::ProvingKey::build::(), &mut rng, ) @@ -978,7 +980,7 @@ impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder< ) }) .unwrap(), - )), + ))), None => None, Some(_) => unreachable!(), diff --git a/zcash_primitives/src/transaction/components/orchard.rs b/zcash_primitives/src/transaction/components/orchard.rs index 81bd2fc56..aa7e5ac20 100644 --- a/zcash_primitives/src/transaction/components/orchard.rs +++ b/zcash_primitives/src/transaction/components/orchard.rs @@ -69,14 +69,14 @@ impl BuildBundle for OrchardVanilla { anchor: Anchor, authorization: A, ) -> OrchardBundle { - OrchardBundle::OrchardVanilla(Bundle::from_parts( + OrchardBundle::OrchardVanilla(Box::new(Bundle::from_parts( actions, flags, value_balance, burn, anchor, authorization, - )) + ))) } } @@ -90,14 +90,14 @@ impl BuildBundle for OrchardZSA { anchor: Anchor, authorization: A, ) -> OrchardBundle { - OrchardBundle::OrchardZSA(orchard::Bundle::from_parts( + OrchardBundle::OrchardZSA(Box::new(orchard::Bundle::from_parts( actions, flags, value_balance, burn, anchor, authorization, - )) + ))) } } @@ -424,7 +424,7 @@ pub mod testing { ) -> OrchardBundle { // overwrite the value balance, as we can't guarantee that the // value doesn't exceed the MAX_MONEY bounds. - OrchardBundle::OrchardVanilla(bundle.try_map_value_balance::<_, (), _>(|_| Ok(orchard_value_balance)).unwrap()) + OrchardBundle::OrchardVanilla(Box::new(bundle.try_map_value_balance::<_, (), _>(|_| Ok(orchard_value_balance)).unwrap())) } } @@ -438,7 +438,7 @@ pub mod testing { // value doesn't exceed the MAX_MONEY bounds. let _bundle: Bundle<_, _, OrchardZSA> = bundle.try_map_value_balance::<_, (), _>(|_| Ok(orchard_value_balance)).unwrap(); #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] - return OrchardBundle::OrchardZSA(_bundle); + return OrchardBundle::OrchardZSA(Box::new(_bundle)); panic!("ZSA is not supported in this version"); } } diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index 32362481b..d15ad8c63 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -375,9 +375,9 @@ impl PartialEq for Transaction { #[derive(Debug, Clone)] pub enum OrchardBundle { - OrchardVanilla(Bundle), + OrchardVanilla(Box>), #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] - OrchardZSA(Bundle), + OrchardZSA(Box>), #[doc(hidden)] _Phantom(PhantomData), } @@ -418,15 +418,15 @@ impl Orcha #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] step_zsa: impl FnOnce(&mut R2, Z) -> NZ, ) -> OrchardBundle { match self { - OrchardBundle::OrchardVanilla(b) => { - OrchardBundle::OrchardVanilla(b.map_authorization(context, spend_auth, step)) - } + OrchardBundle::OrchardVanilla(b) => OrchardBundle::OrchardVanilla(Box::new( + b.map_authorization(context, spend_auth, step), + )), #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] - OrchardBundle::OrchardZSA(b) => OrchardBundle::OrchardZSA(b.map_authorization( + OrchardBundle::OrchardZSA(b) => OrchardBundle::OrchardZSA(Box::new(b.map_authorization( context_zsa, spend_auth_zsa, step_zsa, - )), + ))), _ => unreachable!(), } } @@ -906,7 +906,7 @@ impl Transaction { transparent_bundle, sprout_bundle: None, sapling_bundle, - orchard_bundle: orchard_bundle.map(OrchardBundle::OrchardVanilla), + orchard_bundle: orchard_bundle.map(|b| OrchardBundle::OrchardVanilla(Box::new(b))), #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] issue_bundle: None, #[cfg(zcash_unstable = "zfuture")] @@ -962,7 +962,7 @@ impl Transaction { transparent_bundle, sprout_bundle: None, sapling_bundle, - orchard_bundle: orchard_bundle.map(OrchardBundle::OrchardZSA), + orchard_bundle: orchard_bundle.map(|b| OrchardBundle::OrchardZSA(Box::new(b))), issue_bundle, #[cfg(zcash_unstable = "zfuture")] tze_bundle, diff --git a/zcash_primitives/src/transaction/txid.rs b/zcash_primitives/src/transaction/txid.rs index 0a288be5b..e730ad878 100644 --- a/zcash_primitives/src/transaction/txid.rs +++ b/zcash_primitives/src/transaction/txid.rs @@ -25,9 +25,7 @@ use super::{ }; #[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )] -use orchard::{ - issuance::{IssueBundle, Signed}, -}; +use orchard::issuance::{IssueBundle, Signed}; #[cfg(zcash_unstable = "zfuture")] use super::{