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

[JSON-RPC] - Upgrade jsonrpsee to v0.16.1 #6387

Merged
merged 6 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
195 changes: 126 additions & 69 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/sui-cluster-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ futures = "0.3.24"
serde_json = "1.0.88"
tempfile = "3.3.0"
tokio = { workspace = true, features = ["full"] }
jsonrpsee = { version = "0.15.1", features = ["full"] }
jsonrpsee = { git="https://github.com/patrickkuo/jsonrpsee.git", rev= "adc19a124ed7045744442ca67f084ddfba4ba177", features = ["full"] }
tracing = { version = "0.1.36", features = ["log"] }
clap = { version = "3.1.14", features = ["derive"] }
reqwest = { version = "0.11.11", features = ["blocking", "json"] }
Expand Down
24 changes: 1 addition & 23 deletions crates/sui-cluster-test/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub trait Cluster {
Self: Sized;

fn fullnode_url(&self) -> &str;
fn websocket_url(&self) -> Option<&str>;
fn user_key(&self) -> AccountKeyPair;

/// Returns faucet url in a remote cluster.
Expand Down Expand Up @@ -107,9 +106,7 @@ impl Cluster for RemoteRunningCluster {
fn fullnode_url(&self) -> &str {
&self.fullnode_url
}
fn websocket_url(&self) -> Option<&str> {
None
}

fn user_key(&self) -> AccountKeyPair {
get_key_pair().1
}
Expand All @@ -126,7 +123,6 @@ pub struct LocalNewCluster {
test_cluster: TestCluster,
fullnode_url: String,
faucet_key: AccountKeyPair,
websocket_url: Option<String>,
}

impl LocalNewCluster {
Expand All @@ -149,20 +145,11 @@ impl Cluster for LocalNewCluster {
.port()
});

let websocket_port = options.websocket_address.as_ref().map(|addr| {
addr.parse::<SocketAddr>()
.expect("Unable to parse fullnode address")
.port()
});

let mut cluster_builder = TestClusterBuilder::new().set_genesis_config(genesis_config);

if let Some(rpc_port) = fullnode_port {
cluster_builder = cluster_builder.set_fullnode_rpc_port(rpc_port);
}
if let Some(ws_port) = websocket_port {
cluster_builder = cluster_builder.set_fullnode_ws_port(ws_port);
}

let mut test_cluster = cluster_builder.build().await?;

Expand All @@ -187,18 +174,13 @@ impl Cluster for LocalNewCluster {
test_cluster,
fullnode_url,
faucet_key,
websocket_url: options.websocket_address.clone(),
})
}

fn fullnode_url(&self) -> &str {
&self.fullnode_url
}

fn websocket_url(&self) -> Option<&str> {
self.websocket_url.as_deref()
}

fn user_key(&self) -> AccountKeyPair {
get_key_pair().1
}
Expand All @@ -224,10 +206,6 @@ impl Cluster for Box<dyn Cluster + Send + Sync> {
(**self).fullnode_url()
}

fn websocket_url(&self) -> Option<&str> {
(**self).websocket_url()
}

fn user_key(&self) -> AccountKeyPair {
(**self).user_key()
}
Expand Down
3 changes: 0 additions & 3 deletions crates/sui-cluster-test/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ pub struct ClusterTestOpt {
pub faucet_address: Option<String>,
#[clap(long)]
pub fullnode_address: Option<String>,
#[clap(long)]
pub websocket_address: Option<String>,
}

impl ClusterTestOpt {
Expand All @@ -31,7 +29,6 @@ impl ClusterTestOpt {
env: Env::NewLocal,
faucet_address: None,
fullnode_address: None,
websocket_address: None,
}
}
}
4 changes: 2 additions & 2 deletions crates/sui-cluster-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cluster::{Cluster, ClusterFactory};
use config::ClusterTestOpt;
use futures::{stream::FuturesUnordered, StreamExt};
use helper::ObjectChecker;
use jsonrpsee::types::ParamsSer;
use jsonrpsee::core::params::ArrayParams;
use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder};
use std::sync::Arc;
use sui::client_commands::WalletContext;
Expand Down Expand Up @@ -115,7 +115,7 @@ impl TestContext {
pub async fn build_transaction_remotely(
&self,
method: &str,
params: Option<ParamsSer<'_>>,
params: ArrayParams,
) -> anyhow::Result<TransactionData> {
let fn_rpc_url = self.get_fullnode_rpc_url();
// TODO cache this?
Expand Down
1 change: 0 additions & 1 deletion crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ impl<R: rand::RngCore + rand::CryptoRng> ConfigBuilder<R> {
metrics_address: utils::available_local_socket_address(),
admin_interface_port: utils::get_available_port(),
json_rpc_address: utils::available_local_socket_address(),
websocket_address: None,
consensus_config: Some(consensus_config),
enable_event_processing: false,
enable_checkpoint: false,
Expand Down
2 changes: 0 additions & 2 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ pub struct NodeConfig {
pub network_address: Multiaddr,
#[serde(default = "default_json_rpc_address")]
pub json_rpc_address: SocketAddr,
#[serde(default = "default_websocket_address")]
pub websocket_address: Option<SocketAddr>,

#[serde(default = "default_metrics_address")]
pub metrics_address: SocketAddr,
Expand Down
8 changes: 1 addition & 7 deletions crates/sui-config/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ impl NetworkConfig {
}

pub fn generate_fullnode_config(&self) -> NodeConfig {
self.generate_fullnode_config_with_random_dir_name(false, true)
self.generate_fullnode_config_with_random_dir_name(false)
}

/// Generate a fullnode config based on this `NetworkConfig`. This is useful if you want to run
/// a fullnode and have it connect to a network defined by this `NetworkConfig`.
pub fn generate_fullnode_config_with_random_dir_name(
&self,
use_random_dir_name: bool,
enable_websocket: bool,
) -> NodeConfig {
let protocol_key_pair: Arc<AuthorityKeyPair> =
Arc::new(get_key_pair_from_rng(&mut OsRng).1);
Expand Down Expand Up @@ -113,11 +112,6 @@ impl NetworkConfig {
metrics_address: utils::available_local_socket_address(),
admin_interface_port: utils::get_available_port(),
json_rpc_address: utils::available_local_socket_address(),
websocket_address: if enable_websocket {
Some(utils::available_local_socket_address())
} else {
None
},
consensus_config: None,
enable_event_processing,
enable_checkpoint: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down Expand Up @@ -58,7 +57,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down Expand Up @@ -106,7 +104,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down Expand Up @@ -154,7 +151,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down Expand Up @@ -202,7 +198,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down Expand Up @@ -250,7 +245,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down Expand Up @@ -298,7 +292,6 @@ validator_configs:
db-path: /tmp/foo/
network-address: ""
json-rpc-address: "0.0.0.0:1"
websocket-address: ~
metrics-address: "0.0.0.0:1"
admin-interface-port: 8888
consensus-config:
Expand Down
12 changes: 4 additions & 8 deletions crates/sui-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,16 @@ async fn main() -> anyhow::Result<()> {
let client = GatewayState::create_client(&gateway_config, Some(&prometheus_registry)).await?;

let address = SocketAddr::new(IpAddr::V4(options.host), options.port);
let mut server =
JsonRpcServerBuilder::new(env!("CARGO_PKG_VERSION"), false, &prometheus_registry)?;
let mut server = JsonRpcServerBuilder::new(env!("CARGO_PKG_VERSION"), &prometheus_registry)?;
server.register_module(RpcGatewayImpl::new(client.clone()))?;
server.register_module(GatewayReadApiImpl::new(client.clone()))?;
server.register_module(TransactionBuilderImpl::new(client.clone()))?;
server.register_module(BcsApiImpl::new_with_gateway(client.clone()))?;
server.register_module(GatewayWalletSyncApiImpl::new(client))?;

let server_handle = server
.start(address)
.await?
.into_http_server_handle()
.expect("Expect a http server handle here");
let server_handle = server.start(address).await?;

server_handle.stopped().await;

server_handle.await;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/sui-indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ chrono = { version = "0.4.23", features = [
diesel = { version = "2.0.0", features = ["chrono", "postgres", "serde_json"] }
futures = "0.3.23"
dotenvy = "0.15"
jsonrpsee = { version = "0.15.1", features = ["full"] }
jsonrpsee = { git="https://github.com/patrickkuo/jsonrpsee.git", rev= "adc19a124ed7045744442ca67f084ddfba4ba177", features = ["full"] }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.83"
thiserror = "1.0.34"
Expand Down
8 changes: 5 additions & 3 deletions crates/sui-json-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ edition = "2021"

[dependencies]
fastcrypto = { workspace = true }
jsonrpsee = { version = "0.15.1", features = ["full"] }
jsonrpsee-core = "0.15.1"
jsonrpsee-proc-macros = "0.15.1"
jsonrpsee = { git="https://github.com/patrickkuo/jsonrpsee.git", rev= "adc19a124ed7045744442ca67f084ddfba4ba177", features = ["full"] }
jsonrpsee-proc-macros = {git="https://github.com/patrickkuo/jsonrpsee.git", rev= "adc19a124ed7045744442ca67f084ddfba4ba177"}
hyper = "0.14"
tower = "0.4.12"
tower-http = { version = "0.3.4", features = ["full"] }
move-binary-format.workspace = true
move-bytecode-utils.workspace = true
move-core-types.workspace = true
Expand Down
5 changes: 2 additions & 3 deletions crates/sui-json-rpc/src/event_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use async_trait::async_trait;
use futures::StreamExt;
use jsonrpsee::core::RpcResult;
use jsonrpsee::types::SubscriptionResult;
use jsonrpsee_core::server::rpc_module::RpcModule;
use jsonrpsee_core::server::rpc_module::SubscriptionSink;
use jsonrpsee::{RpcModule, SubscriptionSink};
use tracing::warn;

use sui_core::authority::AuthorityState;
Expand Down Expand Up @@ -46,7 +45,7 @@ impl EventStreamingApiServer for EventStreamingApiImpl {
let filter = match filter.try_into() {
Ok(filter) => filter,
Err(e) => {
let e = jsonrpsee_core::Error::from(e);
let e = jsonrpsee::core::Error::from(e);
warn!(error = ?e, "Rejecting subscription request.");
return Ok(sink.reject(e)?);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-json-rpc/src/gateway_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anyhow::anyhow;
use async_trait::async_trait;
use fastcrypto::encoding::Base64;
use jsonrpsee::core::RpcResult;
use jsonrpsee_core::server::rpc_module::RpcModule;
use jsonrpsee::RpcModule;
use signature::Signature;
use sui_core::gateway_state::GatewayClient;
use sui_json::SuiJsonValue;
Expand Down
Loading