-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move out tendermint::config to tendermint_config crate * Introduce own error type in tendermint-config * Move tendermint::net to tendermint_config::net * Fix tendermint-rpc error * Update Cargo.toml for tendermint-config * Remove #![allow(dead_code)] * Apply suggestions from code review Co-authored-by: Thane Thomson <[email protected]> * Move tendermint_config::files::test to tendermint_config::test * Remove config/tests/config.rs * Minor fixes * Resolve conflict in #986 (#1004) * Fix `cargo test` and add check to CI (#990) * Relocate ABCI test to fix broken doctest Signed-off-by: Thane Thomson <[email protected]> * Use tokio_test for mock client doctest Signed-off-by: Thane Thomson <[email protected]> * Add CI test for default features Signed-off-by: Thane Thomson <[email protected]> * Add `block_search` RPC endpoint (#991) * Add block_search RPC endpoint and tests * Add .changelog entry * Fix comments * tools: Fix `block_search` endpoint integration tests (#999) Closes #998 * Bump integration test tendermint to v0.34.13 * Fix kvstore integration tests * Bump tendermint version to v0.34.13 in CI Signed-off-by: Thane Thomson <[email protected]> * ci: Build and check tools (#997) So far only the kvstore tests ran as part of the Github workfows. This would leave opportunity for changes to introduce breakage to the builds of the tools. In this change the same build and clippy stages are introduced for the tools workspace that currently run for the top-level one. Signed-off-by: xla <[email protected]> * tools: Add `block_search` method to RPC probe (#1002) * Add missing block_search endpoint * Bump tendermint version to v0.34.13 Signed-off-by: Thane Thomson <[email protected]> Co-authored-by: Shoaib Ahmed <[email protected]> Co-authored-by: xla <[email protected]> * Fix abci-test * Add changelog entry Signed-off-by: Thane Thomson <[email protected]> * Add more changelog entries for other breaking changes Signed-off-by: Thane Thomson <[email protected]> * Add tendermint-config to release script Signed-off-by: Thane Thomson <[email protected]> * Fix merge mistakes Co-authored-by: Thane Thomson <[email protected]> Co-authored-by: Shoaib Ahmed <[email protected]> Co-authored-by: xla <[email protected]> Co-authored-by: Thane Thomson <[email protected]>
- Loading branch information
1 parent
e3e4c88
commit 1ab5e86
Showing
32 changed files
with
470 additions
and
360 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.changelog/unreleased/breaking-changes/983-tendermint-config.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- `[tendermint, tendermint-config]` The `tendermint::config` | ||
module has now been broken out into its own crate (`tendermint- | ||
config`) to help towards facilitating `no_std` compatibility | ||
([#983](https://github.com/informalsystems/tendermint-rs/issues/983)) |
4 changes: 4 additions & 0 deletions
4
.changelog/unreleased/breaking-changes/983-tendermint-node-info.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- `[tendermint]` The `tendermint::node::info::OtherInfo::rpc_address` | ||
field type has been changed from `tendermint::net::Address` | ||
to `String` toward facilitating `no_std` compatibility | ||
([#983](https://github.com/informalsystems/tendermint-rs/issues/983)) |
4 changes: 4 additions & 0 deletions
4
.changelog/unreleased/breaking-changes/983-tendermint-node-listen-addr.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- `[tendermint]` The `tendermint::node::info::ListenAddress::to_net_address` | ||
method was replaced with a simple `as_str` method toward facilitating | ||
`no_std` compatibility ([#983](https://github.com/informalsystems/tendermint- | ||
rs/issues/983)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
members = [ | ||
"abci", | ||
"config", | ||
"light-client", | ||
"light-client-js", | ||
"p2p", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[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 | ||
license = "Apache-2.0" | ||
homepage = "https://www.tendermint.com/" | ||
repository = "https://github.com/informalsystems/tendermint-rs/tree/master/tendermint" | ||
readme = "../README.md" | ||
categories = ["cryptography", "cryptography::cryptocurrencies", "database"] | ||
keywords = ["blockchain", "bft", "consensus", "cosmos", "tendermint"] | ||
edition = "2018" | ||
|
||
description = """ | ||
tendermint-config provides functions for loading and validating Tendermint | ||
configuration files. It is moved out of the tendermint crate for no_std support | ||
in the tendermint crate. | ||
""" | ||
|
||
authors = [ | ||
"Informal Systems <[email protected]>", | ||
] | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
tendermint = { version = "0.22.0", default-features = false, path = "../tendermint" } | ||
flex-error = { version = "0.4.1", default-features = false } | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
toml = { version = "0.5" } | ||
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" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use flex_error::{define_error, DisplayOnly}; | ||
use std::io::Error as IoError; | ||
use tendermint::Error as TendermintError; | ||
|
||
define_error! { | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
Error { | ||
Io | ||
[ DisplayOnly<IoError> ] | ||
|_| { format_args!("I/O error") }, | ||
|
||
FileIo | ||
{ path: String } | ||
[ DisplayOnly<IoError> ] | ||
|e| { format_args!("failed to open file: {}", e.path) }, | ||
|
||
Parse | ||
{ data: String } | ||
| e | { format_args!("error parsing data: {}", e.data) }, | ||
|
||
SerdeJson | ||
[ DisplayOnly<serde_json::Error> ] | ||
|_| { format_args!("serde json error") }, | ||
|
||
Toml | ||
[ DisplayOnly<toml::de::Error> ] | ||
|_| { format_args!("toml de error") }, | ||
|
||
ParseUrl | ||
[ DisplayOnly<url::ParseError> ] | ||
|_| { format_args!("error parsing url error") }, | ||
|
||
Tendermint | ||
[ TendermintError ] | ||
|_| { format_args!("tendermint error") }, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! Tendermint Configuration Utilities | ||
//! | ||
//! This crate defines the [`TendermintConfig`] type, which is used by | ||
//! crates such as `tendermint-rpc` to perform operations based on | ||
//! a common configuration type. | ||
|
||
#![cfg_attr(docsrs, feature(doc_cfg))] | ||
#![deny( | ||
warnings, | ||
trivial_casts, | ||
trivial_numeric_casts, | ||
unused_import_braces, | ||
unused_qualifications | ||
)] | ||
#![forbid(unsafe_code)] | ||
|
||
pub mod net; | ||
|
||
mod config; | ||
mod error; | ||
mod node_key; | ||
mod priv_validator_key; | ||
|
||
pub use config::*; | ||
pub use error::*; | ||
pub use node_key::NodeKey; | ||
pub use priv_validator_key::PrivValidatorKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
//! Remote addresses (`tcp://` or `unix://`) | ||
|
||
use crate::{error::Error, node}; | ||
use crate::error::Error; | ||
|
||
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer}; | ||
use std::{ | ||
fmt::{self, Display}, | ||
path::PathBuf, | ||
str::{self, FromStr}, | ||
}; | ||
use tendermint::node::{self, info::ListenAddress}; | ||
use url::Url; | ||
|
||
/// URI prefix for TCP connections | ||
|
@@ -40,10 +40,23 @@ pub enum Address { | |
/// UNIX domain sockets | ||
Unix { | ||
/// Path to a UNIX domain socket path | ||
path: PathBuf, | ||
path: String, | ||
}, | ||
} | ||
|
||
impl Address { | ||
/// Convert `ListenAddress` to a `net::Address` | ||
pub fn from_listen_address(address: &ListenAddress) -> Option<Self> { | ||
let raw_address = address.as_str(); | ||
// TODO(tarcieri): validate these and handle them better at parse time | ||
if raw_address.starts_with("tcp://") { | ||
raw_address.parse().ok() | ||
} else { | ||
format!("tcp://{}", raw_address).parse().ok() | ||
} | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for Address { | ||
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | ||
Self::from_str(&String::deserialize(deserializer)?) | ||
|
@@ -64,7 +77,7 @@ impl Display for Address { | |
host, | ||
port, | ||
} => write!(f, "{}{}@{}:{}", TCP_PREFIX, peer_id, host, port), | ||
Address::Unix { path } => write!(f, "{}{}", UNIX_PREFIX, path.display()), | ||
Address::Unix { path } => write!(f, "{}{}", UNIX_PREFIX, path), | ||
} | ||
} | ||
} | ||
|
@@ -83,7 +96,8 @@ impl FromStr for Address { | |
match url.scheme() { | ||
"tcp" => Ok(Self::Tcp { | ||
peer_id: if !url.username().is_empty() { | ||
Some(url.username().parse()?) | ||
let username = url.username().parse().map_err(Error::tendermint)?; | ||
Some(username) | ||
} else { | ||
None | ||
}, | ||
|
@@ -98,7 +112,7 @@ impl FromStr for Address { | |
})?, | ||
}), | ||
"unix" => Ok(Self::Unix { | ||
path: PathBuf::from(url.path()), | ||
path: url.path().to_string(), | ||
}), | ||
_ => Err(Error::parse(format!("invalid address scheme: {:?}", addr))), | ||
} | ||
|
@@ -114,7 +128,7 @@ impl Serialize for Address { | |
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::node; | ||
use tendermint::node; | ||
|
||
const EXAMPLE_TCP_ADDR: &str = | ||
"tcp://[email protected]:26656"; | ||
|
@@ -175,7 +189,7 @@ mod tests { | |
let addr = EXAMPLE_UNIX_ADDR.parse::<Address>().unwrap(); | ||
match addr { | ||
Address::Unix { path } => { | ||
assert_eq!(path.to_str().unwrap(), "/tmp/node.sock"); | ||
assert_eq!(path, "/tmp/node.sock"); | ||
} | ||
other => panic!("unexpected address type: {:?}", other), | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.