Skip to content

feat(p2p): hardcode Morph bootnodes in chainspec and simplify startup#94

Merged
panos-xyz merged 5 commits intomainfrom
feat/p2p-bootnodes-and-startup
Apr 13, 2026
Merged

feat(p2p): hardcode Morph bootnodes in chainspec and simplify startup#94
panos-xyz merged 5 commits intomainfrom
feat/p2p-bootnodes-and-startup

Conversation

@panos-xyz
Copy link
Copy Markdown
Contributor

@panos-xyz panos-xyz commented Apr 10, 2026

Summary

  • Add Morph bootnodes to chainspec: morph-reth previously had no hardcoded bootnodes, causing reth to fall back to Ethereum L1 (EF) bootnodes for discv4 discovery. Now MorphChainSpec::bootnodes() returns the correct Morph network nodes based on chain ID — 7 mainnet nodes and 3 Hoodi nodes, sourced from go-ethereum/params/bootnodes.go.
  • Simplify startup script: remove redundant flags that have matching code defaults (MORPH_MAX_TX_PAYLOAD_BYTES, MORPH_MAX_TX_PER_BLOCK, --nat none), remove RETH_BOOTNODES (no longer needed), add RETH_TRUSTED_PEERS for optional persistent peer connections (equivalent to geth's static-nodes.json), and add --rpc.eth-proof-window 1209600.
  • Genesis JSON: set useZktrie to false in mainnet and hoodi genesis files.

Test plan

  • cargo check -p morph-chainspec passes
  • cargo test -p morph-chainspec passes (44 tests)
  • On startup, discv4 pings Morph bootnodes (52.193.82.123, 52.197.80.227, etc.) instead of Ethereum L1 EF bootnodes (3.209.45.79, 18.138.108.67, etc.)

Summary by CodeRabbit

  • New Features

    • Built-in bootnode configurations for Morph Mainnet and Hoodi testnet; no manual bootnode flag required.
  • Chores

    • Updated local test defaults: RPC bind address changed to 0.0.0.0 and trusted peers option added (empty by default).
    • Simplified local start scripts: enabled HTTP admin API, removed several legacy morph/engine flags, and adjusted RPC proof window.
  • Documentation

    • README updated to reflect hardcoded bootnodes and removed environment-variable guidance.

- Add Morph mainnet (7 nodes) and Hoodi (3 nodes) bootnodes from
  go-ethereum/params/bootnodes.go into chainspec, so discv4 discovery
  targets the correct Morph network instead of falling back to
  Ethereum L1 bootnodes.
- Simplify reth-start.sh: remove RETH_BOOTNODES, MORPH_MAX_TX_PAYLOAD_BYTES,
  MORPH_MAX_TX_PER_BLOCK (all have code defaults), and --nat none.
- Add RETH_TRUSTED_PEERS for optional persistent peer connections.
- Add --rpc.eth-proof-window 1209600 (14 days).
- Set useZktrie to false in mainnet/hoodi genesis.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

Adds a new internal Rust module that hardcodes Morph Mainnet and Hoodi bootnodes and surfaces them via helper functions; updates the chain spec to return these bootnodes for matching chain IDs; and simplifies local-test scripts and reth startup flags, changing a default bind address and removing some environment defaults.

Changes

Cohort / File(s) Summary
Bootnode Module
crates/chainspec/src/bootnodes.rs, crates/chainspec/src/lib.rs
New internal module providing MORPH_MAINNET_BOOTNODES (7) and MORPH_HOODI_BOOTNODES (3) string arrays and helper functions morph_mainnet_nodes() / morph_hoodi_nodes() that parse them into Vec<NodeRecord>.
ChainSpec Update
crates/chainspec/src/spec.rs
EthChainSpec for MorphChainSpec::bootnodes() now returns hardcoded Morph bootnodes for known Morph chain IDs, otherwise falls back to self.inner.bootnodes().
Local Test Scripts & Docs
local-test/common.sh, local-test/reth-start.sh, local-test/README.md
Default RETH_AUTHRPC_ADDR changed to 0.0.0.0; removed several default env vars (RETH_BOOTNODES, MORPH_MAX_TX_PAYLOAD_BYTES, MORPH_MAX_TX_PER_BLOCK); added RETH_TRUSTED_PEERS default; reth startup flags simplified (added --http.api admin, removed several morph/engine flags, added --rpc.eth-proof-window 1209600); README updated to note bootnodes are hardcoded.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • anylots
  • chengwenxi

Poem

🐰 I hopped through code where bootnodes dwell,
Seven for Mainnet, three that Hoodi tells,
Scripts trimmed and ports set free to roam,
A rabbit's small patch to help the network home. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: hardcoding Morph bootnodes in the chainspec and simplifying the startup configuration, which directly aligns with the file modifications and PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/p2p-bootnodes-and-startup

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
crates/chainspec/src/bootnodes.rs (1)

25-30: Add regression tests for bootnode parsing/counts.

Since these are hardcoded critical peers, add unit tests that assert parsed counts (7 mainnet, 3 hoodi) to catch typos or accidental edits early.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/chainspec/src/bootnodes.rs` around lines 25 - 30, Add unit tests that
verify the hardcoded bootnode lists parse to the expected counts: create a
#[cfg(test)] mod tests in the same module (crates/chainspec/src/bootnodes.rs)
and add two tests, e.g., test_morph_mainnet_bootnode_count and
test_morph_hoodi_bootnode_count, that call morph_mainnet_nodes() and
morph_hoodi_nodes() and assert_eq! their .len() to 7 and 3 respectively; use the
existing parse_nodes, MORPH_MAINNET_BOOTNODES and MORPH_HOODI_BOOTNODES symbols
to locate the logic under test and keep the tests simple and deterministic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/chainspec/src/bootnodes.rs`:
- Around line 29-31: The file fails rustfmt checks: reformat the small function
so it meets rustfmt style (e.g., adjust spacing/indentation) — locate the
function morph_hoodi_nodes and ensure its body and call to
parse_nodes(MORPH_HOODI_BOOTNODES) are formatted with rustfmt conventions; run
cargo fmt --all (or rustfmt on this file) and commit the formatted changes so CI
passes.

In `@local-test/reth-start.sh`:
- Around line 43-46: Update the README to remove references to the removed env
vars RETH_BOOTNODES and MORPH_MAX_TX_PAYLOAD_BYTES and instead document the new
peer configuration env var RETH_TRUSTED_PEERS used by reth-start.sh; show a
short example of how to set RETH_TRUSTED_PEERS (comma- or space-separated
multiaddr/peer entries as accepted by the script), update the startup/example
commands to use RETH_TRUSTED_PEERS, and clarify that this enables persistent TCP
trusted peers (replacing the old bootnode-driven workflow).

---

Nitpick comments:
In `@crates/chainspec/src/bootnodes.rs`:
- Around line 25-30: Add unit tests that verify the hardcoded bootnode lists
parse to the expected counts: create a #[cfg(test)] mod tests in the same module
(crates/chainspec/src/bootnodes.rs) and add two tests, e.g.,
test_morph_mainnet_bootnode_count and test_morph_hoodi_bootnode_count, that call
morph_mainnet_nodes() and morph_hoodi_nodes() and assert_eq! their .len() to 7
and 3 respectively; use the existing parse_nodes, MORPH_MAINNET_BOOTNODES and
MORPH_HOODI_BOOTNODES symbols to locate the logic under test and keep the tests
simple and deterministic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3300016e-43b9-4f18-a673-483c50010632

📥 Commits

Reviewing files that changed from the base of the PR and between 53ed544 and 3d6acd1.

📒 Files selected for processing (7)
  • crates/chainspec/res/genesis/hoodi.json
  • crates/chainspec/res/genesis/mainnet.json
  • crates/chainspec/src/bootnodes.rs
  • crates/chainspec/src/lib.rs
  • crates/chainspec/src/spec.rs
  • local-test/common.sh
  • local-test/reth-start.sh
👮 Files not reviewed due to content moderation or server errors (2)
  • crates/chainspec/res/genesis/mainnet.json
  • crates/chainspec/res/genesis/hoodi.json

Comment thread crates/chainspec/src/bootnodes.rs Outdated
Comment thread local-test/reth-start.sh Outdated
Trusted peers can be passed directly via env if needed; no need to
expose it as a default variable in the common config.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
local-test/reth-start.sh (1)

27-41: ⚠️ Potential issue | 🟠 Major

RETH_TRUSTED_PEERS appears to be dropped from startup wiring.

The startup args are now static, and there’s no path here to pass optional trusted/persistent peers from env. That conflicts with the PR objective of adding RETH_TRUSTED_PEERS support for persistent peer connections.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@local-test/reth-start.sh` around lines 27 - 41, The args array for Reth
startup no longer includes the optional RETH_TRUSTED_PEERS env var, so
reintroduce conditional wiring: detect if RETH_TRUSTED_PEERS is non-empty and
append the appropriate flag and value to the args array (e.g., add
"--trusted-peers" or the Reth-equivalent flag) so persistent/trusted peers are
passed through at startup; handle comma-separated lists by passing the env value
verbatim (or split/join if the flag expects multiple entries) and reference the
existing args array and the RETH_TRUSTED_PEERS env var when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@local-test/reth-start.sh`:
- Around line 27-41: The args array for Reth startup no longer includes the
optional RETH_TRUSTED_PEERS env var, so reintroduce conditional wiring: detect
if RETH_TRUSTED_PEERS is non-empty and append the appropriate flag and value to
the args array (e.g., add "--trusted-peers" or the Reth-equivalent flag) so
persistent/trusted peers are passed through at startup; handle comma-separated
lists by passing the env value verbatim (or split/join if the flag expects
multiple entries) and reference the existing args array and the
RETH_TRUSTED_PEERS env var when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f19c564-5bbf-418e-a829-6a23be00da31

📥 Commits

Reviewing files that changed from the base of the PR and between a9021cc and 7a09537.

📒 Files selected for processing (3)
  • local-test/README.md
  • local-test/common.sh
  • local-test/reth-start.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • local-test/common.sh

Copy link
Copy Markdown
Contributor

@chengwenxi chengwenxi left a comment

Choose a reason for hiding this comment

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

lgtm

@panos-xyz panos-xyz merged commit c957148 into main Apr 13, 2026
12 checks passed
@panos-xyz panos-xyz deleted the feat/p2p-bootnodes-and-startup branch April 13, 2026 05:51
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.

2 participants