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

Reorged logs temp #25

Merged
merged 7 commits into from
Jan 1, 2024
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
11 changes: 10 additions & 1 deletion Cargo.lock

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

6 changes: 5 additions & 1 deletion bin/reth/src/args/rpc_server_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,16 @@ impl RpcServerArgs {
}

/// Create Engine API server.
pub async fn start_auth_server<Provider, Pool, Network, Tasks>(
#[allow(clippy::too_many_arguments)]
pub async fn start_auth_server<Provider, Pool, Network, Tasks, Events>(
&self,
provider: Provider,
pool: Pool,
network: Network,
executor: Tasks,
engine_api: EngineApi<Provider>,
jwt_secret: JwtSecret,
events: Events,
) -> Result<AuthServerHandle, RpcError>
where
Provider: BlockReaderIdExt
Expand All @@ -343,6 +345,7 @@ impl RpcServerArgs {
Pool: TransactionPool + Clone + 'static,
Network: NetworkInfo + Peers + Clone + 'static,
Tasks: TaskSpawner + Clone + 'static,
Events: CanonStateSubscriptions + Clone + 'static,
{
let socket_address = SocketAddr::new(self.auth_addr, self.auth_port);

Expand All @@ -354,6 +357,7 @@ impl RpcServerArgs {
engine_api,
socket_address,
jwt_secret,
events,
)
.await
}
Expand Down
41 changes: 32 additions & 9 deletions crates/rpc/rpc-builder/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ use jsonrpsee::{
};
use reth_network_api::{NetworkInfo, Peers};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, ReceiptProviderIdExt,
StateProviderFactory,
BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider, EvmEnvProvider, HeaderProvider,
ReceiptProviderIdExt, StateProviderFactory,
};
use reth_rpc::{
eth::{
cache::EthStateCache, gas_oracle::GasPriceOracle, EthFilterConfig, FeeHistoryCache,
FeeHistoryCacheConfig,
},
AuthLayer, BlockingTaskPool, Claims, EngineEthApi, EthApi, EthFilter,
AuthLayer, BlockingTaskPool, Claims, EngineEthApi, EthApi, EthFilter, EthPubSub,
EthSubscriptionIdProvider, JwtAuthValidator, JwtSecret,
};
use reth_rpc_api::{servers::*, EngineApiServer};
Expand All @@ -33,14 +33,15 @@ use std::{

/// Configure and launch a _standalone_ auth server with `engine` and a _new_ `eth` namespace.
#[allow(clippy::too_many_arguments)]
pub async fn launch<Provider, Pool, Network, Tasks, EngineApi>(
pub async fn launch<Provider, Pool, Network, Tasks, EngineApi, Events>(
provider: Provider,
pool: Pool,
network: Network,
executor: Tasks,
engine_api: EngineApi,
socket_addr: SocketAddr,
secret: JwtSecret,
events: Events,
) -> Result<AuthServerHandle, RpcError>
where
Provider: BlockReaderIdExt
Expand All @@ -56,6 +57,7 @@ where
Network: NetworkInfo + Peers + Clone + 'static,
Tasks: TaskSpawner + Clone + 'static,
EngineApi: EngineApiServer,
Events: CanonStateSubscriptions + Clone + 'static,
{
// spawn a new cache task
let eth_cache =
Expand All @@ -68,7 +70,7 @@ where
let eth_api = EthApi::with_spawner(
provider.clone(),
pool.clone(),
network,
network.clone(),
eth_cache.clone(),
gas_oracle,
EthConfig::default().rpc_gas_cap,
Expand All @@ -79,13 +81,33 @@ where
let config = EthFilterConfig::default()
.max_logs_per_response(DEFAULT_MAX_LOGS_PER_RESPONSE)
.max_blocks_per_filter(DEFAULT_MAX_BLOCKS_PER_FILTER);
let eth_filter =
EthFilter::new(provider, pool, eth_cache.clone(), config, Box::new(executor.clone()));
launch_with_eth_api(eth_api, eth_filter, engine_api, socket_addr, secret).await
let eth_pubsub = EthPubSub::with_spawner(
provider.clone(),
pool.clone(),
events.clone(),
network.clone(),
Box::new(executor.clone()),
);
let eth_filter = EthFilter::new(
provider.clone(),
pool.clone(),
eth_cache.clone(),
config,
Box::new(executor.clone()),
eth_pubsub.clone(),
);
launch_with_eth_api::<Provider, Pool, Network, EngineApi, Events>(
eth_api,
eth_filter,
engine_api,
socket_addr,
secret,
)
.await
}

/// Configure and launch a _standalone_ auth server with existing EthApi implementation.
pub async fn launch_with_eth_api<Provider, Pool, Network, EngineApi>(
pub async fn launch_with_eth_api<Provider, Pool, Network, EngineApi, Events>(
eth_api: EthApi<Provider, Pool, Network>,
eth_filter: EthFilter<Provider, Pool>,
engine_api: EngineApi,
Expand All @@ -104,6 +126,7 @@ where
Pool: TransactionPool + Clone + 'static,
Network: NetworkInfo + Peers + Clone + 'static,
EngineApi: EngineApiServer,
Events: CanonStateSubscriptions + Clone + 'static,
{
// Configure the module and start the server.
let mut module = RpcModule::new(());
Expand Down
16 changes: 8 additions & 8 deletions crates/rpc/rpc-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,20 +1234,20 @@ where
blocking_task_pool.clone(),
fee_history_cache,
);
let filter = EthFilter::new(
let pubsub = EthPubSub::with_spawner(
self.provider.clone(),
self.pool.clone(),
cache.clone(),
self.config.eth.filter_config(),
self.events.clone(),
self.network.clone(),
executor.clone(),
);

let pubsub = EthPubSub::with_spawner(
let filter = EthFilter::new(
self.provider.clone(),
self.pool.clone(),
self.events.clone(),
self.network.clone(),
executor,
cache.clone(),
self.config.eth.filter_config(),
executor.clone(),
pubsub.clone(),
);

let eth = EthHandlers { api, cache, filter, pubsub, blocking_task_pool };
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 @@ -47,4 +47,4 @@ arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
rand.workspace = true
similar-asserts = "1.4"
similar-asserts = "1.4"
2 changes: 1 addition & 1 deletion crates/rpc/rpc-types/src/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub struct Filter {
pub block_option: FilterBlockOption,
/// Address
pub address: FilterSet<Address>,
/// Topics (maxmimum of 4)
/// Topics (maximum of 4)
pub topics: [Topic; 4],
}

Expand Down
Loading
Loading