Skip to content
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: 11 additions & 0 deletions client/rpc/src/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct EthFilter<B: BlockT, C, BE, A: ChainApi> {
filter_pool: FilterPool,
max_stored_filters: usize,
max_past_logs: u32,
max_block_range: u32,
block_data_cache: Arc<EthBlockDataCacheTask<B>>,
_marker: PhantomData<BE>,
}
Expand All @@ -62,6 +63,7 @@ impl<B: BlockT, C, BE, A: ChainApi> EthFilter<B, C, BE, A> {
filter_pool: FilterPool,
max_stored_filters: usize,
max_past_logs: u32,
max_block_range: u32,
block_data_cache: Arc<EthBlockDataCacheTask<B>>,
) -> Self {
Self {
Expand All @@ -71,6 +73,7 @@ impl<B: BlockT, C, BE, A: ChainApi> EthFilter<B, C, BE, A> {
filter_pool,
max_stored_filters,
max_past_logs,
max_block_range,
block_data_cache,
_marker: PhantomData,
}
Expand Down Expand Up @@ -507,6 +510,14 @@ where
.map(|s| s.unique_saturated_into())
.unwrap_or(best_number);

let block_range = current_number.saturating_sub(from_number);
if block_range > self.max_block_range.into() {
return Err(internal_err(format!(
"block range is too wide (maximum {})",
self.max_block_range
)));
}

if backend.is_indexed() {
let _ = filter_range_logs_indexed(
client.as_ref(),
Expand Down
4 changes: 4 additions & 0 deletions template/node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub struct EthConfiguration {
#[arg(long, default_value = "10000")]
pub max_past_logs: u32,

/// Maximum block range to query logs from.
#[arg(long, default_value = "1024")]
pub max_block_range: u32,

/// Maximum fee history cache size.
#[arg(long, default_value = "2048")]
pub fee_history_limit: u64,
Expand Down
4 changes: 4 additions & 0 deletions template/node/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub struct EthDeps<B: BlockT, C, P, A: ChainApi, CT, CIDP> {
pub filter_pool: Option<FilterPool>,
/// Maximum number of logs in a query.
pub max_past_logs: u32,
/// Maximum block range for eth_getLogs.
pub max_block_range: u32,
/// Fee history cache.
pub fee_history_cache: FeeHistoryCache,
/// Maximum fee history cache size.
Expand Down Expand Up @@ -115,6 +117,7 @@ where
block_data_cache,
filter_pool,
max_past_logs,
max_block_range,
fee_history_cache,
fee_history_cache_limit,
execute_gas_limit_multiplier,
Expand Down Expand Up @@ -159,6 +162,7 @@ where
filter_pool,
500_usize, // max stored filters
max_past_logs,
max_block_range,
block_data_cache.clone(),
)
.into_rpc(),
Expand Down
2 changes: 2 additions & 0 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ where
let is_authority = role.is_authority();
let enable_dev_signer = eth_config.enable_dev_signer;
let max_past_logs = eth_config.max_past_logs;
let max_block_range = eth_config.max_block_range;
let execute_gas_limit_multiplier = eth_config.execute_gas_limit_multiplier;
let filter_pool = filter_pool.clone();
let frontier_backend = frontier_backend.clone();
Expand Down Expand Up @@ -457,6 +458,7 @@ where
block_data_cache: block_data_cache.clone(),
filter_pool: filter_pool.clone(),
max_past_logs,
max_block_range,
fee_history_cache: fee_history_cache.clone(),
fee_history_cache_limit,
execute_gas_limit_multiplier,
Expand Down