diff --git a/.circleci/config.yml b/.circleci/config.yml index b42c313a..7b976b4f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,7 +51,7 @@ jobs: - "/go/pkg/mod" rust: docker: - - image: rust:1.51.0 + - image: rust:1.56.1 working_directory: ~/proofs/rust steps: - checkout: @@ -61,7 +61,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - v4-cargo-cache-rust:1.51.0-{{ arch }}-{{ checksum "Cargo.toml" }} + - v4-cargo-cache-rust:1.56.1-{{ arch }}-{{ checksum "Cargo.toml" }} - run: name: install protobuf dependencies command: | @@ -91,14 +91,14 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: v4-cargo-cache-rust:1.51.0-{{ arch }}-{{ checksum "Cargo.toml" }} + key: v4-cargo-cache-rust:1.56.1-{{ arch }}-{{ checksum "Cargo.toml" }} - run: name: Run all tests command: cargo test --all lint-rust: docker: - - image: rust:1.51.0 + - image: rust:1.56.1 working_directory: ~/proofs/rust steps: - checkout: @@ -108,7 +108,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-lint-rust:1.51.0-{{ checksum "Cargo.toml" }} + - cargocache-v2-lint-rust:1.56.1-{{ checksum "Cargo.toml" }} - run: name: Add rustfmt component command: rustup component add rustfmt @@ -130,4 +130,4 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-lint-rust:1.51.0-{{ checksum "Cargo.toml" }} + key: cargocache-v2-lint-rust:1.56.1-{{ checksum "Cargo.toml" }} diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 21021ea0..3cba61f4 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -2,11 +2,12 @@ name = "ics23" version = "0.8.0-alpha" authors = ["Ethan Frey "] -edition = "2018" +edition = "2021" exclude = ["codegen"] description = "Merkle proof verification library - implements Cosmos ICS23 Spec" repository = "https://github.com/confio/ics23/tree/master/rust" license = "Apache-2.0" +rust-version = "1.56.1" [workspace] members = ["codegen"] diff --git a/rust/README.md b/rust/README.md index 74469a58..2234c285 100644 --- a/rust/README.md +++ b/rust/README.md @@ -24,4 +24,4 @@ Unless you modify the protobuf file, you can ignore this step. ## MSRV -The minimum supported Rust version (MSRV) is 1.51.0. +The minimum supported Rust version (MSRV) is 1.56.1. diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 05a7e23e..7b31a611 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -19,8 +19,8 @@ pub use api::{ }; pub use compress::{compress, decompress, is_compressed}; pub use helpers::{Hash, Result}; -pub use verify::calculate_existence_root; pub use host_functions::HostFunctionsProvider; +pub use verify::calculate_existence_root; -#[cfg(feature ="std")] +#[cfg(feature = "std")] pub use host_functions::host_functions_impl::HostFunctionsManager; diff --git a/rust/src/ops.rs b/rust/src/ops.rs index 7574803f..60acf993 100644 --- a/rust/src/ops.rs +++ b/rust/src/ops.rs @@ -40,12 +40,12 @@ fn prepare_leaf_data( fn do_hash(hash: HashOp, data: &[u8]) -> Hash { match hash { HashOp::NoHash => Hash::from(data), - HashOp::Sha256 => Hash::from(H::sha2_256(data).as_slice()), - HashOp::Sha512 => Hash::from(H::sha2_512(data).as_slice()), - HashOp::Keccak => Hash::from(H::sha3_512(data).as_slice()), - HashOp::Ripemd160 => Hash::from(H::ripemd160(data).as_slice()), - HashOp::Bitcoin => Hash::from(H::ripemd160(H::sha2_256(data).as_slice()).as_slice()), - HashOp::Sha512256 => Hash::from(H::sha2_512_truncated(data).as_slice()), + HashOp::Sha256 => Hash::from(H::sha2_256(data)), + HashOp::Sha512 => Hash::from(H::sha2_512(data)), + HashOp::Keccak => Hash::from(H::sha3_512(data)), + HashOp::Ripemd160 => Hash::from(H::ripemd160(data)), + HashOp::Bitcoin => Hash::from(H::ripemd160(&H::sha2_256(data)[..])), + HashOp::Sha512256 => Hash::from(H::sha2_512_truncated(data)), } } @@ -81,6 +81,7 @@ fn proto_len(length: usize) -> Result { mod tests { use super::*; use crate::host_functions::host_functions_impl::HostFunctionsManager; + use sp_std::vec; use sp_std::vec::Vec; fn decode(input: &str) -> Vec {