execution/chain, execution/vm/evmtypes: L2 fork oracle on Rules - #22195
Merged
Merged
Conversation
Adds L2JSON json.RawMessage + L2 L2Config to Config, mirroring the BorJSON/Bor contract: chainspec JSON round-trips the "l2" key into L2JSON via the existing plain json.Decode, and the registering L2 package unmarshals it into L2 at spec-registration time. L2Config is minimal for now (Name() string only); ResolveRules lands in a later PR.
Rules gains L2Version; L2Config.ResolveRules is consulted at the single per-block Rules choke point (BlockContext.Rules) so an L2 stack can flip EVM-fork booleans off its own version ladder instead of L1 time/number. MakeSignerFromRules mirrors MakeSigner's fork cascade for Rules-driven signer gating. BlockContext.L2Version population arrives with the engine-hook PR.
BlockContext.Rules folds Bhilai into IsPrague, so a Rules-driven signer checking IsPrague first would enable blob transactions on Bor chains at Bhilai, diverging from MakeSigner's blob=false gating.
6 of 42 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an L2 “fork oracle” hook to the per-block chain.Rules resolution so L2 chains can gate EVM fork booleans (e.g., Cancun/Prague) off an L2-specific version ladder without widening all IsShanghai/IsCancun/… predicate signatures. It also introduces MakeSignerFromRules to derive transaction signer capabilities from an already-resolved Rules instance.
Changes:
- Add
Rules.L2Version/BlockContext.L2Versionand callL2Config.ResolveRules(...)at the end ofBlockContext.Rules. - Extend
chain.L2ConfigwithResolveRules(...)for post-processing per-block rules. - Add
MakeSignerFromRulesplus tests for L2 rules overriding and signer capability equivalence (including Bhilai folding behavior).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| execution/vm/evmtypes/rules.go | Builds Rules into a local r, then lets c.L2.ResolveRules(...) finalize fork booleans/L2Version before returning. |
| execution/vm/evmtypes/rules_test.go | Adds coverage that the L2 oracle is invoked and can override Rules fields; verifies non-L2 behavior remains unchanged. |
| execution/vm/evmtypes/evmtypes.go | Adds BlockContext.L2Version for per-block L2 version ladder propagation. |
| execution/types/transaction_signing.go | Adds MakeSignerFromRules to gate signer capabilities off resolved Rules (including Bhilai-vs-Prague precedence). |
| execution/types/transaction_signing_test.go | Adds tests pinning MakeSignerFromRules vs MakeSigner, plus a Bhilai folding case. |
| execution/chain/chain_config.go | Extends L2Config interface with ResolveRules(...) and adds Rules.L2Version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rules already carries the chain id; a nil chainID argument produced a chainId=0 signer that rejected protected transactions. Also reword the doc comment to describe the Bhilai-before-Prague cascade instead of claiming strict MakeSigner equivalence.
MakeSigner and MakeSignerFromRules duplicated the same ~50-line switch and could drift apart silently. Both now feed makeSigner; MakeSigner resolves the Prague-over-Bhilai precedence before the call, so behavior is unchanged (pinned by the equivalence tests).
This was referenced Jul 3, 2026
SoarinSkySagar
pushed a commit
to SoarinSkySagar/erigon
that referenced
this pull request
Jul 3, 2026
…rigontech#22215) SonarCloud scans the ethereum/tests submodule as first-party production code: the directory restructure moved it from `tests/` to `execution/tests/legacy-tests`, which dropped it out of `sonar.test.inclusions`' stale `tests/**` pattern, and no exclusion covers the new path (the sonar workflow checks out with `submodules: true`). Whenever SonarCloud activates new rules — four landed today (`docker:S8545`, `docker:S8482`, `jssecurity:S8707`, `jssecurity:S8689`), all hitting legacy-tests fixtures — every PR analyzed before the main baseline absorbs the new issues fails its quality gate on third-party files (see erigontech#22194/erigontech#22195/erigontech#22196 this morning, `new_security_rating` 5). ## Changes - Exclude `execution/tests/legacy-tests/**` from analysis — third-party fixture content. - Fix the stale `tests/**` test-inclusion pattern to `execution/tests/**`.
AskAlexSharov
approved these changes
Jul 9, 2026
…5-merge-3f7bd2 # Conflicts: # execution/chain/chain_config.go # execution/chain/chain_config_test.go # execution/types/transaction_signing_test.go
AskAlexSharov
enabled auto-merge
July 9, 2026 02:18
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 9, 2026
AskAlexSharov
enabled auto-merge
July 10, 2026 01:52
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.
An L2 chain activates EVM forks on its own upgrade ladder (e.g. an ArbOS-style version carried in block metadata), not on L1 time/number. The nitro-erigon fork had to widen every
IsShanghai/IsCancun/... predicate signature with an extra version argument — dozens of call sites, re-fought on every rebase.BlockContext.Rulesis the single place per-block fork booleans are resolved, so the oracle belongs there and the predicate signatures stay untouched.Changes
Rules.L2VersionandBlockContext.L2Version(population arrives with the engine-hook PR).L2Config.ResolveRules(l2Version, blockNum, blockTime, *Rules)— consulted at the end ofBlockContext.Rules, after the standard resolution and the Bor folds, so an L2 can flip fork booleans off its own ladder.MakeSignerFromRulesmirrorsMakeSigner's fork cascade for Rules-driven signer gating. Bhilai is tested before Prague:Rulesconstruction folds Bhilai intoIsPrague, and the Bhilai tier does not enable blob transactions.Stacked on the L2 config slot PR. Part of #22193.