chore: remove allow unused in rpc (#2617)

This commit is contained in:
Matthias Seitz
2023-05-09 16:41:53 +02:00
committed by GitHub
parent bda830c1a5
commit 21217cbed3
10 changed files with 34 additions and 42 deletions

View File

@ -820,12 +820,12 @@ where
self.config.eth.max_logs_per_response,
);
let pubsub = EthPubSub::new(
let pubsub = EthPubSub::with_spawner(
self.client.clone(),
self.pool.clone(),
self.events.clone(),
self.network.clone(),
cache.clone(),
Box::new(self.executor.clone()),
);
let eth = EthHandlers { api, cache, filter, pubsub };

View File

@ -28,6 +28,7 @@ use reth_rpc_types::{
};
use revm::primitives::Env;
use revm_primitives::{db::DatabaseCommit, BlockEnv, CfgEnv};
use tokio::sync::{AcquireError, OwnedSemaphorePermit};
/// `debug` API implementation.
///
@ -38,7 +39,7 @@ pub struct DebugApi<Client, Eth> {
client: Client,
/// The implementation of `eth` API
eth_api: Eth,
// restrict the number of concurrent calls to `debug_traceTransaction`
// restrict the number of concurrent calls to tracing calls
tracing_call_guard: TracingCallGuard,
}
@ -58,6 +59,11 @@ where
Client: BlockProvider + HeaderProvider + 'static,
Eth: EthTransactions + 'static,
{
/// Acquires a permit to execute a tracing call.
async fn acquire_trace_permit(&self) -> Result<OwnedSemaphorePermit, AcquireError> {
self.tracing_call_guard.clone().acquire_owned().await
}
/// Trace the entire block
fn trace_block_with(
&self,
@ -288,6 +294,7 @@ where
rlp_block: Bytes,
opts: GethDebugTracingOptions,
) -> RpcResult<Vec<TraceResult>> {
let _permit = self.acquire_trace_permit().await;
Ok(DebugApi::debug_trace_raw_block(self, rlp_block, opts).await?)
}
@ -297,6 +304,7 @@ where
block: H256,
opts: GethDebugTracingOptions,
) -> RpcResult<Vec<TraceResult>> {
let _permit = self.acquire_trace_permit().await;
Ok(DebugApi::debug_trace_block(self, block.into(), opts).await?)
}
@ -306,6 +314,7 @@ where
block: BlockNumberOrTag,
opts: GethDebugTracingOptions,
) -> RpcResult<Vec<TraceResult>> {
let _permit = self.acquire_trace_permit().await;
Ok(DebugApi::debug_trace_block(self, block.into(), opts).await?)
}
@ -315,6 +324,7 @@ where
tx_hash: H256,
opts: GethDebugTracingOptions,
) -> RpcResult<GethTraceFrame> {
let _permit = self.acquire_trace_permit().await;
Ok(DebugApi::debug_trace_transaction(self, tx_hash, opts).await?)
}
@ -325,6 +335,7 @@ where
block_number: Option<BlockId>,
opts: GethDebugTracingCallOptions,
) -> RpcResult<GethTraceFrame> {
let _permit = self.acquire_trace_permit().await;
Ok(DebugApi::debug_trace_call(self, request, block_number, opts).await?)
}
}

View File

@ -68,14 +68,6 @@ where
Ok(self.cache().get_block_transactions(block_hash).await?.map(|txs| txs.len()))
}
/// Returns the block header for the given block id.
pub(crate) async fn header(
&self,
block_id: impl Into<BlockId>,
) -> EthResult<Option<reth_primitives::SealedHeader>> {
Ok(self.block(block_id).await?.map(|block| block.header))
}
/// Returns the block object for the given block id.
pub(crate) async fn block(
&self,

View File

@ -3,7 +3,11 @@
//! The entire implementation of the namespace is quite large, hence it is divided across several
//! files.
use crate::eth::{cache::EthStateCache, signer::EthSigner};
use crate::eth::{
cache::EthStateCache,
error::{EthApiError, EthResult},
signer::EthSigner,
};
use async_trait::async_trait;
use reth_interfaces::Result;
use reth_network_api::NetworkInfo;
@ -20,7 +24,7 @@ mod server;
mod sign;
mod state;
mod transactions;
use crate::eth::error::{EthApiError, EthResult};
pub use transactions::{EthTransactions, TransactionSource};
/// Cache limit of block-level fee history for `eth_feeHistory` RPC method.

View File

@ -81,6 +81,7 @@ where
Ok(H256(value.to_be_bytes()))
}
#[allow(unused)]
pub(crate) fn get_proof(
&self,
address: Address,

View File

@ -187,6 +187,7 @@ where
#[derive(Debug)]
struct EthFilterInner<Client, Pool> {
/// The transaction pool.
#[allow(unused)] // we need this for non standard full transactions eventually
pool: Pool,
/// The client that can interact with the chain.
client: Client,

View File

@ -1,5 +1,5 @@
//! `eth_` PubSub RPC handler implementation
use crate::eth::{cache::EthStateCache, logs_utils};
use crate::eth::logs_utils;
use futures::StreamExt;
use jsonrpsee::{types::SubscriptionResult, SubscriptionSink};
use reth_network_api::NetworkInfo;
@ -37,21 +37,8 @@ impl<Client, Pool, Events, Network> EthPubSub<Client, Pool, Events, Network> {
/// Creates a new, shareable instance.
///
/// Subscription tasks are spawned via [tokio::task::spawn]
pub fn new(
client: Client,
pool: Pool,
chain_events: Events,
network: Network,
eth_cache: EthStateCache,
) -> Self {
Self::with_spawner(
client,
pool,
chain_events,
network,
eth_cache,
Box::<TokioTaskExecutor>::default(),
)
pub fn new(client: Client, pool: Pool, chain_events: Events, network: Network) -> Self {
Self::with_spawner(client, pool, chain_events, network, Box::<TokioTaskExecutor>::default())
}
/// Creates a new, shareable instance.
@ -60,10 +47,9 @@ impl<Client, Pool, Events, Network> EthPubSub<Client, Pool, Events, Network> {
pool: Pool,
chain_events: Events,
network: Network,
eth_cache: EthStateCache,
subscription_task_spawner: Box<dyn TaskSpawner>,
) -> Self {
let inner = EthPubSubInner { client, pool, chain_events, network, eth_cache };
let inner = EthPubSubInner { client, pool, chain_events, network };
Self { inner, subscription_task_spawner }
}
}
@ -168,12 +154,10 @@ struct EthPubSubInner<Client, Pool, Events, Network> {
pool: Pool,
/// The client that can interact with the chain.
client: Client,
/// A type that allows to create new event subscriptions,
/// A type that allows to create new event subscriptions.
chain_events: Events,
/// The network.
network: Network,
/// The async cache frontend for eth related data
eth_cache: EthStateCache,
}
// == impl EthPubSubInner ===

View File

@ -4,8 +4,6 @@
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
// TODO remove later
#![allow(dead_code)]
//! Reth RPC implementation
//!

View File

@ -164,7 +164,6 @@ pub(crate) fn rpc_err(code: i32, msg: impl Into<String>, data: Option<&[u8]>) ->
#[cfg(test)]
mod tests {
use super::*;
fn assert_rpc_result<Ok, Err, T: ToRpcResult<Ok, Err>>() {}
@ -173,10 +172,6 @@ mod tests {
Ok(o)
}
fn to_optional_reth_err<Ok>(o: Ok) -> reth_interfaces::Result<Option<Ok>> {
Ok(Some(o))
}
#[test]
fn can_convert_rpc() {
assert_rpc_result::<(), reth_interfaces::Error, reth_interfaces::Result<()>>();

View File

@ -37,7 +37,8 @@ pub struct TraceApi<Client, Eth> {
client: Client,
/// Access to commonly used code of the `eth` namespace
eth_api: Eth,
/// The async cache frontend for eth related data
/// The async cache frontend for eth-related data
#[allow(unused)] // we need this for trace_filter eventually
eth_cache: EthStateCache,
// restrict the number of concurrent calls to `trace_*`
tracing_call_guard: TracingCallGuard,
@ -46,6 +47,11 @@ pub struct TraceApi<Client, Eth> {
// === impl TraceApi ===
impl<Client, Eth> TraceApi<Client, Eth> {
/// The client that can interact with the chain.
pub fn client(&self) -> &Client {
&self.client
}
/// Create a new instance of the [TraceApi]
pub fn new(
client: Client,