Skip to content

feat: move GasParams to Cfg#3229

Merged
rakita merged 24 commits intomainfrom
rakita/cfg-gas-params
Jan 8, 2026
Merged

feat: move GasParams to Cfg#3229
rakita merged 24 commits intomainfrom
rakita/cfg-gas-params

Conversation

@rakita
Copy link
Member

@rakita rakita commented Dec 16, 2025

Moves GasParams to the Cfg so that it can be accessed with Context easily from instructions. GasParams is removed from Frame/Interpreter.

Gas calculation stuff is moved from Interpreter to cfg.

CfgEnv functions now require setting gas_params and CfgEnv::with_spec got deprecated and it is pointing to with_spec_and_mainnet_gas_params as alternative.

Performance boost is because the first time initialisation of Precompiles was inside codspeed scope, with this PR this is moved outside, and simple check if spec is same is done there. Precompiles is still initialised only once, but now outside of codspeed.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 16, 2025

Merging this PR will improve performance by 4.91%

Summary

⚡ 2 improved benchmarks
✅ 171 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
DELEGATECALL_50 93 µs 90.1 µs +3.25%
STATICCALL_50 99.1 µs 94.4 µs +4.91%

Comparing rakita/cfg-gas-params (536cfb1) with main (6857592)

Open in CodSpeed

@rakita rakita force-pushed the rakita/cfg-gas-params branch from 196e6da to 92c6a93 Compare December 17, 2025 12:15
@rakita rakita force-pushed the rakita/cfg-gas-params branch from 883898f to a552ff9 Compare December 17, 2025 13:23
@rakita rakita marked this pull request as ready for review December 18, 2025 06:27
Comment on lines +69 to +71
/// Returns `EthInstructions` with mainnet spec.
pub fn new_mainnet_with_spec(spec: SpecId) -> Self {
Self::new(instruction_table_gas_changes_spec(spec), spec)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this take GasParams as input? so that all instructions have direct access to it without expecting Host to provide it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not work like that, instructions have access to context and interpreter

@rakita rakita force-pushed the rakita/cfg-gas-params branch from d733681 to eb14b9c Compare December 22, 2025 16:50
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this makes sense

but would like @klkvr to revisit this once more before release

@rakita rakita force-pushed the rakita/cfg-gas-params branch from 17a072d to 536cfb1 Compare January 8, 2026 10:17
@rakita rakita merged commit 7f3083b into main Jan 8, 2026
31 checks passed
@rakita rakita deleted the rakita/cfg-gas-params branch January 8, 2026 10:38
@github-actions github-actions bot mentioned this pull request Jan 8, 2026
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 21, 2026
* feat: move GasParams to Cfg

* propagate spec id

* use cfg spec when evm is created

* nits

* nit

* doc tests

* use derive-where to skip fn

* Move SetSpecTr and use it as main tr

* remove SetSpecTr, introduce is_custom_gas_param flag

* simplification

* nits and tests fix

* morf spec type

* dont compare ptr

* import fix

* typo

* ref alloy-eips

* add core::error::Error impl to BalError

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* send/sync on GasParams

* relex generic for some Cfg functions

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants