mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
chore(deps): bump jsonrpsee 0.18 (#2640)
This commit is contained in:
139
Cargo.lock
generated
139
Cargo.lock
generated
@ -188,6 +188,8 @@ dependencies = [
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"zstd",
|
||||
"zstd-safe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -316,6 +318,12 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.0"
|
||||
@ -2670,9 +2678,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper-rustls"
|
||||
version = "0.23.2"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
|
||||
checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7"
|
||||
dependencies = [
|
||||
"http",
|
||||
"hyper",
|
||||
@ -2681,7 +2689,6 @@ dependencies = [
|
||||
"rustls-native-certs",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2901,11 +2908,12 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
|
||||
|
||||
[[package]]
|
||||
name = "iri-string"
|
||||
version = "0.4.1"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f0f7638c1e223529f1bfdc48c8b133b9e0b434094d1d28473161ee48b235f78"
|
||||
checksum = "21859b667d66a4c1dacd9df0863b3efb65785474255face87f5bca39dd8407c0"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2975,9 +2983,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e"
|
||||
checksum = "1822d18e4384a5e79d94dc9e4d1239cfa9fad24e55b44d2efeff5b394c9fece4"
|
||||
dependencies = [
|
||||
"jsonrpsee-client-transport",
|
||||
"jsonrpsee-core",
|
||||
@ -2992,18 +3000,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-client-transport"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb"
|
||||
checksum = "11aa5766d5c430b89cb26a99b88f3245eb91534be8126102cea9e45ee3891b22"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"futures-channel",
|
||||
"futures-timer",
|
||||
"futures-util",
|
||||
"gloo-net",
|
||||
"http",
|
||||
"jsonrpsee-core",
|
||||
"jsonrpsee-types",
|
||||
"pin-project",
|
||||
"rustls-native-certs",
|
||||
"soketto",
|
||||
@ -3017,16 +3022,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-core"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b"
|
||||
checksum = "64c6832a55f662b5a6ecc844db24b8b9c387453f923de863062c60ce33d62b81"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrayvec",
|
||||
"async-lock",
|
||||
"async-trait",
|
||||
"beef",
|
||||
"futures-channel",
|
||||
"futures-timer",
|
||||
"futures-util",
|
||||
"globset",
|
||||
@ -3040,34 +3043,35 @@ dependencies = [
|
||||
"soketto",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"wasm-bindgen-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-http-client"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad"
|
||||
checksum = "1705c65069729e3dccff6fd91ee431d5d31cabcf00ce68a62a2c6435ac713af9"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"jsonrpsee-core",
|
||||
"jsonrpsee-types",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-proc-macros"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baa6da1e4199c10d7b1d0a6e5e8bd8e55f351163b6f4b3cbb044672a69bd4c1c"
|
||||
checksum = "c6027ac0b197ce9543097d02a290f550ce1d9432bf301524b013053c0b75cc94"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-crate",
|
||||
@ -3078,13 +3082,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-server"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fb69dad85df79527c019659a992498d03f8495390496da2f07e6c24c2b356fc"
|
||||
checksum = "4f06661d1a6b6e5b85469dc9c29acfbb9b3bb613797a6fd10a3ebb8a70754057"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http",
|
||||
"hyper",
|
||||
"jsonrpsee-core",
|
||||
"jsonrpsee-types",
|
||||
@ -3100,9 +3102,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-types"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c"
|
||||
checksum = "6e5bf6c75ce2a4217421154adfc65a24d2b46e77286e59bba5d9fa6544ccc8f4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"beef",
|
||||
@ -3114,9 +3116,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-wasm-client"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a77310456f43c6c89bcba1f6b2fc2a28300da7c341f320f5128f8c83cc63232d"
|
||||
checksum = "34e6ea7c6d862e60f8baebd946c037b70c6808a4e4e31e792a4029184e3ce13a"
|
||||
dependencies = [
|
||||
"jsonrpsee-client-transport",
|
||||
"jsonrpsee-core",
|
||||
@ -3125,9 +3127,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-ws-client"
|
||||
version = "0.16.2"
|
||||
version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b83daeecfc6517cfe210df24e570fb06213533dfb990318fae781f4c7119dd9"
|
||||
checksum = "a64b2589680ba1ad7863f279cd2d5083c1dc0a7c0ea959d22924553050f8ab9f"
|
||||
dependencies = [
|
||||
"http",
|
||||
"jsonrpsee-client-transport",
|
||||
@ -5738,14 +5740,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.20.8"
|
||||
version = "0.21.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
|
||||
checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring",
|
||||
"rustls-webpki",
|
||||
"sct",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5769,6 +5771,16 @@ dependencies = [
|
||||
"base64 0.21.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.100.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.11"
|
||||
@ -6722,13 +6734,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.23.4"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
|
||||
checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5"
|
||||
dependencies = [
|
||||
"rustls",
|
||||
"tokio",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -6865,12 +6876,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tower-http"
|
||||
version = "0.3.5"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858"
|
||||
checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"base64 0.13.1",
|
||||
"base64 0.20.0",
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
@ -7467,23 +7478,13 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.22.6"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
|
||||
checksum = "aa54963694b65584e170cf5dc46aeb4dcaa5584e652ff5f3952e56d66aff0125"
|
||||
dependencies = [
|
||||
"webpki",
|
||||
"rustls-webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -7762,3 +7763,33 @@ dependencies = [
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd"
|
||||
version = "0.11.2+zstd.1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
|
||||
dependencies = [
|
||||
"zstd-safe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-safe"
|
||||
version = "5.0.2+zstd.1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"zstd-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-sys"
|
||||
version = "2.0.8+zstd.1.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
@ -21,7 +21,7 @@ pin-project = "1.0"
|
||||
tower = "0.4"
|
||||
|
||||
# misc
|
||||
jsonrpsee = { version = "0.16", features = ["server", "client"] }
|
||||
jsonrpsee = { version = "0.18", features = ["server", "client"] }
|
||||
serde_json = "1.0"
|
||||
tracing = "0.1.37"
|
||||
bytes = "1.4"
|
||||
|
||||
@ -2,19 +2,17 @@
|
||||
use futures::{stream::FuturesOrdered, StreamExt};
|
||||
use jsonrpsee::{
|
||||
core::{
|
||||
server::{
|
||||
helpers::{prepare_error, BatchResponse, BatchResponseBuilder, MethodResponse},
|
||||
resource_limiting::Resources,
|
||||
rpc_module::{MethodKind, Methods},
|
||||
},
|
||||
server::helpers::{prepare_error, BatchResponseBuilder, MethodResponse},
|
||||
tracing::{rx_log_from_json, tx_log_from_str},
|
||||
JsonRawValue,
|
||||
},
|
||||
helpers::batch_response_error,
|
||||
server::{
|
||||
logger,
|
||||
logger::{Logger, TransportProtocol},
|
||||
},
|
||||
types::{error::ErrorCode, ErrorObject, Id, InvalidRequest, Notification, Params, Request},
|
||||
MethodCallback, Methods,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::OwnedSemaphorePermit;
|
||||
@ -36,7 +34,6 @@ pub(crate) struct CallData<'a, L: Logger> {
|
||||
methods: &'a Methods,
|
||||
max_response_body_size: u32,
|
||||
max_log_length: u32,
|
||||
resources: &'a Resources,
|
||||
request_start: L::Instant,
|
||||
}
|
||||
|
||||
@ -44,7 +41,7 @@ pub(crate) struct CallData<'a, L: Logger> {
|
||||
// request in the batch and read the results off of a new channel, `rx_batch`, and then send the
|
||||
// complete batch response back to the client over `tx`.
|
||||
#[instrument(name = "batch", skip(b), level = "TRACE")]
|
||||
pub(crate) async fn process_batch_request<L>(b: Batch<'_, L>) -> BatchResponse
|
||||
pub(crate) async fn process_batch_request<L>(b: Batch<'_, L>) -> String
|
||||
where
|
||||
L: Logger,
|
||||
{
|
||||
@ -60,9 +57,7 @@ where
|
||||
.filter_map(|v| {
|
||||
if let Ok(req) = serde_json::from_str::<Request<'_>>(v.get()) {
|
||||
Some(Either::Right(execute_call(req, call.clone())))
|
||||
} else if let Ok(_notif) =
|
||||
serde_json::from_str::<Notification<'_, &JsonRawValue>>(v.get())
|
||||
{
|
||||
} else if let Ok(_notif) = serde_json::from_str::<Notif<'_>>(v.get()) {
|
||||
// notifications should not be answered.
|
||||
got_notif = true;
|
||||
None
|
||||
@ -87,12 +82,12 @@ where
|
||||
}
|
||||
|
||||
if got_notif && batch_response.is_empty() {
|
||||
BatchResponse { result: String::new(), success: true }
|
||||
String::new()
|
||||
} else {
|
||||
batch_response.finish()
|
||||
}
|
||||
} else {
|
||||
BatchResponse::error(Id::Null, ErrorObject::from(ErrorCode::ParseError))
|
||||
batch_response_error(Id::Null, ErrorObject::from(ErrorCode::ParseError))
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +118,6 @@ pub(crate) async fn execute_call<L: Logger>(
|
||||
call: CallData<'_, L>,
|
||||
) -> MethodResponse {
|
||||
let CallData {
|
||||
resources,
|
||||
methods,
|
||||
logger,
|
||||
max_response_body_size,
|
||||
@ -148,61 +142,28 @@ pub(crate) async fn execute_call<L: Logger>(
|
||||
);
|
||||
MethodResponse::error(id, ErrorObject::from(ErrorCode::MethodNotFound))
|
||||
}
|
||||
Some((name, method)) => match &method.inner() {
|
||||
MethodKind::Sync(callback) => {
|
||||
Some((name, method)) => match method {
|
||||
MethodCallback::Sync(callback) => {
|
||||
logger.on_call(
|
||||
name,
|
||||
params.clone(),
|
||||
logger::MethodKind::MethodCall,
|
||||
TransportProtocol::Http,
|
||||
);
|
||||
|
||||
match method.claim(name, resources) {
|
||||
Ok(guard) => {
|
||||
let r = (callback)(id, params, max_response_body_size as usize);
|
||||
drop(guard);
|
||||
r
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(
|
||||
"[Methods::execute_with_resources] failed to lock resources: {}",
|
||||
err
|
||||
);
|
||||
MethodResponse::error(id, ErrorObject::from(ErrorCode::ServerIsBusy))
|
||||
}
|
||||
}
|
||||
(callback)(id, params, max_response_body_size as usize)
|
||||
}
|
||||
MethodKind::Async(callback) => {
|
||||
MethodCallback::Async(callback) => {
|
||||
logger.on_call(
|
||||
name,
|
||||
params.clone(),
|
||||
logger::MethodKind::MethodCall,
|
||||
TransportProtocol::Http,
|
||||
);
|
||||
match method.claim(name, resources) {
|
||||
Ok(guard) => {
|
||||
let id = id.into_owned();
|
||||
let params = params.into_owned();
|
||||
|
||||
(callback)(
|
||||
id,
|
||||
params,
|
||||
conn_id,
|
||||
max_response_body_size as usize,
|
||||
Some(guard),
|
||||
)
|
||||
.await
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(
|
||||
"[Methods::execute_with_resources] failed to lock resources: {}",
|
||||
err
|
||||
);
|
||||
MethodResponse::error(id, ErrorObject::from(ErrorCode::ServerIsBusy))
|
||||
}
|
||||
}
|
||||
let id = id.into_owned();
|
||||
let params = params.into_owned();
|
||||
(callback)(id, params, conn_id, max_response_body_size as usize).await
|
||||
}
|
||||
MethodKind::Subscription(_) | MethodKind::Unsubscription(_) => {
|
||||
MethodCallback::Subscription(_) | MethodCallback::Unsubscription(_) => {
|
||||
logger.on_call(
|
||||
name,
|
||||
params.clone(),
|
||||
@ -231,7 +192,6 @@ fn execute_notification(notif: Notif<'_>, max_log_length: u32) -> MethodResponse
|
||||
#[allow(unused)]
|
||||
pub(crate) struct HandleRequest<L: Logger> {
|
||||
pub(crate) methods: Methods,
|
||||
pub(crate) resources: Resources,
|
||||
pub(crate) max_request_body_size: u32,
|
||||
pub(crate) max_response_body_size: u32,
|
||||
pub(crate) max_log_length: u32,
|
||||
@ -241,15 +201,7 @@ pub(crate) struct HandleRequest<L: Logger> {
|
||||
}
|
||||
|
||||
pub(crate) async fn handle_request<L: Logger>(request: String, input: HandleRequest<L>) -> String {
|
||||
let HandleRequest {
|
||||
methods,
|
||||
resources,
|
||||
max_response_body_size,
|
||||
max_log_length,
|
||||
logger,
|
||||
conn,
|
||||
..
|
||||
} = input;
|
||||
let HandleRequest { methods, max_response_body_size, max_log_length, logger, conn, .. } = input;
|
||||
|
||||
enum Kind {
|
||||
Single,
|
||||
@ -273,7 +225,6 @@ pub(crate) async fn handle_request<L: Logger>(request: String, input: HandleRequ
|
||||
methods: &methods,
|
||||
max_response_body_size,
|
||||
max_log_length,
|
||||
resources: &resources,
|
||||
request_start,
|
||||
};
|
||||
// Single request or notification
|
||||
@ -281,8 +232,7 @@ pub(crate) async fn handle_request<L: Logger>(request: String, input: HandleRequ
|
||||
let response = process_single_request(request.into_bytes(), call).await;
|
||||
response.result
|
||||
} else {
|
||||
let response = process_batch_request(Batch { data: request.into_bytes(), call }).await;
|
||||
response.result
|
||||
process_batch_request(Batch { data: request.into_bytes(), call }).await
|
||||
};
|
||||
|
||||
drop(conn);
|
||||
|
||||
@ -6,11 +6,9 @@ use crate::server::{
|
||||
};
|
||||
use futures::{FutureExt, SinkExt, Stream, StreamExt};
|
||||
use jsonrpsee::{
|
||||
core::{
|
||||
server::{resource_limiting::Resources, rpc_module::Methods},
|
||||
Error, TEN_MB_SIZE_BYTES,
|
||||
},
|
||||
core::{Error, TEN_MB_SIZE_BYTES},
|
||||
server::{logger::Logger, IdProvider, RandomIntegerIdProvider, ServerHandle},
|
||||
Methods,
|
||||
};
|
||||
use std::{
|
||||
future::Future,
|
||||
@ -39,7 +37,6 @@ mod ipc;
|
||||
pub struct IpcServer<B = Identity, L = ()> {
|
||||
/// The endpoint we listen for incoming transactions
|
||||
endpoint: Endpoint,
|
||||
resources: Resources,
|
||||
logger: L,
|
||||
id_provider: Arc<dyn IdProvider>,
|
||||
cfg: Settings,
|
||||
@ -63,7 +60,7 @@ impl IpcServer {
|
||||
/// async fn run_server() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
/// let server = Builder::default().build("/tmp/my-uds")?;
|
||||
/// let mut module = RpcModule::new(());
|
||||
/// module.register_method("say_hello", |_, _| Ok("lo"))?;
|
||||
/// module.register_method("say_hello", |_, _| "lo")?;
|
||||
/// let handle = server.start(module).await?;
|
||||
///
|
||||
/// // In this example we don't care about doing shutdown so let's it run forever.
|
||||
@ -74,7 +71,7 @@ impl IpcServer {
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn start(mut self, methods: impl Into<Methods>) -> Result<ServerHandle, Error> {
|
||||
let methods = methods.into().initialize_resources(&self.resources)?;
|
||||
let methods = methods.into();
|
||||
let (stop_tx, stop_rx) = watch::channel(());
|
||||
|
||||
let stop_handle = StopHandle::new(stop_rx);
|
||||
@ -110,7 +107,6 @@ impl IpcServer {
|
||||
let max_request_body_size = self.cfg.max_request_body_size;
|
||||
let max_response_body_size = self.cfg.max_response_body_size;
|
||||
let max_log_length = self.cfg.max_log_length;
|
||||
let resources = self.resources;
|
||||
let id_provider = self.id_provider;
|
||||
let max_subscriptions_per_connection = self.cfg.max_subscriptions_per_connection;
|
||||
let logger = self.logger;
|
||||
@ -148,7 +144,6 @@ impl IpcServer {
|
||||
let tower_service = TowerService {
|
||||
inner: ServiceData {
|
||||
methods: methods.clone(),
|
||||
resources: resources.clone(),
|
||||
max_request_body_size,
|
||||
max_response_body_size,
|
||||
max_log_length,
|
||||
@ -184,7 +179,6 @@ impl std::fmt::Debug for IpcServer {
|
||||
.field("endpoint", &self.endpoint.path())
|
||||
.field("cfg", &self.cfg)
|
||||
.field("id_provider", &self.id_provider)
|
||||
.field("resources", &self.resources)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
@ -195,8 +189,6 @@ impl std::fmt::Debug for IpcServer {
|
||||
pub(crate) struct ServiceData<L: Logger> {
|
||||
/// Registered server methods.
|
||||
pub(crate) methods: Methods,
|
||||
/// Tracker for currently used resources on the server.
|
||||
pub(crate) resources: Resources,
|
||||
/// Max request body size.
|
||||
pub(crate) max_request_body_size: u32,
|
||||
/// Max request body size.
|
||||
@ -246,7 +238,6 @@ impl<L: Logger> Service<String> for TowerService<L> {
|
||||
// handle the request
|
||||
let data = ipc::HandleRequest {
|
||||
methods: self.inner.methods.clone(),
|
||||
resources: self.inner.resources.clone(),
|
||||
max_request_body_size: self.inner.max_request_body_size,
|
||||
max_response_body_size: self.inner.max_response_body_size,
|
||||
max_log_length: self.inner.max_log_length,
|
||||
@ -382,7 +373,6 @@ impl Default for Settings {
|
||||
#[derive(Debug)]
|
||||
pub struct Builder<B = Identity, L = ()> {
|
||||
settings: Settings,
|
||||
resources: Resources,
|
||||
logger: L,
|
||||
/// Subscription ID provider.
|
||||
id_provider: Arc<dyn IdProvider>,
|
||||
@ -393,7 +383,6 @@ impl Default for Builder {
|
||||
fn default() -> Self {
|
||||
Builder {
|
||||
settings: Settings::default(),
|
||||
resources: Resources::default(),
|
||||
logger: (),
|
||||
id_provider: Arc::new(RandomIntegerIdProvider),
|
||||
service_builder: tower::ServiceBuilder::new(),
|
||||
@ -432,26 +421,10 @@ impl<B, L> Builder<B, L> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Register a new resource kind. Errors if `label` is already registered, or if the number of
|
||||
/// registered resources on this server instance would exceed 8.
|
||||
///
|
||||
/// See the module documentation for
|
||||
/// [`resource_limiting`][jsonrpsee::core::server::resource_limiting] for details.
|
||||
pub fn register_resource(
|
||||
mut self,
|
||||
label: &'static str,
|
||||
capacity: u16,
|
||||
default: u16,
|
||||
) -> Result<Self, Error> {
|
||||
self.resources.register(label, capacity, default)?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Add a logger to the builder [`Logger`].
|
||||
pub fn set_logger<T: Logger>(self, logger: T) -> Builder<B, T> {
|
||||
Builder {
|
||||
settings: self.settings,
|
||||
resources: self.resources,
|
||||
logger,
|
||||
id_provider: self.id_provider,
|
||||
service_builder: self.service_builder,
|
||||
@ -513,7 +486,6 @@ impl<B, L> Builder<B, L> {
|
||||
pub fn set_middleware<T>(self, service_builder: tower::ServiceBuilder<T>) -> Builder<T, L> {
|
||||
Builder {
|
||||
settings: self.settings,
|
||||
resources: self.resources,
|
||||
logger: self.logger,
|
||||
id_provider: self.id_provider,
|
||||
service_builder,
|
||||
@ -531,7 +503,6 @@ impl<B, L> Builder<B, L> {
|
||||
Ok(IpcServer {
|
||||
endpoint,
|
||||
cfg: self.settings,
|
||||
resources: self.resources,
|
||||
logger: self.logger,
|
||||
id_provider: self.id_provider,
|
||||
service_builder: self.service_builder,
|
||||
@ -554,7 +525,7 @@ mod tests {
|
||||
let server = Builder::default().build(&endpoint).unwrap();
|
||||
let mut module = RpcModule::new(());
|
||||
let msg = r#"{"jsonrpc":"2.0","id":83,"result":"0x7a69"}"#;
|
||||
module.register_method("eth_chainId", move |_, _| Ok(msg)).unwrap();
|
||||
module.register_method("eth_chainId", move |_, _| msg).unwrap();
|
||||
let handle = server.start(module).await.unwrap();
|
||||
tokio::spawn(handle.stopped());
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ reth-primitives = { path = "../../primitives" }
|
||||
reth-rpc-types = { path = "../rpc-types" }
|
||||
|
||||
# misc
|
||||
jsonrpsee = { version = "0.16", features = ["server", "macros"] }
|
||||
jsonrpsee = { version = "0.18", features = ["server", "macros"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
[features]
|
||||
|
||||
@ -34,7 +34,7 @@ pub trait AdminApi {
|
||||
unsubscribe = "admin_peerEvents_unsubscribe",
|
||||
item = String
|
||||
)]
|
||||
fn subscribe_peer_events(&self);
|
||||
async fn subscribe_peer_events(&self) -> jsonrpsee::core::SubscriptionResult;
|
||||
|
||||
/// Returns the ENR of the node.
|
||||
#[method(name = "admin_nodeInfo")]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::{BlockId, BlockNumberOrTag, Bytes, H256};
|
||||
use reth_rpc_types::{
|
||||
trace::geth::{
|
||||
@ -14,23 +14,23 @@ use reth_rpc_types::{
|
||||
pub trait DebugApi {
|
||||
/// Returns an RLP-encoded header.
|
||||
#[method(name = "debug_getRawHeader")]
|
||||
async fn raw_header(&self, block_id: BlockId) -> Result<Bytes>;
|
||||
async fn raw_header(&self, block_id: BlockId) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns an RLP-encoded block.
|
||||
#[method(name = "debug_getRawBlock")]
|
||||
async fn raw_block(&self, block_id: BlockId) -> Result<Bytes>;
|
||||
async fn raw_block(&self, block_id: BlockId) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns a EIP-2718 binary-encoded transaction.
|
||||
#[method(name = "debug_getRawTransaction")]
|
||||
async fn raw_transaction(&self, hash: H256) -> Result<Bytes>;
|
||||
async fn raw_transaction(&self, hash: H256) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns an array of EIP-2718 binary-encoded receipts.
|
||||
#[method(name = "debug_getRawReceipts")]
|
||||
async fn raw_receipts(&self, block_id: BlockId) -> Result<Vec<Bytes>>;
|
||||
async fn raw_receipts(&self, block_id: BlockId) -> RpcResult<Vec<Bytes>>;
|
||||
|
||||
/// Returns an array of recent bad blocks that the client has seen on the network.
|
||||
#[method(name = "debug_getBadBlocks")]
|
||||
async fn bad_blocks(&self) -> Result<Vec<RichBlock>>;
|
||||
async fn bad_blocks(&self) -> RpcResult<Vec<RichBlock>>;
|
||||
|
||||
/// Returns the structured logs created during the execution of EVM between two blocks
|
||||
/// (excluding start) as a JSON object.
|
||||
@ -39,7 +39,7 @@ pub trait DebugApi {
|
||||
&self,
|
||||
start_exclusive: BlockNumberOrTag,
|
||||
end_inclusive: BlockNumberOrTag,
|
||||
) -> Result<Vec<BlockTraceResult>>;
|
||||
) -> RpcResult<Vec<BlockTraceResult>>;
|
||||
|
||||
/// The `debug_traceBlock` method will return a full stack trace of all invoked opcodes of all
|
||||
/// transaction that were included in this block.
|
||||
@ -53,7 +53,7 @@ pub trait DebugApi {
|
||||
&self,
|
||||
rlp_block: Bytes,
|
||||
opts: GethDebugTracingOptions,
|
||||
) -> Result<Vec<TraceResult>>;
|
||||
) -> RpcResult<Vec<TraceResult>>;
|
||||
|
||||
/// Similar to `debug_traceBlock`, `debug_traceBlockByHash` accepts a block hash and will replay
|
||||
/// the block that is already present in the database. For the second parameter see
|
||||
@ -63,7 +63,7 @@ pub trait DebugApi {
|
||||
&self,
|
||||
block: H256,
|
||||
opts: GethDebugTracingOptions,
|
||||
) -> Result<Vec<TraceResult>>;
|
||||
) -> RpcResult<Vec<TraceResult>>;
|
||||
|
||||
/// Similar to `debug_traceBlockByNumber`, `debug_traceBlockByHash` accepts a block number
|
||||
/// [BlockNumberOrTag] and will replay the block that is already present in the database.
|
||||
@ -73,7 +73,7 @@ pub trait DebugApi {
|
||||
&self,
|
||||
block: BlockNumberOrTag,
|
||||
opts: GethDebugTracingOptions,
|
||||
) -> Result<Vec<TraceResult>>;
|
||||
) -> RpcResult<Vec<TraceResult>>;
|
||||
|
||||
/// The `debug_traceTransaction` debugging method will attempt to run the transaction in the
|
||||
/// exact same manner as it was executed on the network. It will replay any transaction that
|
||||
@ -84,7 +84,7 @@ pub trait DebugApi {
|
||||
&self,
|
||||
tx_hash: H256,
|
||||
opts: GethDebugTracingOptions,
|
||||
) -> Result<GethTraceFrame>;
|
||||
) -> RpcResult<GethTraceFrame>;
|
||||
|
||||
/// The debug_traceCall method lets you run an `eth_call` within the context of the given block
|
||||
/// execution using the final state of parent block as the base.
|
||||
@ -101,5 +101,5 @@ pub trait DebugApi {
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
opts: GethDebugTracingCallOptions,
|
||||
) -> Result<GethTraceFrame>;
|
||||
) -> RpcResult<GethTraceFrame>;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::{
|
||||
filter::Filter, Address, BlockHash, BlockId, BlockNumberOrTag, Bytes, H256, U256, U64,
|
||||
};
|
||||
@ -17,11 +17,11 @@ pub trait EngineApi {
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_newpayloadv1>
|
||||
/// Caution: This should not accept the `withdrawals` field
|
||||
#[method(name = "engine_newPayloadV1")]
|
||||
async fn new_payload_v1(&self, payload: ExecutionPayload) -> Result<PayloadStatus>;
|
||||
async fn new_payload_v1(&self, payload: ExecutionPayload) -> RpcResult<PayloadStatus>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/shanghai.md#engine_newpayloadv2>
|
||||
#[method(name = "engine_newPayloadV2")]
|
||||
async fn new_payload_v2(&self, payload: ExecutionPayload) -> Result<PayloadStatus>;
|
||||
async fn new_payload_v2(&self, payload: ExecutionPayload) -> RpcResult<PayloadStatus>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_forkchoiceupdatedv1>
|
||||
///
|
||||
@ -31,7 +31,7 @@ pub trait EngineApi {
|
||||
&self,
|
||||
fork_choice_state: ForkchoiceState,
|
||||
payload_attributes: Option<PayloadAttributes>,
|
||||
) -> Result<ForkchoiceUpdated>;
|
||||
) -> RpcResult<ForkchoiceUpdated>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/shanghai.md#engine_forkchoiceupdatedv2>
|
||||
#[method(name = "engine_forkchoiceUpdatedV2")]
|
||||
@ -39,7 +39,7 @@ pub trait EngineApi {
|
||||
&self,
|
||||
fork_choice_state: ForkchoiceState,
|
||||
payload_attributes: Option<PayloadAttributes>,
|
||||
) -> Result<ForkchoiceUpdated>;
|
||||
) -> RpcResult<ForkchoiceUpdated>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_getpayloadv1>
|
||||
///
|
||||
@ -51,7 +51,7 @@ pub trait EngineApi {
|
||||
/// Note:
|
||||
/// > Client software MAY stop the corresponding build process after serving this call.
|
||||
#[method(name = "engine_getPayloadV1")]
|
||||
async fn get_payload_v1(&self, payload_id: PayloadId) -> Result<ExecutionPayload>;
|
||||
async fn get_payload_v1(&self, payload_id: PayloadId) -> RpcResult<ExecutionPayload>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/shanghai.md#engine_getpayloadv2>
|
||||
///
|
||||
@ -59,14 +59,14 @@ pub trait EngineApi {
|
||||
/// payload build process at the time of receiving this call. Note:
|
||||
/// > Client software MAY stop the corresponding build process after serving this call.
|
||||
#[method(name = "engine_getPayloadV2")]
|
||||
async fn get_payload_v2(&self, payload_id: PayloadId) -> Result<ExecutionPayloadEnvelope>;
|
||||
async fn get_payload_v2(&self, payload_id: PayloadId) -> RpcResult<ExecutionPayloadEnvelope>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1>
|
||||
#[method(name = "engine_getPayloadBodiesByHashV1")]
|
||||
async fn get_payload_bodies_by_hash_v1(
|
||||
&self,
|
||||
block_hashes: Vec<BlockHash>,
|
||||
) -> Result<ExecutionPayloadBodies>;
|
||||
) -> RpcResult<ExecutionPayloadBodies>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyrangev1>
|
||||
#[method(name = "engine_getPayloadBodiesByRangeV1")]
|
||||
@ -74,18 +74,18 @@ pub trait EngineApi {
|
||||
&self,
|
||||
start: U64,
|
||||
count: U64,
|
||||
) -> Result<ExecutionPayloadBodies>;
|
||||
) -> RpcResult<ExecutionPayloadBodies>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_exchangetransitionconfigurationv1>
|
||||
#[method(name = "engine_exchangeTransitionConfigurationV1")]
|
||||
async fn exchange_transition_configuration(
|
||||
&self,
|
||||
transition_configuration: TransitionConfiguration,
|
||||
) -> Result<TransitionConfiguration>;
|
||||
) -> RpcResult<TransitionConfiguration>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/common.md#capabilities>
|
||||
#[method(name = "engine_exchangeCapabilities")]
|
||||
async fn exchange_capabilities(&self, capabilities: Vec<String>) -> Result<Vec<String>>;
|
||||
async fn exchange_capabilities(&self, capabilities: Vec<String>) -> RpcResult<Vec<String>>;
|
||||
}
|
||||
|
||||
/// A subset of the ETH rpc interface: <https://ethereum.github.io/execution-apis/api-documentation/>
|
||||
@ -97,15 +97,15 @@ pub trait EngineApi {
|
||||
pub trait EngineEthApi {
|
||||
/// Returns an object with data about the sync status or false.
|
||||
#[method(name = "eth_syncing")]
|
||||
fn syncing(&self) -> Result<SyncStatus>;
|
||||
fn syncing(&self) -> RpcResult<SyncStatus>;
|
||||
|
||||
/// Returns the chain ID of the current network.
|
||||
#[method(name = "eth_chainId")]
|
||||
async fn chain_id(&self) -> Result<Option<U64>>;
|
||||
async fn chain_id(&self) -> RpcResult<Option<U64>>;
|
||||
|
||||
/// Returns the number of most recent block.
|
||||
#[method(name = "eth_blockNumber")]
|
||||
fn block_number(&self) -> Result<U256>;
|
||||
fn block_number(&self) -> RpcResult<U256>;
|
||||
|
||||
/// Executes a new message call immediately without creating a transaction on the block chain.
|
||||
#[method(name = "eth_call")]
|
||||
@ -114,15 +114,15 @@ pub trait EngineEthApi {
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
) -> Result<Bytes>;
|
||||
) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns code at a given address at given block number.
|
||||
#[method(name = "eth_getCode")]
|
||||
async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> Result<Bytes>;
|
||||
async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns information about a block by hash.
|
||||
#[method(name = "eth_getBlockByHash")]
|
||||
async fn block_by_hash(&self, hash: H256, full: bool) -> Result<Option<RichBlock>>;
|
||||
async fn block_by_hash(&self, hash: H256, full: bool) -> RpcResult<Option<RichBlock>>;
|
||||
|
||||
/// Returns information about a block by number.
|
||||
#[method(name = "eth_getBlockByNumber")]
|
||||
@ -130,13 +130,13 @@ pub trait EngineEthApi {
|
||||
&self,
|
||||
number: BlockNumberOrTag,
|
||||
full: bool,
|
||||
) -> Result<Option<RichBlock>>;
|
||||
) -> RpcResult<Option<RichBlock>>;
|
||||
|
||||
/// Sends signed transaction, returning its hash.
|
||||
#[method(name = "eth_sendRawTransaction")]
|
||||
async fn send_raw_transaction(&self, bytes: Bytes) -> Result<H256>;
|
||||
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<H256>;
|
||||
|
||||
/// Returns logs matching given filter object.
|
||||
#[method(name = "eth_getLogs")]
|
||||
async fn logs(&self, filter: Filter) -> Result<Vec<Log>>;
|
||||
async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::{
|
||||
serde_helper::JsonStorageKey, AccessListWithGasUsed, Address, BlockId, BlockNumberOrTag, Bytes,
|
||||
H256, H64, U256, U64,
|
||||
@ -15,31 +15,31 @@ use reth_rpc_types::{
|
||||
pub trait EthApi {
|
||||
/// Returns the protocol version encoded as a string.
|
||||
#[method(name = "eth_protocolVersion")]
|
||||
async fn protocol_version(&self) -> Result<U64>;
|
||||
async fn protocol_version(&self) -> RpcResult<U64>;
|
||||
|
||||
/// Returns an object with data about the sync status or false.
|
||||
#[method(name = "eth_syncing")]
|
||||
fn syncing(&self) -> Result<SyncStatus>;
|
||||
fn syncing(&self) -> RpcResult<SyncStatus>;
|
||||
|
||||
/// Returns the client coinbase address.
|
||||
#[method(name = "eth_coinbase")]
|
||||
async fn author(&self) -> Result<Address>;
|
||||
async fn author(&self) -> RpcResult<Address>;
|
||||
|
||||
/// Returns a list of addresses owned by client.
|
||||
#[method(name = "eth_accounts")]
|
||||
async fn accounts(&self) -> Result<Vec<Address>>;
|
||||
async fn accounts(&self) -> RpcResult<Vec<Address>>;
|
||||
|
||||
/// Returns the number of most recent block.
|
||||
#[method(name = "eth_blockNumber")]
|
||||
fn block_number(&self) -> Result<U256>;
|
||||
fn block_number(&self) -> RpcResult<U256>;
|
||||
|
||||
/// Returns the chain ID of the current network.
|
||||
#[method(name = "eth_chainId")]
|
||||
async fn chain_id(&self) -> Result<Option<U64>>;
|
||||
async fn chain_id(&self) -> RpcResult<Option<U64>>;
|
||||
|
||||
/// Returns information about a block by hash.
|
||||
#[method(name = "eth_getBlockByHash")]
|
||||
async fn block_by_hash(&self, hash: H256, full: bool) -> Result<Option<RichBlock>>;
|
||||
async fn block_by_hash(&self, hash: H256, full: bool) -> RpcResult<Option<RichBlock>>;
|
||||
|
||||
/// Returns information about a block by number.
|
||||
#[method(name = "eth_getBlockByNumber")]
|
||||
@ -47,26 +47,29 @@ pub trait EthApi {
|
||||
&self,
|
||||
number: BlockNumberOrTag,
|
||||
full: bool,
|
||||
) -> Result<Option<RichBlock>>;
|
||||
) -> RpcResult<Option<RichBlock>>;
|
||||
|
||||
/// Returns the number of transactions in a block from a block matching the given block hash.
|
||||
#[method(name = "eth_getBlockTransactionCountByHash")]
|
||||
async fn block_transaction_count_by_hash(&self, hash: H256) -> Result<Option<U256>>;
|
||||
async fn block_transaction_count_by_hash(&self, hash: H256) -> RpcResult<Option<U256>>;
|
||||
|
||||
/// Returns the number of transactions in a block matching the given block number.
|
||||
#[method(name = "eth_getBlockTransactionCountByNumber")]
|
||||
async fn block_transaction_count_by_number(
|
||||
&self,
|
||||
number: BlockNumberOrTag,
|
||||
) -> Result<Option<U256>>;
|
||||
) -> RpcResult<Option<U256>>;
|
||||
|
||||
/// Returns the number of uncles in a block from a block matching the given block hash.
|
||||
#[method(name = "eth_getUncleCountByBlockHash")]
|
||||
async fn block_uncles_count_by_hash(&self, hash: H256) -> Result<Option<U256>>;
|
||||
async fn block_uncles_count_by_hash(&self, hash: H256) -> RpcResult<Option<U256>>;
|
||||
|
||||
/// Returns the number of uncles in a block with given block number.
|
||||
#[method(name = "eth_getUncleCountByBlockNumber")]
|
||||
async fn block_uncles_count_by_number(&self, number: BlockNumberOrTag) -> Result<Option<U256>>;
|
||||
async fn block_uncles_count_by_number(
|
||||
&self,
|
||||
number: BlockNumberOrTag,
|
||||
) -> RpcResult<Option<U256>>;
|
||||
|
||||
/// Returns an uncle block of the given block and index.
|
||||
#[method(name = "eth_getUncleByBlockHashAndIndex")]
|
||||
@ -74,7 +77,7 @@ pub trait EthApi {
|
||||
&self,
|
||||
hash: H256,
|
||||
index: Index,
|
||||
) -> Result<Option<RichBlock>>;
|
||||
) -> RpcResult<Option<RichBlock>>;
|
||||
|
||||
/// Returns an uncle block of the given block and index.
|
||||
#[method(name = "eth_getUncleByBlockNumberAndIndex")]
|
||||
@ -82,11 +85,11 @@ pub trait EthApi {
|
||||
&self,
|
||||
number: BlockNumberOrTag,
|
||||
index: Index,
|
||||
) -> Result<Option<RichBlock>>;
|
||||
) -> RpcResult<Option<RichBlock>>;
|
||||
|
||||
/// Returns the information about a transaction requested by transaction hash.
|
||||
#[method(name = "eth_getTransactionByHash")]
|
||||
async fn transaction_by_hash(&self, hash: H256) -> Result<Option<Transaction>>;
|
||||
async fn transaction_by_hash(&self, hash: H256) -> RpcResult<Option<Transaction>>;
|
||||
|
||||
/// Returns information about a transaction by block hash and transaction index position.
|
||||
#[method(name = "eth_getTransactionByBlockHashAndIndex")]
|
||||
@ -94,7 +97,7 @@ pub trait EthApi {
|
||||
&self,
|
||||
hash: H256,
|
||||
index: Index,
|
||||
) -> Result<Option<Transaction>>;
|
||||
) -> RpcResult<Option<Transaction>>;
|
||||
|
||||
/// Returns information about a transaction by block number and transaction index position.
|
||||
#[method(name = "eth_getTransactionByBlockNumberAndIndex")]
|
||||
@ -102,15 +105,15 @@ pub trait EthApi {
|
||||
&self,
|
||||
number: BlockNumberOrTag,
|
||||
index: Index,
|
||||
) -> Result<Option<Transaction>>;
|
||||
) -> RpcResult<Option<Transaction>>;
|
||||
|
||||
/// Returns the receipt of a transaction by transaction hash.
|
||||
#[method(name = "eth_getTransactionReceipt")]
|
||||
async fn transaction_receipt(&self, hash: H256) -> Result<Option<TransactionReceipt>>;
|
||||
async fn transaction_receipt(&self, hash: H256) -> RpcResult<Option<TransactionReceipt>>;
|
||||
|
||||
/// Returns the balance of the account of given address.
|
||||
#[method(name = "eth_getBalance")]
|
||||
async fn balance(&self, address: Address, block_number: Option<BlockId>) -> Result<U256>;
|
||||
async fn balance(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<U256>;
|
||||
|
||||
/// Returns the value from a storage position at a given address
|
||||
#[method(name = "eth_getStorageAt")]
|
||||
@ -119,7 +122,7 @@ pub trait EthApi {
|
||||
address: Address,
|
||||
index: JsonStorageKey,
|
||||
block_number: Option<BlockId>,
|
||||
) -> Result<H256>;
|
||||
) -> RpcResult<H256>;
|
||||
|
||||
/// Returns the number of transactions sent from an address at given block number.
|
||||
#[method(name = "eth_getTransactionCount")]
|
||||
@ -127,11 +130,11 @@ pub trait EthApi {
|
||||
&self,
|
||||
address: Address,
|
||||
block_number: Option<BlockId>,
|
||||
) -> Result<U256>;
|
||||
) -> RpcResult<U256>;
|
||||
|
||||
/// Returns code at a given address at given block number.
|
||||
#[method(name = "eth_getCode")]
|
||||
async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> Result<Bytes>;
|
||||
async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes>;
|
||||
|
||||
/// Executes a new message call immediately without creating a transaction on the block chain.
|
||||
#[method(name = "eth_call")]
|
||||
@ -140,7 +143,7 @@ pub trait EthApi {
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
) -> Result<Bytes>;
|
||||
) -> RpcResult<Bytes>;
|
||||
|
||||
/// Generates an access list for a transaction.
|
||||
///
|
||||
@ -161,7 +164,7 @@ pub trait EthApi {
|
||||
&self,
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
) -> Result<AccessListWithGasUsed>;
|
||||
) -> RpcResult<AccessListWithGasUsed>;
|
||||
|
||||
/// Generates and returns an estimate of how much gas is necessary to allow the transaction to
|
||||
/// complete.
|
||||
@ -170,15 +173,15 @@ pub trait EthApi {
|
||||
&self,
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
) -> Result<U256>;
|
||||
) -> RpcResult<U256>;
|
||||
|
||||
/// Returns the current price per gas in wei.
|
||||
#[method(name = "eth_gasPrice")]
|
||||
async fn gas_price(&self) -> Result<U256>;
|
||||
async fn gas_price(&self) -> RpcResult<U256>;
|
||||
|
||||
/// Introduced in EIP-1159, returns suggestion for the priority for dynamic fee transactions.
|
||||
#[method(name = "eth_maxPriorityFeePerGas")]
|
||||
async fn max_priority_fee_per_gas(&self) -> Result<U256>;
|
||||
async fn max_priority_fee_per_gas(&self) -> RpcResult<U256>;
|
||||
|
||||
/// Returns the Transaction fee history
|
||||
///
|
||||
@ -193,20 +196,20 @@ pub trait EthApi {
|
||||
block_count: U64,
|
||||
newest_block: BlockId,
|
||||
reward_percentiles: Option<Vec<f64>>,
|
||||
) -> Result<FeeHistory>;
|
||||
) -> RpcResult<FeeHistory>;
|
||||
|
||||
/// Returns whether the client is actively mining new blocks.
|
||||
#[method(name = "eth_mining")]
|
||||
async fn is_mining(&self) -> Result<bool>;
|
||||
async fn is_mining(&self) -> RpcResult<bool>;
|
||||
|
||||
/// Returns the number of hashes per second that the node is mining with.
|
||||
#[method(name = "eth_hashrate")]
|
||||
async fn hashrate(&self) -> Result<U256>;
|
||||
async fn hashrate(&self) -> RpcResult<U256>;
|
||||
|
||||
/// Returns the hash of the current block, the seedHash, and the boundary condition to be met
|
||||
/// (“target”)
|
||||
#[method(name = "eth_getWork")]
|
||||
async fn get_work(&self) -> Result<Work>;
|
||||
async fn get_work(&self) -> RpcResult<Work>;
|
||||
|
||||
/// Used for submitting mining hashrate.
|
||||
///
|
||||
@ -214,34 +217,34 @@ pub trait EthApi {
|
||||
/// It accepts the miner hash rate and an identifier which must be unique between nodes.
|
||||
/// Returns `true` if the block was successfully submitted, `false` otherwise.
|
||||
#[method(name = "eth_submitHashrate")]
|
||||
async fn submit_hashrate(&self, hashrate: U256, id: H256) -> Result<bool>;
|
||||
async fn submit_hashrate(&self, hashrate: U256, id: H256) -> RpcResult<bool>;
|
||||
|
||||
/// Used for submitting a proof-of-work solution.
|
||||
#[method(name = "eth_submitWork")]
|
||||
async fn submit_work(&self, nonce: H64, pow_hash: H256, mix_digest: H256) -> Result<bool>;
|
||||
async fn submit_work(&self, nonce: H64, pow_hash: H256, mix_digest: H256) -> RpcResult<bool>;
|
||||
|
||||
/// Sends transaction; will block waiting for signer to return the
|
||||
/// transaction hash.
|
||||
#[method(name = "eth_sendTransaction")]
|
||||
async fn send_transaction(&self, request: TransactionRequest) -> Result<H256>;
|
||||
async fn send_transaction(&self, request: TransactionRequest) -> RpcResult<H256>;
|
||||
|
||||
/// Sends signed transaction, returning its hash.
|
||||
#[method(name = "eth_sendRawTransaction")]
|
||||
async fn send_raw_transaction(&self, bytes: Bytes) -> Result<H256>;
|
||||
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<H256>;
|
||||
|
||||
/// Returns an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n"
|
||||
/// + len(message) + message))).
|
||||
#[method(name = "eth_sign")]
|
||||
async fn sign(&self, address: Address, message: Bytes) -> Result<Bytes>;
|
||||
async fn sign(&self, address: Address, message: Bytes) -> RpcResult<Bytes>;
|
||||
|
||||
/// Signs a transaction that can be submitted to the network at a later time using with
|
||||
/// `eth_sendRawTransaction.`
|
||||
#[method(name = "eth_signTransaction")]
|
||||
async fn sign_transaction(&self, transaction: CallRequest) -> Result<Bytes>;
|
||||
async fn sign_transaction(&self, transaction: CallRequest) -> RpcResult<Bytes>;
|
||||
|
||||
/// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md).
|
||||
#[method(name = "eth_signTypedData")]
|
||||
async fn sign_typed_data(&self, address: Address, data: serde_json::Value) -> Result<Bytes>;
|
||||
async fn sign_typed_data(&self, address: Address, data: serde_json::Value) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns the account and storage values of the specified account including the Merkle-proof.
|
||||
/// This call can be used to verify that the data you are pulling from is not tampered with.
|
||||
@ -251,5 +254,5 @@ pub trait EthApi {
|
||||
address: Address,
|
||||
keys: Vec<JsonStorageKey>,
|
||||
block_number: Option<BlockId>,
|
||||
) -> Result<EIP1186AccountProofResponse>;
|
||||
) -> RpcResult<EIP1186AccountProofResponse>;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::filter::Filter;
|
||||
use reth_rpc_types::{FilterChanges, FilterId, Log};
|
||||
|
||||
@ -8,29 +8,29 @@ use reth_rpc_types::{FilterChanges, FilterId, Log};
|
||||
pub trait EthFilterApi {
|
||||
/// Creates anew filter and returns its id.
|
||||
#[method(name = "eth_newFilter")]
|
||||
async fn new_filter(&self, filter: Filter) -> Result<FilterId>;
|
||||
async fn new_filter(&self, filter: Filter) -> RpcResult<FilterId>;
|
||||
|
||||
/// Creates a new block filter and returns its id.
|
||||
#[method(name = "eth_newBlockFilter")]
|
||||
async fn new_block_filter(&self) -> Result<FilterId>;
|
||||
async fn new_block_filter(&self) -> RpcResult<FilterId>;
|
||||
|
||||
/// Creates a pending transaction filter and returns its id.
|
||||
#[method(name = "eth_newPendingTransactionFilter")]
|
||||
async fn new_pending_transaction_filter(&self) -> Result<FilterId>;
|
||||
async fn new_pending_transaction_filter(&self) -> RpcResult<FilterId>;
|
||||
|
||||
/// Returns all filter changes since last poll.
|
||||
#[method(name = "eth_getFilterChanges")]
|
||||
async fn filter_changes(&self, id: FilterId) -> Result<FilterChanges>;
|
||||
async fn filter_changes(&self, id: FilterId) -> RpcResult<FilterChanges>;
|
||||
|
||||
/// Returns all logs matching given filter (in a range 'from' - 'to').
|
||||
#[method(name = "eth_getFilterLogs")]
|
||||
async fn filter_logs(&self, id: FilterId) -> Result<Vec<Log>>;
|
||||
async fn filter_logs(&self, id: FilterId) -> RpcResult<Vec<Log>>;
|
||||
|
||||
/// Uninstalls filter.
|
||||
#[method(name = "eth_uninstallFilter")]
|
||||
async fn uninstall_filter(&self, id: FilterId) -> Result<bool>;
|
||||
async fn uninstall_filter(&self, id: FilterId) -> RpcResult<bool>;
|
||||
|
||||
/// Returns logs matching given filter object.
|
||||
#[method(name = "eth_getLogs")]
|
||||
async fn logs(&self, filter: Filter) -> Result<Vec<Log>>;
|
||||
async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;
|
||||
}
|
||||
|
||||
@ -10,5 +10,9 @@ pub trait EthPubSubApi {
|
||||
unsubscribe = "eth_unsubscribe",
|
||||
item = reth_rpc_types::pubsub::SubscriptionResult
|
||||
)]
|
||||
fn subscribe(&self, kind: SubscriptionKind, params: Option<Params>);
|
||||
async fn subscribe(
|
||||
&self,
|
||||
kind: SubscriptionKind,
|
||||
params: Option<Params>,
|
||||
) -> jsonrpsee::core::SubscriptionResult;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_rpc_types::PeerCount;
|
||||
|
||||
/// Net rpc interface.
|
||||
@ -7,14 +7,14 @@ use reth_rpc_types::PeerCount;
|
||||
pub trait NetApi {
|
||||
/// Returns protocol version.
|
||||
#[method(name = "net_version")]
|
||||
fn version(&self) -> Result<String>;
|
||||
fn version(&self) -> RpcResult<String>;
|
||||
|
||||
/// Returns number of peers connected to node.
|
||||
#[method(name = "net_peerCount")]
|
||||
fn peer_count(&self) -> Result<PeerCount>;
|
||||
fn peer_count(&self) -> RpcResult<PeerCount>;
|
||||
|
||||
/// Returns true if client is actively listening for network connections.
|
||||
/// Otherwise false.
|
||||
#[method(name = "net_listening")]
|
||||
fn is_listening(&self) -> Result<bool>;
|
||||
fn is_listening(&self) -> RpcResult<bool>;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::{BlockId, Bytes, H256};
|
||||
use reth_rpc_types::{
|
||||
trace::{filter::TraceFilter, parity::*},
|
||||
@ -17,7 +17,7 @@ pub trait TraceApi {
|
||||
call: CallRequest,
|
||||
trace_types: HashSet<TraceType>,
|
||||
block_id: Option<BlockId>,
|
||||
) -> Result<TraceResults>;
|
||||
) -> RpcResult<TraceResults>;
|
||||
|
||||
/// Performs multiple call traces on top of the same block. i.e. transaction n will be executed
|
||||
/// on top of a pending block with all n-1 transactions applied (traced) first. Allows to trace
|
||||
@ -27,7 +27,7 @@ pub trait TraceApi {
|
||||
&self,
|
||||
calls: Vec<(CallRequest, HashSet<TraceType>)>,
|
||||
block_id: Option<BlockId>,
|
||||
) -> Result<Vec<TraceResults>>;
|
||||
) -> RpcResult<Vec<TraceResults>>;
|
||||
|
||||
/// Traces a call to `eth_sendRawTransaction` without making the call, returning the traces.
|
||||
///
|
||||
@ -38,7 +38,7 @@ pub trait TraceApi {
|
||||
data: Bytes,
|
||||
trace_types: HashSet<TraceType>,
|
||||
block_id: Option<BlockId>,
|
||||
) -> Result<TraceResults>;
|
||||
) -> RpcResult<TraceResults>;
|
||||
|
||||
/// Replays all transactions in a block returning the requested traces for each transaction.
|
||||
#[method(name = "trace_replayBlockTransactions")]
|
||||
@ -46,7 +46,7 @@ pub trait TraceApi {
|
||||
&self,
|
||||
block_id: BlockId,
|
||||
trace_types: HashSet<TraceType>,
|
||||
) -> Result<Option<Vec<TraceResultsWithTransactionHash>>>;
|
||||
) -> RpcResult<Option<Vec<TraceResultsWithTransactionHash>>>;
|
||||
|
||||
/// Replays a transaction, returning the traces.
|
||||
#[method(name = "trace_replayTransaction")]
|
||||
@ -54,18 +54,18 @@ pub trait TraceApi {
|
||||
&self,
|
||||
transaction: H256,
|
||||
trace_types: HashSet<TraceType>,
|
||||
) -> Result<TraceResults>;
|
||||
) -> RpcResult<TraceResults>;
|
||||
|
||||
/// Returns traces created at given block.
|
||||
#[method(name = "trace_block")]
|
||||
async fn trace_block(
|
||||
&self,
|
||||
block_id: BlockId,
|
||||
) -> Result<Option<Vec<LocalizedTransactionTrace>>>;
|
||||
) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
|
||||
|
||||
/// Returns traces matching given filter
|
||||
#[method(name = "trace_filter")]
|
||||
async fn trace_filter(&self, filter: TraceFilter) -> Result<Vec<LocalizedTransactionTrace>>;
|
||||
async fn trace_filter(&self, filter: TraceFilter) -> RpcResult<Vec<LocalizedTransactionTrace>>;
|
||||
|
||||
/// Returns transaction trace at given index.
|
||||
#[method(name = "trace_get")]
|
||||
@ -73,10 +73,12 @@ pub trait TraceApi {
|
||||
&self,
|
||||
hash: H256,
|
||||
indices: Vec<Index>,
|
||||
) -> Result<Option<LocalizedTransactionTrace>>;
|
||||
) -> RpcResult<Option<LocalizedTransactionTrace>>;
|
||||
|
||||
/// Returns all traces of given transaction.
|
||||
#[method(name = "trace_transaction")]
|
||||
async fn trace_transaction(&self, hash: H256)
|
||||
-> Result<Option<Vec<LocalizedTransactionTrace>>>;
|
||||
async fn trace_transaction(
|
||||
&self,
|
||||
hash: H256,
|
||||
) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::Address;
|
||||
use reth_rpc_types::txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolStatus};
|
||||
|
||||
@ -11,26 +11,26 @@ pub trait TxPoolApi {
|
||||
/// well as the ones that are being scheduled for future execution only.
|
||||
/// Ref: [Here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_status)
|
||||
#[method(name = "txpool_status")]
|
||||
async fn txpool_status(&self) -> Result<TxpoolStatus>;
|
||||
async fn txpool_status(&self) -> RpcResult<TxpoolStatus>;
|
||||
|
||||
/// Returns a summary of all the transactions currently pending for inclusion in the next
|
||||
/// block(s), as well as the ones that are being scheduled for future execution only.
|
||||
///
|
||||
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_inspect) for more details
|
||||
#[method(name = "txpool_inspect")]
|
||||
async fn txpool_inspect(&self) -> Result<TxpoolInspect>;
|
||||
async fn txpool_inspect(&self) -> RpcResult<TxpoolInspect>;
|
||||
|
||||
/// Retrieves the transactions contained within the txpool, returning pending as well as queued
|
||||
/// transactions of this address, grouped by nonce.
|
||||
///
|
||||
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_contentFrom) for more details
|
||||
#[method(name = "txpool_contentFrom")]
|
||||
async fn txpool_content_from(&self, from: Address) -> Result<TxpoolContentFrom>;
|
||||
async fn txpool_content_from(&self, from: Address) -> RpcResult<TxpoolContentFrom>;
|
||||
|
||||
/// Returns the details of all transactions currently pending for inclusion in the next
|
||||
/// block(s), as well as the ones that are being scheduled for future execution only.
|
||||
///
|
||||
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) for more details
|
||||
#[method(name = "txpool_content")]
|
||||
async fn txpool_content(&self) -> Result<TxpoolContent>;
|
||||
async fn txpool_content(&self) -> RpcResult<TxpoolContent>;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::{Bytes, H256};
|
||||
|
||||
/// Web3 rpc interface.
|
||||
@ -8,9 +8,9 @@ use reth_primitives::{Bytes, H256};
|
||||
pub trait Web3Api {
|
||||
/// Returns current client version.
|
||||
#[method(name = "web3_clientVersion")]
|
||||
async fn client_version(&self) -> Result<String>;
|
||||
async fn client_version(&self) -> RpcResult<String>;
|
||||
|
||||
/// Returns sha3 of the given data.
|
||||
#[method(name = "web3_sha3")]
|
||||
fn sha3(&self, input: Bytes) -> Result<H256>;
|
||||
fn sha3(&self, input: Bytes) -> RpcResult<H256>;
|
||||
}
|
||||
|
||||
@ -21,8 +21,8 @@ reth-tasks = { path = "../../tasks" }
|
||||
reth-transaction-pool = { path = "../../transaction-pool" }
|
||||
|
||||
# rpc/net
|
||||
jsonrpsee = { version = "0.16", features = ["server"] }
|
||||
tower-http = { version = "0.3", features = ["full"] }
|
||||
jsonrpsee = { version = "0.18", features = ["server"] }
|
||||
tower-http = { version = "0.4", features = ["full"] }
|
||||
tower = { version = "0.4", features = ["full"] }
|
||||
hyper = "0.14"
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ impl RpcError {
|
||||
}
|
||||
}
|
||||
}
|
||||
RpcError::RpcError(err.into())
|
||||
RpcError::RpcError(JsonRpseeError::Transport(err))
|
||||
}
|
||||
_ => err.into(),
|
||||
}
|
||||
|
||||
@ -100,9 +100,8 @@
|
||||
use constants::*;
|
||||
use error::{RpcError, ServerKind};
|
||||
use jsonrpsee::{
|
||||
core::server::rpc_module::Methods,
|
||||
server::{IdProvider, Server, ServerHandle},
|
||||
RpcModule,
|
||||
Methods, RpcModule,
|
||||
};
|
||||
use reth_ipc::server::IpcServer;
|
||||
use reth_network_api::{NetworkInfo, Peers};
|
||||
|
||||
@ -6,7 +6,7 @@ use jsonrpsee::{
|
||||
client::{ClientT, SubscriptionClientT},
|
||||
error::Error,
|
||||
},
|
||||
types::error::{CallError, ErrorCode},
|
||||
types::error::ErrorCode,
|
||||
};
|
||||
use reth_primitives::{
|
||||
hex_literal::hex, Address, BlockId, BlockNumberOrTag, Bytes, NodeRecord, TxHash, H256, H64,
|
||||
@ -22,7 +22,7 @@ use std::collections::HashSet;
|
||||
|
||||
fn is_unimplemented(err: Error) -> bool {
|
||||
match err {
|
||||
Error::Call(CallError::Custom(error_obj)) => {
|
||||
Error::Call(error_obj) => {
|
||||
error_obj.code() == ErrorCode::InternalError.code() &&
|
||||
error_obj.message() == "unimplemented"
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ tokio = { version = "1", features = ["sync"] }
|
||||
# misc
|
||||
async-trait = "0.1"
|
||||
thiserror = "1.0.37"
|
||||
jsonrpsee-types = "0.16"
|
||||
jsonrpsee-core = "0.16"
|
||||
jsonrpsee-types = "0.18"
|
||||
jsonrpsee-core = "0.18"
|
||||
tracing = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@ -93,7 +93,7 @@ impl From<oneshot::error::RecvError> for EngineApiError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EngineApiError> for jsonrpsee_types::error::CallError {
|
||||
impl From<EngineApiError> for jsonrpsee_types::error::ErrorObject<'static> {
|
||||
fn from(error: EngineApiError) -> Self {
|
||||
let code = match error {
|
||||
EngineApiError::InvalidBodiesRange { .. } |
|
||||
@ -105,17 +105,17 @@ impl From<EngineApiError> for jsonrpsee_types::error::CallError {
|
||||
// Any other server error
|
||||
_ => INTERNAL_ERROR_CODE,
|
||||
};
|
||||
jsonrpsee_types::error::CallError::Custom(jsonrpsee_types::error::ErrorObject::owned(
|
||||
jsonrpsee_types::error::ErrorObject::owned(
|
||||
code,
|
||||
// TODO properly convert to rpc error
|
||||
error.to_string(),
|
||||
None::<()>,
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EngineApiError> for jsonrpsee_core::error::Error {
|
||||
fn from(error: EngineApiError) -> Self {
|
||||
jsonrpsee_types::error::CallError::from(error).into()
|
||||
jsonrpsee_core::error::Error::Call(error.into())
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ tokio = { version = "1", features = ["sync"] }
|
||||
# misc
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
jsonrpsee-types = { version = "0.16" }
|
||||
jsonrpsee-types = { version = "0.18" }
|
||||
lru = "0.9"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@ -32,7 +32,7 @@ pub struct Peers {
|
||||
}
|
||||
|
||||
/// Number of peers connected to.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PeerCount {
|
||||
/// Peer count as integer
|
||||
@ -98,7 +98,7 @@ pub struct PipProtocolInfo {
|
||||
}
|
||||
|
||||
/// Sync status
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum SyncStatus {
|
||||
/// Info when syncing
|
||||
Info(SyncInfo),
|
||||
|
||||
@ -31,7 +31,7 @@ revm-primitives = { version = "1.1", features = ["serde"] }
|
||||
|
||||
|
||||
# rpc
|
||||
jsonrpsee = { version = "0.16" }
|
||||
jsonrpsee = { version = "0.18" }
|
||||
http = "0.2.8"
|
||||
http-body = "0.4.5"
|
||||
hyper = "0.14.24"
|
||||
@ -62,4 +62,4 @@ schnellru = "0.2"
|
||||
futures = "0.3.26"
|
||||
|
||||
[dev-dependencies]
|
||||
jsonrpsee = { version = "0.16", features = ["client"] }
|
||||
jsonrpsee = { version = "0.18", features = ["client"] }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use crate::result::{internal_rpc_err, ToRpcResult};
|
||||
use crate::result::ToRpcResult;
|
||||
use async_trait::async_trait;
|
||||
use jsonrpsee::core::RpcResult;
|
||||
use reth_network_api::{NetworkInfo, PeerKind, Peers};
|
||||
@ -51,12 +51,11 @@ where
|
||||
}
|
||||
|
||||
/// Handler for `admin_peerEvents`
|
||||
fn subscribe_peer_events(
|
||||
async fn subscribe_peer_events(
|
||||
&self,
|
||||
sink: jsonrpsee::SubscriptionSink,
|
||||
) -> jsonrpsee::types::SubscriptionResult {
|
||||
sink.close(internal_rpc_err("admin_peerEvents is not implemented yet"));
|
||||
Ok(())
|
||||
_pending: jsonrpsee::PendingSubscriptionSink,
|
||||
) -> jsonrpsee::core::SubscriptionResult {
|
||||
Err("admin_peerEvents is not implemented yet".into())
|
||||
}
|
||||
|
||||
/// Handler for `admin_nodeInfo`
|
||||
|
||||
@ -261,8 +261,8 @@ where
|
||||
BlockId::Hash(hash) => self.client.header(&hash.into()).to_rpc_result()?,
|
||||
BlockId::Number(number_or_tag) => {
|
||||
let number =
|
||||
self.client.convert_block_number(number_or_tag).to_rpc_result()?.ok_or(
|
||||
jsonrpsee::core::Error::Custom("Pending block not supported".to_string()),
|
||||
self.client.convert_block_number(number_or_tag).to_rpc_result()?.ok_or_else(
|
||||
|| internal_rpc_err("Pending block not supported".to_string()),
|
||||
)?;
|
||||
self.client.header_by_number(number).to_rpc_result()?
|
||||
}
|
||||
|
||||
@ -365,10 +365,7 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{eth::cache::EthStateCache, EthApi};
|
||||
use jsonrpsee::{
|
||||
core::{error::Error as RpcError, RpcResult},
|
||||
types::error::{CallError, INVALID_PARAMS_CODE},
|
||||
};
|
||||
use jsonrpsee::types::error::INVALID_PARAMS_CODE;
|
||||
use rand::random;
|
||||
use reth_network_api::test_utils::NoopNetwork;
|
||||
use reth_primitives::{Block, BlockNumberOrTag, Header, TransactionSigned, H256, U256};
|
||||
@ -393,8 +390,8 @@ mod tests {
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert!(matches!(response, RpcResult::Err(RpcError::Call(CallError::Custom(_)))));
|
||||
let Err(RpcError::Call(CallError::Custom(error_object))) = response else { unreachable!() };
|
||||
assert!(response.is_err());
|
||||
let error_object = response.unwrap_err();
|
||||
assert_eq!(error_object.code(), INVALID_PARAMS_CODE);
|
||||
|
||||
let block_count = 10;
|
||||
@ -477,8 +474,8 @@ mod tests {
|
||||
Some(vec![10.0]),
|
||||
)
|
||||
.await;
|
||||
assert!(matches!(response, RpcResult::Err(RpcError::Call(CallError::Custom(_)))));
|
||||
let Err(RpcError::Call(CallError::Custom(error_object))) = response else { unreachable!() };
|
||||
assert!(response.is_err());
|
||||
let error_object = response.unwrap_err();
|
||||
assert_eq!(error_object.code(), INVALID_PARAMS_CODE);
|
||||
|
||||
// newest_block is finalized
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Implementation specific Errors for the `eth_` namespace.
|
||||
|
||||
use crate::result::{internal_rpc_err, invalid_params_rpc_err, rpc_err, rpc_error_with_code};
|
||||
use jsonrpsee::core::Error as RpcError;
|
||||
use jsonrpsee::{core::Error as RpcError, types::ErrorObject};
|
||||
use reth_primitives::{abi::decode_revert_reason, Address, Bytes, U256};
|
||||
use reth_rpc_types::{error::EthRpcErrorCode, BlockError};
|
||||
use reth_transaction_pool::error::{InvalidPoolTransactionError, PoolError};
|
||||
@ -65,7 +65,7 @@ pub enum EthApiError {
|
||||
InvalidRewardPercentile(f64),
|
||||
}
|
||||
|
||||
impl From<EthApiError> for RpcError {
|
||||
impl From<EthApiError> for ErrorObject<'static> {
|
||||
fn from(error: EthApiError) -> Self {
|
||||
match error {
|
||||
EthApiError::FailedToDecodeSignedTransaction |
|
||||
@ -91,6 +91,12 @@ impl From<EthApiError> for RpcError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EthApiError> for RpcError {
|
||||
fn from(error: EthApiError) -> Self {
|
||||
RpcError::Call(error.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<EVMError<T>> for EthApiError
|
||||
where
|
||||
T: Into<EthApiError>,
|
||||
@ -227,7 +233,7 @@ impl InvalidTransactionError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InvalidTransactionError> for RpcError {
|
||||
impl From<InvalidTransactionError> for ErrorObject<'static> {
|
||||
fn from(err: InvalidTransactionError) -> Self {
|
||||
match err {
|
||||
InvalidTransactionError::Revert(revert) => {
|
||||
|
||||
@ -399,7 +399,7 @@ pub enum FilterError {
|
||||
}
|
||||
|
||||
// convert the error
|
||||
impl From<FilterError> for jsonrpsee::core::Error {
|
||||
impl From<FilterError> for jsonrpsee::types::error::ErrorObject<'static> {
|
||||
fn from(err: FilterError) -> Self {
|
||||
match err {
|
||||
FilterError::FilterNotFound(_) => rpc_error_with_code(
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
//! `eth_` PubSub RPC handler implementation
|
||||
use crate::eth::logs_utils;
|
||||
use futures::StreamExt;
|
||||
use jsonrpsee::{types::SubscriptionResult, SubscriptionSink};
|
||||
use jsonrpsee::{server::SubscriptionMessage, PendingSubscriptionSink, SubscriptionSink};
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_primitives::{filter::FilteredParams, TxHash};
|
||||
use reth_provider::{BlockProvider, CanonStateSubscriptions, EvmEnvProvider};
|
||||
use reth_rpc_api::EthPubSubApiServer;
|
||||
|
||||
use reth_rpc_types::{
|
||||
pubsub::{
|
||||
Params, PubSubSyncStatus, SubscriptionKind, SubscriptionResult as EthSubscriptionResult,
|
||||
@ -15,6 +16,7 @@ use reth_rpc_types::{
|
||||
};
|
||||
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use serde::Serialize;
|
||||
use tokio_stream::{
|
||||
wrappers::{BroadcastStream, ReceiverStream},
|
||||
Stream,
|
||||
@ -54,6 +56,7 @@ impl<Client, Pool, Events, Network> EthPubSub<Client, Pool, Events, Network> {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<Client, Pool, Events, Network> EthPubSubApiServer for EthPubSub<Client, Pool, Events, Network>
|
||||
where
|
||||
Client: BlockProvider + EvmEnvProvider + Clone + 'static,
|
||||
@ -62,17 +65,16 @@ where
|
||||
Network: NetworkInfo + Clone + 'static,
|
||||
{
|
||||
/// Handler for `eth_subscribe`
|
||||
fn subscribe(
|
||||
async fn subscribe(
|
||||
&self,
|
||||
mut sink: SubscriptionSink,
|
||||
pending: PendingSubscriptionSink,
|
||||
kind: SubscriptionKind,
|
||||
params: Option<Params>,
|
||||
) -> SubscriptionResult {
|
||||
sink.accept()?;
|
||||
|
||||
) -> jsonrpsee::core::SubscriptionResult {
|
||||
let sink = pending.accept().await?;
|
||||
let pubsub = self.inner.clone();
|
||||
self.subscription_task_spawner.spawn(Box::pin(async move {
|
||||
handle_accepted(pubsub, sink, kind, params).await;
|
||||
let _ = handle_accepted(pubsub, sink, kind, params).await;
|
||||
}));
|
||||
|
||||
Ok(())
|
||||
@ -82,10 +84,11 @@ where
|
||||
/// The actual handler for and accepted [`EthPubSub::subscribe`] call.
|
||||
async fn handle_accepted<Client, Pool, Events, Network>(
|
||||
pubsub: EthPubSubInner<Client, Pool, Events, Network>,
|
||||
mut accepted_sink: SubscriptionSink,
|
||||
accepted_sink: SubscriptionSink,
|
||||
kind: SubscriptionKind,
|
||||
params: Option<Params>,
|
||||
) where
|
||||
) -> Result<(), jsonrpsee::core::Error>
|
||||
where
|
||||
Client: BlockProvider + EvmEnvProvider + Clone + 'static,
|
||||
Pool: TransactionPool + 'static,
|
||||
Events: CanonStateSubscriptions + Clone + 'static,
|
||||
@ -96,7 +99,7 @@ async fn handle_accepted<Client, Pool, Events, Network>(
|
||||
let stream = pubsub
|
||||
.into_new_headers_stream()
|
||||
.map(|block| EthSubscriptionResult::Header(Box::new(block.into())));
|
||||
accepted_sink.pipe_from_stream(stream).await;
|
||||
pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
SubscriptionKind::Logs => {
|
||||
// if no params are provided, used default filter params
|
||||
@ -106,13 +109,13 @@ async fn handle_accepted<Client, Pool, Events, Network>(
|
||||
};
|
||||
let stream =
|
||||
pubsub.into_log_stream(filter).map(|log| EthSubscriptionResult::Log(Box::new(log)));
|
||||
accepted_sink.pipe_from_stream(stream).await;
|
||||
pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
SubscriptionKind::NewPendingTransactions => {
|
||||
let stream = pubsub
|
||||
.into_pending_transaction_stream()
|
||||
.map(EthSubscriptionResult::TransactionHash);
|
||||
accepted_sink.pipe_from_stream(stream).await;
|
||||
pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
SubscriptionKind::Syncing => {
|
||||
// get new block subscription
|
||||
@ -123,7 +126,10 @@ async fn handle_accepted<Client, Pool, Events, Network>(
|
||||
let current_sub_res = pubsub.sync_status(initial_sync_status).await;
|
||||
|
||||
// send the current status immediately
|
||||
let _ = accepted_sink.send(¤t_sub_res);
|
||||
let msg = SubscriptionMessage::from_json(¤t_sub_res)?;
|
||||
if accepted_sink.send(msg).await.is_err() {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
while (canon_state.next().await).is_some() {
|
||||
let current_syncing = pubsub.network.is_syncing();
|
||||
@ -134,7 +140,44 @@ async fn handle_accepted<Client, Pool, Events, Network>(
|
||||
|
||||
// send a new message now that the status changed
|
||||
let sync_status = pubsub.sync_status(current_syncing).await;
|
||||
let _ = accepted_sink.send(&sync_status);
|
||||
let msg = SubscriptionMessage::from_json(&sync_status)?;
|
||||
if accepted_sink.send(msg).await.is_err() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pipes all stream items to the subscription sink.
|
||||
async fn pipe_from_stream<T, St>(
|
||||
sink: SubscriptionSink,
|
||||
mut stream: St,
|
||||
) -> Result<(), jsonrpsee::core::Error>
|
||||
where
|
||||
St: Stream<Item = T> + Unpin,
|
||||
T: Serialize,
|
||||
{
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = sink.closed() => {
|
||||
// connection dropped
|
||||
break Ok(())
|
||||
},
|
||||
maybe_item = stream.next() => {
|
||||
let item = match maybe_item {
|
||||
Some(item) => item,
|
||||
None => {
|
||||
// stream ended
|
||||
break Ok(())
|
||||
},
|
||||
};
|
||||
let msg = SubscriptionMessage::from_json(&item)?;
|
||||
if sink.send(msg).await.is_err() {
|
||||
break Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ mod tests {
|
||||
|
||||
// Create a mock rpc module
|
||||
let mut module = RpcModule::new(());
|
||||
module.register_method("greet_melkor", |_, _| Ok("You are the dark lord")).unwrap();
|
||||
module.register_method("greet_melkor", |_, _| "You are the dark lord").unwrap();
|
||||
|
||||
server.start(module).unwrap()
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Additional helpers for converting errors.
|
||||
|
||||
use crate::eth::error::EthApiError;
|
||||
use jsonrpsee::core::{Error as RpcError, RpcResult};
|
||||
use jsonrpsee::core::RpcResult;
|
||||
use reth_interfaces::Result as RethResult;
|
||||
use reth_primitives::Block;
|
||||
use std::fmt::Display;
|
||||
@ -126,12 +126,16 @@ impl ToRpcResultExt for RethResult<Option<Block>> {
|
||||
}
|
||||
|
||||
/// Constructs an invalid params JSON-RPC error.
|
||||
pub(crate) fn invalid_params_rpc_err(msg: impl Into<String>) -> jsonrpsee::core::Error {
|
||||
pub(crate) fn invalid_params_rpc_err(
|
||||
msg: impl Into<String>,
|
||||
) -> jsonrpsee::types::error::ErrorObject<'static> {
|
||||
rpc_err(jsonrpsee::types::error::INVALID_PARAMS_CODE, msg, None)
|
||||
}
|
||||
|
||||
/// Constructs an internal JSON-RPC error.
|
||||
pub(crate) fn internal_rpc_err(msg: impl Into<String>) -> jsonrpsee::core::Error {
|
||||
pub(crate) fn internal_rpc_err(
|
||||
msg: impl Into<String>,
|
||||
) -> jsonrpsee::types::error::ErrorObject<'static> {
|
||||
rpc_err(jsonrpsee::types::error::INTERNAL_ERROR_CODE, msg, None)
|
||||
}
|
||||
|
||||
@ -139,27 +143,32 @@ pub(crate) fn internal_rpc_err(msg: impl Into<String>) -> jsonrpsee::core::Error
|
||||
pub(crate) fn internal_rpc_err_with_data(
|
||||
msg: impl Into<String>,
|
||||
data: &[u8],
|
||||
) -> jsonrpsee::core::Error {
|
||||
) -> jsonrpsee::types::error::ErrorObject<'static> {
|
||||
rpc_err(jsonrpsee::types::error::INTERNAL_ERROR_CODE, msg, Some(data))
|
||||
}
|
||||
|
||||
/// Constructs an internal JSON-RPC error with code and message
|
||||
pub(crate) fn rpc_error_with_code(code: i32, msg: impl Into<String>) -> jsonrpsee::core::Error {
|
||||
pub(crate) fn rpc_error_with_code(
|
||||
code: i32,
|
||||
msg: impl Into<String>,
|
||||
) -> jsonrpsee::types::error::ErrorObject<'static> {
|
||||
rpc_err(code, msg, None)
|
||||
}
|
||||
|
||||
/// Constructs a JSON-RPC error, consisting of `code`, `message` and optional `data`.
|
||||
pub(crate) fn rpc_err(code: i32, msg: impl Into<String>, data: Option<&[u8]>) -> RpcError {
|
||||
RpcError::Call(jsonrpsee::types::error::CallError::Custom(
|
||||
jsonrpsee::types::error::ErrorObject::owned(
|
||||
code,
|
||||
msg.into(),
|
||||
data.map(|data| {
|
||||
jsonrpsee::core::to_json_raw_value(&format!("0x{}", hex::encode(data)))
|
||||
.expect("serializing String does fail")
|
||||
}),
|
||||
),
|
||||
))
|
||||
pub(crate) fn rpc_err(
|
||||
code: i32,
|
||||
msg: impl Into<String>,
|
||||
data: Option<&[u8]>,
|
||||
) -> jsonrpsee::types::error::ErrorObject<'static> {
|
||||
jsonrpsee::types::error::ErrorObject::owned(
|
||||
code,
|
||||
msg.into(),
|
||||
data.map(|data| {
|
||||
jsonrpsee::core::to_json_raw_value(&format!("0x{}", hex::encode(data)))
|
||||
.expect("serializing String does fail")
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -53,6 +53,8 @@ allow = [
|
||||
"LicenseRef-ring",
|
||||
# https://github.com/briansmith/webpki/issues/148
|
||||
"LicenseRef-webpki",
|
||||
# https://github.com/rustls/webpki/blob/main/LICENSE ISC Style
|
||||
"LicenseRef-rustls-webpki",
|
||||
]
|
||||
|
||||
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
|
||||
@ -77,6 +79,11 @@ name = "webpki"
|
||||
expression = "LicenseRef-webpki"
|
||||
license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
|
||||
|
||||
[[licenses.clarify]]
|
||||
name = "rustls-webpki"
|
||||
expression = "LicenseRef-rustls-webpki"
|
||||
license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
|
||||
|
||||
# This section is considered when running `cargo deny check sources`.
|
||||
# More documentation about the 'sources' section can be found here:
|
||||
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
|
||||
|
||||
Reference in New Issue
Block a user