Skip to content

Commit

Permalink
chore: features improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 9, 2025
1 parent c434b67 commit 82cc923
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 34 deletions.
33 changes: 20 additions & 13 deletions abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,38 @@ rust-version.workspace = true
version.workspace = true

[features]
default = [
"server",
"docker-tests",
"crypto",
"tcp",
"unix",
"grpc",
"tracing-span",
]
# By default, include the server feature together with both tcp and unix transports.
default = ["server", "docker-tests", "crypto", "tcp", "unix", "tracing-span"]
# docker-tests includes integration tests that require docker to be available
docker-tests = ["server"]
# Enable server support; this is most likely what you want (plus `tcp` and/or `unix`)
server = [
"tracing-subscriber/fmt",
"tenderdash-proto/server",
"dep:tokio",
"dep:tokio-util",
"dep:futures",
"grpc",
"std",
]
# std is deprecated, use "grpc" instead
std = ["grpc"]
grpc = ["tenderdash-proto/server"]
# DEPRECATED; use `server` instead
grpc = ["server"]

# Disable no_std support
std = ["tenderdash-proto/std"]

# Include crypto features, like signature verification
crypto = ["dep:lhash"]

# Include server TCP support
tcp = ["server"]

# Include server unix socket support
unix = ["server"]

# Include `tracing` crate spans
tracing-span = ["dep:uuid"]

# Include `serde` support
serde = ["tenderdash-proto/serde", "dep:serde_json"]

[[example]]
Expand Down
15 changes: 11 additions & 4 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@ all-features = true
# issues related to outdated generated files.
default = ["server"]

# Enable standard library support; DEPRECATED - use `client` and/or `server` instead
# Enable standard library support; required by `client` and `server`
std = ["client"]
# Enable gRPC support using tonic; internal, consider using `server` or `client` instead
grpc = ["client", "dep:tonic", "tonic/codegen", "tonic/prost"]
# Enable gRPC support using tonic; DEPRECATED, consider using `server` or `client` instead
grpc = ["client"]
# Build gRPC server using tonic. Includes `client` feature.
server = ["client", "tonic/transport"]
# Build minimal gRPC client using tonic, without transport
client = ["tenderdash-proto-compiler/grpc", "prost/std", "grpc"]
client = [
"tenderdash-proto-compiler/grpc",
"prost/std",
"dep:tonic",
"tonic/codegen",
"tonic/prost",
"std",
]

serde = ["dep:serde", "bytes/serde"]

Expand Down
4 changes: 2 additions & 2 deletions proto/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! This module defines the various errors that be raised during Protobuf
//! conversions.
#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::{convert::TryFrom, fmt::Display, num::TryFromIntError};
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::{fmt::Display, num::TryFromIntError};

use flex_error::{define_error, DisplayOnly};
Expand Down
6 changes: 3 additions & 3 deletions proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! tenderdash-proto library gives the developer access to the Tenderdash
//! proto-defined structs.
#![cfg_attr(not(feature = "grpc"), no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)]
#![allow(clippy::large_enum_variant)]
#![allow(clippy::doc_lazy_continuation)]
Expand All @@ -21,12 +21,12 @@ pub mod google {

mod error;

#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::{
convert::{TryFrom, TryInto},
fmt::Display,
};
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::fmt::Display;

use bytes::{Buf, BufMut};
Expand Down
2 changes: 1 addition & 1 deletion proto/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use alloc::{
};
pub use core::prelude::v1::*;

#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
pub use tonic;

pub use crate::time::{FromMillis, ToMillis};
4 changes: 2 additions & 2 deletions proto/src/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// Prost does not seem to have a way yet to remove documentations defined in
// protobuf files. These structs are defined in gogoproto v1.3.1 at https://github.com/gogo/protobuf/tree/v1.3.1/protobuf/google/protobuf

#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::fmt;
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::fmt;

/// A Timestamp represents a point in time independent of any time zone or local
Expand Down
4 changes: 2 additions & 2 deletions proto/src/serializers/from_str.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! 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.
#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::{fmt::Display, str::FromStr};
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::{fmt::Display, str::FromStr};

use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
Expand Down
4 changes: 2 additions & 2 deletions proto/src/serializers/part_set_header_total.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//! Tendermint Core v0.34.0. This deserializer allows backwards-compatibility by
//! deserializing both ways. See also: <https://github.com/informalsystems/tendermint-rs/issues/679>
#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::{convert::TryFrom, fmt::Formatter};
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::fmt::Formatter;

use serde::{
Expand Down
4 changes: 2 additions & 2 deletions proto/src/serializers/time_duration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Serialize/deserialize core::time::Duration type from and into string:
#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::time::Duration;
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::time::Duration;

use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
Expand Down
4 changes: 2 additions & 2 deletions proto/src/serializers/timestamp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Serialize/deserialize Timestamp type from and into string:
#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::fmt::{self, Debug};
#[cfg(feature = "grpc")]
#[cfg(feature = "std")]
use std::fmt::{self, Debug};

use serde::{de::Error as _, ser::Error, Deserialize, Deserializer, Serialize, Serializer};
Expand Down
2 changes: 1 addition & 1 deletion proto/tests/unit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(not(feature = "grpc"))]
#[cfg(not(feature = "std"))]
use core::convert::TryFrom;

use tenderdash_proto::{
Expand Down

0 comments on commit 82cc923

Please sign in to comment.