From 5567163275554688653ac6f7fb426320a84ee825 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 29 Sep 2021 12:10:15 +0200 Subject: [PATCH 01/18] Use core and alloc crates for no_std compatibility --- abci/Cargo.toml | 2 +- light-client/Cargo.toml | 5 +- light-client/src/components/verifier.rs | 10 ++-- light-client/tests/model_based.rs | 4 +- p2p/Cargo.toml | 2 +- pbt-gen/Cargo.toml | 2 +- proto/Cargo.toml | 20 ++++---- proto/src/error.rs | 7 +-- proto/src/lib.rs | 16 ++++-- proto/src/prelude.rs | 11 ++++ proto/src/serializers.rs | 2 +- proto/src/serializers/bytes.rs | 5 ++ proto/src/serializers/from_str.rs | 11 ++-- proto/src/serializers/optional_from_str.rs | 8 +-- .../src/serializers/part_set_header_total.rs | 7 +-- proto/src/serializers/time_duration.rs | 5 +- proto/src/serializers/timestamp.rs | 1 + proto/src/serializers/txs.rs | 1 + proto/src/tendermint.rs | 1 + proto/tests/unit.rs | 2 +- rpc/Cargo.toml | 36 ++++++------- rpc/src/client.rs | 3 +- rpc/src/client/bin/main.rs | 2 +- rpc/src/client/subscription.rs | 3 +- rpc/src/client/sync.rs | 2 +- rpc/src/client/transport/http.rs | 6 ++- rpc/src/client/transport/mock.rs | 3 +- rpc/src/client/transport/router.rs | 6 ++- rpc/src/client/transport/websocket.rs | 19 ++++--- rpc/src/endpoint/abci_info.rs | 4 +- rpc/src/endpoint/abci_query.rs | 2 + rpc/src/endpoint/block_results.rs | 2 + rpc/src/endpoint/block_search.rs | 1 + rpc/src/endpoint/blockchain.rs | 4 +- rpc/src/endpoint/broadcast/tx_commit.rs | 2 + rpc/src/endpoint/consensus_state.rs | 5 +- rpc/src/endpoint/net_info.rs | 6 ++- rpc/src/endpoint/subscribe.rs | 2 + rpc/src/endpoint/tx_search.rs | 1 + rpc/src/endpoint/unsubscribe.rs | 1 + rpc/src/endpoint/validators.rs | 1 + rpc/src/error.rs | 7 +-- rpc/src/event.rs | 3 +- rpc/src/id.rs | 5 +- rpc/src/lib.rs | 7 +++ rpc/src/method.rs | 7 +-- rpc/src/order.rs | 3 +- rpc/src/paging.rs | 12 ++--- rpc/src/prelude.rs | 11 ++++ rpc/src/query.rs | 9 ++-- rpc/src/request.rs | 3 +- rpc/src/response_error.rs | 5 +- rpc/src/rpc_url.rs | 7 +-- rpc/src/utils.rs | 1 + rpc/src/version.rs | 5 +- rpc/tests/kvstore_fixtures.rs | 4 +- rpc/tests/parse_response.rs | 2 +- tendermint/Cargo.toml | 50 +++++++++---------- tendermint/src/abci/code.rs | 2 +- tendermint/src/abci/data.rs | 2 + tendermint/src/abci/gas.rs | 5 +- tendermint/src/abci/info.rs | 3 +- tendermint/src/abci/log.rs | 5 +- tendermint/src/abci/path.rs | 5 +- tendermint/src/abci/responses.rs | 3 +- tendermint/src/abci/tag.rs | 3 +- tendermint/src/abci/transaction.rs | 4 +- tendermint/src/abci/transaction/hash.rs | 7 +-- tendermint/src/account.rs | 10 ++-- tendermint/src/block.rs | 5 +- tendermint/src/block/commit.rs | 3 +- tendermint/src/block/commit_sig.rs | 3 +- tendermint/src/block/header.rs | 3 +- tendermint/src/block/height.rs | 8 +-- tendermint/src/block/id.rs | 7 +-- tendermint/src/block/meta.rs | 3 +- tendermint/src/block/parts.rs | 3 +- tendermint/src/block/round.rs | 7 +-- tendermint/src/block/signed_header.rs | 2 +- tendermint/src/block/size.rs | 2 +- tendermint/src/chain/id.rs | 7 +-- tendermint/src/channel.rs | 6 ++- tendermint/src/config.rs | 13 +++-- tendermint/src/config/node_key.rs | 1 + tendermint/src/config/priv_validator_key.rs | 1 + tendermint/src/consensus/params.rs | 3 +- tendermint/src/consensus/state.rs | 5 +- tendermint/src/error.rs | 14 +++--- tendermint/src/evidence.rs | 17 ++++--- tendermint/src/genesis.rs | 1 + tendermint/src/hash.rs | 9 ++-- tendermint/src/lib.rs | 3 ++ tendermint/src/merkle.rs | 1 + tendermint/src/merkle/proof.rs | 3 +- tendermint/src/moniker.rs | 5 +- tendermint/src/net.rs | 7 +-- tendermint/src/node/id.rs | 3 +- tendermint/src/node/info.rs | 3 +- tendermint/src/prelude.rs | 11 ++++ tendermint/src/private_key.rs | 1 + tendermint/src/proposal.rs | 6 ++- tendermint/src/proposal/canonical_proposal.rs | 6 ++- tendermint/src/proposal/msg_type.rs | 3 +- tendermint/src/proposal/sign_proposal.rs | 3 +- tendermint/src/public_key.rs | 8 +-- tendermint/src/public_key/pub_key_request.rs | 6 ++- tendermint/src/public_key/pub_key_response.rs | 2 +- tendermint/src/serializers/apphash.rs | 1 + tendermint/src/serializers/hash.rs | 1 + tendermint/src/serializers/hash_base64.rs | 1 + tendermint/src/serializers/time.rs | 1 + tendermint/src/signature.rs | 3 +- tendermint/src/test.rs | 2 +- tendermint/src/time.rs | 14 +++--- tendermint/src/timeout.rs | 3 +- tendermint/src/trust_threshold.rs | 5 +- tendermint/src/validator.rs | 5 +- tendermint/src/version.rs | 3 +- tendermint/src/vote.rs | 7 +-- tendermint/src/vote/canonical_vote.rs | 6 ++- tendermint/src/vote/power.rs | 5 +- tendermint/src/vote/sign_vote.rs | 9 ++-- tendermint/src/vote/validator_index.rs | 6 +-- test/Cargo.toml | 2 +- 124 files changed, 432 insertions(+), 259 deletions(-) create mode 100644 proto/src/prelude.rs create mode 100644 rpc/src/prelude.rs create mode 100644 tendermint/src/prelude.rs diff --git a/abci/Cargo.toml b/abci/Cargo.toml index 912a5aa64..4a8e4c492 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -36,7 +36,7 @@ bytes = "1.0" prost = "0.7" tendermint-proto = { version = "0.22.0", path = "../proto" } tracing = "0.1" -flex-error = { version = "0.4.1", default-features = false } +flex-error = { version = "0.4.3", default-features = false } structopt = { version = "0.3", optional = true } tracing-subscriber = { version = "0.2", optional = true } diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index b494d7d17..3c7705e10 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -35,7 +35,8 @@ secp256k1 = ["tendermint/secp256k1", "tendermint-rpc/secp256k1"] lightstore-sled = ["sled"] unstable = [] std = [ - "flex-error/std" + "flex-error/std", + "tendermint/std", ] # Enable to execute long-running model-based tests mbt = [] @@ -54,7 +55,7 @@ serde_derive = "1.0.106" sled = { version = "0.34.3", optional = true } static_assertions = "1.1.0" tokio = { version = "1.0", features = ["rt"], optional = true } -flex-error = { version = "0.4.1", default-features = false } +flex-error = { version = "0.4.3", default-features = false } [dev-dependencies] tendermint-testgen = { path = "../testgen" } diff --git a/light-client/src/components/verifier.rs b/light-client/src/components/verifier.rs index a800296e7..5bf03bc54 100644 --- a/light-client/src/components/verifier.rs +++ b/light-client/src/components/verifier.rs @@ -128,14 +128,12 @@ where /// /// - Ensure the latest trusted header hasn't expired /// - Ensure the header validator hashes match the given validators - /// - Ensure the header next validator hashes match the given next - /// validators + /// - Ensure the header next validator hashes match the given next validators /// - Additional implementation specific validation via `commit_validator` /// - Check that the untrusted block is more recent than the trusted state - /// - If the untrusted block is the very next block after the trusted block, - /// check that their (next) validator sets hashes match. - /// - Otherwise, ensure that the untrusted block has a greater height than - /// the trusted block. + /// - If the untrusted block is the very next block after the trusted block, check that their + /// (next) validator sets hashes match. + /// - Otherwise, ensure that the untrusted block has a greater height than the trusted block. /// /// **NOTE**: If the untrusted state's `next_validators` field is `None`, /// this will not (and will not be able to) check whether the untrusted diff --git a/light-client/tests/model_based.rs b/light-client/tests/model_based.rs index 48a883136..9ceba88e3 100644 --- a/light-client/tests/model_based.rs +++ b/light-client/tests/model_based.rs @@ -125,8 +125,8 @@ mod mbt { impl SingleStepTestFuzzer for HeaderVersionFuzzer { // TODO: rehash the header and re-compute commit with it // TODO: Unlike in tendermint-go, we don't assert for a particular version in rust - // TODO: Either add this check in verification or remove this test because otherwise there's no - // point of it + // TODO: Either add this check in verification or remove this test because otherwise there's + // no point of it fn fuzz_input(input: &mut BlockVerdict) -> (String, LiteVerdict) { let mut rng = rand::thread_rng(); diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 1d880f525..59c779002 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -45,7 +45,7 @@ x25519-dalek = "1.1" zeroize = "1" signature = "1.3.0" aead = "0.4.1" -flex-error = { version = "0.4.1", default-features = false } +flex-error = { version = "0.4.3", default-features = false } # path dependencies tendermint = { path = "../tendermint", version = "0.22.0" } diff --git a/pbt-gen/Cargo.toml b/pbt-gen/Cargo.toml index 81a7f7f7c..fdd13f3f1 100644 --- a/pbt-gen/Cargo.toml +++ b/pbt-gen/Cargo.toml @@ -20,5 +20,5 @@ default = ["time"] time = ["chrono"] [dependencies] -chrono = { version = "0.4", features = ["serde"], optional = true} +chrono = { version = "0.4", default-features = false, features = ["serde"], optional = true} proptest = "0.10.1" diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 33dd433c0..cda1410a6 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -17,16 +17,16 @@ description = """ all-features = true [dependencies] -prost = "0.7" -prost-types = "0.7" -bytes = "1.0" -serde = { version = "1.0", features = ["derive"] } -subtle-encoding = "0.5" -serde_bytes = "0.11" -num-traits = "0.2" -num-derive = "0.3" -chrono = { version = "0.4", features = ["serde"] } -flex-error = { version = "0.4.1", default-features = false } +prost = { version = "0.7", default-features = false } +prost-types = { version = "0.7", default-features = false } +bytes = { version = "1.0", default-features = false } +serde = { version = "1.0", default-features = false, features = ["derive"] } +serde_bytes = { version = "0.11", default-features = false, features = ["alloc"] } +subtle-encoding = { version = "0.5", default-features = false, features = ["hex", "base64", "std"] } +num-traits = { version = "0.2", default-features = false } +num-derive = { version = "0.3", default-features = false } +chrono = { version = "0.4", default-features = false, features = ["serde", "clock"] } +flex-error = { version = "0.4.3", default-features = false } [dev-dependencies] serde_json = "1.0" diff --git a/proto/src/error.rs b/proto/src/error.rs index ab2d30b27..1fcde3e16 100644 --- a/proto/src/error.rs +++ b/proto/src/error.rs @@ -1,10 +1,11 @@ //! This module defines the various errors that be raised during Protobuf conversions. +use crate::prelude::*; +use core::convert::TryFrom; +use core::fmt::Display; +use core::num::TryFromIntError; use flex_error::{define_error, DisplayOnly}; use prost::{DecodeError, EncodeError}; -use std::convert::TryFrom; -use std::fmt::Display; -use std::num::TryFromIntError; define_error! { Error { diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 4e37cbaf8..4a471a60e 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -1,10 +1,18 @@ //! tendermint-proto library gives the developer access to the Tendermint proto-defined structs. +#![no_std] #![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)] #![allow(clippy::large_enum_variant)] #![forbid(unsafe_code)] #![doc(html_root_url = "https://docs.rs/tendermint-proto/0.22.0")] +extern crate alloc; + +#[cfg(feature = "std")] +extern crate std; + +mod prelude; + /// Built-in prost_types with slight customization to enable JSON-encoding #[allow(warnings)] pub mod google { @@ -23,13 +31,15 @@ pub use error::Error; pub use tendermint::*; use bytes::{Buf, BufMut}; +use core::convert::{TryFrom, TryInto}; +use core::fmt::Display; use prost::encoding::encoded_len_varint; use prost::Message; -use std::convert::{TryFrom, TryInto}; -use std::fmt::Display; pub mod serializers; +use prelude::*; + /// Allows for easy Google Protocol Buffers encoding and decoding of domain /// types with validation. /// @@ -38,7 +48,7 @@ pub mod serializers; /// ```rust /// use bytes::BufMut; /// use prost::Message; -/// use std::convert::TryFrom; +/// use core::convert::TryFrom; /// use tendermint_proto::Protobuf; /// /// // This struct would ordinarily be automatically generated by prost. diff --git a/proto/src/prelude.rs b/proto/src/prelude.rs new file mode 100644 index 000000000..9ff42a989 --- /dev/null +++ b/proto/src/prelude.rs @@ -0,0 +1,11 @@ +pub use core::prelude::v1::*; + +// Re-export according to alloc::prelude::v1 because it is not yet stabilized +// https://doc.rust-lang.org/src/alloc/prelude/v1.rs.html +pub use alloc::borrow::ToOwned; +pub use alloc::boxed::Box; +pub use alloc::string::{String, ToString}; +pub use alloc::vec::Vec; + +pub use alloc::format; +pub use alloc::vec; diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index 239a8b53f..749ec893d 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -32,7 +32,7 @@ //! Available serializers: //! i64 <-> string: #[serde(with="serializers::from_str")] //! u64 <-> string: #[serde(with="serializers::from_str")] -//! std::time::Duration <-> nanoseconds as string #[serde(with="serializers::time_duration")] +//! core::time::Duration <-> nanoseconds as string #[serde(with="serializers::time_duration")] //! Vec <-> HexString: #[serde(with="serializers::bytes::hexstring")] //! Vec <-> Base64String: #[serde(with="serializers::bytes::base64string")] //! Vec <-> String: #[serde(with="serializers::bytes::string")] diff --git a/proto/src/serializers/bytes.rs b/proto/src/serializers/bytes.rs index 7cffcfb64..c3ea9443e 100644 --- a/proto/src/serializers/bytes.rs +++ b/proto/src/serializers/bytes.rs @@ -2,6 +2,7 @@ /// Serialize into hexstring, deserialize from hexstring pub mod hexstring { + use crate::prelude::*; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::hex; @@ -30,6 +31,7 @@ pub mod hexstring { /// Serialize into base64string, deserialize from base64string pub mod base64string { + use crate::prelude::*; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::base64; @@ -66,6 +68,7 @@ pub mod base64string { /// Serialize into Vec, deserialize from Vec pub mod vec_base64string { + use crate::prelude::*; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::base64; @@ -99,6 +102,7 @@ pub mod vec_base64string { /// Serialize into Option, deserialize from Option pub mod option_base64string { + use crate::prelude::*; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::base64; @@ -125,6 +129,7 @@ pub mod option_base64string { /// Serialize into string, deserialize from string pub mod string { + use crate::prelude::*; use serde::{Deserialize, Deserializer, Serializer}; /// Deserialize string into Vec diff --git a/proto/src/serializers/from_str.rs b/proto/src/serializers/from_str.rs index 9fe5800bb..7e3583538 100644 --- a/proto/src/serializers/from_str.rs +++ b/proto/src/serializers/from_str.rs @@ -1,14 +1,15 @@ -//! Serialize and deserialize any `T` that implements [[std::str::FromStr]] -//! and [[std::fmt::Display]] from or into string. Note this can be used for +//! Serialize and deserialize any `T` that implements [[core::str::FromStr]] +//! and [[core::fmt::Display]] from or into string. Note this can be used for //! all primitive data types. +use crate::prelude::*; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; /// Deserialize string into T pub fn deserialize<'de, D, T>(deserializer: D) -> Result where D: Deserializer<'de>, - T: std::str::FromStr, - ::Err: std::fmt::Display, + T: core::str::FromStr, + ::Err: core::fmt::Display, { String::deserialize(deserializer)? .parse::() @@ -19,7 +20,7 @@ where pub fn serialize(value: &T, serializer: S) -> Result where S: Serializer, - T: std::fmt::Display, + T: core::fmt::Display, { format!("{}", value).serialize(serializer) } diff --git a/proto/src/serializers/optional_from_str.rs b/proto/src/serializers/optional_from_str.rs index 2752be880..ab6da70c8 100644 --- a/proto/src/serializers/optional_from_str.rs +++ b/proto/src/serializers/optional_from_str.rs @@ -1,8 +1,10 @@ //! De/serialize an optional type that must be converted from/to a string. +use crate::prelude::*; +use core::fmt::Display; +use core::str::FromStr; use serde::de::Error; use serde::{Deserialize, Deserializer, Serializer}; -use std::str::FromStr; pub fn serialize(value: &Option, serializer: S) -> Result where @@ -19,13 +21,13 @@ pub fn deserialize<'de, D, T>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, T: FromStr, - T::Err: std::error::Error, + T::Err: Display, { let s = match Option::::deserialize(deserializer)? { Some(s) => s, None => return Ok(None), }; Ok(Some(s.parse().map_err(|e: ::Err| { - D::Error::custom(e.to_string()) + D::Error::custom(format!("{}", e)) })?)) } diff --git a/proto/src/serializers/part_set_header_total.rs b/proto/src/serializers/part_set_header_total.rs index 75cf35654..549c088ae 100644 --- a/proto/src/serializers/part_set_header_total.rs +++ b/proto/src/serializers/part_set_header_total.rs @@ -5,9 +5,10 @@ //! string-quoted integer value into an integer value without quotes in Tendermint Core v0.34.0. //! This deserializer allows backwards-compatibility by deserializing both ways. //! See also: +use crate::prelude::*; +use core::convert::TryFrom; +use core::fmt::Formatter; use serde::{de::Error, de::Visitor, Deserializer, Serialize, Serializer}; -use std::convert::TryFrom; -use std::fmt::Formatter; struct PartSetHeaderTotalStringOrU32; @@ -30,7 +31,7 @@ where impl<'de> Visitor<'de> for PartSetHeaderTotalStringOrU32 { type Value = u32; - fn expecting(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result { + fn expecting(&self, formatter: &mut Formatter<'_>) -> core::fmt::Result { formatter.write_str("an u32 integer or string between 0 and 2^32") } diff --git a/proto/src/serializers/time_duration.rs b/proto/src/serializers/time_duration.rs index baa66d30c..08692224a 100644 --- a/proto/src/serializers/time_duration.rs +++ b/proto/src/serializers/time_duration.rs @@ -1,7 +1,8 @@ -//! Serialize/deserialize std::time::Duration type from and into string: +//! Serialize/deserialize core::time::Duration type from and into string: +use crate::prelude::*; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::time::Duration; +use core::time::Duration; /// Deserialize string into Duration pub fn deserialize<'de, D>(deserializer: D) -> Result diff --git a/proto/src/serializers/timestamp.rs b/proto/src/serializers/timestamp.rs index 8627cd208..8843c17ef 100644 --- a/proto/src/serializers/timestamp.rs +++ b/proto/src/serializers/timestamp.rs @@ -2,6 +2,7 @@ use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; use crate::google::protobuf::Timestamp; +use crate::prelude::*; use chrono::{DateTime, LocalResult, TimeZone, Utc}; use serde::ser::Error; diff --git a/proto/src/serializers/txs.rs b/proto/src/serializers/txs.rs index 05b2767f1..ff45b05cc 100644 --- a/proto/src/serializers/txs.rs +++ b/proto/src/serializers/txs.rs @@ -1,4 +1,5 @@ //! Serialize/deserialize Vec> type from and into transactions (Base64String array). +use crate::prelude::*; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use subtle_encoding::base64; diff --git a/proto/src/tendermint.rs b/proto/src/tendermint.rs index 335cb2877..dbfda20a7 100644 --- a/proto/src/tendermint.rs +++ b/proto/src/tendermint.rs @@ -53,6 +53,7 @@ pub mod p2p { } pub mod abci { + use crate::prelude::*; include!("prost/tendermint.abci.rs"); } diff --git a/proto/tests/unit.rs b/proto/tests/unit.rs index f50d35507..03efe33bb 100644 --- a/proto/tests/unit.rs +++ b/proto/tests/unit.rs @@ -1,4 +1,4 @@ -use std::convert::TryFrom; +use core::convert::TryFrom; use tendermint_proto::types::BlockId as RawBlockId; use tendermint_proto::types::PartSetHeader as RawPartSetHeader; use tendermint_proto::Protobuf; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 384208921..64209d2b2 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -61,26 +61,28 @@ websocket-client = [ "tracing" ] std = [ - "flex-error/std" + "flex-error/std", + "tendermint/std", + "tendermint-proto/std", ] [dependencies] -bytes = "1.0" -chrono = "0.4" -getrandom = "0.1" -peg = "0.7.0" -pin-project = "1.0.1" -serde = { version = "1", features = [ "derive" ] } -serde_bytes = "0.11" -serde_json = "1" -tendermint = { version = "0.22.0", path = "../tendermint" } -tendermint-proto = { version = "0.22.0", path = "../proto" } -thiserror = "1" +bytes = { version = "1.0", default-features = false } +chrono = { version = "0.4", default-features = false } +getrandom = { version = "0.1", default-features = false } +peg = { version = "0.7.0", default-features = false } +pin-project = { version = "1.0.1", default-features = false } +serde = { version = "1", default-features = false, features = [ "derive" ] } +serde_bytes = { version = "0.11", default-features = false } +serde_json = { version = "1", default-features = false, features = ["std"] } +tendermint = { version = "0.22.0", default-features = false, path = "../tendermint" } +tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } +thiserror = { version = "1", default-features = false } uuid = { version = "0.8", default-features = false } -subtle-encoding = { version = "0.5", features = ["bech32-preview"] } -url = "2.2" -walkdir = "2.3" -flex-error = { version = "0.4.1", default-features = false } +subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } +url = { version = "2.2", default-features = false } +walkdir = { version = "2.3", default-features = false } +flex-error = { version = "0.4.3", default-features = false } # Optional dependencies async-trait = { version = "0.1", optional = true } @@ -91,7 +93,7 @@ hyper = { version = "0.14", optional = true, features = ["client", "http1", "htt hyper-proxy = { version = "0.9", optional = true } hyper-rustls = { version = "0.22.1", optional = true } structopt = { version = "0.3", optional = true } -tokio = { version = "1.0", optional = true } +tokio = { version = "1.0", optional = true, features = ["rt-multi-thread"] } tracing = { version = "0.1", optional = true } tracing-subscriber = { version = "0.2", optional = true } diff --git a/rpc/src/client.rs b/rpc/src/client.rs index 2dc6e153a..a1ce9ad3a 100644 --- a/rpc/src/client.rs +++ b/rpc/src/client.rs @@ -17,10 +17,11 @@ pub use transport::websocket::{ use crate::endpoint::validators::DEFAULT_VALIDATORS_PER_PAGE; use crate::endpoint::*; use crate::paging::Paging; +use crate::prelude::*; use crate::query::Query; use crate::{Error, Order, SimpleRequest}; use async_trait::async_trait; -use std::time::Duration; +use core::time::Duration; use tendermint::abci::{self, Transaction}; use tendermint::block::Height; use tendermint::evidence::Evidence; diff --git a/rpc/src/client/bin/main.rs b/rpc/src/client/bin/main.rs index b4e48c572..eab7664f0 100644 --- a/rpc/src/client/bin/main.rs +++ b/rpc/src/client/bin/main.rs @@ -1,7 +1,7 @@ //! CLI for performing simple interactions against a Tendermint node's RPC. +use core::str::FromStr; use futures::StreamExt; -use std::str::FromStr; use structopt::StructOpt; use tendermint::abci::transaction::Hash; use tendermint::abci::{Path, Transaction}; diff --git a/rpc/src/client/subscription.rs b/rpc/src/client/subscription.rs index 8b913dcc5..0d3855783 100644 --- a/rpc/src/client/subscription.rs +++ b/rpc/src/client/subscription.rs @@ -2,13 +2,14 @@ use crate::client::sync::{ChannelRx, ChannelTx}; use crate::event::Event; +use crate::prelude::*; use crate::query::Query; use crate::Error; use async_trait::async_trait; +use core::pin::Pin; use futures::task::{Context, Poll}; use futures::Stream; use pin_project::pin_project; -use std::pin::Pin; /// A client that exclusively provides [`Event`] subscription capabilities, /// without any other RPC method support. diff --git a/rpc/src/client/sync.rs b/rpc/src/client/sync.rs index 466d8977a..a2867e6a5 100644 --- a/rpc/src/client/sync.rs +++ b/rpc/src/client/sync.rs @@ -4,7 +4,7 @@ //! convenience methods. We also only implement unbounded channels at present. //! In future, if RPC consumers need it, we will implement bounded channels. -use std::pin::Pin; +use core::pin::Pin; use futures::task::{Context, Poll}; use futures::Stream; diff --git a/rpc/src/client/transport/http.rs b/rpc/src/client/transport/http.rs index 40abb925c..146068379 100644 --- a/rpc/src/client/transport/http.rs +++ b/rpc/src/client/transport/http.rs @@ -1,10 +1,11 @@ //! HTTP-based transport for Tendermint RPC Client. use crate::client::Client; +use crate::prelude::*; use crate::{Error, Scheme, SimpleRequest, Url}; use async_trait::async_trait; -use std::convert::{TryFrom, TryInto}; -use std::str::FromStr; +use core::convert::{TryFrom, TryInto}; +use core::str::FromStr; use tendermint::net; /// A JSON-RPC/HTTP Tendermint RPC client (implements [`crate::Client`]). @@ -153,6 +154,7 @@ impl TryFrom for hyper::Uri { } mod sealed { + use crate::prelude::*; use crate::{Error, Response, SimpleRequest}; use hyper::body::Buf; use hyper::client::connect::Connect; diff --git a/rpc/src/client/transport/mock.rs b/rpc/src/client/transport/mock.rs index c1382a8d0..f600b5c31 100644 --- a/rpc/src/client/transport/mock.rs +++ b/rpc/src/client/transport/mock.rs @@ -4,11 +4,12 @@ use crate::client::subscription::SubscriptionTx; use crate::client::sync::{unbounded, ChannelRx, ChannelTx}; use crate::client::transport::router::SubscriptionRouter; use crate::event::Event; +use crate::prelude::*; use crate::query::Query; use crate::utils::uuid_str; use crate::{Client, Error, Method, Request, Response, Subscription, SubscriptionClient}; +use alloc::collections::BTreeMap as HashMap; use async_trait::async_trait; -use std::collections::HashMap; /// A mock client implementation for use in testing. /// diff --git a/rpc/src/client/transport/router.rs b/rpc/src/client/transport/router.rs index 34b2fc979..c699717c3 100644 --- a/rpc/src/client/transport/router.rs +++ b/rpc/src/client/transport/router.rs @@ -1,12 +1,14 @@ //! Event routing for subscriptions. -use std::collections::{HashMap, HashSet}; +use alloc::collections::BTreeMap as HashMap; +use alloc::collections::BTreeSet as HashSet; use tracing::debug; use crate::client::subscription::SubscriptionTx; use crate::error::Error; use crate::event::Event; +use crate::prelude::*; pub type SubscriptionQuery = String; pub type SubscriptionId = String; @@ -175,7 +177,7 @@ mod test { async fn must_not_recv(ch: &mut ChannelRx, timeout_ms: u64) where - T: std::fmt::Debug, + T: core::fmt::Debug, { let delay = time::sleep(Duration::from_millis(timeout_ms)); tokio::select! { diff --git a/rpc/src/client/transport/websocket.rs b/rpc/src/client/transport/websocket.rs index 01ef6d715..71fadc0d9 100644 --- a/rpc/src/client/transport/websocket.rs +++ b/rpc/src/client/transport/websocket.rs @@ -5,25 +5,26 @@ use crate::client::sync::{ChannelRx, ChannelTx}; use crate::client::transport::router::{PublishResult, SubscriptionRouter}; use crate::endpoint::{subscribe, unsubscribe}; use crate::event::Event; +use crate::prelude::*; use crate::query::Query; use crate::request::Wrapper; use crate::{ error::Error, response, Client, Id, Request, Response, Scheme, SimpleRequest, Subscription, SubscriptionClient, Url, }; +use alloc::borrow::Cow; +use alloc::collections::BTreeMap as HashMap; use async_trait::async_trait; use async_tungstenite::tokio::ConnectStream; use async_tungstenite::tungstenite::protocol::frame::coding::CloseCode; use async_tungstenite::tungstenite::protocol::CloseFrame; use async_tungstenite::tungstenite::Message; use async_tungstenite::WebSocketStream; +use core::convert::{TryFrom, TryInto}; +use core::ops::Add; +use core::str::FromStr; use futures::{SinkExt, StreamExt}; use serde::{Deserialize, Serialize}; -use std::borrow::Cow; -use std::collections::HashMap; -use std::convert::{TryFrom, TryInto}; -use std::ops::Add; -use std::str::FromStr; use tendermint::net; use tokio::time::{Duration, Instant}; use tracing::{debug, error}; @@ -257,6 +258,7 @@ mod sealed { }; use crate::client::sync::{unbounded, ChannelTx}; + use crate::prelude::*; use crate::query::Query; use crate::request::Wrapper; use crate::utils::uuid_str; @@ -288,7 +290,7 @@ mod sealed { #[derive(Debug, Clone)] pub struct AsyncTungsteniteClient { cmd_tx: ChannelTx, - _client_type: std::marker::PhantomData, + _client_type: core::marker::PhantomData, } impl AsyncTungsteniteClient { @@ -801,11 +803,12 @@ mod test { use crate::client::sync::unbounded; use crate::query::EventType; use crate::{request, Id, Method}; + use alloc::collections::BTreeMap as HashMap; use async_tungstenite::tokio::{accept_async, TokioAdapter}; + use core::str::FromStr; use futures::StreamExt; - use std::collections::HashMap; use std::path::PathBuf; - use std::str::FromStr; + use std::println; use tendermint::net; use tokio::fs; use tokio::net::{TcpListener, TcpStream}; diff --git a/rpc/src/endpoint/abci_info.rs b/rpc/src/endpoint/abci_info.rs index f28a2f98c..37e6fd90a 100644 --- a/rpc/src/endpoint/abci_info.rs +++ b/rpc/src/endpoint/abci_info.rs @@ -2,11 +2,13 @@ use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint::block; use tendermint::Error; use tendermint_proto::abci::ResponseInfo; +use crate::prelude::*; + /// Request ABCI information from a node #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct Request; diff --git a/rpc/src/endpoint/abci_query.rs b/rpc/src/endpoint/abci_query.rs index 946964495..c4dacc5fc 100644 --- a/rpc/src/endpoint/abci_query.rs +++ b/rpc/src/endpoint/abci_query.rs @@ -7,6 +7,8 @@ use tendermint::block; use tendermint::merkle::proof::Proof; use tendermint::serializers; +use crate::prelude::*; + /// Query the ABCI application for information #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Request { diff --git a/rpc/src/endpoint/block_results.rs b/rpc/src/endpoint/block_results.rs index 5e3b70eed..0f2c8fcb6 100644 --- a/rpc/src/endpoint/block_results.rs +++ b/rpc/src/endpoint/block_results.rs @@ -4,6 +4,8 @@ use serde::{Deserialize, Serialize}; use tendermint::{abci, block, consensus, validator}; +use crate::prelude::*; + /// Get ABCI results at a given height. #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] pub struct Request { diff --git a/rpc/src/endpoint/block_search.rs b/rpc/src/endpoint/block_search.rs index ef1e19c4a..badd94b9e 100644 --- a/rpc/src/endpoint/block_search.rs +++ b/rpc/src/endpoint/block_search.rs @@ -2,6 +2,7 @@ pub use super::{block, block_results}; +use crate::prelude::*; use crate::{Method, Order}; use serde::{Deserialize, Serialize}; diff --git a/rpc/src/endpoint/blockchain.rs b/rpc/src/endpoint/blockchain.rs index a334ae1f6..a883ce73b 100644 --- a/rpc/src/endpoint/blockchain.rs +++ b/rpc/src/endpoint/blockchain.rs @@ -1,10 +1,12 @@ //! `/block` endpoint JSON-RPC wrapper +use core::ops::Range; use serde::{Deserialize, Serialize}; -use std::ops::Range; use tendermint::block; +use crate::prelude::*; + /// Get information about a specific block #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct Request { diff --git a/rpc/src/endpoint/broadcast/tx_commit.rs b/rpc/src/endpoint/broadcast/tx_commit.rs index 5d9e8f51f..bb4cf93a5 100644 --- a/rpc/src/endpoint/broadcast/tx_commit.rs +++ b/rpc/src/endpoint/broadcast/tx_commit.rs @@ -10,6 +10,8 @@ use tendermint::{ block, }; +use crate::prelude::*; + /// `/broadcast_tx_commit`: only returns error if `mempool.CheckTx()` errs or /// if we timeout waiting for tx to commit. /// diff --git a/rpc/src/endpoint/consensus_state.rs b/rpc/src/endpoint/consensus_state.rs index 38569585d..91b36f8a7 100644 --- a/rpc/src/endpoint/consensus_state.rs +++ b/rpc/src/endpoint/consensus_state.rs @@ -1,9 +1,10 @@ //! `/consensus_state` endpoint JSON-RPC wrapper +use crate::prelude::*; use crate::{Error, Method}; +use core::fmt; +use core::str::FromStr; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; -use std::str::FromStr; use subtle_encoding::hex; use tendermint::block::{Height, Round}; use tendermint::{account, hash, vote, Hash, Time}; diff --git a/rpc/src/endpoint/net_info.rs b/rpc/src/endpoint/net_info.rs index 7efd58739..c3a7787c7 100644 --- a/rpc/src/endpoint/net_info.rs +++ b/rpc/src/endpoint/net_info.rs @@ -1,12 +1,14 @@ //! `/net_info` endpoint JSON-RPC wrapper +use core::fmt::{self, Display}; +use core::time::Duration; use serde::{Deserialize, Serialize}; -use std::fmt::{self, Display}; use std::net::IpAddr; -use std::time::Duration; use tendermint::{channel::Channel, node, serializers, Time}; +use crate::prelude::*; + /// Request network information from a node #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct Request; diff --git a/rpc/src/endpoint/subscribe.rs b/rpc/src/endpoint/subscribe.rs index 1bd84d10b..2874bf8b7 100644 --- a/rpc/src/endpoint/subscribe.rs +++ b/rpc/src/endpoint/subscribe.rs @@ -2,6 +2,8 @@ use serde::{Deserialize, Serialize}; +use crate::prelude::*; + /// Subscription request for events. /// /// A subscription request is not a [`SimpleRequest`], because it does not diff --git a/rpc/src/endpoint/tx_search.rs b/rpc/src/endpoint/tx_search.rs index d0c0d6242..dfc5cc251 100644 --- a/rpc/src/endpoint/tx_search.rs +++ b/rpc/src/endpoint/tx_search.rs @@ -2,6 +2,7 @@ pub use super::tx; +use crate::prelude::*; use crate::{Method, Order}; use serde::{Deserialize, Serialize}; diff --git a/rpc/src/endpoint/unsubscribe.rs b/rpc/src/endpoint/unsubscribe.rs index 0bae0dc66..6804b68cb 100644 --- a/rpc/src/endpoint/unsubscribe.rs +++ b/rpc/src/endpoint/unsubscribe.rs @@ -1,5 +1,6 @@ //! `/unsubscribe` endpoint JSON-RPC wrapper +use crate::prelude::*; use serde::{Deserialize, Serialize}; /// Request to unsubscribe from events relating to a given query. diff --git a/rpc/src/endpoint/validators.rs b/rpc/src/endpoint/validators.rs index efe3f0c31..7897afeeb 100644 --- a/rpc/src/endpoint/validators.rs +++ b/rpc/src/endpoint/validators.rs @@ -1,5 +1,6 @@ //! `/validators` endpoint JSON-RPC wrapper +use crate::prelude::*; use crate::{PageNumber, PerPage}; use serde::{Deserialize, Serialize}; use tendermint::{block, validator}; diff --git a/rpc/src/error.rs b/rpc/src/error.rs index 99e63f33e..6bc732eec 100644 --- a/rpc/src/error.rs +++ b/rpc/src/error.rs @@ -1,8 +1,9 @@ //! JSON-RPC error types +use core::time::Duration; use flex_error::{define_error, DefaultTracer, DisplayError, DisplayOnly, ErrorMessageTracer}; -use std::time::Duration; +use crate::prelude::*; use crate::response_error::ResponseError; use crate::rpc_url::Url; @@ -145,11 +146,11 @@ define_error! { | _ | { "tendermint error" }, ParseInt - [ DisplayOnly ] + [ DisplayOnly ] | _ | { "error parsing integer" }, OutOfRange - [ DisplayOnly ] + [ DisplayOnly ] | _ | { "number out of range" }, InvalidNetworkAddress diff --git a/rpc/src/event.rs b/rpc/src/event.rs index bf1bcb106..cae0c62fd 100644 --- a/rpc/src/event.rs +++ b/rpc/src/event.rs @@ -1,10 +1,11 @@ //! RPC subscription event-related data structures. +use alloc::collections::BTreeMap as HashMap; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use tendermint::abci::responses::{BeginBlock, EndBlock}; use tendermint::Block; +use crate::prelude::*; use crate::query::EventType; use crate::{response::Wrapper, Response}; diff --git a/rpc/src/id.rs b/rpc/src/id.rs index 1a21acb89..5083b88d4 100644 --- a/rpc/src/id.rs +++ b/rpc/src/id.rs @@ -1,8 +1,9 @@ //! JSON-RPC IDs +use crate::prelude::*; use crate::utils::uuid_str; +use core::fmt; use serde::{Deserialize, Serialize}; -use std::fmt; /// JSON-RPC ID: request-specific identifier #[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd)] @@ -35,8 +36,8 @@ impl fmt::Display for Id { #[cfg(test)] mod tests { + use core::fmt::Debug; use serde::{de::DeserializeOwned, Serialize}; - use std::fmt::Debug; use super::*; diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 5efea9f67..9ab6b672f 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -25,6 +25,13 @@ //! [Tendermint RPC]: https://docs.tendermint.com/master/rpc/ //! [`/subscribe` endpoint]: https://docs.tendermint.com/master/rpc/#/Websocket/subscribe +#![no_std] + +extern crate alloc; +extern crate std; + +mod prelude; + #[cfg(any(feature = "http-client", feature = "websocket-client"))] mod client; #[cfg(any(feature = "http-client", feature = "websocket-client"))] diff --git a/rpc/src/method.rs b/rpc/src/method.rs index 5a3fd47bc..f2c821202 100644 --- a/rpc/src/method.rs +++ b/rpc/src/method.rs @@ -1,16 +1,17 @@ //! JSON-RPC request methods +use crate::prelude::*; use crate::Error; -use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::{ +use core::{ fmt::{self, Display}, str::FromStr, }; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; /// JSON-RPC request methods. /// /// Serialized as the "method" field of JSON-RPC/HTTP requests. -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] pub enum Method { /// Get ABCI info AbciInfo, diff --git a/rpc/src/order.rs b/rpc/src/order.rs index f5079cc60..3ea60da09 100644 --- a/rpc/src/order.rs +++ b/rpc/src/order.rs @@ -1,8 +1,9 @@ //! Ordering of paginated RPC responses. +use crate::prelude::*; use crate::Error; +use core::str::FromStr; use serde::{Deserialize, Serialize}; -use std::str::FromStr; /// Ordering of paginated RPC responses. #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] diff --git a/rpc/src/paging.rs b/rpc/src/paging.rs index 25768dcca..427f08aa7 100644 --- a/rpc/src/paging.rs +++ b/rpc/src/paging.rs @@ -1,9 +1,9 @@ //! Pagination-related data structures for the Tendermint RPC. use crate::Error; +use core::convert::TryInto; +use core::str::FromStr; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; -use std::str::FromStr; /// Pagination control for those RPC client methods supporting pagination. #[derive(Debug, Clone, Copy, Eq, PartialEq)] @@ -35,8 +35,8 @@ impl FromStr for PageNumber { } } -impl std::fmt::Display for PageNumber { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Display for PageNumber { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.0) } } @@ -61,8 +61,8 @@ impl FromStr for PerPage { } } -impl std::fmt::Display for PerPage { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Display for PerPage { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.0) } } diff --git a/rpc/src/prelude.rs b/rpc/src/prelude.rs new file mode 100644 index 000000000..9ff42a989 --- /dev/null +++ b/rpc/src/prelude.rs @@ -0,0 +1,11 @@ +pub use core::prelude::v1::*; + +// Re-export according to alloc::prelude::v1 because it is not yet stabilized +// https://doc.rust-lang.org/src/alloc/prelude/v1.rs.html +pub use alloc::borrow::ToOwned; +pub use alloc::boxed::Box; +pub use alloc::string::{String, ToString}; +pub use alloc::vec::Vec; + +pub use alloc::format; +pub use alloc::vec; diff --git a/rpc/src/query.rs b/rpc/src/query.rs index d6df24e69..7a4de90e3 100644 --- a/rpc/src/query.rs +++ b/rpc/src/query.rs @@ -4,10 +4,11 @@ //! //! [`Query`]: struct.Query.html +use crate::prelude::*; use crate::Error; use chrono::{Date, DateTime, FixedOffset, NaiveDate, Utc}; -use std::fmt; -use std::str::FromStr; +use core::fmt; +use core::str::FromStr; /// A structured query for use in interacting with the Tendermint RPC event /// subscription system. @@ -828,7 +829,7 @@ mod test { assert_eq!(tag, "short.pi"); match op { Operand::Float(f) => { - assert!(floats_eq(*f, std::f64::consts::PI, 5)); + assert!(floats_eq(*f, core::f64::consts::PI, 5)); } _ => panic!("unexpected operand: {:?}", op), } @@ -844,7 +845,7 @@ mod test { assert_eq!(tag, "short.pi"); match op { Operand::Float(f) => { - assert!(floats_eq(*f, -std::f64::consts::PI, 5)); + assert!(floats_eq(*f, -core::f64::consts::PI, 5)); } _ => panic!("unexpected operand: {:?}", op), } diff --git a/rpc/src/request.rs b/rpc/src/request.rs index 9aebd50c9..a2ed62085 100644 --- a/rpc/src/request.rs +++ b/rpc/src/request.rs @@ -1,8 +1,9 @@ //! JSON-RPC requests use super::{Id, Method, Version}; +use crate::prelude::*; +use core::fmt::Debug; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use std::fmt::Debug; /// JSON-RPC requests pub trait Request: Debug + DeserializeOwned + Serialize + Sized + Send { diff --git a/rpc/src/response_error.rs b/rpc/src/response_error.rs index 087218a83..4e1211829 100644 --- a/rpc/src/response_error.rs +++ b/rpc/src/response_error.rs @@ -1,5 +1,6 @@ +use crate::prelude::*; +use core::fmt::Display; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt::Display; #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct ResponseError { @@ -107,7 +108,7 @@ impl From for i32 { } impl Display for ResponseError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match &self.data { Some(data) => write!( f, diff --git a/rpc/src/rpc_url.rs b/rpc/src/rpc_url.rs index 3b077a629..96768b751 100644 --- a/rpc/src/rpc_url.rs +++ b/rpc/src/rpc_url.rs @@ -1,11 +1,12 @@ //! URL representation for RPC clients. use crate::error::Error; +use crate::prelude::*; +use core::convert::TryFrom; +use core::fmt; +use core::str::FromStr; use serde::de::Error as SerdeError; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::convert::TryFrom; -use std::fmt; -use std::str::FromStr; /// The various schemes supported by Tendermint RPC clients. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/rpc/src/utils.rs b/rpc/src/utils.rs index 76934a967..6f117e6e1 100644 --- a/rpc/src/utils.rs +++ b/rpc/src/utils.rs @@ -1,5 +1,6 @@ //! Utility methods for the Tendermint RPC crate. +use crate::prelude::*; use getrandom::getrandom; /// Produce a string containing a UUID. diff --git a/rpc/src/version.rs b/rpc/src/version.rs index 6722ae2be..f302e9a3e 100644 --- a/rpc/src/version.rs +++ b/rpc/src/version.rs @@ -1,11 +1,12 @@ //! JSON-RPC versions use super::error::Error; -use serde::{Deserialize, Serialize}; -use std::{ +use crate::prelude::*; +use core::{ fmt::{self, Display}, str::FromStr, }; +use serde::{Deserialize, Serialize}; /// Supported JSON-RPC version const SUPPORTED_VERSION: &str = "2.0"; diff --git a/rpc/tests/kvstore_fixtures.rs b/rpc/tests/kvstore_fixtures.rs index b7df5db50..f1bb65bde 100644 --- a/rpc/tests/kvstore_fixtures.rs +++ b/rpc/tests/kvstore_fixtures.rs @@ -1,6 +1,6 @@ //! Tendermint kvstore RPC endpoint testing. -use std::str::FromStr; +use core::str::FromStr; use std::{fs, path::PathBuf}; use subtle_encoding::{base64, hex}; use tendermint::abci::transaction::Hash; @@ -710,7 +710,7 @@ fn incoming_fixtures() { assert_eq!(result.consensus_params.block.time_iota_ms, 500_i64); assert_eq!( result.consensus_params.evidence.max_age_duration, - Duration(std::time::Duration::from_nanos(172800000000000_u64)) + Duration(core::time::Duration::from_nanos(172800000000000_u64)) ); assert_eq!( result.consensus_params.evidence.max_age_num_blocks, diff --git a/rpc/tests/parse_response.rs b/rpc/tests/parse_response.rs index e3aff8857..6acc0c345 100644 --- a/rpc/tests/parse_response.rs +++ b/rpc/tests/parse_response.rs @@ -3,7 +3,7 @@ use std::{fs, path::PathBuf}; use tendermint::abci::Code; -use std::str::FromStr; +use core::str::FromStr; use tendermint::vote; use tendermint_rpc::endpoint::consensus_state::RoundVote; use tendermint_rpc::{ diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index 8c6ebb3a7..023b7d24c 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -33,40 +33,40 @@ rustdoc-args = ["--cfg", "docsrs"] crate-type = ["cdylib", "rlib"] [dependencies] -async-trait = "0.1" -bytes = "1.0" -chrono = { version = "0.4.19", features = ["serde"] } -ed25519 = "1" -ed25519-dalek = { version = "1", features = ["serde"] } -futures = "0.3" -num-traits = "0.2" -once_cell = "1.3" -prost = "0.7" -prost-types = "0.7" -serde = { version = "1", features = ["derive"] } -serde_json = "1" -serde_bytes = "0.11" -serde_repr = "0.1" +async-trait = { version = "0.1", default-features = false } +bytes = { version = "1.0", default-features = false } +chrono = { version = "0.4.19", default-features = false, features = ["serde"] } +ed25519 = { version = "1", default-features = false } +ed25519-dalek = { version = "1", default-features = false, features = ["serde", "u64_backend"] } +futures = { version = "0.3", default-features = false } +num-traits = { version = "0.2", default-features = false } +once_cell = { version = "1.3", default-features = false } +prost = { version = "0.7", default-features = false } +prost-types = { version = "0.7", default-features = false, features = ["std"] } +serde = { version = "1", default-features = false, features = ["derive"] } +serde_json = { version = "1", features = ["alloc"] } +serde_bytes = { version = "0.11", default-features = false } +serde_repr = { version = "0.1", default-features = false } sha2 = { version = "0.9", default-features = false } signature = "1.2" subtle = "2" -subtle-encoding = { version = "0.5", features = ["bech32-preview"] } -tendermint-proto = { version = "0.22.0", path = "../proto" } -toml = { version = "0.5" } -url = { version = "2.2" } -zeroize = { version = "1.1", features = ["zeroize_derive"] } -flex-error = { version = "0.4.1", default-features = false } -time = "0.1.40" - -k256 = { version = "0.9", optional = true, features = ["ecdsa"] } -ripemd160 = { version = "0.9", optional = true } +subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } +tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } +toml = { version = "0.5", default-features = false } +url = { version = "2.2", default-features = false } +zeroize = { version = "1.1", default-features = false, features = ["zeroize_derive", "alloc"] } +flex-error = { version = "0.4.3", default-features = false } +time = { version = "0.1.40", default-features = false } +k256 = { version = "0.9", optional = true, default-features = false , features = ["ecdsa", "sha256"] } +ripemd160 = { version = "0.9", default-features = false , optional = true } [features] default = ["std", "eyre_tracer"] eyre_tracer = ["flex-error/eyre_tracer"] secp256k1 = ["k256", "ripemd160"] std = [ - "flex-error/std" + "flex-error/std", + "tendermint-proto/std", ] [dev-dependencies] diff --git a/tendermint/src/abci/code.rs b/tendermint/src/abci/code.rs index 6b0809447..5a10dedfc 100644 --- a/tendermint/src/abci/code.rs +++ b/tendermint/src/abci/code.rs @@ -1,6 +1,6 @@ +use core::fmt; use serde::de::{Deserialize, Deserializer, Visitor}; use serde::{Serialize, Serializer}; -use std::fmt; /// ABCI application response codes. /// diff --git a/tendermint/src/abci/data.rs b/tendermint/src/abci/data.rs index 99f9428e3..5fc93f00f 100644 --- a/tendermint/src/abci/data.rs +++ b/tendermint/src/abci/data.rs @@ -1,3 +1,4 @@ +use crate::prelude::*; use serde::{Deserialize, Serialize}; /// ABCI transaction data. @@ -30,6 +31,7 @@ impl Data { #[cfg(test)] mod tests { use crate::abci::Data; + use crate::prelude::*; #[test] fn test_deserialization() { diff --git a/tendermint/src/abci/gas.rs b/tendermint/src/abci/gas.rs index eae908fcc..af7721d27 100644 --- a/tendermint/src/abci/gas.rs +++ b/tendermint/src/abci/gas.rs @@ -6,11 +6,12 @@ //! use crate::error::Error; -use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::{ +use crate::prelude::*; +use core::{ fmt::{self, Display}, str::FromStr, }; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; /// Gas: representation of transaction processing resource costs #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)] diff --git a/tendermint/src/abci/info.rs b/tendermint/src/abci/info.rs index 684d79dc4..4d9692718 100644 --- a/tendermint/src/abci/info.rs +++ b/tendermint/src/abci/info.rs @@ -1,5 +1,6 @@ +use crate::prelude::*; +use core::fmt::{self, Display}; use serde::{Deserialize, Serialize}; -use std::fmt::{self, Display}; /// ABCI info #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] diff --git a/tendermint/src/abci/log.rs b/tendermint/src/abci/log.rs index e9fe570fd..10978d9ca 100644 --- a/tendermint/src/abci/log.rs +++ b/tendermint/src/abci/log.rs @@ -1,6 +1,7 @@ +use crate::prelude::*; +use core::fmt; +use core::fmt::Display; use serde::{Deserialize, Serialize}; -use std::fmt; -use std::fmt::Display; /// ABCI log data #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] diff --git a/tendermint/src/abci/path.rs b/tendermint/src/abci/path.rs index 09f63bea5..a49eabc3b 100644 --- a/tendermint/src/abci/path.rs +++ b/tendermint/src/abci/path.rs @@ -1,11 +1,12 @@ //! Paths to ABCI data use crate::error::Error; -use serde::{Deserialize, Serialize}; -use std::{ +use crate::prelude::*; +use core::{ fmt::{self, Display}, str::FromStr, }; +use serde::{Deserialize, Serialize}; /// Path to ABCI data #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] diff --git a/tendermint/src/abci/responses.rs b/tendermint/src/abci/responses.rs index 39e561eaa..4a112fcfa 100644 --- a/tendermint/src/abci/responses.rs +++ b/tendermint/src/abci/responses.rs @@ -1,9 +1,10 @@ //! ABCI response types used by the `/block_results` RPC endpoint. use super::{code::Code, data::Data, gas::Gas, info::Info, log::Log, tag::Tag}; +use crate::prelude::*; use crate::{consensus, serializers, validator}; +use core::fmt::{self, Display}; use serde::{Deserialize, Deserializer, Serialize}; -use std::fmt::{self, Display}; /// Responses for ABCI calls which occur during block processing. /// diff --git a/tendermint/src/abci/tag.rs b/tendermint/src/abci/tag.rs index e610c6d34..50601c5dd 100644 --- a/tendermint/src/abci/tag.rs +++ b/tendermint/src/abci/tag.rs @@ -1,8 +1,9 @@ //! Tags use crate::error::Error; +use crate::prelude::*; +use core::{fmt, str::FromStr}; use serde::{Deserialize, Serialize}; -use std::{fmt, str::FromStr}; use tendermint_proto::serializers::bytes::base64string; /// Tags diff --git a/tendermint/src/abci/transaction.rs b/tendermint/src/abci/transaction.rs index 90721d526..546a1026d 100644 --- a/tendermint/src/abci/transaction.rs +++ b/tendermint/src/abci/transaction.rs @@ -3,8 +3,9 @@ mod hash; pub use self::hash::{Hash, LENGTH as HASH_LENGTH}; +use crate::prelude::*; +use core::{fmt, slice}; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::{fmt, slice}; use subtle_encoding::base64; use tendermint_proto::types::Data as RawData; @@ -124,6 +125,7 @@ impl AsRef<[Transaction]> for Data { #[cfg(test)] mod tests { use super::Transaction; + use crate::prelude::*; #[test] fn upper_hex_serialization() { diff --git a/tendermint/src/abci/transaction/hash.rs b/tendermint/src/abci/transaction/hash.rs index 115c8317b..b9b00136f 100644 --- a/tendermint/src/abci/transaction/hash.rs +++ b/tendermint/src/abci/transaction/hash.rs @@ -1,11 +1,12 @@ //! Transaction hashes use crate::error::Error; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; -use std::{ +use crate::prelude::*; +use core::{ fmt::{self, Debug, Display}, str::FromStr, }; +use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use subtle::{self, ConstantTimeEq}; use subtle_encoding::hex; @@ -44,7 +45,7 @@ impl ConstantTimeEq for Hash { impl core::hash::Hash for Hash { fn hash(&self, hasher: &mut H) where - H: std::hash::Hasher, + H: core::hash::Hasher, { self.0.hash(hasher) } diff --git a/tendermint/src/account.rs b/tendermint/src/account.rs index b79691f7b..9eaf6219a 100644 --- a/tendermint/src/account.rs +++ b/tendermint/src/account.rs @@ -1,14 +1,15 @@ //! Tendermint accounts +use crate::prelude::*; use crate::{error::Error, public_key::Ed25519}; -use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; -use sha2::{Digest, Sha256}; -use std::{ - convert::TryInto, +use core::{ + convert::{TryFrom, TryInto}, fmt::{self, Debug, Display}, str::FromStr, }; +use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use sha2::{Digest, Sha256}; use subtle::{self, ConstantTimeEq}; use subtle_encoding::hex; @@ -16,7 +17,6 @@ use subtle_encoding::hex; use crate::public_key::Secp256k1; #[cfg(feature = "secp256k1")] use ripemd160::Ripemd160; -use std::convert::TryFrom; use tendermint_proto::Protobuf; /// Size of an account ID in bytes diff --git a/tendermint/src/block.rs b/tendermint/src/block.rs index fcc70ad7d..d16d29944 100644 --- a/tendermint/src/block.rs +++ b/tendermint/src/block.rs @@ -21,9 +21,10 @@ pub use self::{ round::*, size::Size, }; +use crate::prelude::*; use crate::{abci::transaction, error::Error, evidence}; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::types::Block as RawBlock; use tendermint_proto::Protobuf; @@ -32,7 +33,7 @@ use tendermint_proto::Protobuf; /// /// // Default serialization - all fields serialize; used by /block endpoint -#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] #[non_exhaustive] pub struct Block { /// Block header diff --git a/tendermint/src/block/commit.rs b/tendermint/src/block/commit.rs index f5e35c0c0..2ba3c2bc1 100644 --- a/tendermint/src/block/commit.rs +++ b/tendermint/src/block/commit.rs @@ -3,8 +3,9 @@ use crate::block::commit_sig::CommitSig; use crate::block::{Height, Id, Round}; use crate::error::Error; +use crate::prelude::*; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::types::Commit as RawCommit; /// Commit contains the justification (ie. a set of signatures) that a block was committed by a set diff --git a/tendermint/src/block/commit_sig.rs b/tendermint/src/block/commit_sig.rs index 0dd7d51e4..3d4a5a45f 100644 --- a/tendermint/src/block/commit_sig.rs +++ b/tendermint/src/block/commit_sig.rs @@ -1,9 +1,10 @@ //! CommitSig within Commit use crate::error::Error; +use crate::prelude::*; use crate::{account, Signature, Time}; +use core::convert::{TryFrom, TryInto}; use num_traits::ToPrimitive; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::types::BlockIdFlag; use tendermint_proto::types::CommitSig as RawCommitSig; diff --git a/tendermint/src/block/header.rs b/tendermint/src/block/header.rs index b9e73e0d9..dee08944d 100644 --- a/tendermint/src/block/header.rs +++ b/tendermint/src/block/header.rs @@ -1,9 +1,10 @@ //! Block headers use crate::merkle::simple_hash_from_byte_vectors; +use crate::prelude::*; use crate::{account, block, chain, AppHash, Error, Hash, Time}; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::types::Header as RawHeader; use tendermint_proto::version::Consensus as RawConsensusVersion; use tendermint_proto::Protobuf; diff --git a/tendermint/src/block/height.rs b/tendermint/src/block/height.rs index 2a50b734f..ecc21eddd 100644 --- a/tendermint/src/block/height.rs +++ b/tendermint/src/block/height.rs @@ -1,11 +1,11 @@ use crate::error::Error; -use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::convert::TryInto; -use std::{ - convert::TryFrom, +use crate::prelude::*; +use core::{ + convert::{TryFrom, TryInto}, fmt::{self, Debug, Display}, str::FromStr, }; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; use tendermint_proto::Protobuf; /// Block height for a particular chain (i.e. number of blocks created since diff --git a/tendermint/src/block/id.rs b/tendermint/src/block/id.rs index 881dc5b8d..a940a6a8f 100644 --- a/tendermint/src/block/id.rs +++ b/tendermint/src/block/id.rs @@ -1,14 +1,15 @@ +use crate::prelude::*; use crate::{ block::parts::Header as PartSetHeader, error::Error, hash::{Algorithm, Hash}, }; -use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; -use std::{ +use core::convert::{TryFrom, TryInto}; +use core::{ fmt::{self, Display}, str::{self, FromStr}, }; +use serde::{Deserialize, Serialize}; use tendermint_proto::types::{ BlockId as RawBlockId, CanonicalBlockId as RawCanonicalBlockId, PartSetHeader as RawPartSetHeader, diff --git a/tendermint/src/block/meta.rs b/tendermint/src/block/meta.rs index 2963e5dae..c46282f00 100644 --- a/tendermint/src/block/meta.rs +++ b/tendermint/src/block/meta.rs @@ -2,8 +2,9 @@ use super::{Header, Id}; use crate::error::Error; +use crate::prelude::*; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::types::BlockMeta as RawMeta; /// Block metadata - Todo: implement constructor and getters diff --git a/tendermint/src/block/parts.rs b/tendermint/src/block/parts.rs index b8479e4b8..07e171c72 100644 --- a/tendermint/src/block/parts.rs +++ b/tendermint/src/block/parts.rs @@ -3,9 +3,10 @@ use crate::error::Error; use crate::hash::Algorithm; use crate::hash::SHA256_HASH_SIZE; +use crate::prelude::*; use crate::Hash; +use core::convert::TryFrom; use serde::{Deserialize, Serialize}; -use std::convert::TryFrom; use tendermint_proto::types::{ CanonicalPartSetHeader as RawCanonicalPartSetHeader, PartSetHeader as RawPartSetHeader, }; diff --git a/tendermint/src/block/round.rs b/tendermint/src/block/round.rs index 6f42468ef..35b68b927 100644 --- a/tendermint/src/block/round.rs +++ b/tendermint/src/block/round.rs @@ -1,11 +1,12 @@ use crate::error::Error; -use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::convert::TryInto; -use std::{ +use crate::prelude::*; +use core::convert::TryInto; +use core::{ convert::TryFrom, fmt::{self, Debug, Display}, str::FromStr, }; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; /// Block round for a particular chain #[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] diff --git a/tendermint/src/block/signed_header.rs b/tendermint/src/block/signed_header.rs index 489a8d362..c3d8e23b5 100644 --- a/tendermint/src/block/signed_header.rs +++ b/tendermint/src/block/signed_header.rs @@ -2,8 +2,8 @@ //! It is what the rpc endpoint /commit returns and hence can be used by a //! light client. use crate::{block, Error}; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::{types::SignedHeader as RawSignedHeader, Protobuf}; /// Signed block headers diff --git a/tendermint/src/block/size.rs b/tendermint/src/block/size.rs index e29edfb58..0781e9058 100644 --- a/tendermint/src/block/size.rs +++ b/tendermint/src/block/size.rs @@ -1,7 +1,7 @@ //! Block size parameters use crate::error::Error; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::Protobuf; use { crate::serializers, diff --git a/tendermint/src/chain/id.rs b/tendermint/src/chain/id.rs index 312a7d89f..7bc1a6933 100644 --- a/tendermint/src/chain/id.rs +++ b/tendermint/src/chain/id.rs @@ -1,14 +1,15 @@ //! Tendermint blockchain identifiers use crate::error::Error; -use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::convert::TryFrom; -use std::{ +use crate::prelude::*; +use core::convert::TryFrom; +use core::{ cmp::Ordering, fmt::{self, Debug, Display}, hash::{Hash, Hasher}, str::{self, FromStr}, }; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; use tendermint_proto::Protobuf; /// Maximum length of a `chain::Id` name. Matches `MaxChainIDLen` from: diff --git a/tendermint/src/channel.rs b/tendermint/src/channel.rs index cba1268c9..190c8126a 100644 --- a/tendermint/src/channel.rs +++ b/tendermint/src/channel.rs @@ -3,9 +3,11 @@ mod id; pub use self::id::Id; + +use crate::prelude::*; use crate::serializers; -pub use serde::{Deserialize, Serialize}; -use std::fmt::{self, Display}; +use core::fmt::{self, Display}; +use serde::{Deserialize, Serialize}; /// Channels #[derive(Clone, Debug, Deserialize, Serialize)] diff --git a/tendermint/src/config.rs b/tendermint/src/config.rs index bf5e59bb2..c4d26abc1 100644 --- a/tendermint/src/config.rs +++ b/tendermint/src/config.rs @@ -11,14 +11,13 @@ mod priv_validator_key; pub use self::{node_key::NodeKey, priv_validator_key::PrivValidatorKey}; +use crate::prelude::*; use crate::{error::Error, genesis::Genesis, net, node, Moniker, Timeout}; +use alloc::collections::{btree_map, BTreeMap}; +use core::{fmt, str::FromStr}; use serde::{de, de::Error as _, ser, Deserialize, Serialize}; -use std::{ - collections::BTreeMap, - fmt, fs, - path::{Path, PathBuf}, - str::FromStr, -}; +use std::fs; +use std::path::{Path, PathBuf}; /// Tendermint `config.toml` file #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] @@ -189,7 +188,7 @@ impl LogLevel { } /// Iterator over log levels -pub type LogLevelIter<'a> = std::collections::btree_map::Iter<'a, String, String>; +pub type LogLevelIter<'a> = btree_map::Iter<'a, String, String>; impl FromStr for LogLevel { type Err = Error; diff --git a/tendermint/src/config/node_key.rs b/tendermint/src/config/node_key.rs index e1abe7e4a..b6361aecd 100644 --- a/tendermint/src/config/node_key.rs +++ b/tendermint/src/config/node_key.rs @@ -1,5 +1,6 @@ //! Node keys +use crate::prelude::*; use crate::{error::Error, node, private_key::PrivateKey, public_key::PublicKey}; use serde::{Deserialize, Serialize}; use std::{fs, path::Path}; diff --git a/tendermint/src/config/priv_validator_key.rs b/tendermint/src/config/priv_validator_key.rs index f6f3d7bc4..f9e157b77 100644 --- a/tendermint/src/config/priv_validator_key.rs +++ b/tendermint/src/config/priv_validator_key.rs @@ -1,5 +1,6 @@ //! Validator private keys +use crate::prelude::*; use crate::public_key::TendermintKey; use crate::{account, error::Error, private_key::PrivateKey, public_key::PublicKey}; use serde::{Deserialize, Serialize}; diff --git a/tendermint/src/consensus/params.rs b/tendermint/src/consensus/params.rs index 3408ffe5d..25e2af838 100644 --- a/tendermint/src/consensus/params.rs +++ b/tendermint/src/consensus/params.rs @@ -1,9 +1,10 @@ //! Tendermint consensus parameters use crate::error::Error; +use crate::prelude::*; use crate::{block, evidence, public_key}; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::abci::ConsensusParams as RawParams; use tendermint_proto::types::ValidatorParams as RawValidatorParams; use tendermint_proto::types::VersionParams as RawVersionParams; diff --git a/tendermint/src/consensus/state.rs b/tendermint/src/consensus/state.rs index 5b9cf7d44..8e7aa2fc6 100644 --- a/tendermint/src/consensus/state.rs +++ b/tendermint/src/consensus/state.rs @@ -1,8 +1,9 @@ //! Tendermint consensus state pub use crate::block; +use crate::prelude::*; +pub use core::{cmp::Ordering, fmt}; use serde::{Deserialize, Serialize}; -pub use std::{cmp::Ordering, fmt}; /// Placeholder string to show when block ID is absent. Syntax from: /// @@ -68,7 +69,7 @@ mod tests { use super::State; use crate::block; use crate::Hash; - use std::str::FromStr; + use core::str::FromStr; #[test] fn state_ord_test() { diff --git a/tendermint/src/error.rs b/tendermint/src/error.rs index 9dacc8669..d838bafb3 100644 --- a/tendermint/src/error.rs +++ b/tendermint/src/error.rs @@ -5,11 +5,11 @@ use crate::vote; use alloc::string::String; use core::num::TryFromIntError; use flex_error::{define_error, DisplayOnly}; +use serde::{Deserialize, Serialize}; use std::io::Error as IoError; -use time::OutOfRangeError; define_error! { - #[derive(Debug, Clone, PartialEq, Eq)] + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] Error { Crypto |_| { format_args!("cryptographic error") }, @@ -36,7 +36,7 @@ define_error! { ParseInt { data: String } - [ DisplayOnly] + [ DisplayOnly] | e | { format_args!("error parsing int data: {}", e.data) }, ParseUrl @@ -47,9 +47,11 @@ define_error! { { detail: String } |e| { format_args!("protocol error: {}", e.detail) }, - OutOfRange - [ DisplayOnly ] - |_| { format_args!("value out of range") }, + // When the oldtime feature is disabled, the chrono::oldtime::OutOfRangeError + // type is private and cannot be referred: + // https://github.com/chronotope/chrono/pull/541 + DurationOutOfRange + |_| { format_args!("duration value out of range") }, EmptySignature |_| { format_args!("empty signature") }, diff --git a/tendermint/src/evidence.rs b/tendermint/src/evidence.rs index 1aca9db12..5e551eb9e 100644 --- a/tendermint/src/evidence.rs +++ b/tendermint/src/evidence.rs @@ -1,11 +1,12 @@ //! Evidence of malfeasance by validators (i.e. signing conflicting votes). +use crate::prelude::*; use crate::{ block::signed_header::SignedHeader, error::Error, serializers, vote::Power, Time, Vote, }; +use core::convert::{TryFrom, TryInto}; +use core::slice; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; -use std::slice; use tendermint_proto::google::protobuf::Duration as RawDuration; use tendermint_proto::types::evidence::Sum as RawSum; use tendermint_proto::types::evidence::Sum; @@ -251,16 +252,16 @@ impl From for RawEvidenceParams { } } -/// Duration is a wrapper around std::time::Duration +/// Duration is a wrapper around core::time::Duration /// essentially, to keep the usages look cleaner /// i.e. you can avoid using serde annotations everywhere -/// Todo: harmonize google::protobuf::Duration, std::time::Duration and this. Too many structs. +/// Todo: harmonize google::protobuf::Duration, core::time::Duration and this. Too many structs. /// #[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] -pub struct Duration(#[serde(with = "serializers::time_duration")] pub std::time::Duration); +pub struct Duration(#[serde(with = "serializers::time_duration")] pub core::time::Duration); -impl From for std::time::Duration { - fn from(d: Duration) -> std::time::Duration { +impl From for core::time::Duration { + fn from(d: Duration) -> core::time::Duration { d.0 } } @@ -271,7 +272,7 @@ impl TryFrom for Duration { type Error = Error; fn try_from(value: RawDuration) -> Result { - Ok(Self(std::time::Duration::new( + Ok(Self(core::time::Duration::new( value.seconds.try_into().map_err(Error::integer_overflow)?, value.nanos.try_into().map_err(Error::integer_overflow)?, ))) diff --git a/tendermint/src/genesis.rs b/tendermint/src/genesis.rs index 6701ced55..83aca31e6 100644 --- a/tendermint/src/genesis.rs +++ b/tendermint/src/genesis.rs @@ -1,5 +1,6 @@ //! Genesis data +use crate::prelude::*; use crate::serializers; use crate::{chain, consensus, validator, Time}; use serde::{Deserialize, Serialize}; diff --git a/tendermint/src/hash.rs b/tendermint/src/hash.rs index 650660af8..237e640d4 100644 --- a/tendermint/src/hash.rs +++ b/tendermint/src/hash.rs @@ -1,13 +1,14 @@ //! Hash functions and their outputs use crate::error::Error; -use serde::de::Error as _; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::convert::TryFrom; -use std::{ +use crate::prelude::*; +use core::convert::TryFrom; +use core::{ fmt::{self, Debug, Display}, str::FromStr, }; +use serde::de::Error as _; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; use subtle_encoding::{Encoding, Hex}; use tendermint_proto::Protobuf; diff --git a/tendermint/src/lib.rs b/tendermint/src/lib.rs index cfe2badda..eac4c8848 100644 --- a/tendermint/src/lib.rs +++ b/tendermint/src/lib.rs @@ -4,6 +4,7 @@ //! blockchain networks, including chain information types, secret connections, //! and remote procedure calls (JSON-RPC). +#![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] #![deny( warnings, @@ -19,6 +20,7 @@ )] extern crate alloc; +extern crate std; #[macro_use] pub mod error; @@ -37,6 +39,7 @@ pub mod merkle; mod moniker; pub mod net; pub mod node; +mod prelude; pub mod private_key; pub mod proposal; pub mod public_key; diff --git a/tendermint/src/merkle.rs b/tendermint/src/merkle.rs index 67d05b418..72bebf857 100644 --- a/tendermint/src/merkle.rs +++ b/tendermint/src/merkle.rs @@ -2,6 +2,7 @@ pub mod proof; +use crate::prelude::*; use sha2::{Digest, Sha256}; /// Size of Merkle root hash diff --git a/tendermint/src/merkle/proof.rs b/tendermint/src/merkle/proof.rs index 9ae747f66..ccd8bf33b 100644 --- a/tendermint/src/merkle/proof.rs +++ b/tendermint/src/merkle/proof.rs @@ -1,11 +1,12 @@ //! Merkle proofs +use core::convert::TryFrom; use serde::{Deserialize, Serialize}; -use std::convert::TryFrom; use tendermint_proto::crypto::ProofOp as RawProofOp; use tendermint_proto::crypto::ProofOps as RawProofOps; use tendermint_proto::Protobuf; +use crate::prelude::*; use crate::serializers; use crate::Error; diff --git a/tendermint/src/moniker.rs b/tendermint/src/moniker.rs index b5ca283da..1665f3d36 100644 --- a/tendermint/src/moniker.rs +++ b/tendermint/src/moniker.rs @@ -1,11 +1,12 @@ //! Monikers: names associated with validators use crate::error::Error; -use serde::{Deserialize, Serialize}; -use std::{ +use crate::prelude::*; +use core::{ fmt::{self, Display}, str::FromStr, }; +use serde::{Deserialize, Serialize}; /// Validator display names #[derive(Serialize, Deserialize, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] diff --git a/tendermint/src/net.rs b/tendermint/src/net.rs index 6e9c4ceff..4c33512b6 100644 --- a/tendermint/src/net.rs +++ b/tendermint/src/net.rs @@ -1,13 +1,14 @@ //! Remote addresses (`tcp://` or `unix://`) +use crate::prelude::*; use crate::{error::Error, node}; -use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; -use std::{ +use core::{ fmt::{self, Display}, - path::PathBuf, str::{self, FromStr}, }; +use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; +use std::path::PathBuf; use url::Url; /// URI prefix for TCP connections diff --git a/tendermint/src/node/id.rs b/tendermint/src/node/id.rs index 160953c7a..7cac17fab 100644 --- a/tendermint/src/node/id.rs +++ b/tendermint/src/node/id.rs @@ -1,6 +1,6 @@ //! Tendermint node IDs -use std::{ +use core::{ convert::TryFrom, fmt::{self, Debug, Display}, str::FromStr, @@ -11,6 +11,7 @@ use sha2::{Digest, Sha256}; use subtle::{self, ConstantTimeEq}; use subtle_encoding::hex; +use crate::prelude::*; use crate::{ error::Error, public_key::{Ed25519, PublicKey}, diff --git a/tendermint/src/node/info.rs b/tendermint/src/node/info.rs index 427813629..f0517b068 100644 --- a/tendermint/src/node/info.rs +++ b/tendermint/src/node/info.rs @@ -1,8 +1,9 @@ //! Node information (used in RPC responses) +use crate::prelude::*; use crate::{chain, channel::Channels, net, node, serializers, Moniker, Version}; +use core::fmt::{self, Display}; use serde::{Deserialize, Serialize}; -use std::fmt::{self, Display}; /// Node information #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] diff --git a/tendermint/src/prelude.rs b/tendermint/src/prelude.rs new file mode 100644 index 000000000..9ff42a989 --- /dev/null +++ b/tendermint/src/prelude.rs @@ -0,0 +1,11 @@ +pub use core::prelude::v1::*; + +// Re-export according to alloc::prelude::v1 because it is not yet stabilized +// https://doc.rust-lang.org/src/alloc/prelude/v1.rs.html +pub use alloc::borrow::ToOwned; +pub use alloc::boxed::Box; +pub use alloc::string::{String, ToString}; +pub use alloc::vec::Vec; + +pub use alloc::format; +pub use alloc::vec; diff --git a/tendermint/src/private_key.rs b/tendermint/src/private_key.rs index dfd6369c7..7d4280bfc 100644 --- a/tendermint/src/private_key.rs +++ b/tendermint/src/private_key.rs @@ -2,6 +2,7 @@ pub use ed25519_dalek::{Keypair as Ed25519, EXPANDED_SECRET_KEY_LENGTH as ED25519_KEYPAIR_SIZE}; +use crate::prelude::*; use crate::public_key::PublicKey; use serde::{de, ser, Deserialize, Serialize}; use subtle_encoding::{Base64, Encoding}; diff --git a/tendermint/src/proposal.rs b/tendermint/src/proposal.rs index c0984d46b..0d3eae4f4 100644 --- a/tendermint/src/proposal.rs +++ b/tendermint/src/proposal.rs @@ -12,10 +12,11 @@ use crate::block::{Height, Id as BlockId, Round}; use crate::chain::Id as ChainId; use crate::consensus::State; use crate::error::Error; +use crate::prelude::*; use crate::Signature; use crate::Time; use bytes::BufMut; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::types::Proposal as RawProposal; use tendermint_proto::{Error as ProtobufError, Protobuf}; @@ -118,11 +119,12 @@ mod tests { use crate::block::{Height, Round}; use crate::chain::Id as ChainId; use crate::hash::{Algorithm, Hash}; + use crate::prelude::*; use crate::proposal::SignProposalRequest; use crate::signature::{Ed25519Signature, ED25519_SIGNATURE_SIZE}; use crate::{proposal::Type, Proposal, Signature}; use chrono::{DateTime, Utc}; - use std::str::FromStr; + use core::str::FromStr; use tendermint_proto::Protobuf; #[test] diff --git a/tendermint/src/proposal/canonical_proposal.rs b/tendermint/src/proposal/canonical_proposal.rs index 13de36f93..3023c6c31 100644 --- a/tendermint/src/proposal/canonical_proposal.rs +++ b/tendermint/src/proposal/canonical_proposal.rs @@ -4,8 +4,9 @@ use super::Type; use crate::block::{Height, Id as BlockId, Round}; use crate::chain::Id as ChainId; use crate::error::Error; +use crate::prelude::*; use crate::Time; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::types::CanonicalProposal as RawCanonicalProposal; use tendermint_proto::Protobuf; @@ -96,9 +97,10 @@ impl CanonicalProposal { #[cfg(test)] mod tests { + use crate::prelude::*; use crate::proposal::canonical_proposal::CanonicalProposal; use crate::proposal::Type; - use std::convert::TryFrom; + use core::convert::TryFrom; use tendermint_proto::types::CanonicalBlockId as RawCanonicalBlockId; use tendermint_proto::types::CanonicalPartSetHeader as RawCanonicalPartSetHeader; use tendermint_proto::types::CanonicalProposal as RawCanonicalProposal; diff --git a/tendermint/src/proposal/msg_type.rs b/tendermint/src/proposal/msg_type.rs index e06319944..7c0b95253 100644 --- a/tendermint/src/proposal/msg_type.rs +++ b/tendermint/src/proposal/msg_type.rs @@ -1,7 +1,8 @@ use crate::error::Error; +use crate::prelude::*; +use core::convert::TryFrom; use serde::de::Error as _; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::convert::TryFrom; use tendermint_proto::Protobuf; /// Types of proposals diff --git a/tendermint/src/proposal/sign_proposal.rs b/tendermint/src/proposal/sign_proposal.rs index e8a23e70a..ddcf7fb0b 100644 --- a/tendermint/src/proposal/sign_proposal.rs +++ b/tendermint/src/proposal/sign_proposal.rs @@ -1,8 +1,9 @@ use super::Proposal; use crate::chain::Id as ChainId; use crate::error::Error; +use crate::prelude::*; use bytes::BufMut; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::privval::RemoteSignerError; use tendermint_proto::privval::SignProposalRequest as RawSignProposalRequest; use tendermint_proto::privval::SignedProposalResponse as RawSignedProposalResponse; diff --git a/tendermint/src/public_key.rs b/tendermint/src/public_key.rs index 837a12ffa..b8a515880 100644 --- a/tendermint/src/public_key.rs +++ b/tendermint/src/public_key.rs @@ -9,11 +9,12 @@ mod pub_key_response; pub use pub_key_request::PubKeyRequest; pub use pub_key_response::PubKeyResponse; +use crate::prelude::*; use crate::{error::Error, signature::Signature}; +use core::convert::TryFrom; +use core::{cmp::Ordering, fmt, ops::Deref, str::FromStr}; use serde::{de, ser, Deserialize, Serialize}; use signature::Verifier as _; -use std::convert::TryFrom; -use std::{cmp::Ordering, fmt, ops::Deref, str::FromStr}; use subtle_encoding::{base64, bech32, hex}; use tendermint_proto::crypto::public_key::Sum; use tendermint_proto::crypto::PublicKey as RawPublicKey; @@ -375,9 +376,10 @@ where #[cfg(test)] mod tests { - use std::convert::TryFrom; + use core::convert::TryFrom; use super::{PublicKey, Signature, TendermintKey}; + use crate::prelude::*; use crate::public_key::PubKeyResponse; use subtle_encoding::hex; use tendermint_proto::Protobuf; diff --git a/tendermint/src/public_key/pub_key_request.rs b/tendermint/src/public_key/pub_key_request.rs index 6632c8586..a1564e49c 100644 --- a/tendermint/src/public_key/pub_key_request.rs +++ b/tendermint/src/public_key/pub_key_request.rs @@ -1,6 +1,7 @@ use crate::chain::Id as ChainId; +use crate::prelude::*; use crate::Error; -use std::convert::TryFrom; +use core::convert::TryFrom; use tendermint_proto::privval::PubKeyRequest as RawPubKeyRequest; use tendermint_proto::Protobuf; @@ -35,7 +36,8 @@ impl From for RawPubKeyRequest { mod tests { use super::PubKeyRequest; use crate::chain::Id as ChainId; - use std::str::FromStr; + use crate::prelude::*; + use core::str::FromStr; use tendermint_proto::Protobuf; #[test] diff --git a/tendermint/src/public_key/pub_key_response.rs b/tendermint/src/public_key/pub_key_response.rs index b58292df1..0a65b7eda 100644 --- a/tendermint/src/public_key/pub_key_response.rs +++ b/tendermint/src/public_key/pub_key_response.rs @@ -1,5 +1,5 @@ use crate::{Error, PublicKey}; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::privval::{PubKeyResponse as RawPubKeyResponse, RemoteSignerError}; use tendermint_proto::Protobuf; diff --git a/tendermint/src/serializers/apphash.rs b/tendermint/src/serializers/apphash.rs index 7fca8b261..94162123a 100644 --- a/tendermint/src/serializers/apphash.rs +++ b/tendermint/src/serializers/apphash.rs @@ -1,5 +1,6 @@ //! AppHash serialization with validation +use crate::prelude::*; use crate::AppHash; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::hex; diff --git a/tendermint/src/serializers/hash.rs b/tendermint/src/serializers/hash.rs index abc349da8..78299add9 100644 --- a/tendermint/src/serializers/hash.rs +++ b/tendermint/src/serializers/hash.rs @@ -1,5 +1,6 @@ //! Hash serialization with validation +use crate::prelude::*; use crate::{hash::Algorithm, Hash}; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::hex; diff --git a/tendermint/src/serializers/hash_base64.rs b/tendermint/src/serializers/hash_base64.rs index 7d4558441..5409ef39d 100644 --- a/tendermint/src/serializers/hash_base64.rs +++ b/tendermint/src/serializers/hash_base64.rs @@ -1,6 +1,7 @@ //! Encoding/decoding ABCI transaction hashes to/from base64. use crate::abci::transaction::{Hash, HASH_LENGTH}; +use crate::prelude::*; use serde::{Deserialize, Deserializer, Serializer}; use subtle_encoding::base64; diff --git a/tendermint/src/serializers/time.rs b/tendermint/src/serializers/time.rs index e61639729..940a9e6b1 100644 --- a/tendermint/src/serializers/time.rs +++ b/tendermint/src/serializers/time.rs @@ -2,6 +2,7 @@ //! RFC3339-compatible timestamps to that provided by the `tendermint-proto` //! crate. +use crate::prelude::*; use crate::Time; use serde::{Deserialize, Deserializer, Serialize, Serializer}; diff --git a/tendermint/src/signature.rs b/tendermint/src/signature.rs index ed6a031d3..63b5e1327 100644 --- a/tendermint/src/signature.rs +++ b/tendermint/src/signature.rs @@ -6,7 +6,8 @@ pub use signature::{Signer, Verifier}; #[cfg(feature = "secp256k1")] pub use k256::ecdsa::Signature as Secp256k1Signature; -use std::convert::TryFrom; +use crate::prelude::*; +use core::convert::TryFrom; use tendermint_proto::Protobuf; use crate::error::Error; diff --git a/tendermint/src/test.rs b/tendermint/src/test.rs index f3ed0a766..fc8c868bb 100644 --- a/tendermint/src/test.rs +++ b/tendermint/src/test.rs @@ -1,5 +1,5 @@ +use core::fmt::Debug; use serde::{de::DeserializeOwned, Serialize}; -use std::fmt::Debug; /// Test that a struct `T` can be: /// diff --git a/tendermint/src/time.rs b/tendermint/src/time.rs index 35dc12103..a85714adc 100644 --- a/tendermint/src/time.rs +++ b/tendermint/src/time.rs @@ -3,10 +3,12 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use std::fmt; -use std::ops::{Add, Sub}; -use std::str::FromStr; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use crate::prelude::*; +use core::fmt; +use core::ops::{Add, Sub}; +use core::str::FromStr; +use core::time::Duration; +use std::time::{SystemTime, UNIX_EPOCH}; use tendermint_proto::google::protobuf::Timestamp; use tendermint_proto::serializers::timestamp; use tendermint_proto::Protobuf; @@ -58,12 +60,12 @@ impl Time { } /// Calculate the amount of time which has passed since another [`Time`] - /// as a [`std::time::Duration`] + /// as a [`core::time::Duration`] pub fn duration_since(&self, other: Time) -> Result { self.0 .signed_duration_since(other.0) .to_std() - .map_err(Error::out_of_range) + .map_err(|_| Error::duration_out_of_range()) } /// Parse [`Time`] from an RFC 3339 date diff --git a/tendermint/src/timeout.rs b/tendermint/src/timeout.rs index d4e75e939..91e4672e7 100644 --- a/tendermint/src/timeout.rs +++ b/tendermint/src/timeout.rs @@ -1,7 +1,8 @@ use crate::error::Error; +use crate::prelude::*; +use core::{fmt, ops::Deref, str::FromStr, time::Duration}; use serde::{de, de::Error as _, ser, Deserialize, Serialize}; -use std::{fmt, ops::Deref, str::FromStr, time::Duration}; /// Timeout durations #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] diff --git a/tendermint/src/trust_threshold.rs b/tendermint/src/trust_threshold.rs index 1f9583540..c237b6f05 100644 --- a/tendermint/src/trust_threshold.rs +++ b/tendermint/src/trust_threshold.rs @@ -1,11 +1,12 @@ //! Define traits and instances for dealing with trust thresholds. -use std::fmt::{self, Debug, Display}; +use core::fmt::{self, Debug, Display}; use crate::error::Error; +use crate::prelude::*; use crate::serializers; +use core::convert::TryFrom; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use std::convert::TryFrom; /// TrustThreshold defines how much of the total voting power of a known /// and trusted validator set is sufficient for a commit to be diff --git a/tendermint/src/validator.rs b/tendermint/src/validator.rs index 2709e0300..67083361c 100644 --- a/tendermint/src/validator.rs +++ b/tendermint/src/validator.rs @@ -3,9 +3,10 @@ use serde::{de::Error as _, Deserialize, Deserializer, Serialize}; use subtle_encoding::base64; +use crate::prelude::*; use crate::{account, hash::Hash, merkle, vote, Error, PublicKey, Signature}; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::types::SimpleValidator as RawSimpleValidator; use tendermint_proto::types::Validator as RawValidator; use tendermint_proto::types::ValidatorSet as RawValidatorSet; @@ -117,7 +118,7 @@ impl Set { /// Sort the validators according to the current Tendermint requirements /// (v. 0.34 -> first by validator power, descending, then by address, ascending) fn sort_validators(vals: &mut Vec) { - vals.sort_by_key(|v| (std::cmp::Reverse(v.power), v.address)); + vals.sort_by_key(|v| (core::cmp::Reverse(v.power), v.address)); } /// Returns the validator with the given Id if its in the Set. diff --git a/tendermint/src/version.rs b/tendermint/src/version.rs index c8189cc44..e262c2e42 100644 --- a/tendermint/src/version.rs +++ b/tendermint/src/version.rs @@ -1,5 +1,6 @@ +use crate::prelude::*; +use core::fmt::{self, Debug, Display}; use serde::{Deserialize, Serialize}; -use std::fmt::{self, Debug, Display}; /// Tendermint version #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] diff --git a/tendermint/src/vote.rs b/tendermint/src/vote.rs index d2672c7c3..eb25c9080 100644 --- a/tendermint/src/vote.rs +++ b/tendermint/src/vote.rs @@ -10,9 +10,9 @@ pub use self::power::Power; pub use self::sign_vote::*; pub use self::validator_index::ValidatorIndex; -use std::convert::{TryFrom, TryInto}; -use std::fmt; -use std::str::FromStr; +use core::convert::{TryFrom, TryInto}; +use core::fmt; +use core::str::FromStr; use bytes::BufMut; use ed25519::Signature as Ed25519Signature; @@ -26,6 +26,7 @@ use crate::chain::Id as ChainId; use crate::consensus::State; use crate::error::Error; use crate::hash; +use crate::prelude::*; use crate::{account, block, Signature, Time}; /// Votes are signed messages from validators for a particular block which diff --git a/tendermint/src/vote/canonical_vote.rs b/tendermint/src/vote/canonical_vote.rs index 92cfa6e62..46c185f32 100644 --- a/tendermint/src/vote/canonical_vote.rs +++ b/tendermint/src/vote/canonical_vote.rs @@ -1,8 +1,9 @@ use crate::chain::Id as ChainId; use crate::error::Error; +use crate::prelude::*; use crate::{block, Time}; +use core::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; use tendermint_proto::types::CanonicalVote as RawCanonicalVote; use tendermint_proto::Protobuf; @@ -87,9 +88,10 @@ impl CanonicalVote { #[cfg(test)] mod tests { + use crate::prelude::*; use crate::vote::canonical_vote::CanonicalVote; use crate::vote::Type; - use std::convert::TryFrom; + use core::convert::TryFrom; use tendermint_proto::google::protobuf::Timestamp; use tendermint_proto::types::CanonicalBlockId as RawCanonicalBlockId; use tendermint_proto::types::CanonicalPartSetHeader as RawCanonicalPartSetHeader; diff --git a/tendermint/src/vote/power.rs b/tendermint/src/vote/power.rs index 86b4bc09e..2499d3335 100644 --- a/tendermint/src/vote/power.rs +++ b/tendermint/src/vote/power.rs @@ -1,11 +1,12 @@ //! Voting power -use std::convert::{TryFrom, TryInto}; -use std::fmt; +use core::convert::{TryFrom, TryInto}; +use core::fmt; use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; use crate::error::Error; +use crate::prelude::*; /// Voting power #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Default)] diff --git a/tendermint/src/vote/sign_vote.rs b/tendermint/src/vote/sign_vote.rs index a954f2bb1..28347a2b7 100644 --- a/tendermint/src/vote/sign_vote.rs +++ b/tendermint/src/vote/sign_vote.rs @@ -1,8 +1,9 @@ use crate::chain; use crate::error::Error; +use crate::prelude::*; use crate::Vote; use bytes::BufMut; -use std::convert::{TryFrom, TryInto}; +use core::convert::{TryFrom, TryInto}; use tendermint_proto::privval::SignedVoteResponse as RawSignedVoteResponse; use tendermint_proto::privval::{RemoteSignerError, SignVoteRequest as RawSignVoteRequest}; use tendermint_proto::Error as ProtobufError; @@ -96,14 +97,16 @@ mod tests { use crate::block::Round; use crate::chain::Id as ChainId; use crate::hash::Algorithm; + use crate::prelude::*; use crate::signature::{Signature, ED25519_SIGNATURE_SIZE}; use crate::vote::{CanonicalVote, ValidatorIndex}; use crate::vote::{SignVoteRequest, Type}; use crate::Hash; use crate::Vote; use chrono::{DateTime, Utc}; - use std::convert::TryFrom; - use std::str::FromStr; + use core::convert::TryFrom; + use core::str::FromStr; + use std::println; use tendermint_proto::Protobuf; #[test] diff --git a/tendermint/src/vote/validator_index.rs b/tendermint/src/vote/validator_index.rs index e11ad1834..6643d31b3 100644 --- a/tendermint/src/vote/validator_index.rs +++ b/tendermint/src/vote/validator_index.rs @@ -1,7 +1,7 @@ use crate::error::Error; -use std::convert::TryInto; -use std::{ - convert::TryFrom, +use crate::prelude::*; +use core::{ + convert::{TryFrom, TryInto}, fmt::{self, Debug, Display}, str::FromStr, }; diff --git a/test/Cargo.toml b/test/Cargo.toml index 4c5fdf8c9..be15c2447 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -15,7 +15,7 @@ test = true [dev-dependencies] ed25519-dalek = "1" -flex-error = "0.4.2" +flex-error = "0.4.3" flume = "0.10" rand_core = { version = "0.5", features = ["std"] } readwrite = "^0.1.1" From 86ff845de27902dff7954c6a85f4824bfaa1d6be Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 30 Sep 2021 14:40:51 +0200 Subject: [PATCH 02/18] Disable default-features for all dependencies --- abci/Cargo.toml | 12 ++++++------ light-client-js/Cargo.toml | 18 ++++++++--------- light-client/Cargo.toml | 40 +++++++++++++++++++++----------------- p2p/Cargo.toml | 36 +++++++++++++++++----------------- p2p/src/error.rs | 2 +- pbt-gen/Cargo.toml | 2 +- proto/Cargo.toml | 2 +- rpc/Cargo.toml | 26 ++++++++++++------------- tendermint/Cargo.toml | 12 ++++++------ test/Cargo.toml | 20 +++++++++---------- testgen/Cargo.toml | 16 +++++++-------- 11 files changed, 95 insertions(+), 91 deletions(-) diff --git a/abci/Cargo.toml b/abci/Cargo.toml index 4a8e4c492..9b74a40d5 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -32,11 +32,11 @@ std = [ ] [dependencies] -bytes = "1.0" -prost = "0.7" -tendermint-proto = { version = "0.22.0", path = "../proto" } -tracing = "0.1" +bytes = { version = "1.0", default-features = false } +prost = { version = "0.7", default-features = false } +tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } +tracing = { version = "0.1", default-features = false } flex-error = { version = "0.4.3", default-features = false } -structopt = { version = "0.3", optional = true } -tracing-subscriber = { version = "0.2", optional = true } +structopt = { version = "0.3", optional = true, default-features = false } +tracing-subscriber = { version = "0.2", optional = true, default-features = false } diff --git a/light-client-js/Cargo.toml b/light-client-js/Cargo.toml index 0bda61054..f047decc3 100644 --- a/light-client-js/Cargo.toml +++ b/light-client-js/Cargo.toml @@ -20,26 +20,26 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -serde = { version = "1.0", features = [ "derive" ] } -serde_json = "1.0" +serde = { version = "1.0", default-features = false, features = [ "derive" ] } +serde_json = { version = "1.0", default-features = false } # TODO(thane): Remove once https://github.com/rustwasm/wasm-bindgen/issues/2508 is resolved -syn = "=1.0.65" -tendermint = { version = "0.22.0", path = "../tendermint" } -tendermint-light-client = { version = "0.22.0", path = "../light-client", default-features = false } -wasm-bindgen = { version = "0.2.63", features = [ "serde-serialize" ] } +syn = { version = "=1.0.65", default-features = false } +tendermint = { version = "0.22.0", default-features = false, path = "../tendermint" } +tendermint-light-client = { version = "0.22.0", default-features = false, path = "../light-client" } +wasm-bindgen = { version = "0.2.63", default-features = false, features = [ "serde-serialize" ] } # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for # code size when deploying. -console_error_panic_hook = { version = "0.1.6", optional = true } +console_error_panic_hook = { version = "0.1.6", default-features = false, optional = true } # `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size # compared to the default allocator's ~10K. It is slower than the default # allocator, however. # # Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. -wee_alloc = { version = "0.4.5", optional = true } +wee_alloc = { version = "0.4.5", default-features = false, optional = true } [dev-dependencies] -wasm-bindgen-test = "0.3.13" +wasm-bindgen-test = { version = "0.3.13", default-features = false } diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 3c7705e10..20db0aeae 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -42,26 +42,30 @@ std = [ mbt = [] [dependencies] -tendermint = { version = "0.22.0", path = "../tendermint" } -tendermint-rpc = { version = "0.22.0", path = "../rpc", default-features = false } +tendermint = { version = "0.22.0", path = "../tendermint", default-features = false } +tendermint-rpc = { version = "0.22.0", path = "../rpc", default-features = false, features = ["http-client"] } -contracts = "0.4.0" -crossbeam-channel = "0.4.2" -derive_more = "0.99.5" -futures = "0.3.4" -serde = "1.0.106" -serde_cbor = "0.11.1" -serde_derive = "1.0.106" -sled = { version = "0.34.3", optional = true } -static_assertions = "1.1.0" -tokio = { version = "1.0", features = ["rt"], optional = true } +contracts = { version = "0.4.0", default-features = false } +crossbeam-channel = { version = "0.4.2", default-features = false } +derive_more = { version = "0.99.5", default-features = false, features = ["display"] } +futures = { version = "0.3.4", default-features = false } +serde = { version = "1.0.106", default-features = false } +serde_cbor = { version = "0.11.1", default-features = false, features = ["alloc", "std"] } +serde_derive = { version = "1.0.106", default-features = false } +sled = { version = "0.34.3", optional = true, default-features = false } +static_assertions = { version = "1.1.0", default-features = false } +tokio = { version = "1.0", default-features = false, features = ["rt"], optional = true } flex-error = { version = "0.4.3", default-features = false } [dev-dependencies] -tendermint-testgen = { path = "../testgen" } +tendermint-testgen = { path = "../testgen", default-features = false } -serde_json = "1.0.51" -gumdrop = "0.8.0" -rand = "0.7.3" -tempfile = "3.2.0" -proptest = "0.10.1" +serde_json = { version = "1.0.51", default-features = false } +gumdrop = { version = "0.8.0", default-features = false } +rand = { version = "0.7.3", default-features = false } +tempfile = { version = "3.2.0", default-features = false } +proptest = { version = "0.10.1", default-features = false, features = ["std"] } + +[[example]] +name = "light_client" +required-features = ["rpc-client"] diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 59c779002..99c0e82d3 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -31,26 +31,26 @@ std = [ ] [dependencies] -chacha20poly1305 = "0.8" -ed25519-dalek = "1" -eyre = "0.6" -flume = "0.10.7" -hkdf = "0.10.0" -merlin = "2" -prost = "0.7" -rand_core = { version = "0.5", features = ["std"] } -sha2 = "0.9" -subtle = "2" -x25519-dalek = "1.1" -zeroize = "1" -signature = "1.3.0" -aead = "0.4.1" +chacha20poly1305 = { version = "0.8", default-features = false, features = ["reduced-round"] } +ed25519-dalek = { version = "1", default-features = false } +eyre = { version = "0.6", default-features = false } +flume = { version = "0.10.7", default-features = false } +hkdf = { version = "0.10.0", default-features = false } +merlin = { version = "2", default-features = false } +prost = { version = "0.7", default-features = false } +rand_core = { version = "0.5", default-features = false, features = ["std"] } +sha2 = { version = "0.9", default-features = false } +subtle = { version = "2", default-features = false } +x25519-dalek = { version = "1.1", default-features = false } +zeroize = { version = "1", default-features = false } +signature = { version = "1.3.0", default-features = false } +aead = { version = "0.4.1", default-features = false } flex-error = { version = "0.4.3", default-features = false } # path dependencies -tendermint = { path = "../tendermint", version = "0.22.0" } -tendermint-proto = { path = "../proto", version = "0.22.0" } -tendermint-std-ext = { path = "../std-ext", version = "0.22.0" } +tendermint = { path = "../tendermint", version = "0.22.0", default-features = false } +tendermint-proto = { path = "../proto", version = "0.22.0", default-features = false } +tendermint-std-ext = { path = "../std-ext", version = "0.22.0", default-features = false } # optional dependencies -prost-derive = { version = "0.7", optional = true } +prost-derive = { version = "0.7", optional = true, default-features = false } diff --git a/p2p/src/error.rs b/p2p/src/error.rs index 3a33aadbe..3b1baa89c 100644 --- a/p2p/src/error.rs +++ b/p2p/src/error.rs @@ -36,7 +36,7 @@ define_error! { | _ | { "public key missing" }, Signature - [ TraceError ] + [ DisplayError ] | _ | { "signature error" }, UnsupportedKey diff --git a/pbt-gen/Cargo.toml b/pbt-gen/Cargo.toml index fdd13f3f1..17432ae96 100644 --- a/pbt-gen/Cargo.toml +++ b/pbt-gen/Cargo.toml @@ -21,4 +21,4 @@ time = ["chrono"] [dependencies] chrono = { version = "0.4", default-features = false, features = ["serde"], optional = true} -proptest = "0.10.1" +proptest = { version = "0.10.1", default-features = false } diff --git a/proto/Cargo.toml b/proto/Cargo.toml index cda1410a6..6903bb55c 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -29,7 +29,7 @@ chrono = { version = "0.4", default-features = false, features = ["serde", "cloc flex-error = { version = "0.4.3", default-features = false } [dev-dependencies] -serde_json = "1.0" +serde_json = { version = "1.0", default-features = false } [features] default = ["std", "eyre_tracer"] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 64209d2b2..58cfdf9f6 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -85,18 +85,18 @@ walkdir = { version = "2.3", default-features = false } flex-error = { version = "0.4.3", default-features = false } # Optional dependencies -async-trait = { version = "0.1", optional = true } -async-tungstenite = { version = "0.12", features = ["tokio-runtime", "tokio-rustls"], optional = true } -futures = { version = "0.3", optional = true } -http = { version = "0.2", optional = true } -hyper = { version = "0.14", optional = true, features = ["client", "http1", "http2", "tcp"] } -hyper-proxy = { version = "0.9", optional = true } -hyper-rustls = { version = "0.22.1", optional = true } -structopt = { version = "0.3", optional = true } -tokio = { version = "1.0", optional = true, features = ["rt-multi-thread"] } -tracing = { version = "0.1", optional = true } -tracing-subscriber = { version = "0.2", optional = true } +async-trait = { version = "0.1", optional = true, default-features = false } +async-tungstenite = { version = "0.12", default-features = false, features = ["tokio-runtime", "tokio-rustls"], optional = true } +futures = { version = "0.3", optional = true, default-features = false } +http = { version = "0.2", optional = true, default-features = false } +hyper = { version = "0.14", optional = true, default-features = false, features = ["client", "http1", "http2", "tcp"] } +hyper-proxy = { version = "0.9", optional = true, default-features = false, features = ["tls"] } +hyper-rustls = { version = "0.22.1", optional = true, default-features = false, features = ["rustls-native-certs", "webpki-roots", "tokio-runtime"] } +structopt = { version = "0.3", optional = true, default-features = false } +tokio = { version = "1.0", optional = true, default-features = false, features = ["rt-multi-thread"] } +tracing = { version = "0.1", optional = true, default-features = false } +tracing-subscriber = { version = "0.2", optional = true, default-features = false, features = ["fmt"] } [dev-dependencies] -lazy_static = "1.4.0" -tokio-test = "0.4" +lazy_static = { version = "1.4.0", default-features = false } +tokio-test = { version = "0.4", default-features = false } diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index 023b7d24c..58a1d0ab5 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -44,12 +44,12 @@ once_cell = { version = "1.3", default-features = false } prost = { version = "0.7", default-features = false } prost-types = { version = "0.7", default-features = false, features = ["std"] } serde = { version = "1", default-features = false, features = ["derive"] } -serde_json = { version = "1", features = ["alloc"] } +serde_json = { version = "1", default-features = false, features = ["alloc"] } serde_bytes = { version = "0.11", default-features = false } serde_repr = { version = "0.1", default-features = false } sha2 = { version = "0.9", default-features = false } -signature = "1.2" -subtle = "2" +signature = { version = "1.2", default-features = false } +subtle = { version = "2", default-features = false } subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } toml = { version = "0.5", default-features = false } @@ -70,6 +70,6 @@ std = [ ] [dev-dependencies] -pretty_assertions = "0.7.2" -proptest = "0.10.1" -tendermint-pbt-gen = { path = "../pbt-gen" } +pretty_assertions = { version = "0.7.2", default-features = false } +proptest = { version = "0.10.1", default-features = false } +tendermint-pbt-gen = { path = "../pbt-gen", default-features = false, features = ["time"] } diff --git a/test/Cargo.toml b/test/Cargo.toml index be15c2447..fec822ff3 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -14,14 +14,14 @@ authors = ["Alexander Simmerl "] test = true [dev-dependencies] -ed25519-dalek = "1" -flex-error = "0.4.3" -flume = "0.10" -rand_core = { version = "0.5", features = ["std"] } -readwrite = "^0.1.1" -subtle-encoding = { version = "0.5" } -x25519-dalek = "1.1" +ed25519-dalek = { version = "1", default-features = false, features = ["rand"] } +flex-error = { version = "0.4.3", default-features = false } +flume = { version = "0.10", default-features = false } +rand_core = { version = "0.5", default-features = false, features = ["std"] } +readwrite = { version = "^0.1.1", default-features = false } +subtle-encoding = { version = "0.5", default-features = false } +x25519-dalek = { version = "1.1", default-features = false } -tendermint = { path = "../tendermint" } -tendermint-p2p = { path = "../p2p" } -tendermint-proto = { path = "../proto" } +tendermint = { path = "../tendermint", default-features = false } +tendermint-p2p = { path = "../p2p", default-features = false } +tendermint-proto = { path = "../proto", default-features = false } diff --git a/testgen/Cargo.toml b/testgen/Cargo.toml index 0da6cedec..27a88063c 100644 --- a/testgen/Cargo.toml +++ b/testgen/Cargo.toml @@ -10,19 +10,19 @@ repository = "https://github.com/informalsystems/tendermint-rs/tree/master/test keywords = ["blockchain", "tendermint", "testing"] categories = ["cryptography::cryptocurrencies", "development-tools"] description = """ - tendermint-testgen is a library and a small binary utility for generating + tendermint-testgen is a library and a small binary utility for generating tendermint datastructures from minimal input (for testing purposes only). The library also contains some functionality to simplify running test batches. """ [dependencies] -tendermint = { version = "0.22.0", path = "../tendermint" } -serde = { version = "1", features = ["derive"] } -serde_json = "1" -ed25519-dalek = "1" -gumdrop = "0.8.0" -simple-error = "0.2.1" -tempfile = "3.1.0" +tendermint = { version = "0.22.0", path = "../tendermint", default-features = false } +serde = { version = "1", default-features = false, features = ["derive"] } +serde_json = { version = "1", default-features = false } +ed25519-dalek = { version = "1", default-features = false } +gumdrop = { version = "0.8.0", default-features = false } +simple-error = { version = "0.2.1", default-features = false } +tempfile = { version = "3.1.0", default-features = false } [[bin]] name = "tendermint-testgen" From a2eb2dcb911d32602fe100f1beccd913c1b6e659 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 30 Sep 2021 15:18:46 +0200 Subject: [PATCH 03/18] Fix features --- proto/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 6903bb55c..165da3052 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -25,11 +25,11 @@ serde_bytes = { version = "0.11", default-features = false, features = ["alloc"] subtle-encoding = { version = "0.5", default-features = false, features = ["hex", "base64", "std"] } num-traits = { version = "0.2", default-features = false } num-derive = { version = "0.3", default-features = false } -chrono = { version = "0.4", default-features = false, features = ["serde", "clock"] } +chrono = { version = "0.4", default-features = false, features = ["serde", "clock", "alloc"] } flex-error = { version = "0.4.3", default-features = false } [dev-dependencies] -serde_json = { version = "1.0", default-features = false } +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } [features] default = ["std", "eyre_tracer"] From 5be3f73c09c3bde28dba23e37c2a5d33fa3fc2fa Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 30 Sep 2021 16:00:22 +0200 Subject: [PATCH 04/18] Fix more features --- pbt-gen/Cargo.toml | 2 +- tendermint/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pbt-gen/Cargo.toml b/pbt-gen/Cargo.toml index 17432ae96..487d32cef 100644 --- a/pbt-gen/Cargo.toml +++ b/pbt-gen/Cargo.toml @@ -21,4 +21,4 @@ time = ["chrono"] [dependencies] chrono = { version = "0.4", default-features = false, features = ["serde"], optional = true} -proptest = { version = "0.10.1", default-features = false } +proptest = { version = "0.10.1", default-features = false, features = ["std"] } diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index 58a1d0ab5..d55555577 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -71,5 +71,5 @@ std = [ [dev-dependencies] pretty_assertions = { version = "0.7.2", default-features = false } -proptest = { version = "0.10.1", default-features = false } +proptest = { version = "0.10.1", default-features = false, features = ["std"] } tendermint-pbt-gen = { path = "../pbt-gen", default-features = false, features = ["time"] } From f8957a7814cfac5aad332f8bfa7427e8a85249d7 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 30 Sep 2021 16:14:54 +0200 Subject: [PATCH 05/18] Fix lightclient-js test --- light-client/Cargo.toml | 4 ++-- rpc/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 20db0aeae..0a1e05def 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -43,7 +43,7 @@ mbt = [] [dependencies] tendermint = { version = "0.22.0", path = "../tendermint", default-features = false } -tendermint-rpc = { version = "0.22.0", path = "../rpc", default-features = false, features = ["http-client"] } +tendermint-rpc = { version = "0.22.0", path = "../rpc", default-features = false } contracts = { version = "0.4.0", default-features = false } crossbeam-channel = { version = "0.4.2", default-features = false } @@ -68,4 +68,4 @@ proptest = { version = "0.10.1", default-features = false, features = ["std"] } [[example]] name = "light_client" -required-features = ["rpc-client"] +required-features = ["rpc-client", "tendermint-rpc/http-client"] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 58cfdf9f6..95bffc708 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -89,7 +89,7 @@ async-trait = { version = "0.1", optional = true, default-features = false } async-tungstenite = { version = "0.12", default-features = false, features = ["tokio-runtime", "tokio-rustls"], optional = true } futures = { version = "0.3", optional = true, default-features = false } http = { version = "0.2", optional = true, default-features = false } -hyper = { version = "0.14", optional = true, default-features = false, features = ["client", "http1", "http2", "tcp"] } +hyper = { version = "0.14", optional = true, default-features = false, features = ["client", "http1", "http2"] } hyper-proxy = { version = "0.9", optional = true, default-features = false, features = ["tls"] } hyper-rustls = { version = "0.22.1", optional = true, default-features = false, features = ["rustls-native-certs", "webpki-roots", "tokio-runtime"] } structopt = { version = "0.3", optional = true, default-features = false } From 69393216bdc4fe5e5310fbe547dafb58723b845d Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Mon, 4 Oct 2021 19:05:58 +0200 Subject: [PATCH 06/18] Disable "ed25519-dalek/serde" feature as it does not support std --- tendermint/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index d55555577..c97f5f5bb 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -37,7 +37,7 @@ async-trait = { version = "0.1", default-features = false } bytes = { version = "1.0", default-features = false } chrono = { version = "0.4.19", default-features = false, features = ["serde"] } ed25519 = { version = "1", default-features = false } -ed25519-dalek = { version = "1", default-features = false, features = ["serde", "u64_backend"] } +ed25519-dalek = { version = "1", default-features = false, features = ["u64_backend"] } futures = { version = "0.3", default-features = false } num-traits = { version = "0.2", default-features = false } once_cell = { version = "1.3", default-features = false } From 109f6b49322b62a28a72407bcef9defe64fb48d8 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 5 Oct 2021 10:17:23 +0200 Subject: [PATCH 07/18] Remove "subtle-encoding/std" feature from tendermint-proto --- proto/Cargo.toml | 2 +- tendermint/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 165da3052..68fa53070 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -22,7 +22,7 @@ prost-types = { version = "0.7", default-features = false } bytes = { version = "1.0", default-features = false } serde = { version = "1.0", default-features = false, features = ["derive"] } serde_bytes = { version = "0.11", default-features = false, features = ["alloc"] } -subtle-encoding = { version = "0.5", default-features = false, features = ["hex", "base64", "std"] } +subtle-encoding = { version = "0.5", default-features = false, features = ["hex", "base64", "alloc"] } num-traits = { version = "0.2", default-features = false } num-derive = { version = "0.3", default-features = false } chrono = { version = "0.4", default-features = false, features = ["serde", "clock", "alloc"] } diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index c97f5f5bb..63533bd4c 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -57,8 +57,8 @@ url = { version = "2.2", default-features = false } zeroize = { version = "1.1", default-features = false, features = ["zeroize_derive", "alloc"] } flex-error = { version = "0.4.3", default-features = false } time = { version = "0.1.40", default-features = false } -k256 = { version = "0.9", optional = true, default-features = false , features = ["ecdsa", "sha256"] } -ripemd160 = { version = "0.9", default-features = false , optional = true } +k256 = { version = "0.9", optional = true, default-features = false, features = ["ecdsa", "sha256"] } +ripemd160 = { version = "0.9", default-features = false, optional = true } [features] default = ["std", "eyre_tracer"] From c1becc94905b3eddf7e60f190fd3039371b4aaa0 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Mon, 25 Oct 2021 14:44:52 -0400 Subject: [PATCH 08/18] Merge latest changes from master and fix conflicts Signed-off-by: Thane Thomson --- abci/Cargo.toml | 4 ++-- config/Cargo.toml | 6 +++--- light-client-js/Cargo.toml | 6 +++--- light-client/Cargo.toml | 6 +++--- light-client/src/lib.rs | 2 +- p2p/Cargo.toml | 8 ++++---- p2p/src/lib.rs | 2 +- pbt-gen/Cargo.toml | 2 +- proto/Cargo.toml | 2 +- proto/src/lib.rs | 2 +- rpc/Cargo.toml | 8 ++++---- std-ext/Cargo.toml | 2 +- tendermint/Cargo.toml | 6 +++--- tendermint/src/lib.rs | 2 +- test/Cargo.toml | 2 +- testgen/Cargo.toml | 4 ++-- tools/abci-test/Cargo.toml | 8 ++++---- tools/kvstore-test/Cargo.toml | 6 +++--- tools/rpc-probe/Cargo.toml | 2 +- 19 files changed, 40 insertions(+), 40 deletions(-) diff --git a/abci/Cargo.toml b/abci/Cargo.toml index ef1524ba7..bb2a808b7 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-abci" -version = "0.22.0" +version = "0.23.0-internal" authors = ["Informal Systems "] edition = "2018" license = "Apache-2.0" @@ -34,7 +34,7 @@ std = [ [dependencies] bytes = { version = "1.0", default-features = false } prost = { package = "informalsystems-prost", version = "0.8.1", default-features = false } -tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } +tendermint-proto = { version = "0.23.0-internal", default-features = false, path = "../proto" } tracing = { version = "0.1", default-features = false } flex-error = { version = "0.4.3", default-features = false } structopt = { version = "0.3", optional = true, default-features = false } diff --git a/config/Cargo.toml b/config/Cargo.toml index 5dbf430ba..36cc77dae 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tendermint-config" -version = "0.22.0" # Also update `html_root_url` in lib.rs and - # depending crates (rpc, light-node, ..) when bumping this +version = "0.23.0-internal" # Also update `html_root_url` in lib.rs and + # depending crates (rpc, light-node, ..) when bumping this license = "Apache-2.0" homepage = "https://www.tendermint.com/" repository = "https://github.com/informalsystems/tendermint-rs/tree/master/tendermint" @@ -28,7 +28,7 @@ rustdoc-args = ["--cfg", "docsrs"] crate-type = ["cdylib", "rlib"] [dependencies] -tendermint = { version = "0.22.0", default-features = false, path = "../tendermint" } +tendermint = { version = "0.23.0-internal", default-features = false, path = "../tendermint" } flex-error = { version = "0.4.1", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/light-client-js/Cargo.toml b/light-client-js/Cargo.toml index f047decc3..dfacc804e 100644 --- a/light-client-js/Cargo.toml +++ b/light-client-js/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-light-client-js" -version = "0.22.0" +version = "0.23.0" authors = ["Informal Systems "] edition = "2018" license = "Apache-2.0" @@ -24,8 +24,8 @@ serde = { version = "1.0", default-features = false, features = [ "derive" ] } serde_json = { version = "1.0", default-features = false } # TODO(thane): Remove once https://github.com/rustwasm/wasm-bindgen/issues/2508 is resolved syn = { version = "=1.0.65", default-features = false } -tendermint = { version = "0.22.0", default-features = false, path = "../tendermint" } -tendermint-light-client = { version = "0.22.0", default-features = false, path = "../light-client" } +tendermint = { version = "0.23.0-internal", default-features = false, path = "../tendermint" } +tendermint-light-client = { version = "0.23.0-internal", default-features = false, path = "../light-client" } wasm-bindgen = { version = "0.2.63", default-features = false, features = [ "serde-serialize" ] } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 779c611f2..346515358 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-light-client" -version = "0.22.0" +version = "0.23.0-internal" edition = "2018" license = "Apache-2.0" readme = "README.md" @@ -42,8 +42,8 @@ std = [ mbt = [] [dependencies] -tendermint = { version = "0.22.0", path = "../tendermint", default-features = false } -tendermint-rpc = { version = "0.22.0", path = "../rpc", default-features = false } +tendermint = { version = "0.23.0-internal", path = "../tendermint", default-features = false } +tendermint-rpc = { version = "0.23.0-internal", path = "../rpc", default-features = false } contracts = { version = "0.4.0", default-features = false } chrono = { version = "0.4", default-features = false, features = ["clock"] } diff --git a/light-client/src/lib.rs b/light-client/src/lib.rs index 92ff1f381..7fd2ceb8a 100644 --- a/light-client/src/lib.rs +++ b/light-client/src/lib.rs @@ -9,7 +9,7 @@ nonstandard_style )] #![doc( - html_root_url = "https://docs.rs/tendermint-light-client/0.22.0", + html_root_url = "https://docs.rs/tendermint-light-client/0.23.0-internal", html_logo_url = "https://raw.githubusercontent.com/informalsystems/tendermint-rs/master/img/logo-tendermint-rs_3961x4001.png" )] #![cfg_attr(docsrs, feature(doc_cfg))] diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 35c1ac5b0..97d5787f2 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-p2p" -version = "0.22.0" +version = "0.23.0-internal" edition = "2018" license = "Apache-2.0" repository = "https://github.com/informalsystems/tendermint-rs" @@ -48,9 +48,9 @@ aead = { version = "0.4.1", default-features = false } flex-error = { version = "0.4.3", default-features = false } # path dependencies -tendermint = { path = "../tendermint", version = "0.22.0", default-features = false } -tendermint-proto = { path = "../proto", version = "0.22.0", default-features = false } -tendermint-std-ext = { path = "../std-ext", version = "0.22.0", default-features = false } +tendermint = { path = "../tendermint", version = "0.23.0-internal", default-features = false } +tendermint-proto = { path = "../proto", version = "0.23.0-internal", default-features = false } +tendermint-std-ext = { path = "../std-ext", version = "0.23.0-internal", default-features = false } # optional dependencies prost-derive = { package = "informalsystems-prost-derive", version = "0.8.1", optional = true } diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs index d888b252b..5a65411a4 100644 --- a/p2p/src/lib.rs +++ b/p2p/src/lib.rs @@ -20,7 +20,7 @@ unused_qualifications )] #![doc( - html_root_url = "https://docs.rs/tendermint-p2p/0.22.0", + html_root_url = "https://docs.rs/tendermint-p2p/0.23.0-internal", html_logo_url = "https://raw.githubusercontent.com/informalsystems/tendermint-rs/master/img/logo-tendermint-rs_3961x4001.png" )] diff --git a/pbt-gen/Cargo.toml b/pbt-gen/Cargo.toml index 487d32cef..de7c9c974 100644 --- a/pbt-gen/Cargo.toml +++ b/pbt-gen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-pbt-gen" -version = "0.22.0" +version = "0.23.0-internal" authors = ["Informal Systems "] edition = "2018" license = "Apache-2.0" diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 19c64e1da..7648530f9 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-proto" -version = "0.22.0" +version = "0.23.0-internal" authors = ["Informal Systems "] edition = "2018" license = "Apache-2.0" diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 4a471a60e..32dd1353e 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -4,7 +4,7 @@ #![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)] #![allow(clippy::large_enum_variant)] #![forbid(unsafe_code)] -#![doc(html_root_url = "https://docs.rs/tendermint-proto/0.22.0")] +#![doc(html_root_url = "https://docs.rs/tendermint-proto/0.23.0-internal")] extern crate alloc; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index e67e181ec..31147311a 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-rpc" -version = "0.22.0" +version = "0.23.0-internal" edition = "2018" license = "Apache-2.0" homepage = "https://www.tendermint.com/" @@ -75,9 +75,9 @@ pin-project = { version = "1.0.1", default-features = false } serde = { version = "1", default-features = false, features = [ "derive" ] } serde_bytes = { version = "0.11", default-features = false } serde_json = { version = "1", default-features = false, features = ["std"] } -tendermint-config = { version = "0.22.0", path = "../config" } -tendermint = { version = "0.22.0", default-features = false, path = "../tendermint" } -tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } +tendermint-config = { version = "0.23.0-internal", path = "../config" } +tendermint = { version = "0.23.0-internal", default-features = false, path = "../tendermint" } +tendermint-proto = { version = "0.23.0-internal", default-features = false, path = "../proto" } thiserror = { version = "1", default-features = false } uuid = { version = "0.8", default-features = false } subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } diff --git a/std-ext/Cargo.toml b/std-ext/Cargo.toml index 990bc0a84..f44b160b4 100644 --- a/std-ext/Cargo.toml +++ b/std-ext/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-std-ext" -version = "0.22.0" +version = "0.23.0-internal" edition = "2018" license = "Apache-2.0" homepage = "https://www.tendermint.com/" diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index 304760f07..b3b57242e 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tendermint" -version = "0.22.0" # Also update `html_root_url` in lib.rs and - # depending crates (rpc, light-node, ..) when bumping this +version = "0.23.0-internal" # Also update `html_root_url` in lib.rs and + # depending crates (rpc, light-node, ..) when bumping this license = "Apache-2.0" homepage = "https://www.tendermint.com/" repository = "https://github.com/informalsystems/tendermint-rs/tree/master/tendermint" @@ -51,7 +51,7 @@ sha2 = { version = "0.9", default-features = false } signature = { version = "1.2", default-features = false } subtle = { version = "2", default-features = false } subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } -tendermint-proto = { version = "0.22.0", default-features = false, path = "../proto" } +tendermint-proto = { version = "0.23.0-internal", default-features = false, path = "../proto" } zeroize = { version = "1.1", default-features = false, features = ["zeroize_derive", "alloc"] } flex-error = { version = "0.4.3", default-features = false } k256 = { version = "0.9", optional = true, default-features = false, features = ["ecdsa", "sha256"] } diff --git a/tendermint/src/lib.rs b/tendermint/src/lib.rs index d8d2acd6c..5394202dd 100644 --- a/tendermint/src/lib.rs +++ b/tendermint/src/lib.rs @@ -15,7 +15,7 @@ )] #![forbid(unsafe_code)] #![doc( - html_root_url = "https://docs.rs/tendermint/0.22.0", + html_root_url = "https://docs.rs/tendermint/0.23.0-internal", html_logo_url = "https://raw.githubusercontent.com/informalsystems/tendermint-rs/master/img/logo-tendermint-rs_3961x4001.png" )] diff --git a/test/Cargo.toml b/test/Cargo.toml index fec822ff3..58690915f 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tendermint-test" description = "Tendermint workspace tests and common utilities for testing." -version = "0.22.0" +version = "0.23.0-internal" edition = "2018" license = "Apache-2.0" categories = ["development", "test", "tools"] diff --git a/testgen/Cargo.toml b/testgen/Cargo.toml index ea455402b..89a06e66d 100644 --- a/testgen/Cargo.toml +++ b/testgen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-testgen" -version = "0.22.0" +version = "0.23.0-internal" authors = ["Informal Systems "] edition = "2018" readme = "README.md" @@ -16,7 +16,7 @@ description = """ """ [dependencies] -tendermint = { version = "0.22.0", path = "../tendermint", default-features = false } +tendermint = { version = "0.23.0-internal", path = "../tendermint" } serde = { version = "1", default-features = false, features = ["derive"] } serde_json = { version = "1", default-features = false } ed25519-dalek = { version = "1", default-features = false } diff --git a/tools/abci-test/Cargo.toml b/tools/abci-test/Cargo.toml index a41bcdf3f..da694fdab 100644 --- a/tools/abci-test/Cargo.toml +++ b/tools/abci-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "abci-test" -version = "0.22.0" +version = "0.23.0-internal" authors = ["Informal Systems "] edition = "2018" description = """ @@ -13,9 +13,9 @@ description = """ [dependencies] futures = "0.3" structopt = "0.3" -tendermint = { version = "0.22.0", path = "../../tendermint" } -tendermint-config = { version = "0.22.0", path = "../../config" } -tendermint-rpc = { version = "0.22.0", path = "../../rpc", features = [ "websocket-client" ] } +tendermint = { version = "0.23.0-internal", path = "../../tendermint" } +tendermint-config = { version = "0.23.0-internal", path = "../../config" } +tendermint-rpc = { version = "0.23.0-internal", path = "../../rpc", features = [ "websocket-client" ] } tracing = "0.1" tracing-subscriber = "0.2" tokio = { version = "1", features = ["full"] } diff --git a/tools/kvstore-test/Cargo.toml b/tools/kvstore-test/Cargo.toml index 6ef6bc403..ba8f1976c 100644 --- a/tools/kvstore-test/Cargo.toml +++ b/tools/kvstore-test/Cargo.toml @@ -10,9 +10,9 @@ edition = "2018" [dev-dependencies] futures = "0.3" -tendermint = { version = "0.22.0", path = "../../tendermint" } -tendermint-light-client = { version = "0.22.0", path = "../../light-client", features = ["unstable"] } -tendermint-rpc = { version = "0.22.0", path = "../../rpc", features = [ "http-client", "websocket-client" ] } +tendermint = { version = "0.23.0-internal", path = "../../tendermint" } +tendermint-light-client = { version = "0.23.0-internal", path = "../../light-client", features = ["unstable"] } +tendermint-rpc = { version = "0.23.0-internal", path = "../../rpc", features = [ "http-client", "websocket-client" ] } tokio = { version = "1.0", features = [ "rt-multi-thread", "macros" ] } tracing = "0.1" tracing-subscriber = "0.2" diff --git a/tools/rpc-probe/Cargo.toml b/tools/rpc-probe/Cargo.toml index d3abadc7c..c4f5ef501 100644 --- a/tools/rpc-probe/Cargo.toml +++ b/tools/rpc-probe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tendermint-rpc-probe" -version = "0.22.0" +version = "0.23.0-internal" authors = ["Informal Systems "] edition = "2018" license = "Apache-2.0" From a28ee20ce8c4b3a80549de8b6012e50525c967bd Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Mon, 25 Oct 2021 15:05:29 -0400 Subject: [PATCH 09/18] testgen: Remove unnecessary return Signed-off-by: Thane Thomson --- testgen/src/tester.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testgen/src/tester.rs b/testgen/src/tester.rs index 0a9dc2114..484ad91ad 100644 --- a/testgen/src/tester.rs +++ b/testgen/src/tester.rs @@ -460,9 +460,7 @@ impl Tester { let path = format!("{}", entry.path().display()); let rel_path = self.env().unwrap().rel_path(&path).unwrap(); if kind.is_file() || kind.is_symlink() { - if !rel_path.ends_with(".json") { - return; - } else { + if rel_path.ends_with(".json") { self.run_for_file(&rel_path); } } else if kind.is_dir() { From 335e6a924a16d8332cbe3a4e3d8dd17352112b45 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Mon, 25 Oct 2021 15:12:22 -0400 Subject: [PATCH 10/18] testgen: Enable serde_json/std feature to fix error Signed-off-by: Thane Thomson --- testgen/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testgen/Cargo.toml b/testgen/Cargo.toml index 89a06e66d..b41da1622 100644 --- a/testgen/Cargo.toml +++ b/testgen/Cargo.toml @@ -18,7 +18,7 @@ description = """ [dependencies] tendermint = { version = "0.23.0-internal", path = "../tendermint" } serde = { version = "1", default-features = false, features = ["derive"] } -serde_json = { version = "1", default-features = false } +serde_json = { version = "1", default-features = false, features = ["std"] } ed25519-dalek = { version = "1", default-features = false } gumdrop = { version = "0.8.0", default-features = false } simple-error = { version = "0.2.1", default-features = false } From 7bc04abbf1f7d4ec4633ff89fa94003d6e636d56 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Mon, 25 Oct 2021 15:20:13 -0400 Subject: [PATCH 11/18] proto: Fix formatting in docstring Signed-off-by: Thane Thomson --- proto/src/serializers.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index 749ec893d..7c839fb83 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -30,12 +30,12 @@ //! ``` //! //! Available serializers: -//! i64 <-> string: #[serde(with="serializers::from_str")] -//! u64 <-> string: #[serde(with="serializers::from_str")] +//! i64 <-> string: #[serde(with="serializers::from_str")] +//! u64 <-> string: #[serde(with="serializers::from_str")] //! core::time::Duration <-> nanoseconds as string #[serde(with="serializers::time_duration")] -//! Vec <-> HexString: #[serde(with="serializers::bytes::hexstring")] -//! Vec <-> Base64String: #[serde(with="serializers::bytes::base64string")] -//! Vec <-> String: #[serde(with="serializers::bytes::string")] +//! Vec <-> HexString: #[serde(with="serializers::bytes::hexstring")] +//! Vec <-> Base64String: #[serde(with="serializers::bytes::base64string")] +//! Vec <-> String: #[serde(with="serializers::bytes::string")] //! //! Notes: //! * Any type that has the "FromStr" trait can be serialized into a string with From 43d5e77870e7d8d533fb3fbf9cf4955ea21a4321 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 26 Oct 2021 13:21:19 +0200 Subject: [PATCH 12/18] Remove default std features in tendermint crates --- abci/Cargo.toml | 6 +----- config/Cargo.toml | 7 ------- light-client/Cargo.toml | 7 +------ p2p/Cargo.toml | 6 +----- proto/Cargo.toml | 7 ------- rpc/Cargo.toml | 8 +------- tendermint/Cargo.toml | 7 +------ 7 files changed, 5 insertions(+), 43 deletions(-) diff --git a/abci/Cargo.toml b/abci/Cargo.toml index bb2a808b7..70da41e34 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -21,15 +21,11 @@ path = "src/application/kvstore/main.rs" required-features = [ "binary", "kvstore-app" ] [features] -default = ["std", "eyre_tracer"] -eyre_tracer = ["flex-error/eyre_tracer"] +default = [] client = [] echo-app = [] kvstore-app = [] binary = [ "structopt", "tracing-subscriber" ] -std = [ - "flex-error/std" -] [dependencies] bytes = { version = "1.0", default-features = false } diff --git a/config/Cargo.toml b/config/Cargo.toml index 36cc77dae..064c58bdf 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -37,10 +37,3 @@ url = { version = "2.2" } [dev-dependencies] pretty_assertions = "0.7.2" - -[features] -default = ["std", "eyre_tracer"] -eyre_tracer = ["flex-error/eyre_tracer"] -std = [ - "flex-error/std" -] diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 346515358..825c22497 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -28,16 +28,11 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] -default = ["std", "eyre_tracer", "rpc-client"] -eyre_tracer = ["flex-error/eyre_tracer"] +default = ["rpc-client"] rpc-client = ["tokio", "tendermint-rpc/http-client"] secp256k1 = ["tendermint/secp256k1", "tendermint-rpc/secp256k1"] lightstore-sled = ["sled"] unstable = [] -std = [ - "flex-error/std", - "tendermint/std", -] # Enable to execute long-running model-based tests mbt = [] diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 97d5787f2..e70462168 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -23,12 +23,8 @@ description = """ test = false [features] -default = ["std", "eyre_tracer"] -eyre_tracer = ["flex-error/eyre_tracer"] +default = [] amino = ["prost-derive"] -std = [ - "flex-error/std" -] [dependencies] chacha20poly1305 = { version = "0.8", default-features = false, features = ["reduced-round"] } diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 7648530f9..a14add854 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -30,10 +30,3 @@ flex-error = { version = "0.4.3", default-features = false } [dev-dependencies] serde_json = { version = "1.0", default-features = false, features = ["alloc"] } - -[features] -default = ["std", "eyre_tracer"] -eyre_tracer = ["flex-error/eyre_tracer"] -std = [ - "flex-error/std" -] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 31147311a..1a969e589 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -29,8 +29,7 @@ path = "src/client/bin/main.rs" required-features = [ "cli" ] [features] -default = ["std", "eyre_tracer"] -eyre_tracer = ["flex-error/eyre_tracer"] +default = [] cli = [ "http-client", "structopt", @@ -60,11 +59,6 @@ websocket-client = [ "tokio/time", "tracing" ] -std = [ - "flex-error/std", - "tendermint/std", - "tendermint-proto/std", -] [dependencies] bytes = { version = "1.0", default-features = false } diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index b3b57242e..3a0ac55f1 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -58,13 +58,8 @@ k256 = { version = "0.9", optional = true, default-features = false, features = ripemd160 = { version = "0.9", default-features = false, optional = true } [features] -default = ["std", "eyre_tracer"] -eyre_tracer = ["flex-error/eyre_tracer"] +default = [] secp256k1 = ["k256", "ripemd160"] -std = [ - "flex-error/std", - "tendermint-proto/std", -] [dev-dependencies] pretty_assertions = { version = "0.7.2", default-features = false } From f9145cbe4325b63a2f31dd0f849023cce4a0a96d Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 26 Oct 2021 13:22:38 +0200 Subject: [PATCH 13/18] Add default-features = false for tendermint-config --- rpc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 1a969e589..5eb21edc0 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -69,7 +69,7 @@ pin-project = { version = "1.0.1", default-features = false } serde = { version = "1", default-features = false, features = [ "derive" ] } serde_bytes = { version = "0.11", default-features = false } serde_json = { version = "1", default-features = false, features = ["std"] } -tendermint-config = { version = "0.23.0-internal", path = "../config" } +tendermint-config = { version = "0.23.0-internal", path = "../config", default-features = false } tendermint = { version = "0.23.0-internal", default-features = false, path = "../tendermint" } tendermint-proto = { version = "0.23.0-internal", default-features = false, path = "../proto" } thiserror = { version = "1", default-features = false } From 872116539db00701c71d3f78e74a5bf100a9480e Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 26 Oct 2021 13:36:00 +0200 Subject: [PATCH 14/18] Fix build errors and update flex-error version --- abci/Cargo.toml | 2 +- config/Cargo.toml | 2 +- light-client/Cargo.toml | 4 ++-- p2p/Cargo.toml | 2 +- proto/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- tendermint/Cargo.toml | 2 +- test/Cargo.toml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/abci/Cargo.toml b/abci/Cargo.toml index 70da41e34..ea6a68f72 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -32,6 +32,6 @@ bytes = { version = "1.0", default-features = false } prost = { package = "informalsystems-prost", version = "0.8.1", default-features = false } tendermint-proto = { version = "0.23.0-internal", default-features = false, path = "../proto" } tracing = { version = "0.1", default-features = false } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } structopt = { version = "0.3", optional = true, default-features = false } tracing-subscriber = { version = "0.2", optional = true, default-features = false } diff --git a/config/Cargo.toml b/config/Cargo.toml index 064c58bdf..50f5644fe 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -29,7 +29,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] tendermint = { version = "0.23.0-internal", default-features = false, path = "../tendermint" } -flex-error = { version = "0.4.1", default-features = false } +flex-error = { version = "0.4.4", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" toml = { version = "0.5" } diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 825c22497..1a27ae53c 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -51,7 +51,7 @@ serde_derive = { version = "1.0.106", default-features = false } sled = { version = "0.34.3", optional = true, default-features = false } static_assertions = { version = "1.1.0", default-features = false } tokio = { version = "1.0", default-features = false, features = ["rt"], optional = true } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } [dev-dependencies] tendermint-testgen = { path = "../testgen", default-features = false } @@ -64,4 +64,4 @@ proptest = { version = "0.10.1", default-features = false, features = ["std"] } [[example]] name = "light_client" -required-features = ["rpc-client", "tendermint-rpc/http-client"] +required-features = ["rpc-client", "tendermint-rpc/http-client", "flex-error/std"] diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index e70462168..7aa6f65b3 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -41,7 +41,7 @@ x25519-dalek = { version = "1.1", default-features = false } zeroize = { version = "1", default-features = false } signature = { version = "1.3.0", default-features = false } aead = { version = "0.4.1", default-features = false } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } # path dependencies tendermint = { path = "../tendermint", version = "0.23.0-internal", default-features = false } diff --git a/proto/Cargo.toml b/proto/Cargo.toml index a14add854..a750c9a0a 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -26,7 +26,7 @@ subtle-encoding = { version = "0.5", default-features = false, features = ["hex" num-traits = { version = "0.2", default-features = false } num-derive = { version = "0.3", default-features = false } chrono = { version = "0.4", default-features = false, features = ["serde", "alloc"] } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } [dev-dependencies] serde_json = { version = "1.0", default-features = false, features = ["alloc"] } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 5eb21edc0..d1a2afbd6 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -77,7 +77,7 @@ uuid = { version = "0.8", default-features = false } subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } url = { version = "2.2", default-features = false } walkdir = { version = "2.3", default-features = false } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } # Optional dependencies async-trait = { version = "0.1", optional = true, default-features = false } diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index 3a0ac55f1..a77300194 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -53,7 +53,7 @@ subtle = { version = "2", default-features = false } subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } tendermint-proto = { version = "0.23.0-internal", default-features = false, path = "../proto" } zeroize = { version = "1.1", default-features = false, features = ["zeroize_derive", "alloc"] } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } k256 = { version = "0.9", optional = true, default-features = false, features = ["ecdsa", "sha256"] } ripemd160 = { version = "0.9", default-features = false, optional = true } diff --git a/test/Cargo.toml b/test/Cargo.toml index 58690915f..5a56ace7f 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -15,7 +15,7 @@ test = true [dev-dependencies] ed25519-dalek = { version = "1", default-features = false, features = ["rand"] } -flex-error = { version = "0.4.3", default-features = false } +flex-error = { version = "0.4.4", default-features = false } flume = { version = "0.10", default-features = false } rand_core = { version = "0.5", default-features = false, features = ["std"] } readwrite = { version = "^0.1.1", default-features = false } From 9ac5c16d3711aeef4f992965c4c21c22cf163efb Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 26 Oct 2021 15:38:05 +0200 Subject: [PATCH 15/18] Disable use of std in tendermint and tendermint-proto crates --- proto/src/lib.rs | 3 --- tendermint/src/lib.rs | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 32dd1353e..cbf5b3752 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -8,9 +8,6 @@ extern crate alloc; -#[cfg(feature = "std")] -extern crate std; - mod prelude; /// Built-in prost_types with slight customization to enable JSON-encoding diff --git a/tendermint/src/lib.rs b/tendermint/src/lib.rs index 5394202dd..6a100620d 100644 --- a/tendermint/src/lib.rs +++ b/tendermint/src/lib.rs @@ -20,6 +20,8 @@ )] extern crate alloc; + +#[cfg(test)] extern crate std; #[macro_use] From 40af7a79467ee839499cb4f7a60e2d2e54597b0b Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 26 Oct 2021 15:38:46 +0200 Subject: [PATCH 16/18] Fix formatting --- proto/src/serializers.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index 7c839fb83..d9b8d5904 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -34,8 +34,9 @@ //! u64 <-> string: #[serde(with="serializers::from_str")] //! core::time::Duration <-> nanoseconds as string #[serde(with="serializers::time_duration")] //! Vec <-> HexString: #[serde(with="serializers::bytes::hexstring")] -//! Vec <-> Base64String: #[serde(with="serializers::bytes::base64string")] -//! Vec <-> String: #[serde(with="serializers::bytes::string")] +//! Vec <-> Base64String: +//! #[serde(with="serializers::bytes::base64string")] Vec <-> String: +//! #[serde(with="serializers::bytes::string")] //! //! Notes: //! * Any type that has the "FromStr" trait can be serialized into a string with From 4faa88d0e6ba926155b4bca4e1b37b02395549a3 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Tue, 26 Oct 2021 15:48:31 +0200 Subject: [PATCH 17/18] Enable flex-error/std and flex-error/eyre_tracer by default in crates --- abci/Cargo.toml | 2 +- light-client/Cargo.toml | 2 +- p2p/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- tendermint/Cargo.toml | 2 +- tools/abci-test/Cargo.toml | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/abci/Cargo.toml b/abci/Cargo.toml index ea6a68f72..b135ec7cd 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -21,7 +21,7 @@ path = "src/application/kvstore/main.rs" required-features = [ "binary", "kvstore-app" ] [features] -default = [] +default = ["flex-error/std", "flex-error/eyre_tracer"] client = [] echo-app = [] kvstore-app = [] diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 1a27ae53c..333c67a91 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -28,7 +28,7 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] -default = ["rpc-client"] +default = ["rpc-client", "flex-error/std", "flex-error/eyre_tracer"] rpc-client = ["tokio", "tendermint-rpc/http-client"] secp256k1 = ["tendermint/secp256k1", "tendermint-rpc/secp256k1"] lightstore-sled = ["sled"] diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 7aa6f65b3..1e53baa87 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -23,7 +23,7 @@ description = """ test = false [features] -default = [] +default = ["flex-error/std", "flex-error/eyre_tracer"] amino = ["prost-derive"] [dependencies] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index d1a2afbd6..9c713f12e 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -29,7 +29,7 @@ path = "src/client/bin/main.rs" required-features = [ "cli" ] [features] -default = [] +default = ["flex-error/std", "flex-error/eyre_tracer"] cli = [ "http-client", "structopt", diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index a77300194..f82d8ecfe 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -58,7 +58,7 @@ k256 = { version = "0.9", optional = true, default-features = false, features = ripemd160 = { version = "0.9", default-features = false, optional = true } [features] -default = [] +default = ["flex-error/std", "flex-error/eyre_tracer"] secp256k1 = ["k256", "ripemd160"] [dev-dependencies] diff --git a/tools/abci-test/Cargo.toml b/tools/abci-test/Cargo.toml index da694fdab..e2c9dfb1d 100644 --- a/tools/abci-test/Cargo.toml +++ b/tools/abci-test/Cargo.toml @@ -11,6 +11,7 @@ description = """ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } futures = "0.3" structopt = "0.3" tendermint = { version = "0.23.0-internal", path = "../../tendermint" } From 7d32779e21c9ee90ac5578abce4016e44fb658d8 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 26 Oct 2021 11:52:17 -0400 Subject: [PATCH 18/18] proto: Restructure serializer docs into table Signed-off-by: Thane Thomson --- proto/src/serializers.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index d9b8d5904..d94281e20 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -30,18 +30,25 @@ //! ``` //! //! Available serializers: -//! i64 <-> string: #[serde(with="serializers::from_str")] -//! u64 <-> string: #[serde(with="serializers::from_str")] -//! core::time::Duration <-> nanoseconds as string #[serde(with="serializers::time_duration")] -//! Vec <-> HexString: #[serde(with="serializers::bytes::hexstring")] -//! Vec <-> Base64String: -//! #[serde(with="serializers::bytes::base64string")] Vec <-> String: -//! #[serde(with="serializers::bytes::string")] +//! +//! | Field Type | String Format | Serializer | +//! |--------------|-------------------------------|-------------------| +//! | `i64` | e.g. `-5` | [`from_str`] | +//! | `u64` | e.g. `100` | [`from_str`] | +//! | [`Duration`] | Nanoseconds (e.g. `100`) | [`time_duration`] | +//! | `Vec` | Hexadecimal (e.g. `1AF2B3C4`) | [`hexstring`] | +//! | `Vec` | Base64-encoded | [`base64string`] | +//! | `Vec` | Raw bytes in string | [`string`] | //! //! Notes: //! * Any type that has the "FromStr" trait can be serialized into a string with //! serializers::primitives::string. //! * serializers::bytes::* deserializes a null value into an empty vec![]. +//! +//! [`Duration`]: core::time::Duration +//! [`hexstring`]: bytes::hexstring +//! [`base64string`]: bytes::base64string +//! [`string`]: bytes::string // Todo: remove dead_code allowance as soon as more types are implemented #![allow(dead_code)]