Skip to content

Commit

Permalink
chore: upgrade tonic and prost (#6067)
Browse files Browse the repository at this point in the history
Description
---
We were hoping to get moved onto a more modern version of both but this
will not be possible. Between versions 0.8.4 and 0.9.0 of tonic they
dropped support for the rust 2018 version. We would also need to upgrade
to 2021 to make further use of more recent versions of tonic.

This PR upgrades them to the most recent possible.

I additionally tried seeing if we could run older versions only _where
nedded_ and run more modern version in other places but most of our
tonic use is tied to the grpc and the grpc clients require the older
version, in turn most everything requires the old version.

Motivation and Context
---
Upgrade the old to something newer.

How Has This Been Tested?
---
CI

Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

---------

Co-authored-by: SW van Heerden <[email protected]>
  • Loading branch information
brianp and SWvheerden authored Jan 12, 2024
1 parent a4c5bc2 commit 3ab7d5d
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 166 deletions.
194 changes: 66 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions applications/minotari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ base64 = "0.13.0"
borsh = "1.2"
chrono = { version = "0.4.19", default-features = false }
log = "0.4"
prost = "0.9"
prost-types = "0.9"
prost = "0.11.9"
prost-types = "0.11.9"
rand = "0.8"
rcgen = "0.11.3"
subtle = { version = "2.5.0", features = ["core_hint_black_box"] }
thiserror = "1"
tokio = { version = "1.23", features = ["fs"] }
tonic = "0.6.2"
tonic = { version = "0.8.3", features = ["tls"]}
zeroize = "1"

[build-dependencies]
tonic-build = "0.6.2"
tonic-build = "0.8.4"

[package.metadata.cargo-machete]
ignored = ["prost"] # this is so we can run cargo machete without getting false positive about macro dependancies
20 changes: 8 additions & 12 deletions applications/minotari_app_grpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
// SPDX-License-Identifier: BSD-3-Clause

fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_client(true)
.build_server(true)
.format(false)
.compile(
&[
"proto/base_node.proto",
"proto/wallet.proto",
"proto/validator_node.proto",
],
&["proto"],
)?;
tonic_build::configure().build_client(true).build_server(true).compile(
&[
"proto/base_node.proto",
"proto/wallet.proto",
"proto/validator_node.proto",
],
&["proto"],
)?;

Ok(())
}
2 changes: 1 addition & 1 deletion applications/minotari_app_grpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod authentication;
pub mod conversions;

pub mod tls;

#[allow(clippy::all, clippy::pedantic)]
pub mod tari_rpc {
tonic::include_proto!("tari.rpc");
}
2 changes: 1 addition & 1 deletion applications/minotari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tokio = { version = "1.23", features = ["signal"] }
serde = "1.0.126"
thiserror = "^1.0.26"
dialoguer = { version = "0.10" }
tonic = "0.6.2"
tonic = "0.8.3"


[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sha2 = "0.10"
strum = "0.22"
strum_macros = "0.22"
thiserror = "1.0.26"
tonic = "0.6.2"
tonic = "0.8.3"
unicode-segmentation = "1.6.0"
unicode-width = "0.1"
zeroize = "1"
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_merge_mining_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ serde = { version = "1.0.106", features = ["derive"] }
serde_json = "1.0.57"
thiserror = "1.0.26"
tokio = { version = "1.23", features = ["macros"] }
tonic = "0.6.2"
tonic = "0.8.3"
tracing = "0.1"
url = "2.1.1"

Expand Down
4 changes: 2 additions & 2 deletions applications/minotari_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ serde = { version = "1.0", default_features = false, features = ["derive"] }
serde_json = "1.0.57"
thiserror = "1.0"
tokio = { version = "1.23", default_features = false, features = ["rt-multi-thread"] }
tonic = { version = "0.6.2", features = ["tls", "tls-roots" ] }
tonic = { version = "0.8.3", features = ["tls", "tls-roots" ] }

[dev-dependencies]
prost-types = "0.9"
prost-types = "0.11.9"
chrono = { version = "0.4.19", default-features = false }
config = "0.13.0"

Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ serde = "1.0.136"
strum = { version = "0.22", features = ["derive"] }
thiserror = "^1.0.26"
tokio = { version = "1.23", features = ["signal"] }
tonic = { version = "0.6.2", features = ["tls", "tls-roots" ] }
tonic = { version = "0.8.3", features = ["tls", "tls-roots" ] }

# Metrics
tari_metrics = { path = "../../infrastructure/metrics", optional = true, features = ["server"] }
Expand Down
2 changes: 1 addition & 1 deletion base_layer/contacts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ futures = { version = "^0.3.1", features = ["compat", "std"] }
log = "0.4.6"
num-derive = "0.3.3"
num-traits = "0.2.15"
prost = "0.9"
prost = "0.11.9"
rand = "0.8"
serde = "1.0.136"
serde_json = "1.0.79"
Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ num-traits = "0.2.15"
num-derive = "0.3.3"
num-format = "0.4.0"
once_cell = "1.8.0"
prost = "0.9"
prost = "0.11.9"
rand = "0.8"
randomx-rs = { version = "1.3", optional = true }
serde = { version = "1.0.106", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion base_layer/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ futures = { version = "^0.3.1" }
lmdb-zero = "0.4.4"
log = "0.4.6"
pgp = { version = "0.10", optional = true }
prost = "=0.9.0"
prost = "0.11.9"
rand = "0.8"
reqwest = { version = "0.11", optional = true, default-features = false }
rustls = "0.20.2"
Expand Down
2 changes: 2 additions & 0 deletions base_layer/p2p/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#[allow(clippy::all, clippy::pedantic)]
pub(crate) mod liveness {
tari_comms::outdir_include!("tari.p2p.liveness.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub(crate) mod message_type {
tari_comms::outdir_include!("tari.p2p.message_type.rs");
}
4 changes: 2 additions & 2 deletions base_layer/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ strum_macros = "0.22"
tempfile = "3.1.0"
thiserror = "1.0.26"
tower = "0.4"
prost = "0.9"
prost = "0.11.9"
itertools = "0.10.3"
chacha20poly1305 = "0.10.1"
zeroize = "1"
Expand All @@ -65,7 +65,7 @@ tari_comms_dht = { path = "../../comms/dht", features = ["test-mocks"] }
tari_test_utils = { path = "../../infrastructure/test_utils" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions", "mempool_proto", "base_node_proto", "base_node"] }
env_logger = "0.7.1"
prost = "0.9.0"
prost = "0.11.9"

[features]
default = ["bundled_sqlite"]
Expand Down
2 changes: 1 addition & 1 deletion clients/rust/wallet_grpc_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ minotari_app_grpc = { path = "../../../applications/minotari_app_grpc" }
tari_common_types = { path = "../../../base_layer/common_types" }

thiserror = "1.0.35"
tonic = { version = "0.6", default-features = false, features = ["codegen", "transport"] }
tonic = { version = "0.8.3", default-features = false, features = ["codegen", "transport", "tls"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ log = "0.4.8"
log4rs = { git = "https://github.com/tari-project/log4rs.git", default_features = false, features = ["config_parsing", "threshold_filter", "yaml_format"] }
multiaddr = { version = "0.14.0" }
path-clean = "0.1.0"
prost-build = { version = "0.9.0", optional = true }
prost-build = { version = "0.11.9", optional = true }
serde = { version = "1.0.106", default_features = false }
serde_json = "1.0.51"
serde_yaml = "0.9.17"
Expand Down
2 changes: 1 addition & 1 deletion comms/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ multiaddr = { version = "0.14.0" }
nom = { version = "7.1", features = ["std"], default-features = false }
once_cell = "1.8.0"
pin-project = "1.0.8"
prost = "=0.9.0"
prost = "=0.11.9"
rand = "0.8"
serde = "1.0.119"
serde_derive = "1.0.119"
Expand Down
3 changes: 3 additions & 0 deletions comms/core/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#[allow(clippy::all, clippy::pedantic)]
pub(crate) mod envelope {
outdir_include!("tari.comms.envelope.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub(crate) mod identity {
outdir_include!("tari.comms.identity.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub(crate) mod rpc {
outdir_include!("tari.comms.rpc.rs");
}
2 changes: 1 addition & 1 deletion comms/dht/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ digest = "0.10"
futures = "^0.3.1"
log = "0.4.8"
log-mdc = "0.1.0"
prost = "=0.9.0"
prost = "=0.11.9"
rand = "0.8"
serde = "1.0.90"
thiserror = "1.0.26"
Expand Down
6 changes: 6 additions & 0 deletions comms/dht/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,33 @@ use tari_utilities::{hex::Hex, ByteArray};

use crate::{proto::dht::JoinMessage, rpc::UnvalidatedPeerInfo};

#[allow(clippy::all, clippy::pedantic)]
pub mod common {
tari_comms::outdir_include!("tari.dht.common.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub mod envelope {
tari_comms::outdir_include!("tari.dht.envelope.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub mod dht {
use super::common;
tari_comms::outdir_include!("tari.dht.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub mod rpc {
tari_comms::outdir_include!("tari.dht.rpc.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub mod store_forward {
tari_comms::outdir_include!("tari.dht.store_forward.rs");
}

#[allow(clippy::all, clippy::pedantic)]
pub mod message_header {
tari_comms::outdir_include!("tari.dht.message_header.rs");
}
Expand Down
2 changes: 1 addition & 1 deletion comms/rpc_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ tari_comms = { path = "../core", features = ["rpc"] }
tari_test_utils = { path = "../../infrastructure/test_utils" }

futures = "0.3.5"
prost = "0.9.0"
prost = "0.11.9"
tokio = { version = "1", features = ["macros"] }
tower-service = "0.3"
8 changes: 4 additions & 4 deletions comms/rpc_macros/tests/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub trait Test: Sync + Send + 'static {
fn some_non_rpc_method(&self);
}

#[derive(prost::Message)]
pub struct CustomMessage;
#[derive(Clone, PartialEq, prost::Message)]
pub struct CustomMessage {}

#[derive(Default)]
pub struct TestService {
Expand Down Expand Up @@ -127,7 +127,7 @@ async fn it_correctly_maps_the_method_nums() {
.unwrap();
assert_eq!(*spy.read().await.get("request_response").unwrap(), 1);
server
.call(Request::new(2.into(), CustomMessage.to_encoded_bytes().into()))
.call(Request::new(2.into(), CustomMessage {}.to_encoded_bytes().into()))
.await
.unwrap();
assert_eq!(*spy.read().await.get("server_streaming").unwrap(), 1);
Expand Down Expand Up @@ -167,7 +167,7 @@ async fn it_generates_client_calls() {
// This is a test that the correct client functions are generated - if this test compiles then it has already passed
task::spawn(async move {
let _result = client.request_response(111).await;
let mut streaming_resp = client.server_streaming(CustomMessage).await.unwrap();
let mut streaming_resp = client.server_streaming(CustomMessage {}).await.unwrap();
streaming_resp.next().await;
let _result = client.unit().await;
});
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tempfile = "3.3.0"
thiserror = "^1.0.20"
time = "0.3.15"
tokio = { version = "1.10", features = ["macros", "time", "sync", "rt-multi-thread"] }
tonic = "0.6.2"
tonic = "0.8.3"

[package.metadata.cargo-machete]
ignored = ["minotari_wallet_ffi", "minotari_chat_ffi"]
Expand Down

0 comments on commit 3ab7d5d

Please sign in to comment.