Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full support of no_std in tendermint crate #988

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .changelog/unreleased/bug-fixes/1016-lowercase-node-id.md

This file was deleted.

3 changes: 3 additions & 0 deletions .changelog/v0.23.1/bug-fixes/1016-lowercase-node-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[tendermint]` The `tendermint::node::Id` `Display` implementation now prints
the hexadecimal string in lowercase
([#971](https://github.com/informalsystems/tendermint-rs/issues/971))
3 changes: 3 additions & 0 deletions .changelog/v0.23.1/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*Nov 15, 2021*

Minor bug fixes.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# CHANGELOG

## v0.23.1

*Nov 15, 2021*

Minor bug fixes.

### BUG FIXES

- `[tools/proto-compiler]` Fixed our proto-compiler, which was producing
protos that did not compile due to an incorrect Prost field annotation
([#1014](https://github.com/informalsystems/tendermint-rs/issues/1014))
- `[tendermint]` The `tendermint::node::Id` `Display` implementation now prints
the hexadecimal string in lowercase
([#971](https://github.com/informalsystems/tendermint-rs/issues/971))

## v0.23.0

*Oct 27, 2021*
Expand Down
4 changes: 2 additions & 2 deletions abci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tendermint-abci"
version = "0.23.0"
version = "0.23.1"
authors = ["Informal Systems <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand Down Expand Up @@ -33,7 +33,7 @@ binary = [
[dependencies]
bytes = { version = "1.0", default-features = false }
prost = { version = "0.9", default-features = false }
tendermint-proto = { version = "0.23.0", default-features = false, path = "../proto" }
tendermint-proto = { version = "0.23.1", default-features = false, path = "../proto" }
tracing = { version = "0.1", default-features = false }
flex-error = { version = "0.4.4", default-features = false }
structopt = { version = "0.3", optional = true, default-features = false }
Expand Down
14 changes: 7 additions & 7 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tendermint-config"
version = "0.23.0" # Also update `html_root_url` in lib.rs and
version = "0.23.1" # 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/"
Expand Down Expand Up @@ -28,12 +28,12 @@ rustdoc-args = ["--cfg", "docsrs"]
crate-type = ["cdylib", "rlib"]

[dependencies]
tendermint = { version = "0.23.0", default-features = false, path = "../tendermint" }
tendermint = { version = "0.23.1", default-features = false, path = "../tendermint" }
flex-error = { version = "0.4.4", default-features = false }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
toml = { version = "0.5" }
url = { version = "2.2" }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = { version = "1", default-features = false }
toml = { version = "0.5", default-features = false }
url = { version = "2.2", default-features = false }

[dev-dependencies]
pretty_assertions = "0.7.2"
pretty_assertions = { version = "0.7.2", default-features = false }
2 changes: 1 addition & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

use crate::net;
use crate::node_key::NodeKey;
use crate::prelude::*;
use crate::Error;

use crate::prelude::*;
use alloc::collections::{btree_map, BTreeMap};
use core::{fmt, str::FromStr};
use serde::{de, de::Error as _, ser, Deserialize, Serialize};
Expand Down
6 changes: 3 additions & 3 deletions light-client-js/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tendermint-light-client-js"
version = "0.23.0"
version = "0.23.1"
authors = ["Informal Systems <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -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.23.0", default-features = false, path = "../tendermint" }
tendermint-light-client = { version = "0.23.0", default-features = false, path = "../light-client" }
tendermint = { version = "0.23.1", default-features = false, path = "../tendermint" }
tendermint-light-client = { version = "0.23.1", 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
Expand Down
24 changes: 12 additions & 12 deletions light-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tendermint-light-client"
version = "0.23.0"
version = "0.23.1"
edition = "2018"
license = "Apache-2.0"
readme = "README.md"
Expand Down Expand Up @@ -28,40 +28,40 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["rpc-client", "flex-error/std", "flex-error/eyre_tracer"]
rpc-client = ["tokio", "tendermint-rpc/http-client"]
default = ["std"]
std = ["rpc-client", "chrono/clock", "flex-error/std", "flex-error/eyre_tracer"]
rpc-client = ["tokio", "tendermint-rpc", "tendermint-rpc/http-client"]
secp256k1 = ["tendermint/secp256k1", "tendermint-rpc/secp256k1"]
lightstore-sled = ["sled"]
unstable = []
# Enable to execute long-running model-based tests
mbt = []

[dependencies]
tendermint = { version = "0.23.0", path = "../tendermint", default-features = false }
tendermint-rpc = { version = "0.23.0", path = "../rpc", default-features = false }
tendermint = { version = "0.23.1", path = "../tendermint", default-features = false }
tendermint-rpc = { version = "0.23.1", path = "../rpc", default-features = false, optional = true }
tokio = { version = "1.0", default-features = false, features = ["rt"], optional = true }

contracts = { version = "0.4.0", default-features = false }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
chrono = { version = "0.4", 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 = { version = "1.0.106", default-features = false, features = ["derive"] }
serde_cbor = { version = "0.11.2", default-features = false, features = ["alloc"] }
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.4", default-features = false }

[dev-dependencies]
tendermint-testgen = { path = "../testgen", default-features = false }

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"] }
proptest = { version = "0.10.1", default-features = false }

[[example]]
name = "light_client"
required-features = ["rpc-client", "tendermint-rpc/http-client", "flex-error/std"]
# required-features = ["rpc-client", "tendermint-rpc/http-client", "flex-error/std"]
3 changes: 3 additions & 0 deletions light-client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
mod light_client;
pub use light_client::LightClientBuilder;

#[cfg(feature = "rpc-client")]
mod supervisor;

#[cfg(feature = "rpc-client")]
pub use supervisor::SupervisorBuilder;

pub mod error;
3 changes: 2 additions & 1 deletion light-client/src/builder/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::components::verifier::Verifier;
use crate::light_client::{LightClient, Options};
use crate::operations::Hasher;
use crate::predicates::VerificationPredicates;
use crate::prelude::*;
use crate::state::{State, VerificationTrace};
use crate::store::LightStore;
use crate::supervisor::Instance;
Expand All @@ -19,7 +20,7 @@ use crate::types::{LightBlock, PeerId, Status};
use {
crate::components::clock::SystemClock, crate::components::io::ProdIo,
crate::components::scheduler, crate::components::verifier::ProdVerifier,
crate::operations::ProdHasher, crate::predicates::ProdPredicates, std::time::Duration,
crate::operations::ProdHasher, crate::predicates::ProdPredicates, core::time::Duration,
tendermint_rpc as rpc,
};

Expand Down
2 changes: 1 addition & 1 deletion light-client/src/builder/supervisor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::Duration;
use core::time::Duration;

use crate::builder::error::Error;
use crate::peer_list::{PeerList, PeerListBuilder};
Expand Down
6 changes: 3 additions & 3 deletions light-client/src/components/clock.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Provides an interface and a default implementation of the `Clock` component

use crate::types::Time;
use chrono::Utc;

/// Abstracts over the current time.
pub trait Clock: Send + Sync {
/// Get the current time.
Expand All @@ -12,8 +10,10 @@ pub trait Clock: Send + Sync {
/// Provides the current wall clock time.
#[derive(Copy, Clone)]
pub struct SystemClock;

#[cfg(feature = "std")]
impl Clock for SystemClock {
fn now(&self) -> Time {
Time(Utc::now())
Time(chrono::Utc::now())
}
}
23 changes: 18 additions & 5 deletions light-client/src/components/io.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! Provides an interface and a default implementation of the `Io` component

use flex_error::{define_error, TraceError};
use std::time::Duration;
use core::time::Duration;
use flex_error::define_error;

#[cfg(feature = "rpc-client")]
use tendermint_rpc::Client;

#[cfg(feature = "rpc-client")]
use tendermint_rpc as rpc;

use crate::types::{Height, LightBlock};
Expand All @@ -16,6 +17,18 @@ type TimeoutError = flex_error::DisplayOnly<tokio::time::error::Elapsed>;
#[cfg(not(feature = "tokio"))]
type TimeoutError = flex_error::NoSource;

#[cfg(feature = "rpc-client")]
type RpcError = rpc::Error;

#[cfg(not(feature = "rpc-client"))]
type RpcError = flex_error::NoSource;

#[cfg(feature = "std")]
type StdIoError = flex_error::DisplayOnly<std::io::Error>;

#[cfg(not(feature = "std"))]
type StdIoError = flex_error::NoSource;

/// Type for selecting either a specific height or the latest one
pub enum AtHeight {
/// A specific height
Expand All @@ -38,7 +51,7 @@ define_error! {
#[derive(Debug)]
IoError {
Rpc
[ rpc::Error ]
[ RpcError ]
| _ | { "rpc error" },

InvalidHeight
Expand All @@ -59,7 +72,7 @@ define_error! {
},

Runtime
[ TraceError<std::io::Error> ]
[ StdIoError ]
| _ | { "failed to initialize runtime" },

}
Expand Down Expand Up @@ -97,7 +110,7 @@ pub use self::prod::ProdIo;
mod prod {
use super::*;

use std::time::Duration;
use core::time::Duration;

use crate::types::PeerId;
use crate::utils::block_on;
Expand Down
2 changes: 1 addition & 1 deletion light-client/src/components/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use contracts::*;

use crate::store::LightStore;
use crate::types::Height;
use std::convert::TryInto;
use core::convert::TryInto;

/// The scheduler decides what block to verify next given the current and target heights.
///
Expand Down
2 changes: 1 addition & 1 deletion light-client/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
types::{Height, LightBlock, Status, Time},
};

use std::time::Duration;
use core::time::Duration;

/// Whether or not the given light store contains a verified or
/// trusted block at the given target height.
Expand Down
11 changes: 6 additions & 5 deletions light-client/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Toplevel errors raised by the light client.

use std::fmt::Debug;
use std::time::Duration;
use core::fmt::Debug;
use core::time::Duration;

use crate::operations::voting_power::VotingPowerTally;
use crate::prelude::*;
use crossbeam_channel as crossbeam;

use crate::{
Expand All @@ -12,10 +13,10 @@ use crate::{
predicates::errors::VerificationErrorDetail,
types::{Hash, Height, LightBlock, PeerId, Status},
};
use flex_error::{define_error, DisplayError, TraceError};
use flex_error::{define_error, DisplayError, DisplayOnly};

#[cfg(feature = "sled")]
type SledError = TraceError<sled::Error>;
type SledError = DisplayOnly<sled::Error>;

#[cfg(not(feature = "sled"))]
type SledError = flex_error::NoSource;
Expand Down Expand Up @@ -111,7 +112,7 @@ define_error! {
| _ | { "sled error" },

SerdeCbor
[ TraceError<serde_cbor::Error> ]
[ DisplayOnly<serde_cbor::Error> ]
| _ | { "serde cbor error" },

}
Expand Down
4 changes: 3 additions & 1 deletion light-client/src/evidence.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Fork evidence data structures and interfaces.

use crate::prelude::*;
use crate::{components::io::IoError, types::PeerId};

use tendermint::abci::transaction::Hash;
Expand All @@ -24,8 +25,9 @@ mod prod {
use super::*;
use crate::utils::block_on;

use alloc::collections::BTreeMap as HashMap;
use contracts::pre;
use std::{collections::HashMap, time::Duration};
use core::time::Duration;

use tendermint_rpc as rpc;
use tendermint_rpc::Client;
Expand Down
1 change: 1 addition & 0 deletions light-client/src/fork_detector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Fork detection data structures and implementation.

use crate::prelude::*;
use crate::{
errors::{Error, ErrorDetail, ErrorExt},
operations::{Hasher, ProdHasher},
Expand Down
10 changes: 9 additions & 1 deletion light-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![no_std]
#![forbid(unsafe_code)]
#![deny(
warnings,
Expand All @@ -9,13 +10,20 @@
nonstandard_style
)]
#![doc(
html_root_url = "https://docs.rs/tendermint-light-client/0.23.0",
html_root_url = "https://docs.rs/tendermint-light-client/0.23.1",
html_logo_url = "https://raw.githubusercontent.com/informalsystems/tendermint-rs/master/img/logo-tendermint-rs_3961x4001.png"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]

//! See the `light_client` module for the main documentation.

extern crate alloc;

#[cfg(any(test, feature = "std", feature = "rpc-client"))]
extern crate std;

mod prelude;

pub mod builder;
pub mod components;
pub mod contracts;
Expand Down
Loading