feat: make logs per response configurable (#2559)

This commit is contained in:
Matthias Seitz
2023-05-04 21:27:31 +02:00
committed by GitHub
parent 6a79b16737
commit acbbd6788c
4 changed files with 33 additions and 12 deletions

View File

@ -1,6 +1,7 @@
use crate::{
constants,
error::{RpcError, ServerKind},
eth::DEFAULT_MAX_LOGS_IN_RESPONSE,
};
use hyper::header::AUTHORIZATION;
pub use jsonrpsee::server::ServerBuilder;
@ -49,7 +50,7 @@ where
// spawn a new cache task
let eth_cache = EthStateCache::spawn_with(client.clone(), Default::default(), executor);
let eth_api = EthApi::new(client.clone(), pool.clone(), network, eth_cache.clone());
let eth_filter = EthFilter::new(client, pool, eth_cache.clone());
let eth_filter = EthFilter::new(client, pool, eth_cache.clone(), DEFAULT_MAX_LOGS_IN_RESPONSE);
launch_with_eth_api(eth_api, eth_filter, engine_api, socket_addr, secret).await
}

View File

@ -4,6 +4,9 @@ use reth_rpc::{
};
use serde::{Deserialize, Serialize};
/// The default maximum of logs in a single response.
pub(crate) const DEFAULT_MAX_LOGS_IN_RESPONSE: usize = 2_000;
/// All handlers for the `eth` namespace
#[derive(Debug, Clone)]
pub struct EthHandlers<Client, Pool, Network, Events> {
@ -22,13 +25,18 @@ pub struct EthHandlers<Client, Pool, Network, Events> {
pub struct EthConfig {
/// Settings for the caching layer
pub cache: EthStateCacheConfig,
/// The maximum number of tracing calls that can be executed in concurrently.
pub max_tracing_requests: usize,
/// Maximum number of logs that can be returned in a single response in `eth_getLogs` calls.
pub max_logs_per_response: usize,
}
impl Default for EthConfig {
fn default() -> Self {
Self { cache: EthStateCacheConfig::default(), max_tracing_requests: 10 }
Self {
cache: EthStateCacheConfig::default(),
max_tracing_requests: 10,
max_logs_per_response: DEFAULT_MAX_LOGS_IN_RESPONSE,
}
}
}

View File

@ -798,7 +798,12 @@ where
self.network.clone(),
cache.clone(),
);
let filter = EthFilter::new(self.client.clone(), self.pool.clone(), cache.clone());
let filter = EthFilter::new(
self.client.clone(),
self.pool.clone(),
cache.clone(),
self.config.eth.max_logs_per_response,
);
let pubsub = EthPubSub::new(
self.client.clone(),