Skip to content

Commit

Permalink
Merge of #5378
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 14, 2022
2 parents ff83601 + c6a7f69 commit bc813a7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion zebra-chain/src/history_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl NonEmptyHistoryTree {
// /\ /\ /\ /\ /\ /\ /\ 0
//
// We start by determining the altitude of the highest peak (A).
let mut alt = (32 - ((self.size + 1) as u32).leading_zeros() - 1) - 1;
let mut alt = (32 - (self.size + 1).leading_zeros() - 1) - 1;

// We determine the position of the highest peak (A) by pretending it is the right
// sibling in a tree, and its left-most leaf has position 0. Then the left sibling
Expand Down
5 changes: 4 additions & 1 deletion zebra-chain/src/orchard/shielded_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ impl ZcashDeserialize for Flags {
// Consensus rule: "In a version 5 transaction,
// the reserved bits 2..7 of the flagsOrchard field MUST be zero."
// https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus
//
// Clippy 1.64 is wrong here, this lazy evaluation is necessary, constructors are functions. This is fixed in 1.66.
#[allow(clippy::unnecessary_lazy_evaluations)]
Flags::from_bits(reader.read_u8()?)
.ok_or(SerializationError::Parse("invalid reserved orchard flags"))
.ok_or_else(|| SerializationError::Parse("invalid reserved orchard flags"))
}
}
2 changes: 1 addition & 1 deletion zebra-chain/src/transaction/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ impl Arbitrary for LockTime {
(block::Height::MIN.0..=LockTime::MAX_HEIGHT.0)
.prop_map(|n| LockTime::Height(block::Height(n))),
(LockTime::MIN_TIMESTAMP..=LockTime::MAX_TIMESTAMP)
.prop_map(|n| { LockTime::Time(Utc.timestamp(n as i64, 0)) })
.prop_map(|n| { LockTime::Time(Utc.timestamp(n, 0)) })
]
.boxed()
}
Expand Down
11 changes: 8 additions & 3 deletions zebra-chain/src/transaction/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,16 @@ impl ZcashDeserialize for Transaction {
}
// Denoted as `nConsensusBranchId` in the spec.
// Convert it to a NetworkUpgrade
//
// Clippy 1.64 is wrong here, this lazy evaluation is necessary, constructors are functions. This is fixed in 1.66.
#[allow(clippy::unnecessary_lazy_evaluations)]
let network_upgrade =
NetworkUpgrade::from_branch_id(limited_reader.read_u32::<LittleEndian>()?)
.ok_or(SerializationError::Parse(
"expected a valid network upgrade from the consensus branch id",
))?;
.ok_or_else(|| {
SerializationError::Parse(
"expected a valid network upgrade from the consensus branch id",
)
})?;

// Denoted as `lock_time` in the spec.
let lock_time = LockTime::zcash_deserialize(&mut limited_reader)?;
Expand Down
4 changes: 2 additions & 2 deletions zebra-chain/src/transaction/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ fn test_vec243_2() -> Result<()> {

let lock_script = Script::new(&[]);
let prevout = transparent::Output { value, lock_script };
let index = input_ind as usize;
let index = input_ind;
let all_previous_outputs = mock_pre_v5_output_list(prevout, input_ind);

let alt_sighash = crate::primitives::zcash_primitives::sighash(
Expand Down Expand Up @@ -805,7 +805,7 @@ fn test_vec243_3() -> Result<()> {
"76a914507173527b4c3318a2aecd793bf1cfed705950cf88ac",
)?);
let prevout = transparent::Output { value, lock_script };
let index = input_ind as usize;
let index = input_ind;

let alt_sighash = crate::primitives::zcash_primitives::sighash(
&transaction,
Expand Down
6 changes: 3 additions & 3 deletions zebra-network/src/protocol/external/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,16 @@ impl Decoder for Codec {

impl Codec {
fn read_version<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
// Clippy 1.64 is wrong here, this lazy evaluation is necessary, constructors are functions. This is fixed in 1.66.
#[allow(clippy::unnecessary_lazy_evaluations)]
Ok(VersionMessage {
version: Version(reader.read_u32::<LittleEndian>()?),
// Use from_bits_truncate to discard unknown service bits.
services: PeerServices::from_bits_truncate(reader.read_u64::<LittleEndian>()?),
timestamp: Utc
.timestamp_opt(reader.read_i64::<LittleEndian>()?, 0)
.single()
.ok_or(Error::Parse(
"version timestamp is out of range for DateTime",
))?,
.ok_or_else(|| Error::Parse("version timestamp is out of range for DateTime"))?,
address_recv: AddrInVersion::zcash_deserialize(&mut reader)?,
address_from: AddrInVersion::zcash_deserialize(&mut reader)?,
nonce: Nonce(reader.read_u64::<LittleEndian>()?),
Expand Down

0 comments on commit bc813a7

Please sign in to comment.