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
52 changes: 26 additions & 26 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions node/cli-opt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub struct RpcConfig {
pub eth_statuses_cache: usize,
pub fee_history_limit: u64,
pub max_past_logs: u32,
pub max_block_range: u32,
pub relay_chain_rpc_urls: Vec<url::Url>,
pub tracing_raw_max_memory_usage: usize,
pub frontier_backend_config: FrontierBackendConfig,
Expand Down
5 changes: 5 additions & 0 deletions node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ pub struct RunCmd {
#[clap(long, default_value = "10000")]
pub max_past_logs: u32,

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

/// Force using Moonbase native runtime.
#[clap(long = "force-moonbase")]
pub force_moonbase: bool,
Expand Down Expand Up @@ -351,6 +355,7 @@ impl RunCmd {
eth_statuses_cache: self.eth_statuses_cache,
fee_history_limit: self.fee_history_limit,
max_past_logs: self.max_past_logs,
max_block_range: self.max_block_range,
relay_chain_rpc_urls: self.base.relay_chain_rpc_urls.clone(),
tracing_raw_max_memory_usage: self.tracing_raw_max_memory_usage,
frontier_backend_config: match self.frontier_backend_type {
Expand Down
2 changes: 2 additions & 0 deletions node/service/src/lazy_loading/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ where
let sync = sync_service.clone();
let ethapi_cmd = ethapi_cmd.clone();
let max_past_logs = rpc_config.max_past_logs;
let max_block_range = rpc_config.max_block_range;
let overrides = overrides.clone();
let fee_history_cache = fee_history_cache.clone();
let block_data_cache = block_data_cache.clone();
Expand All @@ -783,6 +784,7 @@ where
pool: pool.clone(),
is_authority: collator,
max_past_logs,
max_block_range,
fee_history_limit,
fee_history_cache: fee_history_cache.clone(),
network: network.clone(),
Expand Down
4 changes: 4 additions & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ where
let backend = backend.clone();
let ethapi_cmd = ethapi_cmd.clone();
let max_past_logs = rpc_config.max_past_logs;
let max_block_range = rpc_config.max_block_range;
let overrides = overrides.clone();
let fee_history_cache = fee_history_cache.clone();
let block_data_cache = block_data_cache.clone();
Expand Down Expand Up @@ -831,6 +832,7 @@ where
pool: pool.clone(),
is_authority: collator,
max_past_logs,
max_block_range,
fee_history_limit,
fee_history_cache: fee_history_cache.clone(),
network: network.clone(),
Expand Down Expand Up @@ -1538,6 +1540,7 @@ where
let sync = sync_service.clone();
let ethapi_cmd = ethapi_cmd.clone();
let max_past_logs = rpc_config.max_past_logs;
let max_block_range = rpc_config.max_block_range;
let overrides = overrides.clone();
let fee_history_cache = fee_history_cache.clone();
let block_data_cache = block_data_cache.clone();
Expand All @@ -1559,6 +1562,7 @@ where
pool: pool.clone(),
is_authority: collator,
max_past_logs,
max_block_range,
fee_history_limit,
fee_history_cache: fee_history_cache.clone(),
network: network.clone(),
Expand Down
4 changes: 4 additions & 0 deletions node/service/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ pub struct FullDeps<C, P, A: ChainApi, BE> {
pub command_sink: Option<futures::channel::mpsc::Sender<EngineCommand<Hash>>>,
/// Maximum number of logs in a query.
pub max_past_logs: u32,
/// Maximum block range in a query.
pub max_block_range: u32,
/// Maximum fee history cache size.
pub fee_history_limit: u64,
/// Fee history cache.
Expand Down Expand Up @@ -195,6 +197,7 @@ where
frontier_backend,
backend: _,
max_past_logs,
max_block_range,
fee_history_limit,
fee_history_cache,
dev_rpc_data,
Expand Down Expand Up @@ -275,6 +278,7 @@ where
filter_pool,
500_usize, // max stored filters
max_past_logs,
max_block_range,
block_data_cache,
)
.into_rpc(),
Expand Down
34 changes: 34 additions & 0 deletions test/suites/tracing-tests/test-get-logs-limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { beforeAll, customDevRpcRequest, describeSuite, expect } from "@moonwall/cli";

describeSuite({
id: "T20",
title: "Test eth_getLogs RPC",
foundationMethods: "dev",
testCases: ({ context, it }) => {
beforeAll(async () => {
// This variable needs to be modified if `--max-blocks-range` CLI parameter is changed
// Using the default of 1024
let blocksToCreate = 1025;
for (; blocksToCreate > 0; blocksToCreate--) {
await context.createBlock();
}
});

it({
id: "T01",
title: "Validate eth_getLogs block range limit",
test: async function () {
expect(
async () =>
await customDevRpcRequest("eth_getLogs", [
{
fromBlock: "0x0",
toBlock: "latest",
topics: [],
},
])
).rejects.toThrowError("block range is too wide (maximum 1024)");
},
});
},
});
Loading