Skip to content

feat: add --mainnet/--hoodi network presets and bump go-ethereum#973

Open
tomatoishealthy wants to merge 3 commits into
feat/sequencer-finalfrom
feat/cli-network-presets
Open

feat: add --mainnet/--hoodi network presets and bump go-ethereum#973
tomatoishealthy wants to merge 3 commits into
feat/sequencer-finalfrom
feat/cli-network-presets

Conversation

@tomatoishealthy
Copy link
Copy Markdown
Contributor

Summary

  • Add --mainnet / --hoodi CLI flags that select preset L1 contract addresses (rollup, sync deposit, L1 sequencer) at startup. Explicit --derivation.rollupAddress, --sync.depositContractAddr, --l1.sequencerContract (or their env vars) still win — presets are defaults, not overrides. The two flags are mutually exclusive.
  • Move the per-network default constants from node/core/config.go to node/types/networks.go. node/core already depends on sync/ and derivation/, so keeping the constants in core would have created an import cycle once those packages started consuming them.
  • derivation.NewDerivationClient now mirrors sync.NewSyncer's latestSynced == nil branch: when the DB has no derivation cursor and cfg.StartHeight == 0, pin StartHeight to the current L1 head and log it. Existing nodes (with a populated derivation cursor) are unaffected.
  • Bump morph-l2/go-ethereum replace directive across all 9 go.mod files in the repo to v0.0.0-20260603075727-e0a2cd340919 (HEAD of feat/sequencer-final on the geth side).

Priority order (CLI/env > preset > fallback)

Field CLI/env --mainnet --hoodi Final fallback
RollupContractAddress --derivation.rollupAddress MainnetRollupContractAddress HoodiRollupContractAddress empty (downstream errors)
L1MessageQueueAddress (sync deposit) --sync.depositContractAddr MainnetSyncDepositContractAddress HoodiSyncDepositContractAddress nil (caller errors)
L1Sequencer contract --l1.sequencerContract MainnetL1SequencerContractAddress HoodiL1SequencerContractAddress empty (caller errors)
derivation StartHeight --derivation.startHeight n/a (uses L1 head fallback) n/a (uses L1 head fallback) current L1 head when DB is empty

The L1Sequencer presets are wired through but currently still hold the zero address — the preset structure is in place ahead of those values being filled in.

Test plan

  • go build ./... clean across all 9 modules
  • go vet ./... clean
  • go mod tidy clean across all 9 modules
  • Devnet smoke run with --mainnet flag (no per-address overrides) confirms rollup/sync deposit addresses load correctly
  • Devnet smoke run with --derivation.rollupAddress set alongside --mainnet confirms CLI wins
  • First-run derivation node without --derivation.startHeight confirms it pins to the current L1 head

🤖 Generated with Claude Code

Wire CLI/env > network preset > existing fallback for the L1 contract
addresses consumed at startup, so operators can run mainnet or hoodi
without listing every address individually:

* --mainnet / --hoodi flags select rollup, sync deposit and L1 sequencer
  contract defaults; --derivation.rollupAddress / --sync.depositContractAddr /
  --l1.sequencerContract still win when provided.
* Mainnet and hoodi flags are mutually exclusive at startup.
* Default constants moved from node/core/config.go to node/types/networks.go
  so sync/, derivation/ and cmd/ can consume them without an import cycle
  through node/core (core already depends on sync).
* derivation.NewDerivationClient now mirrors sync.NewSyncer's
  `latestSynced == nil` branch: when the DB has no derivation cursor and
  no startHeight is configured, pin to the current L1 head.
* Bump morph-l2/go-ethereum replace directive across all go.mod files
  to v0.0.0-20260603075727-e0a2cd340919.
@tomatoishealthy tomatoishealthy requested a review from a team as a code owner June 3, 2026 08:31
@tomatoishealthy tomatoishealthy requested review from dylanCai9 and removed request for a team June 3, 2026 08:31
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bedccb0a-39f1-428e-aae6-d0c7d143814d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-network-presets

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
Collaborator

@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

allen.wu added 2 commits June 3, 2026 17:38
The first-run startHeight fallback in NewDerivationClient was using
l1Client.BlockNumber (raw L1 head). With the default
cfg.L1.Confirmations=safe (or any non-latest setting),
derivationBlock's getLatestConfirmedBlockNumber returns a smaller
height than the head, so on the first poll `latest < start` and the
loop logs "latest less than start" until L1 catches up.

Switch the fallback to nodecommon.GetLatestConfirmedBlockNumber with
the same cfg.L1.Confirmations the rest of the loop uses, so
StartHeight is always <= the next confirmed `latest`.
…Height fallback

Move the first-run startHeight fallback below the &Derivation{...}
construction so it can call the existing d.getLatestConfirmedBlockNumber
method instead of repeating the nodecommon.GetLatestConfirmedBlockNumber
call signature. Pure refactor — same call path, same confirmations
setting, no behavior change.
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