Skip to content

execution/chain, execution/vm/evmtypes: L2 fork oracle on Rules - #22195

Merged
AskAlexSharov merged 9 commits into
mainfrom
awskii/l2-fork-oracle
Jul 10, 2026
Merged

AskAlexSharov merged 9 commits into
mainfrom
awskii/l2-fork-oracle

Conversation

@awskii

@awskii awskii commented Jul 3, 2026

Copy link
Copy Markdown
Member

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.Rules is the single place per-block fork booleans are resolved, so the oracle belongs there and the predicate signatures stay untouched.

Changes

  • Rules.L2Version and BlockContext.L2Version (population arrives with the engine-hook PR).
  • L2Config.ResolveRules(l2Version, blockNum, blockTime, *Rules) — consulted at the end of BlockContext.Rules, after the standard resolution and the Bor folds, so an L2 can flip fork booleans off its own ladder.
  • MakeSignerFromRules mirrors MakeSigner's fork cascade for Rules-driven signer gating. Bhilai is tested before Prague: Rules construction folds Bhilai into IsPrague, and the Bhilai tier does not enable blob transactions.

Stacked on the L2 config slot PR. Part of #22193.

awskii added 3 commits July 3, 2026 15:21
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.L2Version and call L2Config.ResolveRules(...) at the end of BlockContext.Rules.
  • Extend chain.L2Config with ResolveRules(...) for post-processing per-block rules.
  • Add MakeSignerFromRules plus 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.

Comment thread execution/types/transaction_signing.go Outdated
Comment thread execution/types/transaction_signing.go Outdated
awskii added 2 commits July 3, 2026 16:22
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).
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
AskAlexSharov requested a review from Copilot July 3, 2026 23:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread execution/vm/evmtypes/rules.go
Base automatically changed from awskii/l2-config-slot to main July 7, 2026 04:36
…5-merge-3f7bd2

# Conflicts:
#	execution/chain/chain_config.go
#	execution/chain/chain_config_test.go
#	execution/types/transaction_signing_test.go
@AskAlexSharov
AskAlexSharov enabled auto-merge July 9, 2026 02:18
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Jul 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 9, 2026
@AskAlexSharov
AskAlexSharov enabled auto-merge July 10, 2026 01:52
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit 5dee5f9 Jul 10, 2026
92 checks passed
@AskAlexSharov
AskAlexSharov deleted the awskii/l2-fork-oracle branch July 10, 2026 12:39
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