fix(evm): map Constantinople chains to Petersburg spec#26362
Draft
0xalpharush wants to merge 2 commits into
Draft
fix(evm): map Constantinople chains to Petersburg spec#263620xalpharush wants to merge 2 commits into
0xalpharush wants to merge 2 commits into
Conversation
Contributor
Author
|
But this results in gas differences... |
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.
Summary
Map Constantinople-active chains to
SpecId::PETERSBURGinspec_id_by_timestamp_and_block_number.evm2 does not expose a standalone Constantinople execution spec. Its own CLI and EEST paths already treat Constantinople / ConstantinopleFix as Petersburg, so Reth's evm2 fork mapping should do the same instead of falling through to Byzantium.
Why
This was found by differential fuzzing against fork-boundary state tests. The fuzzer can generate a chain where Constantinople is active but Petersburg is not yet active. Byzantium is still active in that case because it is an earlier fork.
On PR #25002, that case falls through to
SpecId::BYZANTIUM:reth/crates/ethereum/evm/src/convert.rs
Lines 44 to 49 in 7ddb494
The executor then passes that
spec_idinto post-block reward calculation:reth/crates/ethereum/evm/src/executor.rs
Lines 72 to 79 in 7ddb494
reth/crates/ethereum/evm/src/executor.rs
Lines 228 to 234 in 7ddb494
base_block_reward(SpecId::BYZANTIUM)then takes the Byzantium reward branch and credits3 ETH:reth/crates/ethereum/evm/src/execution.rs
Lines 1037 to 1044 in 7ddb494
The reth-main/revm path delegates block reward calculation through alloy-evm:
reth/crates/ethereum/evm/src/config.rs
Lines 1 to 4 in dbe7238
alloy-evm treats Constantinople as the
2 ETHreward era:https://github.com/alloy-rs/evm/blob/6e56ca0ae11090d9575008583b4c4a3a469d7428/crates/evm/src/block/calc.rs#L37-L44
Observed fuzzing effect: receipts and sender state match, but the beneficiary balance differs by exactly
1 ETH, causing a state-root divergence. Main credits2 ETH + fees; evm2 credits3 ETH + fees.Alternative Considered
An alternative fix was to keep the EVM spec mapped to Byzantium and use the alloy-evm block reward helper at the reward site.
That would fix the observed reward mismatch, but it would leave the broader fork mapping inconsistent with evm2's own Constantinople / ConstantinopleFix behavior and would add reward-specific plumbing. Mapping Constantinople to Petersburg fixes the mismatch at the spec-selection boundary instead.