reth_rpc_eth_types/settings.rs
1//! Settings for initializing and serving the `eth` RPC API.
2
3use crate::{builder::config::PendingBlockKind, RPC_DEFAULT_GAS_CAP};
4use reth_evm::SenderRecoveryCache;
5use reth_rpc_server_types::constants::{
6 DEFAULT_ETH_PROOF_WINDOW, DEFAULT_MAX_BLOCKING_IO_REQUEST, DEFAULT_MAX_SIMULATE_BLOCKS,
7 DEFAULT_PROOF_PERMITS, RPC_DEFAULT_SEND_RAW_TX_SYNC_TIMEOUT_SECS,
8};
9use std::time::Duration;
10
11/// Settings used when initializing the API and serving `eth` RPC requests.
12///
13/// These settings are shared by the API's helper traits so additional settings can be exposed
14/// without adding individual trait methods. Concurrency and batching limits take effect when the
15/// API is constructed.
16#[derive(Debug, Clone)]
17pub struct EthApiSettings {
18 /// Cache of recovered transaction senders shared with transaction ingress and execution.
19 pub sender_recovery_cache: Option<SenderRecoveryCache>,
20 /// Maximum number of concurrent proof requests.
21 pub proof_permits: usize,
22 /// Maximum batch size for transaction insertions.
23 pub max_batch_size: usize,
24 /// Maximum number of concurrent blocking IO requests.
25 pub max_blocking_io_requests: usize,
26 /// Cache computed block access lists for transaction tracing.
27 pub cache_computed_bals: bool,
28 /// Maximum gas limit for `eth_call`, `eth_estimateGas`, and call tracing RPC methods.
29 pub gas_cap: u64,
30 /// Maximum number of blocks for `eth_simulateV1`.
31 pub max_simulate_blocks: u64,
32 /// Maximum bytes a single traced transaction may record. `None` is unlimited.
33 pub max_trace_bytes: Option<usize>,
34 /// The RPC server's response size limit in bytes, which bounds the struct logs of a debug
35 /// trace response. `None` is unlimited.
36 pub max_response_size: Option<usize>,
37 /// Whether to compute state roots for `eth_simulateV1`.
38 pub compute_state_root_for_eth_simulate: bool,
39 /// Maximum number of blocks into the past for generating state proofs.
40 pub eth_proof_window: u64,
41 /// Configuration for pending block construction.
42 pub pending_block_kind: PendingBlockKind,
43 /// Timeout duration for `send_raw_transaction_sync` RPC method.
44 pub send_raw_transaction_sync_timeout: Duration,
45 /// Maximum memory the EVM can allocate per call frame in an RPC request.
46 pub evm_memory_limit: u64,
47 /// Whether to force upcasting EIP-4844 blob sidecars to EIP-7594 format when Osaka is active.
48 pub force_blob_sidecar_upcasting: bool,
49}
50
51impl Default for EthApiSettings {
52 fn default() -> Self {
53 Self {
54 sender_recovery_cache: None,
55 proof_permits: DEFAULT_PROOF_PERMITS,
56 max_batch_size: 1,
57 max_blocking_io_requests: DEFAULT_MAX_BLOCKING_IO_REQUEST,
58 cache_computed_bals: false,
59 gas_cap: RPC_DEFAULT_GAS_CAP.into(),
60 max_simulate_blocks: DEFAULT_MAX_SIMULATE_BLOCKS,
61 max_trace_bytes: None,
62 max_response_size: None,
63 compute_state_root_for_eth_simulate: false,
64 eth_proof_window: DEFAULT_ETH_PROOF_WINDOW,
65 pending_block_kind: PendingBlockKind::default(),
66 send_raw_transaction_sync_timeout: RPC_DEFAULT_SEND_RAW_TX_SYNC_TIMEOUT_SECS,
67 evm_memory_limit: 100 * 1024 * 1024,
68 force_blob_sidecar_upcasting: false,
69 }
70 }
71}