docs(fundamentals): add Architecture and Database pages [main]#21500
docs(fundamentals): add Architecture and Database pages [main]#21500bloxster wants to merge 12 commits into
Conversation
Closes two of the largest content gaps identified in the [Improving-public-docs](https://github.com/erigontech/erigon-documents/blob/master/public-docs/Improving-public-docs.md) spec: the high-level Architecture overview and the deep-dive Database / datadir page. New pages: - `/fundamentals/architecture` (sidebar_position 3) - At-a-glance ASCII component diagram - Staged Sync pipeline + Erigon 3 consolidation notes - Modular processes (Sentry/Downloader/Execution/RPC Daemon/TxPool/Caplin) - Storage model split (chaindata vs snapshots) - Embedded Caplin consensus layer - Flat KV state model + RPC-latency rationale - Prune-modes vs sync-modes clarification - `/fundamentals/database` (sidebar_position 15) - Datadir directory tree with role per folder - MDBX engine properties (no compaction, mmap reads, single-writer) - Immutable .seg snapshots + BitTorrent distribution - Per-transaction history granularity - Real Nov-2024 mainnet + bor-mainnet sizing numbers - Why chaindata/ stays small (and is recoverable from snapshots) - Tuning flags (--batchSize, --db.size.limit, --db.read.concurrency) - Safe-to-delete subdirectories table Cross-links: both pages link to each other plus existing pages (Modules, Caplin, Optimizing Storage, Hardware Requirements, Sync Modes). No content duplication with Optimizing Storage — that page covers multi-disk tiering recipes, these pages cover concepts. Sources: erigontech/erigon README "Datadir structure", "Erigon3 datadir size", "Erigon3 changes from Erigon2", "Modularity", "More Efficient State Storage" sections. llms.txt and llms-full.txt (both static/ and root copies) regenerated. Build: `pnpm run build` passes with onBrokenLinks/onBrokenAnchors: 'throw'. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nnet sizing - Architecture page: ASCII component diagram → Mermaid flowchart - Database page: remove Polygon (bor-mainnet) disk-size block; we no longer maintain that chain - Add @docusaurus/theme-mermaid@^3.10.0 and enable mermaid in config - Regenerate llms-full.txt Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38658a6 to
c6c18da
Compare
yperbasis
left a comment
There was a problem hiding this comment.
Content and structure are good, but I checked the load-bearing claims against the code and found factual errors that should be fixed before merge.
1. --internalcl does not exist (architecture.md). There is no internalcl flag anywhere in the tree — only externalcl (cmd/utils/flags.go:172). Caplin is embedded by default; you opt out with --externalcl. Reword to: "Caplin runs embedded by default; pass --externalcl to use an external CL."
2. --batchSize example contradicts itself (database.md). Default is 512M (node/cli/flags.go:48), so the suggested --batchSize 1G raises it, not "lower it". Also batchSize is the execution-stage RAM buffer — tying it to "chaindata/ grows unexpectedly" is a dubious rationale. Fix the number or the framing.
3. Cross-page contradiction on receipts. architecture.md pipeline says "Finalization → persist receipts", but database.md correctly says "Receipts are not stored — they are re-computed". Drop "persist receipts" from the pipeline.
4. Mermaid diagram edge TxPool <-- private gRPC --> Caplin is wrong. TxPool does not talk to Caplin (the CL). Its gRPC relationship is with the core/Sentry. This edge should not connect to Caplin.
5. Snapshot sizing doesn't add up (database.md). Listed dirs sum to ~1.13 TB (accessor 120 + domain 300 + history 280 + idx 430) but "snapshots TOTAL 2.3 TB". The gap is presumably the unlisted blocks/transactions .seg files — add those rows or note the breakdown is partial.
6. Likely dead link. https://github.com/erthink/libmdbx — that GitHub repo was taken down; Erigon vendors github.com/erigontech/mdbx-go. onBrokenLinks only checks internal links so the build won't catch it.
All are text edits, no restructuring needed.
There was a problem hiding this comment.
Pull request overview
Adds two new Fundamentals documentation pages (“Architecture” and “Database”) and enables Mermaid rendering in the Docusaurus site so the architecture page can include a component diagram. Also updates the generated llms*.txt artifacts to include the new pages.
Changes:
- Add new
/fundamentals/architectureand/fundamentals/databasepages (incl. Mermaid diagram and datadir/MDBX/snapshots details). - Enable Mermaid support in the docs site via
@docusaurus/theme-mermaidand config updates. - Regenerate
llms.txt/llms-full.txt(anddocs/site/static/copies) to include the new pages.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| llms.txt | Adds links to the new Fundamentals pages. |
| llms-full.txt | Adds full-text entries for the new pages. |
| docs/site/static/llms.txt | Mirrors llms.txt updates for the site static copy. |
| docs/site/static/llms-full.txt | Mirrors llms-full.txt updates for the site static copy. |
| docs/site/package.json | Adds Mermaid theme dependency. |
| docs/site/package-lock.json | Locks Mermaid/theme transitive dependencies. |
| docs/site/docusaurus.config.ts | Enables Mermaid in markdown and registers the Mermaid theme. |
| docs/site/docs/fundamentals/architecture.md | New Architecture page with Mermaid component diagram and system overview. |
| docs/site/docs/fundamentals/database.md | New Database page describing datadir layout, MDBX, snapshots, and sizing/tuning. |
Files not reviewed (1)
- docs/site/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
#21559) Fix --batchSize description/default, remove wrong TxPool↔Caplin diagram edge, add snapshot-sizing note, repoint MDBX link to erigontech/mdbx-go, regenerate llms-full artifacts.
yperbasis
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround — the six items from my previous review are all correctly addressed (verified --externalcl at cmd/utils/flags.go:173, the --batchSize default 512M at node/cli/flags.go:51, the Caplin-edge removal, the sizing note, and the mdbx-go link). I re-checked the remaining load-bearing claims against main and found a few more factual issues — including one I got wrong in my last review. Requesting changes for these. All are text edits, no restructuring.
1. database.md: "Receipts are not stored — they are re-computed" is incorrect (and a correction to my earlier review)
In my previous review I claimed database.md "correctly says Receipts are not stored" and on that basis asked to drop "persist receipts" from the architecture pipeline. That premise was wrong on my part — receipts are stored:
db/kv/tables.go:715-716:ReceiptDomain— "Tiny Receipts - without logs. Required for node-operations.";RCacheDomain— "Fat Receipts - with logs. Optional."- Written every txn during Execution:
db/rawdb/rawtemporaldb/accessors_receipt.go(AppendReceipt→DomainPut(kv.ReceiptDomain, …)for cumulative gas / blob gas / log-index) anddb/rawdb/accessors_chain.go:1373(DomainPut(kv.RCacheDomain, …)for full receipts). - Both are registered aggregated domains, so they produce
.kvfiles insnapshots/domain/(db/state/statecfg/state_schema.go:50,53). - The RPC path is a hybrid, not pure re-exec:
rpc/jsonrpc/receipts/receipts_generator.goreads stored metadata viaReceiptAsOf+ cached full receipts, and only re-executes to re-derive logs when the full receipt isn't cached.
Please reword to something like: full receipts (with logs) aren't persisted by default; Erigon stores compact per-txn receipt metadata (cumulative gas, blob gas, log index) in a required receipt domain and optionally caches full receipts, reconstructing receipts on demand and re-deriving logs by re-execution when needed. Dropping "persist receipts" from the Finalization step was still correct — it's Execution that writes the receipt domain, not Finalization.
2. database.md: "4 domains: account, storage, code, commitment" — there are 6
db/kv/tables.go:711-717 defines 6 domains. The four you list are StateDomains (:720); the other two are ReceiptDomain and RCacheDomain, and all six produce files under snapshots/domain/. Either say "the four state domains" or list all six. (Tied to #1 — receipts literally are domains in that directory.)
3. architecture.md: prune full is not "post-Merge blocks"
FullMode.Blocks = Distance(config3.DefaultPruneDistance) = 262,144 blocks (db/kv/prune/storage_mode.go:38-42, db/config3/config3.go:48) — a rolling window, not all post-Merge blocks. KeepPostMergeBlocksPruneMode is a separate sentinel that is no longer the full default. Suggest matching the flag usage ("keep only necessary blocks + latest state", node/cli/flags.go:79). The (default) label on full is correct.
4. architecture.md: pipeline lists "Commitment" as a separate stage, contradicting the next paragraph
Step 5 "Commitment" is shown as its own stage, but the following paragraph says Execution absorbs stage_trie into a single pass — and DefaultStages (execution/stagedsync/default_stages.go) has no Commitment stage; it runs inside Execution. Also, Snapshots/OtterSync is stage #1 in the real pipeline, not #3 after Headers/Bodies. Either fold Commitment into the Execution line or note it's part of Execution.
Minor
architecture.mdprune table omits theblocksmode.node/cli/flags.go:77-83lists four modes (full,archive,minimal,blocks); the table shows three. Add a row or note it's a subset.database.md"rm -rf chaindata/is recoverable / rebuilds from snapshots" — please double-check before we publish this as safe.chaindata/holds recent blocks and canonical data not yet folded into snapshots, and block download over devp2p was just removed (#21505, engine-API-only), so the refill path may not behave as the doc implies.- Mermaid
Sentry --> Downloaderedge: the Downloader is BitTorrent-based and independent of Sentry (devp2p). Low priority for a high-level diagram, but the linearSentry→Downloader→Execution→RPCchain implies a data flow that doesn't exist. - For the open Copilot comments: please ignore the suggestion to re-add the
TxPool↔Caplinedge (it's reasoning from a since-regenerated llms-full; removing it was correct). Pinning@docusaurus/theme-mermaidto an exact version, as Copilot suggests, is reasonable given the other Docusaurus deps are pinned.
Addresses the CHANGES_REQUESTED review, verified against `main`: database.md - Receipts ARE stored: ReceiptDomain (required) + RCacheDomain (optional). Reword the "not stored / re-computed" claim to: compact per-txn receipt metadata persisted in a required domain, full receipts optionally cached, logs re-derived by re-execution only when not cached. - snapshots/domain holds 6 domains (4 state + 2 receipt), not 4. - Soften "rm -rf chaindata/": recoverable, but re-derives state from snapshots and resyncs the tip from the CL over the Engine API (devp2p block download removed in #21505) — not a quick rebuild. architecture.md - prune `full` keeps a rolling ~262k-block window (DefaultPruneDistance), not all post-Merge blocks; add the `blocks` prune mode to the table. - Pipeline: Snapshots is stage #1; no separate Commitment stage (it runs inside Execution); add Senders. - Mermaid: Downloader (BitTorrent) is independent of Sentry (devp2p); blocks arrive from Caplin via the Engine API. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @yperbasis — all verified against
Minor:
On Copilot: left the |
The `blocks` prune mode was listed in the comparison table but lacked a dedicated section (unlike full/minimal/archive). Add a "Blocks node" section explaining it keeps full block/transaction history while pruning state history to the EIP-8252 window, and link the table row to it. Parity with the architecture.md prune table, which now lists all four modes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Full receipts (RCacheDomain) ARE persisted by default for full/minimal/blocks modes — only archive skips the cache by default (re-derives from full state history). Controlled by --persist.receipts (node/cli/flags.go:248). The prior "not persisted by default" wording was wrong and contradicted the prune-modes page's --persist.receipts note; this aligns the two pages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@yperbasis Thanks again for the careful code-level review. All items from the latest round are now addressed in the branch (commits 1. Receipts are stored (
2. Six domains, not four — 3. Prune 4. Commitment folded into Execution — the separate Minor
|
Port the architecture, database, and prune-modes corrections verified against main (receipt persistence, 6 domains, full-mode rolling window, Commitment folded into Execution, blocks mode, chaindata recovery via Engine API, Mermaid edges) onto release/3.4. Regenerate llms-full.txt.
The committed lockfile was both invalid JSON (a stray trailing `}`) and out of sync with package.json, so CI's `npm ci` failed outright. A from-scratch regen then pulled some @docusaurus/* transitive packages to 3.10.1 while the pinned ones stayed 3.10.0, which breaks Docusaurus's same-version requirement at build time. Reseeded from the main twin (#21500) lockfile — where every @docusaurus/* resolves to 3.10.0 — and reconciled to this branch's package.json with `npm install --package-lock-only`. Verified locally: `npm ci`, `npm run typecheck`, and `npm run build` all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Committed package.json pins @docusaurus/theme-mermaid to 3.10.0 but the lockfile root deps still carried the ^3.10.0 range, so CI's `npm ci` failed as out-of-sync. Align the lockfile spec to the pin. Verified locally: `npm ci`, `npm run typecheck`, and `npm run build` all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
maintwin of #21494. Same two new pages:/fundamentals/architecture— staged sync, modular processes, storage split, embedded Caplin, flat-KV state. Mermaid component diagram./fundamentals/database— datadir layout, MDBX engine, snapshots, per-transaction history granularity, mainnet sizing, tuning flags, safe-to-delete table.Stacked on #21496
Base is
docs/prose-audit-main-2026-05-28so links can target the renamed Prune Modes page. GitHub auto-retargets tomainonce #21496 merges.Verification
npm run buildpasses withonBrokenLinks/onBrokenAnchors: 'throw'docs-site / build(incl. llms verification) ✓ passNotes
README.md"Datadir structure" / "Erigon3 datadir size" / "Modularity" sections.@docusaurus/theme-mermaid@^3.10.0(used by the architecture diagram).