feat(p2p): hardcode Morph bootnodes in chainspec and simplify startup#94
feat(p2p): hardcode Morph bootnodes in chainspec and simplify startup#94
Conversation
- 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.
📝 WalkthroughWalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
crates/chainspec/res/genesis/hoodi.jsoncrates/chainspec/res/genesis/mainnet.jsoncrates/chainspec/src/bootnodes.rscrates/chainspec/src/lib.rscrates/chainspec/src/spec.rslocal-test/common.shlocal-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
Trusted peers can be passed directly via env if needed; no need to expose it as a default variable in the common config.
There was a problem hiding this comment.
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_PEERSappears 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_PEERSsupport 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
📒 Files selected for processing (3)
local-test/README.mdlocal-test/common.shlocal-test/reth-start.sh
🚧 Files skipped from review as they are similar to previous changes (1)
- local-test/common.sh
Summary
MorphChainSpec::bootnodes()returns the correct Morph network nodes based on chain ID — 7 mainnet nodes and 3 Hoodi nodes, sourced fromgo-ethereum/params/bootnodes.go.MORPH_MAX_TX_PAYLOAD_BYTES,MORPH_MAX_TX_PER_BLOCK,--nat none), removeRETH_BOOTNODES(no longer needed), addRETH_TRUSTED_PEERSfor optional persistent peer connections (equivalent to geth'sstatic-nodes.json), and add--rpc.eth-proof-window 1209600.useZktrietofalsein mainnet and hoodi genesis files.Test plan
cargo check -p morph-chainspecpassescargo test -p morph-chainspecpasses (44 tests)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
Chores
Documentation