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

add cli option --eth-log-block-cache #902

Merged
merged 1 commit into from
Oct 14, 2021
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
1 change: 1 addition & 0 deletions node/cli-opt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ pub struct RpcConfig {
pub ethapi_max_permits: u32,
pub ethapi_trace_max_count: u32,
pub ethapi_trace_cache_duration: u64,
pub eth_log_block_cache: usize,
pub max_past_logs: u32,
}
4 changes: 4 additions & 0 deletions node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ pub struct RunCmd {
#[structopt(long, default_value = "300")]
pub ethapi_trace_cache_duration: u64,

/// Size of the LRU cache for block data and their transaction statuses.
#[structopt(long, default_value = "3000")]
girazoki marked this conversation as resolved.
Show resolved Hide resolved
pub eth_log_block_cache: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one usize and the others are u32 or u64? I don't see any problems, just curious about this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the LruCache is waiting for a usize


/// Maximum number of logs in a query.
#[structopt(long, default_value = "10000")]
pub max_past_logs: u32,
Expand Down
1 change: 1 addition & 0 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ pub fn run() -> Result<()> {
ethapi_max_permits: cli.run.ethapi_max_permits,
ethapi_trace_max_count: cli.run.ethapi_trace_max_count,
ethapi_trace_cache_duration: cli.run.ethapi_trace_cache_duration,
eth_log_block_cache: cli.run.eth_log_block_cache,
max_past_logs: cli.run.max_past_logs,
};

Expand Down
30 changes: 16 additions & 14 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,19 @@ where
};

let deps = rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
pool: pool.clone(),
graph: pool.pool().clone(),
command_sink: None,
deny_unsafe,
is_authority: collator,
network: network.clone(),
filter_pool: filter_pool.clone(),
ethapi_cmd: ethapi_cmd.clone(),
command_sink: None,
eth_log_block_cache: rpc_config.eth_log_block_cache,
filter_pool: filter_pool.clone(),
frontier_backend: frontier_backend.clone(),
backend: backend.clone(),
graph: pool.pool().clone(),
pool: pool.clone(),
is_authority: collator,
max_past_logs,
network: network.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like your editor rearranged these in alphabetical order, which might cause some merge headaches. this seems fine to me as long as we're intentional and consistent about it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not my editor, it's intentional.

transaction_converter,
};
#[allow(unused_mut)]
Expand Down Expand Up @@ -868,18 +869,19 @@ where
};

let deps = rpc::FullDeps {
backend: backend.clone(),
client: client.clone(),
pool: pool.clone(),
graph: pool.pool().clone(),
command_sink: command_sink.clone(),
deny_unsafe,
is_authority: collator,
network: network.clone(),
filter_pool: filter_pool.clone(),
ethapi_cmd: ethapi_cmd.clone(),
command_sink: command_sink.clone(),
eth_log_block_cache: rpc_config.eth_log_block_cache,
filter_pool: filter_pool.clone(),
frontier_backend: frontier_backend.clone(),
backend: backend.clone(),
graph: pool.pool().clone(),
pool: pool.clone(),
is_authority: collator,
max_past_logs,
network: network.clone(),
transaction_converter,
};
#[allow(unused_mut)]
Expand Down
8 changes: 7 additions & 1 deletion node/service/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ pub struct FullDeps<C, P, A: ChainApi, BE> {
pub filter_pool: Option<FilterPool>,
/// The list of optional RPC extensions.
pub ethapi_cmd: Vec<EthApiCmd>,
/// Size of the LRU cache for block data and their transaction statuses.
pub eth_log_block_cache: usize,
/// Frontier Backend.
pub frontier_backend: Arc<fc_db::Backend<Block>>,
/// Backend.
Expand Down Expand Up @@ -115,6 +117,7 @@ where
network,
filter_pool,
ethapi_cmd,
eth_log_block_cache,
command_sink,
frontier_backend,
backend: _,
Expand All @@ -133,7 +136,10 @@ where
// TODO: are we supporting signing?
let signers = Vec::new();

let block_data_cache = Arc::new(EthBlockDataCache::new(3000, 3000));
let block_data_cache = Arc::new(EthBlockDataCache::new(
eth_log_block_cache,
eth_log_block_cache,
));

let mut overrides_map = BTreeMap::new();
overrides_map.insert(
Expand Down