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_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    /// Whether to compute state roots for `eth_simulateV1`.
33    pub compute_state_root_for_eth_simulate: bool,
34    /// Maximum number of blocks into the past for generating state proofs.
35    pub eth_proof_window: u64,
36    /// Configuration for pending block construction.
37    pub pending_block_kind: PendingBlockKind,
38    /// Timeout duration for `send_raw_transaction_sync` RPC method.
39    pub send_raw_transaction_sync_timeout: Duration,
40    /// Maximum memory the EVM can allocate per RPC request.
41    pub evm_memory_limit: u64,
42    /// Whether to force upcasting EIP-4844 blob sidecars to EIP-7594 format when Osaka is active.
43    pub force_blob_sidecar_upcasting: bool,
44}
45
46impl Default for EthApiSettings {
47    fn default() -> Self {
48        Self {
49            sender_recovery_cache: None,
50            proof_permits: DEFAULT_PROOF_PERMITS,
51            max_batch_size: 1,
52            max_blocking_io_requests: DEFAULT_MAX_BLOCKING_IO_REQUEST,
53            cache_computed_bals: false,
54            gas_cap: RPC_DEFAULT_GAS_CAP.into(),
55            max_simulate_blocks: DEFAULT_MAX_SIMULATE_BLOCKS,
56            compute_state_root_for_eth_simulate: false,
57            eth_proof_window: DEFAULT_ETH_PROOF_WINDOW,
58            pending_block_kind: PendingBlockKind::default(),
59            send_raw_transaction_sync_timeout: RPC_DEFAULT_SEND_RAW_TX_SYNC_TIMEOUT_SECS,
60            evm_memory_limit: (1 << 32) - 1,
61            force_blob_sidecar_upcasting: false,
62        }
63    }
64}