Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

feat(bin/node): L2 Chain ID Abstraction#2394

Merged
refcell merged 8 commits intoop-rs:mainfrom
varun-doshi:varun/l2-chain
Jul 21, 2025
Merged

feat(bin/node): L2 Chain ID Abstraction#2394
refcell merged 8 commits intoop-rs:mainfrom
varun-doshi:varun/l2-chain

Conversation

@varun-doshi
Copy link
Contributor

Fixes #2316

Copilot AI review requested due to automatic review settings July 11, 2025 12:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Abstracts the L2 chain ID to a Chain enum instead of raw u64 for improved type safety.

  • Changed l2_chain_id in RollupConfig from u64 to Chain, updating defaults and conversions.
  • Replaced hardcoded chain IDs with Chain::{optimism_sepolia, optimism_mainnet, base_sepolia, base_mainnet} in test utilities and module initializers.
  • Propagated Chain usage through batch decoding, gossip, protocol builders, and executor environment; added the alloy-chains dependency where needed.

Reviewed Changes

Copilot reviewed 17 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/protocol/registry/src/test_utils/op_sepolia.rs Use Chain::optimism_sepolia() for L2 chain ID
crates/protocol/registry/src/test_utils/op_mainnet.rs Use Chain::optimism_mainnet() for L2 chain ID
crates/protocol/registry/src/test_utils/base_sepolia.rs Use Chain::base_sepolia() for L2 chain ID
crates/protocol/registry/src/test_utils/base_mainnet.rs Use Chain::base_mainnet() for L2 chain ID
crates/protocol/protocol/src/batch/core.rs Converted .derive() call to accept Chain via .into()
crates/protocol/genesis/src/rollup.rs Changed l2_chain_id type to Chain and updated defaults
crates/protocol/genesis/src/chain/config.rs Converted builder to .into() on chain_id
crates/protocol/genesis/Cargo.toml Added alloy-chains dependency
crates/proof/executor/src/builder/env.rs Updated .with_chain_id() to use .into()
crates/node/service/src/actors/network/builder.rs Updated discovery builder to use .id() on Chain
crates/node/service/Cargo.toml Added alloy-chains workspace dependency
crates/node/p2p/tests/common/mod.rs Use Chain::optimism_mainnet() in test setup
crates/node/p2p/src/gossip/handler.rs Switched test handlers to use Chain enum
crates/node/p2p/src/gossip/driver.rs Updated ENR validation to use .into() on Chain
crates/node/p2p/src/gossip/block_validity.rs Updated signature and tests to use .into() on Chain
crates/node/p2p/src/gossip/behaviour.rs Switched test behavior to use Chain enum
crates/node/p2p/Cargo.toml Added alloy-chains workspace dependency

let validation =
EnrValidation::validate(&enr, self.handler.rollup_config.l2_chain_id.into());
if validation.is_invalid() {
trace!(target: "gossip", "Invalid OP Stack ENR for chain id {}: {}", self.handler.rollup_config.l2_chain_id, validation);
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

The trace macro is printing a Chain enum directly with {}, which may not render the numeric ID as expected. Use self.handler.rollup_config.l2_chain_id.id() (or .into()) to log the actual u64 chain ID.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.

Project coverage is 82.2%. Comparing base (dcaf58a) to head (ec236ed).
Report is 28 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/node/p2p/src/gossip/driver.rs 0.0% 2 Missing ⚠️
bin/supervisor/src/flags/supervisor.rs 0.0% 1 Missing ⚠️
crates/node/p2p/src/gossip/block_validity.rs 0.0% 1 Missing ⚠️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@refcell refcell left a comment

Choose a reason for hiding this comment

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

Few small changes. Otherwise, looks great

@varun-doshi varun-doshi requested review from clabby and refcell July 18, 2025 06:41
Copy link
Contributor

@refcell refcell left a comment

Choose a reason for hiding this comment

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

This is great

@refcell refcell enabled auto-merge July 21, 2025 16:02
@refcell refcell added this pull request to the merge queue Jul 21, 2025
Merged via the queue into op-rs:main with commit f75e631 Jul 21, 2025
28 of 29 checks passed
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Dec 10, 2025
Fixes op-rs/kona#2316

---------

Co-authored-by: refcell <abigger87@gmail.com>
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 14, 2026
Fixes #2316

---------

Co-authored-by: refcell <abigger87@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(bin/node): L2 Chain ID Abstraction

4 participants