Skip to content

docs: add stateless validator guide#39

Open
flyq wants to merge 3 commits intomainfrom
liquan/add_stateless
Open

docs: add stateless validator guide#39
flyq wants to merge 3 commits intomainfrom
liquan/add_stateless

Conversation

@flyq
Copy link
Copy Markdown
Member

@flyq flyq commented Apr 17, 2026

Summary

  • Adds docs/stateless/stateless-validator.md — a guide for operators running a MegaETH stateless validator (system requirements, installation, first-run bootstrap via --genesis-file + --start-block, CLI flags mirrored by env vars, logging config, background deployment, Prometheus metrics, trust model, and troubleshooting).
  • Introduces Stateless Validator as a new top-level chapter in docs/SUMMARY.md, alongside User Guide and Developer Docs.
  • Content fact-checked against the upstream stateless-validator source: clap flag definitions in bin/stateless-validator/src/main.rs, LogArgs in crates/stateless-common/src/logging.rs, and the metric names exposed by the running binary.

Test plan

  • GitBook preview renders the new chapter under the correct section
  • Internal links resolve (../architecture.md, ../mini-block.md)
  • External links resolve (stateless-validator repo, SALT repo, scripts/validator-status.sh)
  • Frontmatter description appears as SEO meta
  • Hint blocks ({% hint style="info" %}) render correctly

@flyq flyq requested review from Troublor and nnsgmsone as code owners April 17, 2026 03:22
A handful of reorgs per day is normal on any L2.
If `reorgs_detected_total` climbs fast, double-check that your RPC endpoint is following the canonical chain — a misconfigured provider may be serving a stale fork.

## Related Pages
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Heading case violation — sentence case required per docs/AGENTS.md.

Suggested change
## Related Pages
## Related pages

1. **`--genesis-file`** — the MegaETH genesis JSON, which encodes the chain ID and hardfork activation schedule.
Obtain it from the [MegaETH repository](https://github.com/megaeth-labs) or the docs release page.
2. **`--start-block`** — a **trusted block hash** that anchors your local chain.
Pick any recent block hash you trust (e.g. copied from a known explorer or from another operator already running the validator).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing comma after e.g. — standard usage is e.g.,.

Suggested change
Pick any recent block hash you trust (e.g. copied from a known explorer or from another operator already running the validator).
Pick any recent block hash you trust (e.g., copied from a known explorer or from another operator already running the validator).

--data-dir "$DATA_DIR" \
--rpc-endpoint "$RPC_ENDPOINT" \
--witness-endpoint "$WITNESS_ENDPOINT" \
--genesis-file "$GENESIS_FILE" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The script always passes --genesis-file, but the prose above (line 83) says to omit it on subsequent runs. If the binary errors when --genesis-file is given but the DB is already initialized, this script will break on restart. Either:

  • Confirm the binary silently ignores --genesis-file on re-runs (and add a note), or
  • Make the flag conditional: ${GENESIS_FILE:+--genesis-file "$GENESIS_FILE" \}

On the first launch, the validator needs two pieces of bootstrap information:

1. **`--genesis-file`** — the MegaETH genesis JSON, which encodes the chain ID and hardfork activation schedule.
Obtain it from the [MegaETH repository](https://github.com/megaeth-labs) or the docs release page.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This link goes to the GitHub org root, not a specific repo or file. An operator following these steps can't actually find the genesis file from this link. Point to the specific file or repo (e.g., the stateless-validator repo's README or a releases page).

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 17, 2026

Review

Good addition — well-structured, thorough CLI reference, and the metrics table is genuinely useful. A few things to address before merging.

Missing AGENTS.md for the stateless/ layer
docs/AGENTS.md says each layer has its own AGENTS.md with layer-specific writing rules, and CLAUDE.md repeats this. The new docs/stateless/ directory doesn't have one. Either add a minimal AGENTS.md (audience: node operators; tone: terse reference, same as dev layer) or document why this layer shares conventions with an existing one.

Four inline comments on specific lines — see the diff for details:

  • Line 60: genesis file link points to the org root, not a usable download location
  • Line 62: e.g.e.g.,
  • Line 178: start_validator.sh always passes --genesis-file but the prose says to omit it on subsequent runs — needs clarification or a conditional
  • Line 279: ## Related Pages## Related pages (sentence case)

Comment on lines +191 to +193
# stateless_validator_local_chain_height 13592258
# stateless_validator_remote_chain_height 13592262
# stateless_validator_validation_lag 4
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The example output is incorrect. In Prometheus text format, # marks HELP/TYPE metadata lines — gauge values are emitted on lines without #. This grep would actually return both the metadata lines and the bare value lines; what's shown here omits the values entirely.

Suggested change
# stateless_validator_local_chain_height 13592258
# stateless_validator_remote_chain_height 13592262
# stateless_validator_validation_lag 4
stateless_validator_local_chain_height 13592258
stateless_validator_remote_chain_height 13592262
stateless_validator_validation_lag 4

## Related Pages

- [Architecture](../architecture.md) — how transactions flow through MegaETH and where validators fit in
- [Mini-Blocks](../mini-block.md) — the two block types the validator re-executes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Terminology violation — per docs/AGENTS.md, the term is always mini-block (lowercase).

Suggested change
- [Mini-Blocks](../mini-block.md) — the two block types the validator re-executes
- [mini-blocks](../mini-block.md) — the two block types the validator re-executes

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 17, 2026

Good overall — well-structured, covers the full operator lifecycle, and the CLI flag tables are thorough. A few issues to resolve before merging:

4 existing threads still open (not yet addressed):

  • ## Related Pages → sentence case (## Related pages)
  • Missing comma: e.g.e.g.,
  • Background launch script passes --genesis-file unconditionally, but subsequent runs should omit it
  • Genesis file link points to GitHub org root (https://github.com/megaeth-labs) — needs a specific repo/file

2 new issues (inline comments added):

  • Prometheus example output (lines 191–193): the #-prefixed lines shown are Prometheus metadata, not gauge values — the actual grep output would show bare metric_name value lines
  • Terminology (line 264): Mini-Blocksmini-blocks per docs/AGENTS.md terminology table

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.

1 participant