refactor(evm): use EvmEnv::with_limits() for evm limit configuration#253
Merged
mattsse merged 9 commits intoalloy-rs:mainfrom Jan 17, 2026
Merged
Conversation
mattsse
requested changes
Jan 17, 2026
| /// These parameters control configurable limits in the EVM that can be | ||
| /// overridden from their spec defaults (EIP-170, EIP-3860, EIP-7825). | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub struct EvmLimitParams { |
Member
There was a problem hiding this comment.
this will likely be a bit inconvenient to manage because we also need this dep in the chainspec
but turns out we already have that in there
crates/evm/src/env.rs
Outdated
| pub fn with_limits(mut self, limits: EvmLimitParams) -> Self { | ||
| self.cfg_env.limit_contract_code_size = Some(limits.max_code_size); | ||
| self.cfg_env.limit_contract_initcode_size = Some(limits.max_initcode_size); | ||
| self.cfg_env.tx_gas_limit_cap = Some(limits.tx_gas_limit_cap.unwrap_or(u64::MAX)); |
Member
There was a problem hiding this comment.
we should not unwrap here and instead leave this as is so that we respect the none value properly
Instead of translating None to u64::MAX, pass it directly to respect the spec's fork-aware default (e.g., EIP-7825 for Osaka).
mattsse
approved these changes
Jan 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Many chains need flexibility around
MAX_CODE_SIZE,MAX_INITCODE_SIZE, andtx_gas_limit_cap(see reth#21018). This need is validated by EIP-7907.Currently, configuring these limits requires verbose manual field assignments:
Solution
Add EvmLimitParams struct and a with_limits() builder method on EvmEnv:
This follows the existing builder pattern used by
CfgEnv(e.g., with_chain_id(), with_spec()).However, a alternative consideration to be made is whether this helper should be configured in
revmdirectly, similar to helpers like belowPR Checklist