diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b18f582e..9de06130f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.51.0 + toolchain: 1.56.1 override: true - name: Fetch path to Zcash parameters @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.51.0 + toolchain: 1.56.1 override: true - name: Add target run: rustup target add ${{ matrix.target }} @@ -78,7 +78,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.51.0 + toolchain: 1.56.1 override: true # Build benchmarks to prevent bitrot - name: Build benchmarks @@ -88,20 +88,20 @@ jobs: args: --all --benches clippy: - name: Clippy (1.51.0) + name: Clippy (1.56.1) timeout-minutes: 30 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.51.0 + toolchain: 1.56.1 components: clippy override: true - name: Run clippy uses: actions-rs/clippy-check@v1 with: - name: Clippy (1.51.0) + name: Clippy (1.56.1) token: ${{ secrets.GITHUB_TOKEN }} args: --all-features --all-targets -- -D warnings @@ -173,7 +173,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.51.0 + toolchain: 1.56.1 override: true - name: cargo fetch uses: actions-rs/cargo@v1 @@ -196,7 +196,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.51.0 + toolchain: 1.56.1 override: true # cargo fmt does not build the code, and running it in a fresh clone of diff --git a/Cargo.toml b/Cargo.toml index b57d3c750..4c95ffb05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,8 @@ panic = 'abort' codegen-units = 1 [patch.crates-io] +hdwallet = { git = "https://github.com/nuttycom/hdwallet", rev = "576683b9f2865f1118c309017ff36e01f84420c9" } +incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "dd57b430dee7c0b163f4035fef2280cd1935036c" } +orchard = { git = "https://github.com/zcash/orchard.git", rev = "8449fd133c002a349869c09c529a4d214b20c0c0" } zcash_encoding = { path = "components/zcash_encoding" } zcash_note_encryption = { path = "components/zcash_note_encryption" } -hdwallet = { git = "https://github.com/nuttycom/hdwallet", rev = "576683b9f2865f1118c309017ff36e01f84420c9" } diff --git a/components/equihash/CHANGELOG.md b/components/equihash/CHANGELOG.md index a0585d64d..3d5392d8a 100644 --- a/components/equihash/CHANGELOG.md +++ b/components/equihash/CHANGELOG.md @@ -7,5 +7,8 @@ and this library adheres to Rust's notion of ## [Unreleased] +### Changed +- MSRV is now 1.56.1. + ## [0.1.0] - 2020-07-10 Initial release. diff --git a/components/zcash_note_encryption/CHANGELOG.md b/components/zcash_note_encryption/CHANGELOG.md index 5dd6dae9c..17634ee17 100644 --- a/components/zcash_note_encryption/CHANGELOG.md +++ b/components/zcash_note_encryption/CHANGELOG.md @@ -7,5 +7,8 @@ and this library adheres to Rust's notion of ## [Unreleased] +### Changed +- MSRV is now 1.56.1. + ## [0.1.0] - 2021-12-17 Initial release. diff --git a/rust-toolchain b/rust-toolchain index ba0a71911..43c989b55 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.51.0 +1.56.1 diff --git a/zcash_client_backend/CHANGELOG.md b/zcash_client_backend/CHANGELOG.md index ec81dbe47..f07a18c28 100644 --- a/zcash_client_backend/CHANGELOG.md +++ b/zcash_client_backend/CHANGELOG.md @@ -38,7 +38,7 @@ and this library adheres to Rust's notion of - `zcash_client_backend::encoding::encode_transparent_address` ### Changed -- MSRV is now 1.51.0. +- MSRV is now 1.56.1. - Bumped dependencies to `ff 0.11`, `group 0.11`, `bls12_381 0.6`, `jubjub 0.8`. - `epk: jubjub::ExtendedPoint` has been replaced by `ephemeral_key: zcash_note_encryption::EphemeralKeyBytes` in various places: diff --git a/zcash_client_sqlite/CHANGELOG.md b/zcash_client_sqlite/CHANGELOG.md index 1050aebda..3fe72ef1a 100644 --- a/zcash_client_sqlite/CHANGELOG.md +++ b/zcash_client_sqlite/CHANGELOG.md @@ -18,7 +18,7 @@ and this library adheres to Rust's notion of rewinds exceed supported bounds. ### Changed -- MSRV is now 1.51.0. +- MSRV is now 1.56.1. - Bumped dependencies to `ff 0.11`, `group 0.11`, `jubjub 0.8`. - Renamed the following to use lower-case abbreviations (matching Rust naming conventions): diff --git a/zcash_history/CHANGELOG.md b/zcash_history/CHANGELOG.md index 3cdcb1221..fe2aa696a 100644 --- a/zcash_history/CHANGELOG.md +++ b/zcash_history/CHANGELOG.md @@ -14,6 +14,7 @@ and this library adheres to Rust's notion of - `zcash_history::Entry::new_leaf` ### Changed +- MSRV is now 1.56.1. - `zcash_history::{Entry, IndexedNode, Tree}` now have a `Version` parameter. ### Removed diff --git a/zcash_primitives/CHANGELOG.md b/zcash_primitives/CHANGELOG.md index d421bf51f..343e46f31 100644 --- a/zcash_primitives/CHANGELOG.md +++ b/zcash_primitives/CHANGELOG.md @@ -101,7 +101,7 @@ and this library adheres to Rust's notion of - `impl Sum<&Amount> for Option` ### Changed -- MSRV is now 1.51.0. +- MSRV is now 1.56.1. - Bumped dependencies to `ff 0.11`, `group 0.11`, `bls12_381 0.6`, `jubjub 0.8`. - The following modules and helpers have been moved into `zcash_primitives::sapling`: diff --git a/zcash_primitives/src/merkle_tree/incremental.rs b/zcash_primitives/src/merkle_tree/incremental.rs index 3e3e3dc52..94e80bebb 100644 --- a/zcash_primitives/src/merkle_tree/incremental.rs +++ b/zcash_primitives/src/merkle_tree/incremental.rs @@ -1,14 +1,11 @@ //! Implementations of serialization and parsing for Orchard note commitment trees. use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; -use std::convert::TryFrom; -use std::hash::Hash; +use std::convert::{TryFrom, TryInto}; use std::io::{self, Read, Write}; use incrementalmerkletree::{ - bridgetree::{ - AuthFragment, BridgeTree, Checkpoint, Frontier, Leaf, MerkleBridge, NonEmptyFrontier, - }, + bridgetree::{AuthFragment, Frontier, Leaf, MerkleBridge, NonEmptyFrontier}, Hashable, Position, }; use orchard::tree::MerkleHashOrchard; @@ -18,14 +15,6 @@ use super::{CommitmentTree, HashSer}; pub const SER_V1: u8 = 1; -pub fn read_frontier_v0( - mut reader: R, -) -> io::Result> { - let tree = CommitmentTree::read(&mut reader)?; - - Ok(tree.to_frontier()) -} - impl HashSer for MerkleHashOrchard { fn read(mut reader: R) -> io::Result where @@ -46,6 +35,14 @@ impl HashSer for MerkleHashOrchard { } } +pub fn read_frontier_v0( + mut reader: R, +) -> io::Result> { + let tree = CommitmentTree::read(&mut reader)?; + + Ok(tree.to_frontier()) +} + pub fn write_nonempty_frontier_v1( mut writer: W, frontier: &NonEmptyFrontier, @@ -108,19 +105,32 @@ pub fn read_frontier_v1(reader: R) -> io::Result(mut writer: W, position: Position) -> io::Result<()> { + writer.write_u64::(position.try_into().unwrap()) +} + +pub fn read_position(mut reader: R) -> io::Result { + let p = reader.read_u64::()?; + ::try_from(p).map(Position::from).map_err(|err| { + io::Error::new( + io::ErrorKind::Unsupported, + format!( + "usize could not be decoded to a 64-bit value on this platform: {:?}", + err + ), + ) + }) +} + pub fn write_auth_fragment_v1( mut writer: W, fragment: &AuthFragment, ) -> io::Result<()> { - writer.write_u64::(::from(fragment.position()))?; - writer.write_u64::(fragment.altitudes_observed() as u64)?; + write_position(&mut writer, fragment.position())?; + writer.write_u64::(fragment.altitudes_observed().try_into().unwrap())?; Vector::write(&mut writer, fragment.values(), |w, a| a.write(w)) } -pub fn read_position(mut reader: R) -> io::Result { - Ok(Position::from(reader.read_u64::()? as usize)) -} - #[allow(clippy::redundant_closure)] pub fn read_auth_fragment_v1(mut reader: R) -> io::Result> { let position = read_position(&mut reader)?; @@ -130,7 +140,7 @@ pub fn read_auth_fragment_v1(mut reader: R) -> io::Result( +pub fn write_bridge_v1( mut writer: W, bridge: &MerkleBridge, ) -> io::Result<()> { @@ -143,7 +153,7 @@ pub fn write_bridge_v1( &mut writer, &bridge.auth_fragments().iter().collect::>(), |w, (i, a)| { - w.write_u64::(**i as u64)?; + w.write_u64::(u64::from(**i))?; write_auth_fragment_v1(w, a) }, )?; @@ -152,13 +162,12 @@ pub fn write_bridge_v1( Ok(()) } -pub fn read_bridge_v1(mut reader: R) -> io::Result> { +pub fn read_bridge_v1( + mut reader: R, +) -> io::Result> { let prior_position = Optional::read(&mut reader, read_position)?; - let auth_fragments = Vector::read(&mut reader, |r| { - Ok(( - r.read_u64::()? as usize, - read_auth_fragment_v1(r)?, - )) + let auth_fragments = Vector::read(&mut reader, |mut r| { + Ok((read_position(&mut r)?, read_auth_fragment_v1(r)?)) })? .into_iter() .collect(); @@ -171,99 +180,22 @@ pub fn read_bridge_v1(mut reader: R) -> io::Result< )) } -pub const EMPTY_CHECKPOINT: u8 = 0; -pub const BRIDGE_CHECKPOINT: u8 = 1; - -pub fn write_checkpoint_v1(mut writer: W, checkpoint: &Checkpoint) -> io::Result<()> { - match checkpoint { - Checkpoint::Empty => { - writer.write_u8(EMPTY_CHECKPOINT)?; - } - Checkpoint::AtIndex(i) => { - writer.write_u8(BRIDGE_CHECKPOINT)?; - writer.write_u64::(*i as u64)?; - } - } - - Ok(()) -} - -pub fn read_checkpoint_v1(mut reader: R) -> io::Result { - match reader.read_u8()? { - EMPTY_CHECKPOINT => Ok(Checkpoint::Empty), - BRIDGE_CHECKPOINT => Ok(Checkpoint::AtIndex( - reader.read_u64::()? as usize - )), - flag => Err(io::Error::new( - io::ErrorKind::InvalidInput, - format!("Unrecognized checkpoint variant identifier: {:?}", flag), - )), - } -} - -pub fn write_tree_v1( - mut writer: W, - tree: &BridgeTree, -) -> io::Result<()> { - Vector::write(&mut writer, tree.bridges(), |w, b| write_bridge_v1(w, b))?; - Vector::write( - &mut writer, - &tree.witnessable_leaves().iter().collect::>(), - |mut w, (a, i)| { - a.write(&mut w)?; - w.write_u64::(**i as u64)?; - Ok(()) - }, - )?; - Vector::write(&mut writer, tree.checkpoints(), |w, c| { - write_checkpoint_v1(w, c) - })?; - writer.write_u64::(tree.max_checkpoints() as u64)?; - - Ok(()) -} - -#[allow(clippy::redundant_closure)] -pub fn read_tree_v1( - mut reader: R, -) -> io::Result> { - BridgeTree::from_parts( - Vector::read(&mut reader, |r| read_bridge_v1(r))?, - Vector::read(&mut reader, |mut r| { - Ok((H::read(&mut r)?, r.read_u64::()? as usize)) - })? - .into_iter() - .collect(), - Vector::read(&mut reader, |r| read_checkpoint_v1(r))?, - reader.read_u64::()? as usize, - ) - .map_err(|err| { - io::Error::new( - io::ErrorKind::InvalidInput, - format!( - "Consistency violation found when attempting to deserialize Merkle tree: {:?}", - err - ), - ) - }) -} - -pub fn write_tree( +pub fn write_bridge( mut writer: W, - tree: &BridgeTree, + bridge: &MerkleBridge, ) -> io::Result<()> { writer.write_u8(SER_V1)?; - write_tree_v1(&mut writer, tree) + write_bridge_v1(writer, bridge) } -pub fn read_tree( +pub fn read_bridge( mut reader: R, -) -> io::Result> { +) -> io::Result> { match reader.read_u8()? { - SER_V1 => read_tree_v1(&mut reader), + SER_V1 => read_bridge_v1(&mut reader), flag => Err(io::Error::new( io::ErrorKind::InvalidInput, - format!("Unrecognized tree serialization version: {:?}", flag), + format!("Unrecognized serialization version: {:?}", flag), )), } } diff --git a/zcash_proofs/CHANGELOG.md b/zcash_proofs/CHANGELOG.md index 124affb4e..b13c262f0 100644 --- a/zcash_proofs/CHANGELOG.md +++ b/zcash_proofs/CHANGELOG.md @@ -7,7 +7,7 @@ and this library adheres to Rust's notion of ## [Unreleased] ### Changed -- MSRV is now 1.51.0. +- MSRV is now 1.56.1. - Bumped dependencies to `ff 0.11`, `group 0.11`, `bellman 0.11.1`, `bls12_381 0.6`, `jubjub 0.8`. - `zcash_proofs::sapling::SaplingVerificationContext::new` now takes a