Skip to main content

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_rpc_server_types::constants::{
5    DEFAULT_ETH_PROOF_WINDOW, DEFAULT_MAX_BLOCKING_IO_REQUEST, DEFAULT_MAX_SIMULATE_BLOCKS,
6    DEFAULT_PROOF_PERMITS, RPC_DEFAULT_SEND_RAW_TX_SYNC_TIMEOUT_SECS,
7};
8use std::time::Duration;
9
10/// Settings used when initializing the API and serving `eth` RPC requests.
11///
12/// These settings are shared by the API's helper traits so additional settings can be exposed
13/// without adding individual trait methods. Concurrency and batching limits take effect when the
14/// API is constructed.
15#[derive(Debug, Clone, Eq, PartialEq)]
16pub struct EthApiSettings {
17    /// Maximum number of concurrent proof requests.
18    pub proof_permits: usize,
19    /// Maximum batch size for transaction insertions.
20    pub max_batch_size: usize,
21    /// Maximum number of concurrent blocking IO requests.
22    pub max_blocking_io_requests: usize,
23    /// Cache computed block access lists for transaction tracing.
24    pub cache_computed_bals: bool,
25    /// Maximum gas limit for `eth_call` and call tracing RPC methods.
26    pub gas_cap: u64,
27    /// Maximum number of blocks for `eth_simulateV1`.
28    pub max_simulate_blocks: u64,
29    /// Whether to compute state roots for `eth_simulateV1`.
30    pub compute_state_root_for_eth_simulate: bool,
31    /// Maximum number of blocks into the past for generating state proofs.
32    pub eth_proof_window: u64,
33    /// Configuration for pending block construction.
34    pub pending_block_kind: PendingBlockKind,
35    /// Timeout duration for `send_raw_transaction_sync` RPC method.
36    pub send_raw_transaction_sync_timeout: Duration,
37    /// Maximum memory the EVM can allocate per RPC request.
38    pub evm_memory_limit: u64,
39    /// Whether to force upcasting EIP-4844 blob sidecars to EIP-7594 format when Osaka is active.
40    pub force_blob_sidecar_upcasting: bool,
41}
42
43impl Default for EthApiSettings {
44    fn default() -> Self {
45        Self {
46            proof_permits: DEFAULT_PROOF_PERMITS,
47            max_batch_size: 1,
48            max_blocking_io_requests: DEFAULT_MAX_BLOCKING_IO_REQUEST,
49            cache_computed_bals: false,
50            gas_cap: RPC_DEFAULT_GAS_CAP.into(),
51            max_simulate_blocks: DEFAULT_MAX_SIMULATE_BLOCKS,
52            compute_state_root_for_eth_simulate: false,
53            eth_proof_window: DEFAULT_ETH_PROOF_WINDOW,
54            pending_block_kind: PendingBlockKind::default(),
55            send_raw_transaction_sync_timeout: RPC_DEFAULT_SEND_RAW_TX_SYNC_TIMEOUT_SECS,
56            evm_memory_limit: (1 << 32) - 1,
57            force_blob_sidecar_upcasting: false,
58        }
59    }
60}