From 4a5df52faf03800712cd0d837279cbc3a96eb070 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:39:26 +0200 Subject: [PATCH 1/3] fix(tenderdash-abci): correct handling of features --- abci/src/lib.rs | 1 + abci/src/server.rs | 15 ++++++++++----- abci/src/server/generic.rs | 16 ++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/abci/src/lib.rs b/abci/src/lib.rs index 9f65419a..53e983d2 100644 --- a/abci/src/lib.rs +++ b/abci/src/lib.rs @@ -21,6 +21,7 @@ use std::io; pub use application::{check_version, Application, RequestDispatcher}; use prost::{DecodeError, EncodeError}; #[allow(deprecated)] +#[cfg(feature = "server")] pub use server::{start_server, CancellationToken, Server, ServerBuilder}; pub use tenderdash_proto as proto; diff --git a/abci/src/server.rs b/abci/src/server.rs index 1ee09590..9b33151b 100644 --- a/abci/src/server.rs +++ b/abci/src/server.rs @@ -2,20 +2,25 @@ mod codec; mod generic; +#[cfg(feature = "tcp")] use std::{ net::{IpAddr, SocketAddr, SocketAddrV4, SocketAddrV6}, str::FromStr, }; -use tokio::{ - net::{TcpListener, UnixListener}, - runtime::{Handle, Runtime}, -}; +#[cfg(feature = "tcp")] +use tokio::net::TcpListener; +#[cfg(feature = "unix")] +use tokio::net::UnixListener; +use tokio::runtime::{Handle, Runtime}; pub use tokio_util::sync::CancellationToken; use self::generic::GenericServer; use crate::{application::RequestDispatcher, Error}; +#[cfg(not(any(feature = "tcp", feature = "unix")))] +compile_error!("At least one of `tcp` or `unix` features must be enabled"); + /// ABCI Server handle. /// /// Use [`Server::handle_connection()`] to accept connection and process all @@ -247,7 +252,7 @@ where { ServerBuilder::new(app, bind_address.as_ref()).build() } - +#[cfg(feature = "tcp")] fn parse_tcp_uri(uri: url::Url) -> SocketAddr { let host = uri.host_str().unwrap(); // remove '[' and ']' from ipv6 address, as per https://github.com/servo/rust-url/issues/770 diff --git a/abci/src/server/generic.rs b/abci/src/server/generic.rs index 2e57496d..75b08d02 100644 --- a/abci/src/server/generic.rs +++ b/abci/src/server/generic.rs @@ -1,11 +1,15 @@ //! Generic ABCI server +#[cfg(feature = "tcp")] +use std::net::ToSocketAddrs; +use std::{fmt::Debug, sync::Arc}; +#[cfg(feature = "unix")] +use std::{fs, path::Path}; -use std::{fmt::Debug, fs, net::ToSocketAddrs, path::Path, sync::Arc}; - -use tokio::{ - net::{TcpListener, UnixListener}, - sync::Mutex, -}; +#[cfg(feature = "tcp")] +use tokio::net::TcpListener; +#[cfg(feature = "unix")] +use tokio::net::UnixListener; +use tokio::sync::Mutex; use tokio_util::net::Listener; use tracing::info; From ffe7c820f83a59d338403bbc81437ce6112181c4 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:47:04 +0200 Subject: [PATCH 2/3] chore: change resolver in cargo.toml to 2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f1f5d87a..78f73332 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] - +resolver = "2" members = ["abci", "proto-compiler", "proto"] From 65fe24b0c5626665243f3a6264d3e539eb320ca2 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:10:59 +0200 Subject: [PATCH 3/3] fix: missing prost-derive feature in proto --- proto/Cargo.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 8e059857..31ad6c15 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -16,7 +16,9 @@ description = """ all-features = true [dependencies] -prost = { version = "0.12", default-features = false } +prost = { version = "0.12", default-features = false, features = [ + "prost-derive", +] } bytes = { version = "1.0", default-features = false, features = ["serde"] } serde = { version = "1.0", default-features = false, features = ["derive"] } subtle-encoding = { version = "0.5", default-features = false, features = [