Skip to content

Commit

Permalink
chore: upgrade prost and tonic (ring dep) (#6603)
Browse files Browse the repository at this point in the history
Description
---
chore: upgrade prost and tonic (ring dep)

Motivation and Context
---
Part of the way to removing ring 0.16. rcgen still required.

How Has This Been Tested?
---

What process can a PR reviewer use to test or verify this change?
---

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

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

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
sdbondi authored Oct 4, 2024
1 parent b7c8810 commit f7f7bb5
Show file tree
Hide file tree
Showing 29 changed files with 420 additions and 234 deletions.
532 changes: 357 additions & 175 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions applications/minotari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "This crate is to provide a single source for all cross applicatio
repository = "https://github.com/tari-project/tari"
license = "BSD-3-Clause"
version = "1.5.1-pre.1"
edition = "2018"
edition = "2021"

[dependencies]
tari_common_types = { path = "../../base_layer/common_types" }
Expand All @@ -21,19 +21,19 @@ base64 = "0.13.0"
borsh = "1.2"
chrono = { version = "0.4.19", default-features = false }
log = "0.4"
prost = "0.11.9"
prost-types = "0.11.9"
prost = "0.13.3"
prost-types = "0.13.3"
rand = "0.8"
rcgen = "0.11.3"
subtle = "2.5.0"
thiserror = "1"
tokio = { version = "1.36", features = ["fs"] }
tonic = { version = "0.8.3", features = ["tls"] }
tonic = { version = "0.12.3", features = ["tls"] }
zeroize = "1"

[build-dependencies]
tari_features = { path = "../../common/tari_features", version = "1.5.1-pre.1" }
tonic-build = "0.8.4"
tonic-build = "0.12.3"

[package.metadata.cargo-machete]
ignored = [
Expand Down
21 changes: 12 additions & 9 deletions applications/minotari_app_grpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ use tari_features::resolver::build_features;

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

Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@
// 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.

use std::borrow::Borrow;

use tari_core::base_node::state_machine_service::states::{
StateInfo,
StateInfo::{BlockSync, Connecting, HeaderSync, HorizonSync, Listening, StartUp, SyncFailed},
};

use crate::tari_rpc as grpc;

impl<T: Borrow<StateInfo>> From<T> for grpc::BaseNodeState {
fn from(info: T) -> Self {
match info.borrow() {
impl From<&StateInfo> for grpc::BaseNodeState {
fn from(info: &StateInfo) -> Self {
match info {
StartUp => grpc::BaseNodeState::HeaderSync,
HeaderSync(_) => grpc::BaseNodeState::HeaderSync,
HorizonSync(_) => grpc::BaseNodeState::HorizonSync,
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tokio = { version = "1.36", features = ["signal"] }
serde = "1.0.126"
thiserror = "^1.0.26"
dialoguer = { version = "0.10" }
tonic = "0.8.3"
tonic = "0.12.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 @@ -66,7 +66,7 @@ serde_json = "1.0.79"
sha2 = "0.10"
strum = "0.22"
thiserror = "1.0.26"
tonic = "0.8.3"
tonic = "0.12.3"
unicode-segmentation = "1.6.0"
unicode-width = "0.1"
url = "2.3.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 @@ -48,7 +48,7 @@ serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.57"
thiserror = "1.0.26"
tokio = { version = "1.36", features = ["macros"] }
tonic = "0.8.3"
tonic = "0.12.3"
tracing = "0.1"
url = "2.1.1"
scraper = "0.19.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ pub mod test {
let btdb = BlockTemplateDataBuilder::new()
.monero_seed(FixedByteArray::new())
.tari_block(block.clone().try_into().unwrap())
.tari_miner_data(miner_data.clone());
.tari_miner_data(miner_data);
assert!(
matches!(btdb.build(), Err(MmProxyError::MissingDataError(err)) if err == *"monero_difficulty not provided")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl BlockTemplateProtocol<'_> {
let miner_data = block
.miner_data
.as_ref()
.cloned()
.copied()
.ok_or_else(|| MmProxyError::GrpcResponseMissingField("miner_data"))?;

(add_monero_data(block, monero_mining_data.clone(), miner_data)?, height)
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 @@ -50,10 +50,10 @@ thiserror = "1.0"
tokio = { version = "1.36", default-features = false, features = [
"rt-multi-thread",
] }
tonic = { version = "0.8.3", features = ["tls", "tls-roots"] }
tonic = { version = "0.12.3", features = ["tls", "tls-roots"] }

[dev-dependencies]
prost-types = "0.11.9"
prost-types = "0.13.3"
chrono = { version = "0.4.19", default-features = false }
config = "0.14.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 @@ -63,7 +63,7 @@ serde_json = "1.0"
strum = { version = "0.22", features = ["derive"] }
thiserror = "^1.0.26"
tokio = { version = "1.36", features = ["signal"] }
tonic = { version = "0.8.3", features = ["tls", "tls-roots"] }
tonic = { version = "0.12.3", features = ["tls", "tls-roots"] }

# Metrics
tari_metrics = { path = "../../infrastructure/metrics", optional = true, features = [
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 @@ -33,7 +33,7 @@ futures = { version = "^0.3.1", features = ["compat", "std"] }
log = "0.4.6"
num-derive = "0.4.2"
num-traits = "0.2.15"
prost = "0.11.9"
prost = "0.13.3"
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 @@ -74,7 +74,7 @@ num-traits = "0.2.15"
num-derive = "0.4.2"
num-format = "0.4.0"
once_cell = "1.8.0"
prost = "0.11.9"
prost = "0.13.3"
rand = "0.8"
randomx-rs = { version = "1.3", optional = true }
serde = { version = "1.0.106", features = ["derive"] }
Expand Down
12 changes: 6 additions & 6 deletions base_layer/core/src/base_node/proto/wallet_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ impl TryFrom<proto::TxSubmissionResponse> for TxSubmissionResponse {
Ok(Self {
accepted: value.accepted,
rejection_reason: TxSubmissionRejectionReason::try_from(
proto::TxSubmissionRejectionReason::from_i32(value.rejection_reason)
.ok_or_else(|| "Invalid or unrecognised `TxSubmissionRejectionReason` enum".to_string())?,
proto::TxSubmissionRejectionReason::try_from(value.rejection_reason)
.map_err(|_| "Invalid or unrecognised `TxSubmissionRejectionReason` enum".to_string())?,
)?,
is_synced: value.is_synced,
})
Expand Down Expand Up @@ -210,8 +210,8 @@ impl TryFrom<proto::TxQueryResponse> for TxQueryResponse {

Ok(Self {
location: TxLocation::try_from(
proto::TxLocation::from_i32(proto_response.location)
.ok_or_else(|| "Invalid or unrecognised `TxLocation` enum".to_string())?,
proto::TxLocation::try_from(proto_response.location)
.map_err(|_| "Invalid or unrecognised `TxLocation` enum".to_string())?,
)?,
best_block_hash: hash,
confirmations: proto_response.confirmations,
Expand Down Expand Up @@ -260,8 +260,8 @@ impl TryFrom<proto::TxQueryBatchResponse> for TxQueryBatchResponse {
.ok_or_else(|| "Signature not present".to_string())?,
)?,
location: TxLocation::try_from(
proto::TxLocation::from_i32(proto_response.location)
.ok_or_else(|| "Invalid or unrecognised `TxLocation` enum".to_string())?,
proto::TxLocation::try_from(proto_response.location)
.map_err(|_| "Invalid or unrecognised `TxLocation` enum".to_string())?,
)?,
best_block_hash: hash,
best_block_height: proto_response.best_block_height,
Expand Down
4 changes: 2 additions & 2 deletions base_layer/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/tari-project/tari"
homepage = "https://tari.com"
readme = "README.md"
license = "BSD-3-Clause"
edition = "2018"
edition = "2021"

[dependencies]
tari_comms = { path = "../../comms/core", version = "1.5.1-pre.1" }
Expand All @@ -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.11.9"
prost = "0.13.3"
rand = "0.8"
reqwest = { version = "0.11", optional = true, default-features = false }
rustls = { version = "0.23.13", default-features = false, features = ["logging", "std", "tls12"] }
Expand Down
2 changes: 1 addition & 1 deletion base_layer/p2p/src/comms_connector/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn pubsub_connector(buf_size: usize) -> (PubsubDomainConnector, Subscription
wrappers::ReceiverStream::new(receiver)
// Map DomainMessage into a TopicPayload
.filter_map(move |msg: Arc<PeerMessage>| {
let opt = match TariMessageType::from_i32(msg.message_header.message_type) {
let opt = match TariMessageType::try_from(msg.message_header.message_type).ok() {
Some(msg_type) => {
let message_tag_trace = msg.dht_header.message_tag;
let payload = TopicPayload::new(msg_type, msg);
Expand Down
2 changes: 1 addition & 1 deletion base_layer/p2p/src/services/liveness/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ impl PingPongMessage {

/// Return the kind of PingPong message. Either a ping or pong.
pub fn kind(&self) -> Option<PingPong> {
PingPong::from_i32(self.ping_pong)
PingPong::try_from(self.ping_pong).ok()
}
}
4 changes: 2 additions & 2 deletions base_layer/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ strum_macros = "0.22"
tempfile = "3.1.0"
thiserror = "1.0.26"
tower = "0.4"
prost = "0.11.9"
prost = "0.13.3"
itertools = "0.10.3"
chacha20poly1305 = "0.10.1"
zeroize = "1"
Expand All @@ -87,7 +87,7 @@ tari_core = { path = "../../base_layer/core", default-features = false, features
"base_node",
] }
env_logger = "0.7.1"
prost = "0.11.9"
prost = "0.13.3"

[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.8.3", default-features = false, features = ["codegen", "transport", "tls"] }
tonic = { version = "0.12.3", default-features = false, features = ["codegen", "transport", "tls"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
4 changes: 2 additions & 2 deletions comms/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage = "https://tari.com"
readme = "README.md"
license = "BSD-3-Clause"
version = "1.5.1-pre.1"
edition = "2018"
edition = "2021"

[dependencies]
tari_crypto = { version = "0.20.3" }
Expand Down Expand Up @@ -37,7 +37,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.11.9"
prost = "0.13.3"
rand = "0.8"
serde = "1.0.119"
serde_derive = "1.0.119"
Expand Down
4 changes: 3 additions & 1 deletion comms/core/src/protocol/rpc/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ impl HandshakeRejectReason {
}

pub fn from_i32(v: i32) -> Option<Self> {
rpc_proto::rpc_session_reply::HandshakeRejectReason::from_i32(v).map(Into::into)
rpc_proto::rpc_session_reply::HandshakeRejectReason::try_from(v)
.map(Into::into)
.ok()
}
}

Expand Down
4 changes: 2 additions & 2 deletions comms/dht/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/tari-project/tari"
homepage = "https://tari.com"
readme = "README.md"
license = "BSD-3-Clause"
edition = "2018"
edition = "2021"

[dependencies]
tari_comms = { path = "../core", features = ["rpc"], version = "1.5.1-pre.1" }
Expand Down Expand Up @@ -36,7 +36,7 @@ digest = "0.10"
futures = "^0.3.1"
log = "0.4.8"
log-mdc = "0.1.0"
prost = "=0.11.9"
prost = "0.13.3"
rand = "0.8"
serde = "1.0.90"
thiserror = "1.0.26"
Expand Down
3 changes: 2 additions & 1 deletion comms/dht/src/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ impl TryFrom<DhtHeader> for DhtMessageHeader {
destination,
message_signature: header.message_signature,
ephemeral_public_key,
message_type: DhtMessageType::from_i32(header.message_type).ok_or(DhtMessageError::InvalidMessageType)?,
message_type: DhtMessageType::try_from(header.message_type)
.map_err(|_| DhtMessageError::InvalidMessageType)?,
flags: DhtMessageFlags::from_bits(header.flags).ok_or(DhtMessageError::InvalidMessageFlags)?,
message_tag: MessageTag::from(header.message_tag),
expires,
Expand Down
2 changes: 1 addition & 1 deletion comms/dht/src/store_forward/saf_handler/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ where S: Service<DecryptedDhtMessage, Response = (), Error = PipelineError>
target: LOG_TARGET,
"Received {} stored messages of type {} from peer `{}` (Trace: {})",
response.messages().len(),
SafResponseType::from_i32(response.response_type)
SafResponseType::try_from(response.response_type).ok()
.as_ref()
.map(|t| format!("{:?}", t))
.unwrap_or_else(|| "<Invalid>".to_string()),
Expand Down
4 changes: 2 additions & 2 deletions comms/dht/tests/dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ async fn test_dht_do_not_store_invalid_message_in_dedup() {
let header_unmodified = msg.dht_header.clone();

// Modify the header
msg.dht_header.message_type = DhtMessageType::from_i32(3i32).unwrap();
msg.dht_header.message_type = DhtMessageType::try_from(3i32).unwrap();

// Forward modified message to Node C - Should get us banned
node_B
Expand Down Expand Up @@ -870,7 +870,7 @@ async fn test_dht_header_not_malleable() {
let mut msg = node_B.next_inbound_message(Duration::from_secs(10)).await.unwrap();

// Modify the header
msg.dht_header.message_type = DhtMessageType::from_i32(21i32).unwrap();
msg.dht_header.message_type = DhtMessageType::try_from(21i32).unwrap();

let envelope = msg.decryption_result.unwrap();
let mut connectivity_events = node_C.comms.connectivity().get_event_subscription();
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.11.9"
prost = "0.13.3"
tokio = { version = "1", features = ["macros"] }
tower-service = "0.3"
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.36"
tokio = { version = "1.36", features = ["macros", "time", "sync", "rt-multi-thread"] }
tonic = "0.8.3"
tonic = "0.12.3"

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

0 comments on commit f7f7bb5

Please sign in to comment.