fix(clippy): resolve various clippy warnings (#4473)
* clippy: unused import on non-linux platforms * Fix some instances of clippy::derive_partial_eq_without_eq * Move a deref to fix clippy::significant_drop_in_scrutinee Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
2ee52f808c
commit
be91ab29ee
|
@ -3,7 +3,7 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[allow(dead_code, missing_docs)]
|
#[allow(dead_code, missing_docs)]
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
pub enum BlockError {
|
pub enum BlockError {
|
||||||
#[error("transaction has wrong consensus branch id for block network upgrade")]
|
#[error("transaction has wrong consensus branch id for block network upgrade")]
|
||||||
WrongTransactionConsensusBranchId,
|
WrongTransactionConsensusBranchId,
|
||||||
|
|
|
@ -38,7 +38,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The randomness used in the Simsemilla hash for note commitment.
|
/// The randomness used in the Simsemilla hash for note commitment.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CommitmentRandomness(pallas::Scalar);
|
pub struct CommitmentRandomness(pallas::Scalar);
|
||||||
|
|
||||||
impl From<SeedRandomness> for CommitmentRandomness {
|
impl From<SeedRandomness> for CommitmentRandomness {
|
||||||
|
@ -54,7 +54,7 @@ impl From<SeedRandomness> for CommitmentRandomness {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Note commitments for the output notes.
|
/// Note commitments for the output notes.
|
||||||
#[derive(Clone, Copy, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct NoteCommitment(#[serde(with = "serde_helpers::Affine")] pub pallas::Affine);
|
pub struct NoteCommitment(#[serde(with = "serde_helpers::Affine")] pub pallas::Affine);
|
||||||
|
|
||||||
impl fmt::Debug for NoteCommitment {
|
impl fmt::Debug for NoteCommitment {
|
||||||
|
@ -76,8 +76,6 @@ impl fmt::Debug for NoteCommitment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for NoteCommitment {}
|
|
||||||
|
|
||||||
impl From<pallas::Point> for NoteCommitment {
|
impl From<pallas::Point> for NoteCommitment {
|
||||||
fn from(projective_point: pallas::Point) -> Self {
|
fn from(projective_point: pallas::Point) -> Self {
|
||||||
Self(pallas::Affine::from(projective_point))
|
Self(pallas::Affine::from(projective_point))
|
||||||
|
@ -159,7 +157,7 @@ impl NoteCommitment {
|
||||||
/// Action descriptions.
|
/// Action descriptions.
|
||||||
///
|
///
|
||||||
/// https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit
|
/// https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit
|
||||||
#[derive(Clone, Copy, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct ValueCommitment(#[serde(with = "serde_helpers::Affine")] pub pallas::Affine);
|
pub struct ValueCommitment(#[serde(with = "serde_helpers::Affine")] pub pallas::Affine);
|
||||||
|
|
||||||
impl<'a> std::ops::Add<&'a ValueCommitment> for ValueCommitment {
|
impl<'a> std::ops::Add<&'a ValueCommitment> for ValueCommitment {
|
||||||
|
@ -209,8 +207,6 @@ impl From<pallas::Point> for ValueCommitment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for ValueCommitment {}
|
|
||||||
|
|
||||||
/// LEBS2OSP256(repr_P(cv))
|
/// LEBS2OSP256(repr_P(cv))
|
||||||
///
|
///
|
||||||
/// https://zips.z.cash/protocol/nu5.pdf#pallasandvesta
|
/// https://zips.z.cash/protocol/nu5.pdf#pallasandvesta
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Orchard key types.
|
//! Orchard key types.
|
||||||
//!
|
//!
|
||||||
//! <https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents>
|
//! <https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents>
|
||||||
#![allow(clippy::unit_arg)]
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -983,7 +983,7 @@ impl PartialEq<[u8; 32]> for TransmissionKey {
|
||||||
///
|
///
|
||||||
/// <https://zips.z.cash/protocol/nu5.pdf#saplingandorchardencrypt>
|
/// <https://zips.z.cash/protocol/nu5.pdf#saplingandorchardencrypt>
|
||||||
// TODO: derive `OutgoingCipherKey`: https://github.com/ZcashFoundation/zebra/issues/2041
|
// TODO: derive `OutgoingCipherKey`: https://github.com/ZcashFoundation/zebra/issues/2041
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct OutgoingCipherKey([u8; 32]);
|
pub struct OutgoingCipherKey([u8; 32]);
|
||||||
|
|
||||||
impl fmt::Debug for OutgoingCipherKey {
|
impl fmt::Debug for OutgoingCipherKey {
|
||||||
|
@ -1040,7 +1040,7 @@ impl PartialEq<[u8; 32]> for EphemeralPrivateKey {
|
||||||
///
|
///
|
||||||
/// <https://zips.z.cash/protocol/nu5.pdf#concreteorchardkeyagreement>
|
/// <https://zips.z.cash/protocol/nu5.pdf#concreteorchardkeyagreement>
|
||||||
/// <https://zips.z.cash/protocol/nu5.pdf#saplingandorchardencrypt>
|
/// <https://zips.z.cash/protocol/nu5.pdf#saplingandorchardencrypt>
|
||||||
#[derive(Copy, Clone, Deserialize, PartialEq, Serialize)]
|
#[derive(Copy, Clone, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct EphemeralPublicKey(#[serde(with = "serde_helpers::Affine")] pub(crate) pallas::Affine);
|
pub struct EphemeralPublicKey(#[serde(with = "serde_helpers::Affine")] pub(crate) pallas::Affine);
|
||||||
|
|
||||||
impl fmt::Debug for EphemeralPublicKey {
|
impl fmt::Debug for EphemeralPublicKey {
|
||||||
|
@ -1062,8 +1062,6 @@ impl fmt::Debug for EphemeralPublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for EphemeralPublicKey {}
|
|
||||||
|
|
||||||
impl From<EphemeralPublicKey> for [u8; 32] {
|
impl From<EphemeralPublicKey> for [u8; 32] {
|
||||||
fn from(epk: EphemeralPublicKey) -> [u8; 32] {
|
fn from(epk: EphemeralPublicKey) -> [u8; 32] {
|
||||||
epk.0.to_bytes()
|
epk.0.to_bytes()
|
||||||
|
|
|
@ -334,9 +334,9 @@ impl NoteCommitmentTree {
|
||||||
.cached_root
|
.cached_root
|
||||||
.write()
|
.write()
|
||||||
.expect("a thread that previously held exclusive lock access panicked");
|
.expect("a thread that previously held exclusive lock access panicked");
|
||||||
match write_root.deref() {
|
match *write_root {
|
||||||
// Another thread got write access first, return cached root.
|
// Another thread got write access first, return cached root.
|
||||||
Some(root) => *root,
|
Some(root) => root,
|
||||||
None => {
|
None => {
|
||||||
// Compute root and cache it.
|
// Compute root and cache it.
|
||||||
let root = Root(self.inner.root().0);
|
let root = Root(self.inner.root().0);
|
||||||
|
|
|
@ -44,11 +44,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The randomness used in the Pedersen Hash for note commitment.
|
/// The randomness used in the Pedersen Hash for note commitment.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CommitmentRandomness(jubjub::Fr);
|
pub struct CommitmentRandomness(jubjub::Fr);
|
||||||
|
|
||||||
/// Note commitments for the output notes.
|
/// Note commitments for the output notes.
|
||||||
#[derive(Clone, Copy, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct NoteCommitment(#[serde(with = "serde_helpers::AffinePoint")] pub jubjub::AffinePoint);
|
pub struct NoteCommitment(#[serde(with = "serde_helpers::AffinePoint")] pub jubjub::AffinePoint);
|
||||||
|
|
||||||
impl fmt::Debug for NoteCommitment {
|
impl fmt::Debug for NoteCommitment {
|
||||||
|
@ -60,8 +60,6 @@ impl fmt::Debug for NoteCommitment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for NoteCommitment {}
|
|
||||||
|
|
||||||
impl From<jubjub::ExtendedPoint> for NoteCommitment {
|
impl From<jubjub::ExtendedPoint> for NoteCommitment {
|
||||||
fn from(extended_point: jubjub::ExtendedPoint) -> Self {
|
fn from(extended_point: jubjub::ExtendedPoint) -> Self {
|
||||||
Self(jubjub::AffinePoint::from(extended_point))
|
Self(jubjub::AffinePoint::from(extended_point))
|
||||||
|
@ -157,7 +155,7 @@ impl NoteCommitment {
|
||||||
/// [`NotSmallOrderValueCommitment`].
|
/// [`NotSmallOrderValueCommitment`].
|
||||||
///
|
///
|
||||||
/// https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit
|
/// https://zips.z.cash/protocol/protocol.pdf#concretehomomorphiccommit
|
||||||
#[derive(Clone, Copy, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct ValueCommitment(#[serde(with = "serde_helpers::AffinePoint")] jubjub::AffinePoint);
|
pub struct ValueCommitment(#[serde(with = "serde_helpers::AffinePoint")] jubjub::AffinePoint);
|
||||||
|
|
||||||
impl<'a> std::ops::Add<&'a ValueCommitment> for ValueCommitment {
|
impl<'a> std::ops::Add<&'a ValueCommitment> for ValueCommitment {
|
||||||
|
@ -199,8 +197,6 @@ impl From<jubjub::ExtendedPoint> for ValueCommitment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for ValueCommitment {}
|
|
||||||
|
|
||||||
/// LEBS2OSP256(repr_J(cv))
|
/// LEBS2OSP256(repr_J(cv))
|
||||||
///
|
///
|
||||||
/// https://zips.z.cash/protocol/protocol.pdf#spendencoding
|
/// https://zips.z.cash/protocol/protocol.pdf#spendencoding
|
||||||
|
|
|
@ -340,9 +340,9 @@ impl NoteCommitmentTree {
|
||||||
.cached_root
|
.cached_root
|
||||||
.write()
|
.write()
|
||||||
.expect("a thread that previously held exclusive lock access panicked");
|
.expect("a thread that previously held exclusive lock access panicked");
|
||||||
match write_root.deref() {
|
match *write_root {
|
||||||
// Another thread got write access first, return cached root.
|
// Another thread got write access first, return cached root.
|
||||||
Some(root) => *root,
|
Some(root) => root,
|
||||||
None => {
|
None => {
|
||||||
// Compute root and cache it.
|
// Compute root and cache it.
|
||||||
let root = Root::try_from(self.inner.root().0).unwrap();
|
let root = Root::try_from(self.inner.root().0).unwrap();
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
//! Sprout commitment types.
|
//! Sprout commitment types.
|
||||||
|
|
||||||
#![allow(clippy::unit_arg)]
|
|
||||||
|
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
use super::note::Note;
|
use super::note::Note;
|
||||||
|
|
||||||
/// The randomness used in the Pedersen Hash for note commitment.
|
/// The randomness used in the Pedersen Hash for note commitment.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
|
@ -21,15 +19,13 @@ impl AsRef<[u8]> for CommitmentRandomness {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Note commitments for the output notes.
|
/// Note commitments for the output notes.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
any(test, feature = "proptest-impl"),
|
any(test, feature = "proptest-impl"),
|
||||||
derive(proptest_derive::Arbitrary)
|
derive(proptest_derive::Arbitrary)
|
||||||
)]
|
)]
|
||||||
pub struct NoteCommitment(pub(crate) [u8; 32]);
|
pub struct NoteCommitment(pub(crate) [u8; 32]);
|
||||||
|
|
||||||
impl Eq for NoteCommitment {}
|
|
||||||
|
|
||||||
impl From<[u8; 32]> for NoteCommitment {
|
impl From<[u8; 32]> for NoteCommitment {
|
||||||
fn from(bytes: [u8; 32]) -> Self {
|
fn from(bytes: [u8; 32]) -> Self {
|
||||||
Self(bytes)
|
Self(bytes)
|
||||||
|
|
|
@ -273,9 +273,9 @@ impl NoteCommitmentTree {
|
||||||
.cached_root
|
.cached_root
|
||||||
.write()
|
.write()
|
||||||
.expect("a thread that previously held exclusive lock access panicked");
|
.expect("a thread that previously held exclusive lock access panicked");
|
||||||
match write_root.deref() {
|
match *write_root {
|
||||||
// Another thread got write access first, return cached root.
|
// Another thread got write access first, return cached root.
|
||||||
Some(root) => *root,
|
Some(root) => root,
|
||||||
None => {
|
None => {
|
||||||
// Compute root and cache it.
|
// Compute root and cache it.
|
||||||
let root = Root(self.inner.root().0);
|
let root = Root(self.inner.root().0);
|
||||||
|
|
|
@ -102,7 +102,7 @@ where
|
||||||
///
|
///
|
||||||
/// Typically, we can rely on outbound addresses, but inbound addresses don't
|
/// Typically, we can rely on outbound addresses, but inbound addresses don't
|
||||||
/// give us enough information to reconnect to that peer.
|
/// give us enough information to reconnect to that peer.
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum ConnectedAddr {
|
pub enum ConnectedAddr {
|
||||||
/// The address we used to make a direct outbound connection.
|
/// The address we used to make a direct outbound connection.
|
||||||
///
|
///
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
use std::{collections::HashSet, convert::TryInto, env, path::PathBuf};
|
use std::{collections::HashSet, convert::TryInto, env, path::PathBuf};
|
||||||
|
|
||||||
use color_eyre::{
|
use color_eyre::{
|
||||||
eyre::{eyre, Result, WrapErr},
|
eyre::{Result, WrapErr},
|
||||||
Help,
|
Help,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1439,6 +1439,8 @@ where
|
||||||
// See #1781.
|
// See #1781.
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
if node2.is_running() {
|
if node2.is_running() {
|
||||||
|
use color_eyre::eyre::eyre;
|
||||||
|
|
||||||
return node2
|
return node2
|
||||||
.kill_on_error::<(), _>(Err(eyre!(
|
.kill_on_error::<(), _>(Err(eyre!(
|
||||||
"conflicted node2 was still running, but the test expected a panic"
|
"conflicted node2 was still running, but the test expected a panic"
|
||||||
|
|
Loading…
Reference in New Issue