Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tonic to version 0.12.3 and jsonrpsee to 0.24 #4759

Merged
merged 10 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
603 changes: 384 additions & 219 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 17 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ massa_versioning = { path = "./massa-versioning" }
massa_wallet = { path = "./massa-wallet" }

# Massa projects dependencies
massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", "rev" = "38950875a7aa406fedc4f0b8336864e5ff290f2c" }
massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "next_breaking_update" }
massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", "rev" = "48295f3bb23a17075b7be9b4c39f249ef77bef40" }
# massa-proto-rs = { path = "../massa-proto-rs" }
modship marked this conversation as resolved.
Show resolved Hide resolved
massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "feature/update_tonic_12_3_v2" }
# massa-sc-runtime = { path = "../massa-sc-runtime_3" }
modship marked this conversation as resolved.
Show resolved Hide resolved
peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" }

# Common dependencies
Expand Down Expand Up @@ -138,15 +140,15 @@ futures = "0.3"
futures-util = "0.3"
h2 = "0.3"
hex-literal = "0.4"
http = "0.2"
http = "1.1.0"
humantime = "2.1"
hyper = "0.14"
hyper = "1"
ip_rfc = "0.1"
is-terminal = "0.4"
itertools = "0.12"
jsonrpsee = "0.20"
jsonrpsee-http-client = "0.20"
jsonrpsee-ws-client = "0.20"
jsonrpsee = "0.24"
jsonrpsee-http-client = "0.24"
jsonrpsee-ws-client = "0.24"
lazy_static = "1.4"
libsecp256k1 = "=0.7"
mio = "0.8.11"
Expand Down Expand Up @@ -191,15 +193,17 @@ time = "0.3"
tokio = "1.23"
tokio-stream = "0.1"
toml_edit = "0.21"
tonic = "0.10"
tonic-health = "0.10"
tonic-reflection = "0.10"
tonic-web = "0.10"
tower = "0.4.13"
tower-http = "0.4.0"
tonic = "0.12"
tonic-health = "0.12"
tonic-reflection = "0.12"
tonic-web = "0.12"
tower = "0.4"
tower-http = "0.6"
tower-service = "0.3"
tracing = "0.1"
tracing-subscriber = "0.3"
unsigned-varint = "0.8"
variant_count = "1.1"
walkdir = "2.3"
zeroize = { version = "1.7", features = ["derive"] }
prost = { version = "=0.13" }
2 changes: 1 addition & 1 deletion massa-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ massa_wallet = { workspace = true }

async-trait = { workspace = true }
futures = { workspace = true }
hyper = { workspace = true }
itertools = { workspace = true }
jsonrpsee = { workspace = true, "features" = ["server", "macros"] }
parking_lot = { workspace = true, "features" = ["deadlock_detection"] }
Expand All @@ -40,6 +39,7 @@ tokio-stream = { workspace = true, "features" = ["sync"] }
tower = { workspace = true, "features" = ["full"] }
tower-http = { workspace = true, "features" = ["cors"] }
tracing = { workspace = true }
http = { workspace = true }

[dev-dependencies]
jsonrpsee = { workspace = true, "features" = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion massa-api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{ApiServer, ApiV2, StopHandle, API};
use async_trait::async_trait;
use futures::future::{self, Either};
use futures::StreamExt;
use jsonrpsee::core::{Error as JsonRpseeError, RpcResult, SubscriptionResult};
use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult, SubscriptionResult};
use jsonrpsee::{PendingSubscriptionSink, SubscriptionMessage};
use massa_api_exports::config::APIConfig;
use massa_api_exports::error::ApiError;
Expand Down
15 changes: 8 additions & 7 deletions massa-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#![warn(unused_crate_dependencies)]

use api_trait::MassaApiServer;
use hyper::Method;
use jsonrpsee::core::{Error as JsonRpseeError, RpcResult};
use http::Method;
use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult};
use jsonrpsee::proc_macros::rpc;
use jsonrpsee::server::middleware::HostFilterLayer;
use jsonrpsee::server::{BatchRequestConfig, ServerBuilder, ServerHandle};
use jsonrpsee::server::middleware::http::HostFilterLayer;
use jsonrpsee::server::{BatchRequestConfig, PingConfig, ServerBuilder, ServerHandle};
use jsonrpsee::RpcModule;
use massa_api_exports::execution::Transfer;
use massa_api_exports::{
Expand Down Expand Up @@ -150,6 +150,7 @@ async fn serve<T>(
url: &SocketAddr,
api_config: &APIConfig,
) -> Result<StopHandle, JsonRpseeError> {
let ping_config = PingConfig::new().ping_interval(api_config.ping_interval.to_duration());
let mut server_builder = ServerBuilder::new()
.max_request_body_size(api_config.max_request_body_size)
.max_response_body_size(api_config.max_response_body_size)
Expand All @@ -159,7 +160,7 @@ async fn serve<T>(
} else {
BatchRequestConfig::Disabled
})
.ping_interval(api_config.ping_interval.to_duration());
.enable_ws_ping(ping_config);

if api_config.enable_http && !api_config.enable_ws {
server_builder = server_builder.http_only();
Expand All @@ -174,7 +175,7 @@ async fn serve<T>(
.allow_methods([Method::POST, Method::OPTIONS])
// Allow requests from any origin
.allow_origin(Any)
.allow_headers([hyper::header::CONTENT_TYPE]);
.allow_headers([http::header::CONTENT_TYPE]);

let hosts = if api_config.allow_hosts.is_empty() {
vec!["*:*"]
Expand All @@ -193,7 +194,7 @@ async fn serve<T>(
.layer(allowed_hosts);

let server = server_builder
.set_middleware(middleware)
.set_http_middleware(middleware)
.build(url)
.await
.expect("failed to build server");
Expand Down
2 changes: 1 addition & 1 deletion massa-api/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::{MassaRpcServer, Private, RpcServer, StopHandle, Value, API};

use async_trait::async_trait;
use jsonrpsee::core::{Error as JsonRpseeError, RpcResult};
use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult};
use massa_api_exports::{
address::{AddressFilter, AddressInfo},
block::{BlockInfo, BlockSummary},
Expand Down
2 changes: 1 addition & 1 deletion massa-api/src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{MassaRpcServer, Public, RpcServer, StopHandle, Value, API};
use async_trait::async_trait;
use itertools::{izip, Itertools};
use jsonrpsee::core::{Error as JsonRpseeError, RpcResult};
use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult};
use massa_api_exports::{
address::{AddressFilter, AddressInfo},
block::{BlockInfo, BlockInfoContent, BlockSummary},
Expand Down
2 changes: 1 addition & 1 deletion massa-api/src/tests/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
};

use jsonrpsee::{
core::{client::ClientT, Error},
core::{client::ClientT, client::Error},
http_client::HttpClientBuilder,
rpc_params,
};
Expand Down
26 changes: 10 additions & 16 deletions massa-api/src/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ async fn max_request_size() {
OperationId::from_str("O1q4CBcuYo8YANEV34W4JRWVHrzcYns19VJfyAB7jT4qfitAnMC").unwrap(),
OperationId::from_str("O1q4CBcuYo8YANEV34W4JRWVHrzcYns19VJfyAB7jT4qfitAnMC").unwrap(),
]];
let response: Result<Vec<OperationInfo>, jsonrpsee::core::Error> =
let response: Result<Vec<OperationInfo>, jsonrpsee::core::client::Error> =
client.request("get_operations", params).await;

assert!(response
.unwrap_err()
.to_string()
.contains("status code: 413"));
let response_str = response.unwrap_err().to_string();
assert!(response_str.contains("Request rejected `413`"));

api_handle.stop().await;
}
Expand Down Expand Up @@ -142,13 +140,11 @@ async fn http_disabled() {
))
.unwrap();

let response: Result<Vec<OperationInfo>, jsonrpsee::core::Error> =
let response: Result<Vec<OperationInfo>, jsonrpsee::core::client::Error> =
client.request("get_operations", rpc_params![]).await;

assert!(response
.unwrap_err()
.to_string()
.contains("status code: 403"));
let response_str = response.unwrap_err().to_string();
assert!(response_str.contains("Request rejected `403`"));

api_handle.stop().await;
}
Expand Down Expand Up @@ -178,7 +174,7 @@ async fn host_allowed() {
))
.unwrap();

let response: Result<Vec<OperationInfo>, jsonrpsee::core::Error> =
let response: Result<Vec<OperationInfo>, jsonrpsee::core::client::Error> =
client.request("get_operations", rpc_params![]).await;

// response OK but invalid params (no params provided)
Expand All @@ -205,14 +201,12 @@ async fn host_allowed() {
))
.unwrap();

let response: Result<Vec<OperationInfo>, jsonrpsee::core::Error> =
let response: Result<Vec<OperationInfo>, jsonrpsee::core::client::Error> =
client.request("get_operations", rpc_params![]).await;

// host not allowed
assert!(response
.unwrap_err()
.to_string()
.contains("status code: 403"));
let response_str = response.unwrap_err().to_string();
assert!(response_str.contains("Request rejected `403`"));

api_handle.stop().await;
api_handle2.stop().await;
Expand Down
2 changes: 1 addition & 1 deletion massa-execution-exports/src/types_trace_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl AbiTrace {
while !to_process.is_empty() {
let t = to_process.pop_front();
if let Some(trace) = t {
if abi_names.iter().find(|t| *(*t) == trace.name).is_some() {
if abi_names.iter().any(|t| *(*t) == trace.name) {
// filtered.extend(&trace)
filtered.push(trace);
}
Expand Down
3 changes: 2 additions & 1 deletion massa-execution-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ tempfile = { workspace = true, optional = true }
massa_wallet = { workspace = true }
massa-proto-rs = { workspace = true }
schnellru = { workspace = true }
prost = { version = "=0.12", optional = true }
# prost = { version = "=0.13", optional = true }
bilboquet marked this conversation as resolved.
Show resolved Hide resolved
prost = { workspace = true, optional = true }
cfg-if = { workspace = true }
rocksdb = { workspace = true }

Expand Down
1 change: 1 addition & 0 deletions massa-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tonic-web = { workspace = true }
tonic-reflection = { workspace = true }
tonic-health = { workspace = true }
tower-http = { workspace = true, "features" = ["cors"] }
tower-service = { workspace = true }
hyper = { workspace = true }
futures-util = { workspace = true }
serde = { workspace = true, "features" = ["derive"] }
Expand Down
10 changes: 5 additions & 5 deletions massa-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use std::sync::{Arc, Condvar, Mutex};
use crate::config::{GrpcConfig, ServiceName};
use crate::error::GrpcError;
use futures_util::FutureExt;
use hyper::service::Service;
use hyper::{Body, Method, Request, Response};
use hyper::{Method, Request, Response};
use massa_consensus_exports::{ConsensusBroadcasts, ConsensusController};
use massa_execution_exports::{ExecutionChannels, ExecutionController};
use massa_pool_exports::{PoolBroadcasts, PoolController};
Expand All @@ -31,7 +30,7 @@ use massa_wallet::Wallet;
use tokio::sync::oneshot;
use tonic::body::BoxBody;
use tonic::codegen::CompressionEncoding;
use tonic::transport::NamedService;
use tonic::server::NamedService;
use tonic::transport::{Certificate, Identity, ServerTlsConfig};
use tonic_health::server::HealthReporter;
use tonic_web::GrpcWebLayer;
Expand Down Expand Up @@ -173,7 +172,7 @@ async fn massa_service_status(mut reporter: HealthReporter) {
// Configure and start the gRPC API with the given service
async fn serve<S>(service: S, config: &GrpcConfig) -> Result<StopHandle, GrpcError>
where
S: Service<Request<Body>, Response = Response<BoxBody>, Error = Infallible>
S: tower_service::Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible>
+ NamedService
+ Clone
+ Send
Expand Down Expand Up @@ -241,7 +240,8 @@ where
};
let reflection_service = tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(file_descriptor_set)
.build()?;
//.build()?;
.build_v1()?;

Some(reflection_service)
} else {
Expand Down
3 changes: 2 additions & 1 deletion massa-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ sandbox = []

[dependencies]
prometheus = {workspace = true, "features" = ["process"]}
hyper = {workspace = true, "features" = ["server", "http1"]} # BOM UPGRADE Revert to {"version": "0.14.26", "features": ["server", "tcp", "http1"]} if problem
# hyper = {workspace = true, "features" = ["server", "http1"]} # BOM UPGRADE Revert to {"version": "0.14.26", "features": ["server", "tcp", "http1"]} if problem
bilboquet marked this conversation as resolved.
Show resolved Hide resolved
hyper = {"version" = "0.14.26", "features" = ["server", "tcp", "http1"]}
tokio = {workspace = true, "features" = ["full"]} # BOM UPGRADE Revert to {"version": "1.28.0", "features": ["full"]} if problem
lazy_static = {workspace = true}
tracing = {workspace = true}
8 changes: 2 additions & 6 deletions massa-metrics/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use std::net::SocketAddr;

use hyper::{
body::Body,
header::CONTENT_TYPE,
service::{make_service_fn, service_fn},
Request, Response,
};
use hyper::service::make_service_fn;
use hyper::{body::Body, header::CONTENT_TYPE, service::service_fn, Request, Response};
use prometheus::{Encoder, TextEncoder};
use tracing::{error, info};

Expand Down
3 changes: 1 addition & 2 deletions massa-pool-worker/src/denunciation_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ impl DenunciationPool {
pub fn _contains(&self, denunciation: &Denunciation) -> bool {
self.denunciations_cache
.iter()
.find(|(_, de_st)| match *de_st {
.any(|(_, de_st)| match de_st {
DenunciationStatus::Accumulating(_) => false,
DenunciationStatus::DenunciationEmitted(de) => de == denunciation,
})
.is_some()
}

/// Add a denunciation precursor to the pool - can lead to a Denunciation creation
Expand Down
4 changes: 2 additions & 2 deletions massa-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"

[dependencies]
jsonrpsee = {workspace = true, "features" = ["client"]}
jsonrpsee-http-client = {workspace = true, "features" = ["webpki-tls"]}
jsonrpsee-ws-client = {workspace = true, "features" = ["webpki-tls"]}
jsonrpsee-http-client = {workspace = true}
jsonrpsee-ws-client = {workspace = true}
http = {workspace = true}
tonic = {workspace = true, "features" = ["gzip"]} # BOM UPGRADE Revert to {"version": "0.9.1", "features": ["gzip"]} if problem
thiserror = {workspace = true}
Expand Down
Loading
Loading