Skip to content

docs: clarify --serveHistoricalState and --chain.pruneHistory help text - #9328

Merged
nflaig merged 5 commits into
ChainSafe:unstablefrom
lodekeeper:docs/cli-help-historical-state-prune
May 6, 2026
Merged

docs: clarify --serveHistoricalState and --chain.pruneHistory help text#9328
nflaig merged 5 commits into
ChainSafe:unstablefrom
lodekeeper:docs/cli-help-historical-state-prune

Conversation

@lodekeeper

Copy link
Copy Markdown
Contributor

Motivation

The current --help text for --serveHistoricalState and --chain.pruneHistory is too terse, which leads to confusion about what these flags actually do. This came up in a question from yorickdowne on Discord about backfill semantics. Nico explained both flags in chat and asked for the help docs to be improved so users don't have to dig into the docs site.

Description

Updates both descriptions in packages/cli/src/options/beaconNodeOptions/chain.ts:

  • --serveHistoricalState: clarifies that it only spawns a worker thread to regenerate states the node already has on demand (i.e. since genesis sync or --checkpointState); it does not backfill historical data. Also notes the regeneration cost tradeoff with --chain.archiveStateEpochFrequency.
  • --chain.pruneHistory: states the actual retention boundary (MIN_EPOCHS_FOR_BLOCK_REQUESTS = 33024 epochs / ~5 months on mainnet) and clarifies that archived states before the finalized epoch are also pruned.

No behavior changes — --help text only.

Steps to test or reproduce

pnpm build && ./packages/cli/bin/lodestar beacon --help | grep -A 4 -E "serveHistoricalState|pruneHistory"

Closes #N/A

…lp text

The current --help descriptions are too terse and lead to confusion about
what these flags actually do.

- --serveHistoricalState: clarify that it only spawns a regen worker for
  states the node already has; it does not backfill any historical data.
  Mention the related --chain.archiveStateEpochFrequency tradeoff.
- --chain.pruneHistory: state the actual retention boundary
  (MIN_EPOCHS_FOR_BLOCK_REQUESTS, 33024 epochs / ~5 months on mainnet)
  and that all archived states before finalized are pruned too.

🤖 Generated with AI assistance
@lodekeeper
lodekeeper requested a review from a team as a code owner May 5, 2026 18:25

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the CLI help descriptions for serveHistoricalState and chain.pruneHistory to provide more detailed information about their functionality and performance implications. Feedback suggests avoiding hardcoded default values and network-specific constants in these descriptions to prevent maintenance issues and user confusion on non-mainnet networks.

Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts Outdated
Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts
…n.pruneHistory help text

Drop hardcoded `1024` default for `--chain.archiveStateEpochFrequency`
in the `--serveHistoricalState` description (already documented on the
flag itself), and prefix the `MIN_EPOCHS_FOR_BLOCK_REQUESTS` example
with `e.g.,` to make it clear those are mainnet-specific values
(2048 epochs on Sepolia/Holesky).

🤖 Generated with AI assistance
Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts Outdated
Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts Outdated
Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts Outdated
…uneHistory

- Drop "Spawn a worker thread to" prefix from --serveHistoricalState; the
  worker-thread implementation detail isn't relevant for operators.
- Replace em-dash with comma in the same description for consistency
  with the rest of the help text.
- Revert the "e.g.," qualifier on `MIN_EPOCHS_FOR_BLOCK_REQUESTS` per
  reviewer preference; restore the original "33024 epochs / ~5 months
  on mainnet" wording.

🤖 Generated with AI assistance
Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts Outdated
…istoricalState

The help text said "debug REST API" but --serveHistoricalState enables
state regeneration for any state-dependent endpoint, not only the
/eth/v2/debug/* namespace.

🤖 Generated with AI assistance
Comment thread packages/cli/src/options/beaconNodeOptions/chain.ts Outdated
Apply Nico's wording suggestion on the prune-history help text.\n\n🤖 Generated with AI assistance
@nflaig nflaig changed the title docs(cli): clarify --serveHistoricalState and --chain.pruneHistory help text docs: clarify --serveHistoricalState and --chain.pruneHistory help text May 6, 2026
@nflaig
nflaig enabled auto-merge (squash) May 6, 2026 12:57
@nflaig
nflaig merged commit 3fe3b04 into ChainSafe:unstable May 6, 2026
20 checks passed
@nflaig

nflaig commented May 6, 2026

Copy link
Copy Markdown
Member

@lodekeeper seems like this is not correctly formatted on the docs page, see screenshot

image

@lodekeeper

Copy link
Copy Markdown
Contributor Author

Good catch — root cause is packages/cli/docsgen/markdown.ts:7 sanitizeDescription(), which globally HTML-encodes {{ and }} even inside backtick code spans, so the entities never decode back to { / } on the rendered docs page.

Filed a hotfix in #9334 swapping {state_id} for the literal head (a valid state_id value), which sidesteps the sanitizer for this description. The underlying sanitizer bug is worth a separate cleanup so future help-text additions can safely use {...} placeholder syntax (and <...>, which has the same issue).

nflaig pushed a commit that referenced this pull request May 6, 2026
## Summary

Fix the broken docs render for the `--serveHistoricalState` help text on
the docs site (reported in [PR
#9328](#9328 (comment))).
Replaces `{state_id}` with `head` in the example URL.

## Root cause

`packages/cli/docsgen/markdown.ts:7` `sanitizeDescription()`
HTML-encodes `{` → `&#123;` and `}` → `&#125;` globally — including text
inside backtick code spans. Markdown code spans render their contents as
literal text, so the encoded entities never decode back to `{` and `}` —
users see `&#123;state_id&#125;` verbatim on the docs page.

This is the only `{...}` placeholder I added in #9328. Sidestepping by
using `head`, which is a valid `state_id` value (the user can substitute
any other real value: `genesis`, `finalized`, `<slot>`, etc.).

## Follow-up

The `sanitizeDescription` function should be fixed properly so future
descriptions can use `{...}` placeholders (and `<...>` placeholders)
without breaking docs rendering. Filing this as a separate concern — out
of scope for this hot-fix.

## Test plan

- [x] Locally verified the diff is the single-line change in `chain.ts`.
- [ ] After merge: confirm the docs page renders the
`serveHistoricalState` help text without HTML entity codes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: lodekeeper <lodekeeper@users.noreply.github.com>
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