Skip to content

Feat(chainspec): adding xlayer-devnet chainspec#167

Merged
louisliu2048 merged 8 commits intomainfrom
dumi/devnet-specs
Mar 6, 2026
Merged

Feat(chainspec): adding xlayer-devnet chainspec#167
louisliu2048 merged 8 commits intomainfrom
dumi/devnet-specs

Conversation

@dloghin
Copy link
Contributor

@dloghin dloghin commented Mar 3, 2026

Description

Adding xlayer-devnet chainspec to chainspec crate. This helps in running devnet with testnet/mainnet data by making the process of starting op-reth-seq (sequencer) and op-reth-rpc (RPC) much faster compared to starting with genesis. Since devnet genesis changes every time we create a devnet, we need to inject genesis hash into chainspec, so we do this by writing the hash into res/genesis/xlayer-devnet-genesis-hash.txt and reading it into XLAYER_DEVNET_GENESIS_HASH.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Code Guidelines

Before submitting your PR, please review the relevant code guidelines in the docs/ folder:

Specific Guidelines by Component:

Checklist

  • I have reviewed the relevant code guidelines in the docs/ folder
  • My code follows the coding standards of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Testing

cargo test --package xlayer-chainspec --lib -- xlayer_devnet::tests --nocapture

@dloghin dloghin changed the title feat(chainspec): adding xlayer-devnet chainspec Feat(chainspec): adding xlayer-devnet chainspec Mar 3, 2026
@dloghin dloghin marked this pull request as ready for review March 3, 2026 09:16
@dloghin dloghin requested a review from Vui-Chee March 3, 2026 09:16
@dloghin dloghin requested a review from Vui-Chee March 4, 2026 03:23
Copy link
Contributor

@Vui-Chee Vui-Chee left a comment

Choose a reason for hiding this comment

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

Review Summary

4 new findings not covered by existing discussion:

1. Inconsistent 0x prefix in fallback hash values (xlayer_devnet.rs)

The genesis hash fallback (line ~28) uses "0xc5d2..." (with 0x prefix), but the state root fallback (line ~53) uses "c5d2..." (without prefix). Both are parsed with .parse::<B256>(). Pick one format — preferably bare hex without 0x to match the b256!() convention used in mainnet/testnet.

2. Doc comment says "testnet" instead of "devnet" (lib.rs line 118)

XLAYER_DEVNET_HARDFORKS has doc comment /// X Layer testnet list of hardforks. — copy-paste error, should say "devnet".

3. Filesystem writes during Lazy static initialization (xlayer_devnet.rs)

XLAYER_DEVNET_GENESIS_HASH and XLAYER_DEVNET_STATE_ROOT create files on disk via std::fs::write if they do not exist. Concerns:

  • Read-only environments (Docker, CI, production): will panic! on first access
  • Silent incorrect state: a fresh clone runs with keccak256("") as genesis hash with no warning to the operator

Consider failing with a clear error when the file is missing (forcing operator to provide the correct hash), or at minimum logging a warning when falling back to the placeholder. The mainnet/testnet equivalents are const values with zero I/O.

4. terminalTotalDifficultyPassed: false in genesis JSON (xlayer-devnet.json line 24)

Both mainnet and testnet genesis files set this to true. With terminalTotalDifficulty: 0, having Passed: false is contradictory. While the programmatic hardfork config likely overrides this, other tooling consuming the raw JSON could be confused. Should this be true?

@dloghin
Copy link
Contributor Author

dloghin commented Mar 5, 2026

  1. Fixed.
  2. Fixed.
  3. Using empty hash is as intended: devnet chainspec should be used only in conjunction with xlayer-toolkit devnet scripts since devnet genesis modifies each time a devnet is set up. Hence, we do not have a consistent pre-defined hash.
  4. terminalTotalDifficulty: 0 is consistent with the genesis files generated during devnet setup.

@dloghin dloghin requested a review from Vui-Chee March 5, 2026 09:06
@Vui-Chee
Copy link
Contributor

Vui-Chee commented Mar 5, 2026

All 4 previous review comments have been addressed:

  1. 0x prefix consistency — Both fallback hashes now consistently use the 0x prefix. ✔
  2. Doc comment fixXLAYER_DEVNET_HARDFORKS doc now correctly says "devnet". ✔
  3. Filesystem writes during Lazy init — Explanation accepted: devnet chainspec is intended to be used with xlayer-toolkit devnet scripts where genesis changes each time, so the file-creation fallback is by design.
  4. terminalTotalDifficultyPassed: false — Acceptable since Paris is explicitly configured in XLAYER_DEVNET_HARDFORKS via ForkCondition::TTD, overriding the JSON value at runtime.

LGTM.

Copy link
Contributor

@Vui-Chee Vui-Chee left a comment

Choose a reason for hiding this comment

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

LGTM — all 4 previous review comments have been addressed.

@louisliu2048 louisliu2048 merged commit c7eb1f2 into main Mar 6, 2026
@dloghin dloghin deleted the dumi/devnet-specs branch March 6, 2026 03:48
Vui-Chee added a commit that referenced this pull request Mar 9, 2026
* main:
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
Vui-Chee added a commit that referenced this pull request Mar 13, 2026
* main: (25 commits)
  fix: bump quinn-proto to 0.11.14 to patch CVE-2026-31812 DoS vuln (#183)
  pre-job authorization (#193)
  fix: trigger review skill failed to ack (#192)
  feat: trigger skill review separately (#191)
  feat: add Claude skills and CLAUDE.md for AI-assisted development (#190)
  rename ext (#185)
  supply workflow for claude (#184)
  feat(builder): incremental trie cache optimization for flashblocks state root (#163)
  chore(flashblocks-rpc): migrate op-reth flashblocks into xlayer-reth (#175)
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
  fix: update testcontainers to v0.27.0 to remediate CVE-2025-62518 (#164)
  chore(builder): further clean up builder crate (#161)
  ...
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