Skip to content

feat(rpc): add configurable EVM memory limit #19107

@wojtek0x

Description

@wojtek0x

Describe the feature

Currently, the only constraint on how much memory the EVM can allocate indirectly comes from the gas cap.
If the gas cap is set very high, it’s possible for a program to request more memory than the host system can provide. This can lead to Reth crashing with an error such as:

memory allocation of 30957566848569344 bytes failed

To prevent such out-of-memory crashes, Reth could support an explicit EVM memory limit configuration.

Proposed Solution
Introduce a command-line flag to cap the maximum memory the EVM can allocate per RPC request:

--rpc.evm-memory-limit <MB>

Additional context

We run Reth with --rpc.gas-cap set to uint64::MAX to support complex EVM computations.
Occasionally Reth crashes due to buggy contracts that attempt invalid allocations (e.g., MSTORE with a huge offset). We haven't run into this problem with Geth, which appears to have additional memory limit check and returns MemoryOOG in such situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions