Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: use tracing pool for tracing calls #3914

Merged
merged 10 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 1 addition & 2 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions crates/rpc/rpc-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ strum = { workspace = true, features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }
tracing = { workspace = true }
rayon = { workspace = true }
pin-project = { workspace = true }
tokio = { workspace = true, features = ["sync"] }

[dev-dependencies]
reth-tracing = { path = "../../tracing" }
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-builder/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use reth_provider::{
use reth_rpc::{
eth::{cache::EthStateCache, gas_oracle::GasPriceOracle},
AuthLayer, Claims, EngineEthApi, EthApi, EthFilter, EthSubscriptionIdProvider,
JwtAuthValidator, JwtSecret,
JwtAuthValidator, JwtSecret, TracingCallPool,
};
use reth_rpc_api::{servers::*, EngineApiServer};
use reth_tasks::TaskSpawner;
Expand Down Expand Up @@ -64,6 +64,7 @@ where
gas_oracle,
EthConfig::default().rpc_gas_cap,
Box::new(executor.clone()),
TracingCallPool::build().expect("failed to build tracing pool"),
);
let eth_filter = EthFilter::new(
provider,
Expand Down
4 changes: 3 additions & 1 deletion crates/rpc/rpc-builder/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use reth_rpc::{
gas_oracle::GasPriceOracleConfig,
RPC_DEFAULT_GAS_CAP,
},
EthApi, EthFilter, EthPubSub,
EthApi, EthFilter, EthPubSub, TracingCallPool,
};
use serde::{Deserialize, Serialize};

Expand All @@ -25,6 +25,8 @@ pub struct EthHandlers<Provider, Pool, Network, Events> {
pub filter: EthFilter<Provider, Pool>,
/// Handler for subscriptions only available for transports that support it (ws, ipc)
pub pubsub: EthPubSub<Provider, Pool, Events, Network>,
/// The configured tracing call pool
pub tracing_call_pool: TracingCallPool,
}

/// Additional config values for the eth namespace
Expand Down
33 changes: 15 additions & 18 deletions crates/rpc/rpc-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ use reth_rpc::{
gas_oracle::GasPriceOracle,
},
AdminApi, DebugApi, EngineEthApi, EthApi, EthFilter, EthPubSub, EthSubscriptionIdProvider,
NetApi, OtterscanApi, RPCApi, RethApi, TraceApi, TracingCallGuard, TxPoolApi, Web3Api,
NetApi, OtterscanApi, RPCApi, RethApi, TraceApi, TracingCallGuard, TracingCallPool, TxPoolApi,
Web3Api,
};
use reth_rpc_api::{servers::*, EngineApiServer};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
Expand Down Expand Up @@ -154,9 +155,6 @@ mod eth;
/// Common RPC constants.
pub mod constants;

/// Additional support for tracing related rpc calls
pub mod tracing_pool;

// Rpc server metrics
mod metrics;

Expand Down Expand Up @@ -816,15 +814,9 @@ where
let eth = self.eth_handlers();
self.modules.insert(
RethRpcModule::Trace,
TraceApi::new(
self.provider.clone(),
eth.api.clone(),
eth.cache,
Box::new(self.executor.clone()),
self.tracing_call_guard.clone(),
)
.into_rpc()
.into(),
TraceApi::new(self.provider.clone(), eth.api.clone(), self.tracing_call_guard.clone())
.into_rpc()
.into(),
);
self
}
Expand Down Expand Up @@ -895,8 +887,13 @@ where
&mut self,
namespaces: impl Iterator<Item = RethRpcModule>,
) -> Vec<Methods> {
let EthHandlers { api: eth_api, cache: eth_cache, filter: eth_filter, pubsub: eth_pubsub } =
self.with_eth(|eth| eth.clone());
let EthHandlers {
api: eth_api,
filter: eth_filter,
pubsub: eth_pubsub,
cache: _,
tracing_call_pool: _,
} = self.with_eth(|eth| eth.clone());

// Create a copy, so we can list out all the methods for rpc_ api
let namespaces: Vec<_> = namespaces.collect();
Expand Down Expand Up @@ -933,8 +930,6 @@ where
RethRpcModule::Trace => TraceApi::new(
self.provider.clone(),
eth_api.clone(),
eth_cache.clone(),
Box::new(self.executor.clone()),
self.tracing_call_guard.clone(),
)
.into_rpc()
Expand Down Expand Up @@ -997,6 +992,7 @@ where
);

let executor = Box::new(self.executor.clone());
let tracing_call_pool = TracingCallPool::build().expect("failed to build tracing pool");
let api = EthApi::with_spawner(
self.provider.clone(),
self.pool.clone(),
Expand All @@ -1005,6 +1001,7 @@ where
gas_oracle,
self.config.eth.rpc_gas_cap,
executor.clone(),
tracing_call_pool.clone(),
);
let filter = EthFilter::new(
self.provider.clone(),
Expand All @@ -1022,7 +1019,7 @@ where
executor,
);

let eth = EthHandlers { api, cache, filter, pubsub };
let eth = EthHandlers { api, cache, filter, pubsub, tracing_call_pool };
self.eth = Some(eth);
}
f(self.eth.as_ref().expect("exists; qed"))
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ tower = "0.4"
tokio-stream = { workspace = true, features = ["sync"] }
tokio-util = "0.7"
pin-project = { workspace = true }
rayon = { workspace = true }

bytes.workspace = true
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }
Expand Down
26 changes: 0 additions & 26 deletions crates/rpc/rpc/src/call_guard.rs

This file was deleted.

Loading
Loading