Skip to content

Commit

Permalink
feat(proto): grpc server and client support
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Feb 20, 2024
1 parent 8b5afe6 commit be0abff
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
12 changes: 12 additions & 0 deletions proto-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ regex = { "version" = "1.7.1" }
ureq = { "version" = "2.6.2" }
zip = { version = "0.6.4", default-features = false, features = ["deflate"] }
fs_extra = { version = "1.3.0" }
tonic-build = { version = "0.11.0", optional = true }


[features]
default = []
# Enable gRPC support; needed by server and client features.
# Conflicts with no_std
grpc = ["dep:tonic-build"]
# Build the gRPC server. Requires tenderdash-proto/std feature.
server = ["grpc"]
# Build the gRPC client. Requires tenderdash-proto/std feature.
client = ["grpc"]
7 changes: 7 additions & 0 deletions proto-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ pub fn proto_compile() {
let tenderdash_ver = tenderdash_version(tenderdash_dir);

println!("[info] => Creating structs.");

#[cfg(feature = "grpc")]
tonic_build::configure()
.compile_with_config(pb, &protos, &proto_includes_paths)
.unwrap();

#[cfg(not(feature = "grpc"))]
pb.compile_protos(&protos, &proto_includes_paths).unwrap();

println!("[info] => Removing old structs and copying new structs.");
Expand Down
12 changes: 12 additions & 0 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ description = """
[package.metadata.docs.rs]
all-features = true

[features]
default = ["grpc-server"]

# Enable standard library support
std = ["prost/std", "prost-types/std"]
# Build gRPC server
grpc-server = ["tenderdash-proto-compiler/server", "std"]
grpc-client = ["tenderdash-proto-compiler/client", "std"]

[dependencies]
prost = { version = "0.12", default-features = false, features = [
"prost-derive",
] }
prost-types = { version = "0.12", default-features = false }
tonic = { version = "0.11" }
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 = [
Expand All @@ -39,6 +50,7 @@ derive_more = { version = "0.99.17" }

[dev-dependencies]
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
tenderdash-abci = { path = "../abci" }

[build-dependencies]
tenderdash-proto-compiler = { path = "../proto-compiler" }
2 changes: 1 addition & 1 deletion proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! tenderdash-proto library gives the developer access to the Tenderdash
//! proto-defined structs.
#![no_std]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)]
#![allow(clippy::large_enum_variant)]
#![forbid(unsafe_code)]
Expand Down
8 changes: 8 additions & 0 deletions proto/tests/grpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use tenderdash_abci::common::docker::TenderdashDocker;

#[test]
fn test_docker() {
let container_name = "tenderdash_test";
let app_address = "tcp://;

}

0 comments on commit be0abff

Please sign in to comment.