diff --git a/Cargo.lock b/Cargo.lock index c96e849bd7..3e94303a35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,13 +265,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.52" +version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -300,6 +300,51 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http 0.2.12", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 0.2.12", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -562,12 +607,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" - [[package]] name = "bytes" version = "1.1.0" @@ -1190,7 +1229,7 @@ dependencies = [ "byteorder", "chrono", "diesel_derives", - "itoa 1.0.1", + "itoa", "pq-sys", "r2d2", ] @@ -1780,7 +1819,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e398946b5721d72478eb647260a1b7c1d5f70f0de35399846c3913bd369a33e" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-executor", "futures-util", "grpcio-sys", @@ -1825,13 +1864,13 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ - "bytes 1.1.0", + "bytes", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.1", - "indexmap", + "http 0.2.12", + "indexmap 2.0.0", "slab", "tokio", "tokio-util", @@ -1877,9 +1916,9 @@ checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.1", "bitflags 1.3.2", - "bytes 1.1.0", + "bytes", "headers-core", - "http 0.2.1", + "http 0.2.12", "httpdate", "mime", "sha1", @@ -1891,7 +1930,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http 0.2.1", + "http 0.2.12", ] [[package]] @@ -1999,13 +2038,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.1" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "bytes 0.5.4", + "bytes", "fnv", - "itoa 0.4.8", + "itoa", ] [[package]] @@ -2014,19 +2053,19 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ - "bytes 1.1.0", + "bytes", "fnv", - "itoa 1.0.1", + "itoa", ] [[package]] name = "http-body" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes 1.1.0", - "http 0.2.1", + "bytes", + "http 0.2.12", "pin-project-lite", ] @@ -2054,16 +2093,16 @@ version = "0.14.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-channel", "futures-core", "futures-util", "h2", - "http 0.2.1", + "http 0.2.12", "http-body", "httparse", "httpdate", - "itoa 1.0.1", + "itoa", "pin-project-lite", "socket2 0.4.9", "tokio", @@ -2078,7 +2117,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ - "http 0.2.1", + "http 0.2.12", "hyper", "log", "rustls 0.20.7", @@ -2094,13 +2133,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", - "http 0.2.1", + "http 0.2.12", "hyper", "rustls 0.21.11", "tokio", "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "iana-time-zone" version = "0.1.47" @@ -2151,6 +2202,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.0.0" @@ -2229,15 +2290,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.8" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" @@ -2406,6 +2461,12 @@ dependencies = [ "regex-automata 0.1.9", ] +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "mbedtls" version = "0.8.1" @@ -2538,6 +2599,8 @@ dependencies = [ "rand", "rand_core", "rand_hc", + "tonic", + "tonic-build", ] [[package]] @@ -2591,6 +2654,8 @@ dependencies = [ "mc-util-build-script", "mc-util-serial", "prost", + "tonic", + "tonic-build", ] [[package]] @@ -2932,6 +2997,8 @@ dependencies = [ "prost", "rand_core", "rand_hc", + "tonic", + "tonic-build", ] [[package]] @@ -3636,6 +3703,8 @@ dependencies = [ "mc-util-test-helper", "mc-watcher-api", "prost", + "tonic", + "tonic-build", ] [[package]] @@ -4320,6 +4389,8 @@ dependencies = [ "mc-util-build-grpc", "mc-util-build-script", "prost", + "tonic", + "tonic-build", ] [[package]] @@ -5221,6 +5292,8 @@ dependencies = [ "mc-util-uri", "prost", "rand", + "tonic", + "tonic-build", ] [[package]] @@ -5713,6 +5786,8 @@ dependencies = [ "mc-util-build-script", "mc-util-uri", "prost", + "tonic", + "tonic-build", ] [[package]] @@ -6591,7 +6666,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" dependencies = [ - "bytes 1.1.0", + "bytes", "encoding_rs", "futures-util", "http 1.2.0", @@ -6728,7 +6803,7 @@ checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" dependencies = [ "futures-core", "futures-sink", - "indexmap", + "indexmap 2.0.0", "js-sys", "once_cell", "pin-project-lite", @@ -6743,8 +6818,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f51189ce8be654f9b5f7e70e49967ed894e84a06fc35c6c042e64ac1fc5399e" dependencies = [ "async-trait", - "bytes 1.1.0", - "http 0.2.1", + "bytes", + "http 0.2.12", "opentelemetry", "reqwest", ] @@ -6759,7 +6834,7 @@ dependencies = [ "futures-core", "futures-util", "headers", - "http 0.2.1", + "http 0.2.12", "opentelemetry", "opentelemetry-http", "opentelemetry-semantic-conventions", @@ -6993,7 +7068,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.0.0", +] + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", ] [[package]] @@ -7231,7 +7326,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ - "bytes 1.1.0", + "bytes", "prost-derive", ] @@ -7241,7 +7336,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ - "bytes 1.1.0", + "bytes", "heck", "itertools 0.10.5", "lazy_static", @@ -7477,12 +7572,12 @@ checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "async-compression", "base64 0.21.7", - "bytes 1.1.0", + "bytes", "encoding_rs", "futures-core", "futures-util", "h2", - "http 0.2.1", + "http 0.2.12", "http-body", "hyper", "hyper-rustls 0.24.1", @@ -7577,11 +7672,11 @@ dependencies = [ "async-trait", "atomic", "binascii", - "bytes 1.1.0", + "bytes", "either", "figment", "futures", - "indexmap", + "indexmap 2.0.0", "log", "memchr", "multer", @@ -7613,7 +7708,7 @@ checksum = "575d32d7ec1a9770108c879fc7c47815a80073f96ca07ff9525a94fcede1dd46" dependencies = [ "devise", "glob", - "indexmap", + "indexmap 2.0.0", "proc-macro2", "quote", "rocket_http", @@ -7631,9 +7726,9 @@ dependencies = [ "cookie", "either", "futures", - "http 0.2.1", + "http 0.2.12", "hyper", - "indexmap", + "indexmap 2.0.0", "log", "memchr", "pear", @@ -7666,10 +7761,10 @@ checksum = "1db30db44ea73551326269adcf7a2169428a054f14faf9e1768f2163494f2fa2" dependencies = [ "async-trait", "base64 0.13.1", - "bytes 1.1.0", + "bytes", "crc32fast", "futures", - "http 0.2.1", + "http 0.2.12", "hyper", "hyper-rustls 0.23.2", "lazy_static", @@ -7708,7 +7803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7aae4677183411f6b0b412d66194ef5403293917d66e70ab118f07cc24c5b14d" dependencies = [ "async-trait", - "bytes 1.1.0", + "bytes", "futures", "rusoto_core", "xml-rs", @@ -7721,13 +7816,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5ae95491c8b4847931e291b151127eccd6ff8ca13f33603eb3d0035ecb05272" dependencies = [ "base64 0.13.1", - "bytes 1.1.0", + "bytes", "chrono", "digest 0.9.0", "futures", "hex", "hmac 0.11.0", - "http 0.2.1", + "http 0.2.12", "hyper", "log", "md-5", @@ -7847,9 +7942,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "rusty-fork" @@ -8152,7 +8247,7 @@ version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ - "itoa 1.0.1", + "itoa", "ryu", "serde", ] @@ -8173,7 +8268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.1", + "itoa", "ryu", "serde", ] @@ -8740,7 +8835,7 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d634a985c4d4238ec39cacaed2e7ae552fbd3c476b552c1deac3021b7d7eaf0c" dependencies = [ - "itoa 1.0.1", + "itoa", "libc", "num_threads", "time-macros", @@ -8803,7 +8898,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", - "bytes 1.1.0", + "bytes", "libc", "mio", "num_cpus", @@ -8815,6 +8910,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd86198d9ee903fedd2f9a2e72014287c0d9167e4ae43b5853007205dda1b76" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-macros" version = "2.2.0" @@ -8864,7 +8969,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-core", "futures-sink", "pin-project-lite", @@ -8920,7 +9025,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -8933,18 +9038,88 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", "winnow", ] +[[package]] +name = "tonic" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "rustls-pemfile", + "tokio", + "tokio-rustls 0.24.1", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" +dependencies = [ + "prettyplease 0.1.25", + "proc-macro2", + "prost-build", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" diff --git a/Cargo.toml b/Cargo.toml index 2a84df8b6c..c8ab926936 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -342,6 +342,8 @@ textwrap = "0.16" tiny-bip39 = "1" tokio = "1" toml = "0.8" +tonic = { version = "0.9", default-features = false } +tonic-build = "0.9" url = "2" walkdir = "2" wasm-bindgen = "0.2" diff --git a/api/Cargo.toml b/api/Cargo.toml index 4e59c043c6..6c49b2edbc 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -33,10 +33,12 @@ mc-sgx-dcap-types = { workspace = true } curve25519-dalek = { workspace = true } prost = { workspace = true } +tonic = { workspace = true, features = ["codegen", "prost"] } [build-dependencies] mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } cargo-emit = { workspace = true } diff --git a/api/build.rs b/api/build.rs index ccc5aa249d..bb82ead998 100644 --- a/api/build.rs +++ b/api/build.rs @@ -12,14 +12,18 @@ fn main() { .expect("Invalid UTF-8 in proto dir"); cargo_emit::pair!("PROTOS_PATH", "{}", proto_str); - mc_util_build_grpc::compile_protos_and_generate_mod_rs( - &[proto_str], - &[ - "blockchain.proto", - "external.proto", - "printable.proto", - "quorum_set.proto", - "watcher.proto", - ], - ); + let protos = [ + "blockchain.proto", + "external.proto", + "printable.proto", + "quorum_set.proto", + "watcher.proto", + ]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(&[proto_str], &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, &[proto_str]) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/api/src/lib.rs b/api/src/lib.rs index 8d1bd06fcf..0bba5ca079 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -6,6 +6,15 @@ mod autogenerated_code { // Include the auto-generated code. include!(concat!(env!("OUT_DIR"), "/protos-auto-gen/mod.rs")); } + +pub mod tonic { + tonic::include_proto!("blockchain"); + tonic::include_proto!("external"); + tonic::include_proto!("printable"); + tonic::include_proto!("quorum_set"); + tonic::include_proto!("watcher"); +} + mod convert; pub mod display; diff --git a/attest/api/Cargo.toml b/attest/api/Cargo.toml index eda77bd233..fc91a27c21 100644 --- a/attest/api/Cargo.toml +++ b/attest/api/Cargo.toml @@ -31,11 +31,13 @@ aead = { workspace = true } digest = { workspace = true } futures = { workspace = true } grpcio = { workspace = true, features = ["prost-codec"] } -prost = { workspace = true } +prost = { workspace = true, features = ["prost-derive"] } +tonic = { workspace = true, features = ["transport", "tls", "codegen", "prost"] } [build-dependencies] mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } cargo-emit = { workspace = true } diff --git a/attest/api/build.rs b/attest/api/build.rs index 2cddbf7bf6..e9461bd59e 100644 --- a/attest/api/build.rs +++ b/attest/api/build.rs @@ -14,5 +14,12 @@ fn main() { .expect("Invalid UTF-8 in proto dir path") ); - mc_util_build_grpc::compile_protos_and_generate_mod_rs(&["./proto"], &["attest.proto"]); + let protos = ["attest.proto"]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(&["./proto"], &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, &["./proto"]) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/attest/api/src/lib.rs b/attest/api/src/lib.rs index 12fc52d27d..a427826d34 100644 --- a/attest/api/src/lib.rs +++ b/attest/api/src/lib.rs @@ -7,5 +7,9 @@ mod autogenerated_code { include!(concat!(env!("OUT_DIR"), "/protos-auto-gen/mod.rs")); } +pub mod tonic { + tonic::include_proto!("attest"); +} + pub mod convert; pub use autogenerated_code::*; diff --git a/consensus/api/Cargo.toml b/consensus/api/Cargo.toml index 7094ea2d6d..8944593c90 100644 --- a/consensus/api/Cargo.toml +++ b/consensus/api/Cargo.toml @@ -18,10 +18,12 @@ mc-transaction-core = { workspace = true } futures = { workspace = true } grpcio = { workspace = true, features = ["prost-codec"] } prost = { workspace = true } +tonic = { workspace = true, features = ["transport", "tls", "codegen", "prost"] } [build-dependencies] mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } cargo-emit = { workspace = true } diff --git a/consensus/api/build.rs b/consensus/api/build.rs index 047631fee5..fc328ff8d5 100644 --- a/consensus/api/build.rs +++ b/consensus/api/build.rs @@ -25,13 +25,17 @@ fn main() { .to_owned(); all_proto_dirs.extend(api_proto_path.split(':').collect::>()); - mc_util_build_grpc::compile_protos_and_generate_mod_rs( - all_proto_dirs.as_slice(), - &[ - "consensus_client.proto", - "consensus_common.proto", - "consensus_config.proto", - "consensus_peer.proto", - ], - ); + let protos = [ + "consensus_client.proto", + "consensus_common.proto", + "consensus_config.proto", + "consensus_peer.proto", + ]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(all_proto_dirs.as_slice(), &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, all_proto_dirs.as_slice()) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/consensus/api/src/lib.rs b/consensus/api/src/lib.rs index a9b227fb9b..8ed9919f3c 100644 --- a/consensus/api/src/lib.rs +++ b/consensus/api/src/lib.rs @@ -37,6 +37,14 @@ mod autogenerated_code { } } +pub mod tonic { + pub use mc_attest_api::tonic as attest; + tonic::include_proto!("consensus_client"); + tonic::include_proto!("consensus_common"); + tonic::include_proto!("consensus_config"); + tonic::include_proto!("consensus_peer"); +} + pub mod conversions; pub use autogenerated_code::*; diff --git a/fog/api/Cargo.toml b/fog/api/Cargo.toml index 88efcebe6c..44bc598652 100644 --- a/fog/api/Cargo.toml +++ b/fog/api/Cargo.toml @@ -13,6 +13,7 @@ displaydoc = { workspace = true } futures = { workspace = true } grpcio = { workspace = true, features = ["prost-codec"] } prost = { workspace = true, features = ["prost-derive"] } +tonic = { workspace = true, features = ["codegen", "prost"] } mc-api = { workspace = true } mc-attest-api = { workspace = true } @@ -34,6 +35,7 @@ mc-watcher-api = { workspace = true } [build-dependencies] mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } cargo-emit = { workspace = true } diff --git a/fog/api/build.rs b/fog/api/build.rs index fa4ddcad41..91ee3e6806 100644 --- a/fog/api/build.rs +++ b/fog/api/build.rs @@ -41,16 +41,20 @@ fn main() { .to_owned(); all_proto_dirs.extend(consensus_api_proto_path.split(':').collect::>()); - mc_util_build_grpc::compile_protos_and_generate_mod_rs( - all_proto_dirs.as_slice(), - &[ - "fog_common.proto", - "ingest.proto", - "ingest_common.proto", - "ingest_peer.proto", - "kex_rng.proto", - "ledger.proto", - "view.proto", - ], - ); + let protos = [ + "fog_common.proto", + "ingest.proto", + "ingest_common.proto", + "ingest_peer.proto", + "kex_rng.proto", + "ledger.proto", + "view.proto", + ]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(all_proto_dirs.as_slice(), &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, all_proto_dirs.as_slice()) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/fog/api/src/lib.rs b/fog/api/src/lib.rs index 36ec8562d9..bba81b376f 100644 --- a/fog/api/src/lib.rs +++ b/fog/api/src/lib.rs @@ -36,6 +36,17 @@ mod autogenerated_code { } } +pub mod tonic { + #![allow(non_camel_case_types)] + tonic::include_proto!("fog_common"); + tonic::include_proto!("account_ingest"); + tonic::include_proto!("ingest_common"); + tonic::include_proto!("ingest_peer"); + tonic::include_proto!("kex_rng"); + tonic::include_proto!("fog_ledger"); + tonic::include_proto!("fog_view"); +} + pub use autogenerated_code::*; pub mod report_parse; diff --git a/fog/report/api/Cargo.toml b/fog/report/api/Cargo.toml index 829e2ebd7e..a2fde6f4b0 100644 --- a/fog/report/api/Cargo.toml +++ b/fog/report/api/Cargo.toml @@ -12,6 +12,7 @@ rust-version = { workspace = true } futures = { workspace = true } grpcio = { workspace = true, features = ["prost-codec"] } prost = { workspace = true, features = ["prost-derive"] } +tonic = { workspace = true, features = ["codegen", "prost"] } mc-api = { workspace = true } mc-attest-api = { workspace = true } @@ -22,6 +23,7 @@ mc-fog-report-types = { workspace = true } [build-dependencies] mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } cargo-emit = { workspace = true } diff --git a/fog/report/api/build.rs b/fog/report/api/build.rs index c1c22b1c72..167fa4e924 100644 --- a/fog/report/api/build.rs +++ b/fog/report/api/build.rs @@ -31,8 +31,12 @@ fn main() { .to_owned(); all_proto_dirs.extend(consensus_api_proto_path.split(':').collect::>()); - mc_util_build_grpc::compile_protos_and_generate_mod_rs( - all_proto_dirs.as_slice(), - &["report.proto"], - ); + let protos = ["report.proto"]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(all_proto_dirs.as_slice(), &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, all_proto_dirs.as_slice()) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/fog/report/api/src/lib.rs b/fog/report/api/src/lib.rs index bba90060e0..f294624c6a 100644 --- a/fog/report/api/src/lib.rs +++ b/fog/report/api/src/lib.rs @@ -9,6 +9,10 @@ mod autogenerated_code { } } +pub mod tonic { + tonic::include_proto!("report"); +} + use crate::fog_report::report::AttestationEvidence as ProtoAttestationEvidence; pub use autogenerated_code::*; use mc_attest_verifier_types::{prost, VerificationReport}; diff --git a/mobilecoind/api/Cargo.toml b/mobilecoind/api/Cargo.toml index 6d1c1152ca..89868de7ae 100644 --- a/mobilecoind/api/Cargo.toml +++ b/mobilecoind/api/Cargo.toml @@ -18,10 +18,12 @@ mc-util-uri = { workspace = true } futures = { workspace = true } grpcio = { workspace = true, features = ["prost-codec"] } prost = { workspace = true, features = ["prost-derive"] } +tonic = { workspace = true, features = ["codegen", "prost"] } [build-dependencies] mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } cargo-emit = { workspace = true } diff --git a/mobilecoind/api/build.rs b/mobilecoind/api/build.rs index 26c91dcedd..827adfe9ef 100644 --- a/mobilecoind/api/build.rs +++ b/mobilecoind/api/build.rs @@ -31,8 +31,12 @@ fn main() { .to_owned(); all_proto_dirs.extend(attest_api_proto_path.split(':')); - mc_util_build_grpc::compile_protos_and_generate_mod_rs( - all_proto_dirs.as_slice(), - &["mobilecoind_api.proto"], - ); + let protos = ["mobilecoind_api.proto"]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(all_proto_dirs.as_slice(), &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, all_proto_dirs.as_slice()) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/mobilecoind/api/src/lib.rs b/mobilecoind/api/src/lib.rs index 320cd27a4a..aa4e397b2c 100644 --- a/mobilecoind/api/src/lib.rs +++ b/mobilecoind/api/src/lib.rs @@ -17,6 +17,10 @@ mod autogenerated_code { } } +pub mod tonic { + tonic::include_proto!("mobilecoind_api"); +} + pub use autogenerated_code::{mobilecoind_api::*, *}; impl OutlayV2 { diff --git a/t3/api/Cargo.toml b/t3/api/Cargo.toml index b931ef962b..ac0d76406a 100644 --- a/t3/api/Cargo.toml +++ b/t3/api/Cargo.toml @@ -11,6 +11,7 @@ rust-version = { workspace = true } futures = { workspace = true } grpcio = { workspace = true, features = ["prost-codec"] } prost = { workspace = true } +tonic = { workspace = true, features = ["codegen", "prost"] } mc-util-uri = { workspace = true } @@ -18,3 +19,4 @@ mc-util-uri = { workspace = true } cargo-emit = { workspace = true } mc-util-build-grpc = { workspace = true } mc-util-build-script = { workspace = true } +tonic-build = { workspace = true } diff --git a/t3/api/build.rs b/t3/api/build.rs index 281d7dda33..35d304961d 100644 --- a/t3/api/build.rs +++ b/t3/api/build.rs @@ -12,8 +12,12 @@ fn main() { .expect("Invalid UTF-8 in proto dir"); cargo_emit::pair!("PROTOS_PATH", "{}", proto_str); - mc_util_build_grpc::compile_protos_and_generate_mod_rs( - &[proto_str], - &["external/v1/external.proto", "t3/v1/t3.proto"], - ); + let protos = ["external/v1/external.proto", "t3/v1/t3.proto"]; + + mc_util_build_grpc::compile_protos_and_generate_mod_rs(&[proto_str], &protos); + + tonic_build::configure() + .protoc_arg("--experimental_allow_proto3_optional") + .compile(&protos, &[proto_str]) + .expect("Failed to compile tonic gRPC definitions!"); } diff --git a/t3/api/src/lib.rs b/t3/api/src/lib.rs index 341ed1ffc2..0df0018f7e 100644 --- a/t3/api/src/lib.rs +++ b/t3/api/src/lib.rs @@ -15,6 +15,19 @@ mod autogenerated_code { } } +pub mod tonic { + pub mod external { + pub mod v1 { + tonic::include_proto!("external.v1"); + } + } + pub mod t3 { + pub mod v1 { + tonic::include_proto!("t3.v1"); + } + } +} + pub use autogenerated_code::{t3_v1::*, *}; pub type T3Uri = Uri;