Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
59 changes: 25 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,10 @@ futures = "0.3.26"
pin-project = "1.0.12"
futures-util = "0.3.25"

## json
jsonrpsee = { version = "0.19" }
jsonrpsee-core = { version = "0.19" }
jsonrpsee-types = { version = "0.19" }

## crypto
secp256k1 = { version = "0.27.0", default-features = false, features = ["global-context", "rand-std", "recovery"] }
2 changes: 1 addition & 1 deletion crates/rpc/ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pin-project.workspace = true
tower = "0.4"

# misc
jsonrpsee = { version = "0.18", features = ["server", "client"] }
jsonrpsee = { workspace = true, features = ["server", "client"] }
serde_json.workspace = true
tracing.workspace = true
bytes.workspace = true
Expand Down
12 changes: 9 additions & 3 deletions crates/rpc/ipc/src/server/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use jsonrpsee::{
tracing::{rx_log_from_json, tx_log_from_str},
JsonRawValue,
},
helpers::batch_response_error,
helpers::{batch_response_error, MethodResponseResult},
server::{
logger,
logger::{Logger, TransportProtocol},
Expand Down Expand Up @@ -219,14 +219,20 @@ pub(crate) async fn execute_call<L: Logger>(
};

tx_log_from_str(&response.as_response().result, max_log_length);
logger.on_result(name, response.as_response().success, request_start, TransportProtocol::Http);
logger.on_result(
name,
response.as_response().success_or_error,
request_start,
TransportProtocol::Http,
);
response
}

#[instrument(name = "notification", fields(method = notif.method.as_ref()), skip(notif, max_log_length), level = "TRACE")]
fn execute_notification(notif: Notif<'_>, max_log_length: u32) -> MethodResponse {
rx_log_from_json(&notif, max_log_length);
let response = MethodResponse { result: String::new(), success: true };
let response =
MethodResponse { result: String::new(), success_or_error: MethodResponseResult::Success };
tx_log_from_str(&response.result, max_log_length);
response
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ reth-primitives.workspace = true
reth-rpc-types.workspace = true

# misc
jsonrpsee = { version = "0.18", features = ["server", "macros"] }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
serde_json.workspace = true

[features]
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ reth-transaction-pool.workspace = true
reth-metrics = { workspace = true, features = ["common"] }

# rpc/net
jsonrpsee = { version = "0.18", features = ["server"] }
jsonrpsee = { workspace = true, features = ["server"] }
tower-http = { version = "0.4", features = ["full"] }
tower = { version = "0.4", features = ["full"] }
hyper = "0.14"
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-builder/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ where

let local_addr = server.local_addr()?;

let handle = server.start(module)?;
let handle = server.start(module);
Ok(AuthServerHandle { handle, local_addr, secret })
}

Expand Down Expand Up @@ -154,7 +154,7 @@ impl AuthServerConfig {

let local_addr = server.local_addr()?;

let handle = server.start(module.inner)?;
let handle = server.start(module.inner);
Ok(AuthServerHandle { handle, local_addr, secret })
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/rpc/rpc-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ impl WsHttpServers {
config.ensure_ws_http_identical()?;

if let Some(module) = http_module.or(ws_module) {
let handle = both.start(module).await?;
let handle = both.start(module).await;
http_handle = Some(handle.clone());
ws_handle = Some(handle);
}
Expand All @@ -1509,12 +1509,12 @@ impl WsHttpServers {
if let Some((server, module)) =
http.and_then(|server| http_module.map(|module| (server, module)))
{
http_handle = Some(server.start(module).await?);
http_handle = Some(server.start(module).await);
}
if let Some((server, module)) =
ws.and_then(|server| ws_module.map(|module| (server, module)))
{
ws_handle = Some(server.start(module).await?);
ws_handle = Some(server.start(module).await);
}
}
}
Expand All @@ -1541,10 +1541,10 @@ enum WsHttpServerKind {

impl WsHttpServerKind {
/// Starts the server and returns the handle
async fn start(self, module: RpcModule<()>) -> Result<ServerHandle, RpcError> {
async fn start(self, module: RpcModule<()>) -> ServerHandle {
match self {
WsHttpServerKind::Plain(server) => Ok(server.start(module)?),
WsHttpServerKind::WithCors(server) => Ok(server.start(module)?),
WsHttpServerKind::Plain(server) => server.start(module),
WsHttpServerKind::WithCors(server) => server.start(module),
}
}

Expand Down
9 changes: 6 additions & 3 deletions crates/rpc/rpc-builder/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use jsonrpsee::server::logger::{HttpRequest, Logger, MethodKind, Params, TransportProtocol};
use jsonrpsee::{
helpers::MethodResponseResult,
server::logger::{HttpRequest, Logger, MethodKind, Params, TransportProtocol},
};
use reth_metrics::{
metrics::{self, Counter, Histogram},
Metrics,
Expand Down Expand Up @@ -58,13 +61,13 @@ impl Logger for RpcServerMetrics {
fn on_result(
&self,
_method_name: &str,
success: bool,
success: MethodResponseResult,
started_at: Self::Instant,
_transport: TransportProtocol,
) {
// capture call duration
self.call_latency.record(started_at.elapsed().as_millis() as f64);
if !success {
if success.is_error() {
self.failed_calls.increment(1);
} else {
self.successful_calls.increment(1);
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-engine-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ tokio = { workspace = true, features = ["sync"] }
# misc
async-trait.workspace = true
thiserror.workspace = true
jsonrpsee-types = "0.18"
jsonrpsee-core = "0.18"
jsonrpsee-types.workspace = true
jsonrpsee-core.workspace = true
tracing.workspace = true

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-testing-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async-trait.workspace = true
futures.workspace = true

# misc
jsonrpsee = { version = "0.18", features = ["client", "async-client"] }
jsonrpsee = { workspace = true, features = ["client", "async-client"] }
serde_json.workspace = true

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ thiserror.workspace = true
itertools = "0.10"
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
jsonrpsee-types = { version = "0.18" }
jsonrpsee-types.workspace = true

[dev-dependencies]
# misc
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ethers-core = { workspace = true, features = ["eip712"] }
revm-primitives = { workspace = true, features = ["serde"] }

# rpc
jsonrpsee = { version = "0.18" }
jsonrpsee.workspace = true
http = "0.2.8"
http-body = "0.4.5"
hyper = "0.14.24"
Expand Down Expand Up @@ -63,7 +63,7 @@ schnellru = "0.2"
futures.workspace = true

[dev-dependencies]
jsonrpsee = { version = "0.18", features = ["client"] }
jsonrpsee = { workspace = true, features = ["client"] }
assert_matches = "1.5.0"
tempfile = "3.5.0"
reth-interfaces = { workspace = true, features = ["test-utils"] }
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/layers/auth_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ mod tests {
let mut module = RpcModule::new(());
module.register_method("greet_melkor", |_, _| "You are the dark lord").unwrap();

server.start(module).unwrap()
server.start(module)
}

fn to_u64(time: SystemTime) -> u64 {
Expand Down