Skip to content

Conversation

@FletcherMan
Copy link
Collaborator

@FletcherMan FletcherMan commented Oct 30, 2025

1. Purpose or design rationale of this PR

Add emerald upgrade

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features
    • Added support for the Emerald blockchain fork era
    • Enabled configuration of Emerald activation timing for networks
    • Implemented Emerald-specific transaction signing and virtual machine opcode support

@FletcherMan FletcherMan requested a review from a team as a code owner October 30, 2025 02:42
@FletcherMan FletcherMan requested review from Web3Jumb0 and removed request for a team October 30, 2025 02:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Walkthrough

Added EmeraldTime fork timestamp support to ChainConfig and ChainOverrides structs. Introduced NewEmeraldSigner constructor and Emerald instruction set in the EVM. Added Emerald fork constants and updated fork validation, initialization logic, and chain rules throughout the codebase.

Changes

Cohort / File(s) Change Summary
Fork Configuration & Rules
params/config.go, params/forks/forks.go
Added EmeraldTime field to ChainConfig with JSON marshaling support. Introduced IsEmerald predicate method and updated fork validation logic to include Emerald in fork ordering checks. Extended Rules struct with IsEmerald field. Added Viridian and Emerald fork constants to the Fork enum with string mappings.
Chain Setup & Genesis
core/genesis.go, genesis_l2.json
Added EmeraldTime field to ChainOverrides struct with fork-order validation. Updated genesis_l2.json with morph203Time, viridianTime, and emeraldTime configuration entries.
Transaction Signing
core/types/transaction_signing.go
Introduced NewEmeraldSigner constructor function. Updated MakeSigner, LatestSigner, and LatestSignerForChainID to route Emerald fork conditions to the new Emerald signer.
EVM Fork Support
core/vm/jump_table.go, core/vm/interpreter.go
Added newEmeraldInstructionSet function that returns Emerald-era instruction set (currently cloned from Viridian set). Updated EVM interpreter jump table initialization to select emeraldInstructionSet when Emerald fork is active.
Tests & Runtime Configuration
core/state_processor_test.go, core/vm/runtime/runtime.go, eth/gasprice/gasprice_test.go
Updated ChainConfig initializations in test and runtime code to include EmeraldTime field. Added EmeraldTime reset to nil in gasprice test backend configuration.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ChainConfig as ChainConfig
    participant SignerSelection as Signer Selection
    participant EVMInterpreter as EVM Interpreter
    
    Client->>ChainConfig: Check IsEmerald(num, time)
    ChainConfig->>ChainConfig: Compare time vs EmeraldTime
    alt Emerald fork active
        ChainConfig-->>SignerSelection: IsEmerald = true
        ChainConfig-->>EVMInterpreter: IsEmerald = true
        SignerSelection->>SignerSelection: Create NewEmeraldSigner
        EVMInterpreter->>EVMInterpreter: Select emeraldInstructionSet
    else Emerald fork inactive
        ChainConfig-->>SignerSelection: IsEmerald = false
        ChainConfig-->>EVMInterpreter: IsEmerald = false
        SignerSelection->>SignerSelection: Create legacy signer
        EVMInterpreter->>EVMInterpreter: Select legacy instruction set
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • params/config.go: Substantial file with multiple method updates (IsEmerald predicate, fork validation, rules computation, string representation) requiring careful verification of fork-ordering logic and compatibility checks.
  • Fork signer selection logic: Review MakeSigner, LatestSigner, and LatestSignerForChainID to ensure Emerald fork conditions are correctly routed to NewEmeraldSigner.
  • Instruction set initialization: Verify that emeraldInstructionSet selection in EVM interpreter is properly gated by IsEmerald flag.
  • Fork validation order: Confirm that EmeraldTime is correctly positioned in fork-order validation sequences relative to other time-based forks.

Possibly related PRs

Suggested reviewers

  • SecurityLife
  • curryxbo

Poem

🐰 Emerald sparkles, bright and new,
Fork by fork, we see it through,
Signers dance, opcodes gleam,
Building consensus, a beautiful dream!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Add emerald upgrade" is directly related to the changeset's primary objective. The title clearly and specifically describes the main change: adding comprehensive support for the Emerald upgrade across the codebase, including new fork constants, chain configuration fields, signer implementations, instruction sets, and validation logic. The title is concise, avoids vague terminology, and provides sufficient clarity for a developer scanning commit history to understand the purpose of the change without requiring every implementation detail to be mentioned.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add_emerald_upgrade

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67087dd and da48b49.

📒 Files selected for processing (10)
  • core/genesis.go (2 hunks)
  • core/state_processor_test.go (1 hunks)
  • core/types/transaction_signing.go (5 hunks)
  • core/vm/interpreter.go (1 hunks)
  • core/vm/jump_table.go (2 hunks)
  • core/vm/runtime/runtime.go (1 hunks)
  • eth/gasprice/gasprice_test.go (1 hunks)
  • genesis_l2.json (1 hunks)
  • params/config.go (12 hunks)
  • params/forks/forks.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
core/types/transaction_signing.go (1)
params/forks/forks.go (1)
  • Emerald (43-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (24)
params/forks/forks.go (2)

42-44: LGTM!

The Emerald fork constant is correctly added to the enum following the established pattern.


75-77: LGTM!

The string representations for Viridian and Emerald forks are correctly added to the mapping.

core/types/transaction_signing.go (5)

45-46: LGTM!

The Emerald fork check is correctly integrated into the signer selection logic, following the established pattern.


76-77: LGTM!

EmeraldTime is correctly prioritized in the latest signer selection logic.


105-105: LGTM!

Using NewEmeraldSigner as the default "most permissive" signer is correct, as LatestSignerForChainID should return the signer that accepts all current transaction types.


231-233: LGTM!

The placeholder comment is good practice for documenting future extensibility points.


305-310: LGTM!

The NewEmeraldSigner constructor correctly follows the same pattern as NewViridianSigner and delegates to newModernSigner with the Emerald fork.

params/config.go (8)

586-586: LGTM!

The EmeraldTime field is correctly added to ChainConfig following the established pattern for timestamp-based forks.


388-388: LGTM!

EmeraldTime is correctly initialized in all test and protocol change configurations.

Also applies to: 426-426, 459-459, 493-493


679-705: LGTM!

The String() method is correctly updated to include Emerald fork information in the output.


870-870: LGTM!

EmeraldTime is correctly added to the fork order validation with the optional flag set appropriately.


977-979: LGTM!

The compatibility check for EmeraldTime follows the established pattern for timestamp-based fork compatibility verification.


1126-1127: LGTM!

The IsEmerald flag is correctly added to the Rules struct.


1153-1153: LGTM!

The IsEmerald rule is correctly computed using the IsEmerald method.


803-805: Remove unused parameter or add prerequisite fork check to IsEmerald.

The num parameter in IsEmerald is unused, whereas IsViridian (the preceding fork) explicitly requires c.IsCurie(num) before checking the timestamp. Either:

  1. Add a prerequisite check (e.g., c.IsCurie(num) or c.IsViridian(num, time)) to maintain consistency with Viridian's dependency model, or
  2. Remove the unused num parameter to match the simpler pattern of IsMorph203, which only checks timestamp.

Verify which approach aligns with the intended fork sequencing and update accordingly.

core/vm/interpreter.go (1)

124-125: LGTM!

The Emerald instruction set is correctly integrated into the jump table selection logic, following the established pattern of checking the most recent fork first.

genesis_l2.json (1)

16-22: LGTM!

The fork timing fields (morph203Time, viridianTime, emeraldTime) are correctly added to the genesis configuration with values of 0, indicating these forks are active from genesis.

core/genesis.go (2)

151-151: LGTM! Consistent field addition.

The EmeraldTime field follows the established pattern for time-based fork configuration alongside Morph203Time and ViridianTime.


165-167: LGTM! Proper override handling.

The EmeraldTime override is correctly applied before the fork order validation on line 168, consistent with the pattern used for other time-based forks.

core/vm/runtime/runtime.go (1)

78-78: LGTM! Consistent default configuration.

EmeraldTime is properly initialized in the default ChainConfig, following the same pattern as Morph203Time and ViridianTime.

core/state_processor_test.go (1)

63-63: LGTM! Test configuration updated correctly.

The test ChainConfig now includes EmeraldTime, maintaining consistency with the other time-based fork fields.

eth/gasprice/gasprice_test.go (1)

119-119: LGTM! Test backend configuration updated.

EmeraldTime is correctly cleared in the test backend configuration, consistent with how Morph203Time and ViridianTime are handled.

core/vm/jump_table.go (2)

60-60: LGTM! Instruction set variable added.

The emeraldInstructionSet global variable is initialized consistently with the existing fork instruction sets.


72-76: LGTM! Emerald instruction set infrastructure in place.

The newEmeraldInstructionSet() function correctly establishes Emerald as an extension of Viridian. Currently, it's functionally identical to Viridian, serving as a placeholder for future Emerald-specific opcode changes as noted in the comment.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FletcherMan FletcherMan merged commit a5e0b44 into main Oct 30, 2025
7 of 8 checks passed
@FletcherMan FletcherMan deleted the add_emerald_upgrade branch October 30, 2025 02:50
@coderabbitai coderabbitai bot mentioned this pull request Nov 18, 2025
13 tasks
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