astar_collator/
evm_tracing_types.rs1use crate::rpc::FrontierBackendType;
20use clap::Parser;
21
22#[derive(Clone)]
24pub enum FrontierBackendConfig {
25 KeyValue,
26 Sql {
27 pool_size: u32,
28 num_ops_timeout: u32,
29 thread_count: u32,
30 cache_size: u64,
31 },
32}
33
34impl Default for FrontierBackendConfig {
35 fn default() -> FrontierBackendConfig {
36 FrontierBackendConfig::KeyValue
37 }
38}
39
40#[derive(Debug, PartialEq, Clone)]
42pub enum EthApi {
43 Debug,
45 Trace,
47 TxPool,
49}
50
51impl std::str::FromStr for EthApi {
52 type Err = String;
53
54 fn from_str(s: &str) -> Result<Self, Self::Err> {
55 Ok(match s {
56 "debug" => Self::Debug,
57 "trace" => Self::Trace,
58 "txpool" => Self::TxPool,
59 _ => {
60 return Err(format!(
61 "`{}` is not recognized as a supported Ethereum Api",
62 s
63 ))
64 }
65 })
66 }
67}
68
69#[allow(dead_code)]
70#[derive(Clone)]
71pub struct FrontierConfig {
74 pub ethapi: Vec<EthApi>,
76 pub ethapi_max_permits: u32,
78 pub ethapi_trace_max_count: u32,
82 pub ethapi_trace_cache_duration: u64,
85 pub eth_log_block_cache: usize,
87 pub eth_statuses_cache: usize,
89 pub max_past_logs: u32,
91 pub tracing_raw_max_memory_usage: usize,
94 pub frontier_backend_config: FrontierBackendConfig,
96}
97
98#[derive(Debug, Parser)]
99pub struct EthApiOptions {
100 #[cfg_attr(
102 not(feature = "manual-seal"),
103 clap(
104 long,
105 conflicts_with = "collator",
106 conflicts_with = "validator",
107 value_delimiter = ','
108 )
109 )]
110 #[cfg_attr(feature = "manual-seal", clap(long))]
111 pub ethapi: Vec<EthApi>,
112
113 #[clap(long, default_value = "10")]
115 pub ethapi_max_permits: u32,
116
117 #[clap(long, default_value = "500")]
122 pub ethapi_trace_max_count: u32,
123
124 #[clap(long, default_value = "300")]
127 pub ethapi_trace_cache_duration: u64,
128
129 #[clap(long, default_value = "300000000")]
131 pub eth_log_block_cache: usize,
132
133 #[clap(long, default_value = "300000000")]
135 pub eth_statuses_cache: usize,
136
137 #[clap(long, default_value = "20000000")]
140 pub tracing_raw_max_memory_usage: usize,
141
142 #[clap(long, default_value = "10000")]
144 pub max_past_logs: u32,
145
146 #[clap(long, value_enum, ignore_case = true, default_value_t = FrontierBackendType::default())]
148 pub frontier_backend_type: FrontierBackendType,
149
150 #[clap(
152 long,
153 default_value = "100",
154 help = "Only used when --frontier-backend-type=sql"
155 )]
156 pub frontier_sql_backend_pool_size: u32,
157
158 #[clap(
160 long,
161 default_value = "10000000",
162 help = "Only used when --frontier-backend-type=sql"
163 )]
164 pub frontier_sql_backend_num_ops_timeout: u32,
165
166 #[clap(
168 long,
169 default_value = "4",
170 help = "Only used when --frontier-backend-type=sql"
171 )]
172 pub frontier_sql_backend_thread_count: u32,
173
174 #[clap(
177 long,
178 default_value = "209715200",
179 help = "Only used when --frontier-backend-type=sql"
180 )]
181 pub frontier_sql_backend_cache_size: u64,
182}
183
184impl EthApiOptions {
185 pub fn new_rpc_config(&self) -> FrontierConfig {
186 FrontierConfig {
187 ethapi: self.ethapi.clone(),
188 ethapi_max_permits: self.ethapi_max_permits,
189 ethapi_trace_max_count: self.ethapi_trace_max_count,
190 ethapi_trace_cache_duration: self.ethapi_trace_cache_duration,
191 eth_log_block_cache: self.eth_log_block_cache,
192 eth_statuses_cache: self.eth_statuses_cache,
193 max_past_logs: self.max_past_logs,
194 tracing_raw_max_memory_usage: self.tracing_raw_max_memory_usage,
195 frontier_backend_config: match self.frontier_backend_type {
196 FrontierBackendType::KeyValue => FrontierBackendConfig::KeyValue,
197 FrontierBackendType::Sql => FrontierBackendConfig::Sql {
198 pool_size: self.frontier_sql_backend_pool_size,
199 num_ops_timeout: self.frontier_sql_backend_num_ops_timeout,
200 thread_count: self.frontier_sql_backend_thread_count,
201 cache_size: self.frontier_sql_backend_cache_size,
202 },
203 },
204 }
205 }
206}