ethereum / ethereum/state-actor

sizecal: ethrex disk cost is ~2x bytesPerSlot (trie + flat rows per slot); docs/CALIBRATION.md missing

Open
#128 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
12
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Found while reviewing #117 (which fixes the RAM side of #116 but explicitly defers this).

## Problem

`--target-size=350GB` for `--client=ethrex` was heading for **~715 GiB on disk** (extrapolated from the killed run: 249 GiB at 38.1% of Phase 2, plus 60 GiB of Phase-0 spec storage). A local 40 GB fill realized 79 GB — the same ~2×.

Cause: `internal/sizecal/factors.go` documents `bytesPerSlot = 140` as **TRIE-only** (`factors.go:10-14`, "Flat-state rows … are ADDITIONAL and not counted"), but the ethrex writer emits **two rows per slot** — one into `storage_trie_nodes` and one into `storage_flatkeyvalue` (the snap-sync flat-KV layer, both uncompressed) — so ethrex's real per-slot disk cost is ~2× what the planner budgets.

## Constraints

- The constant must stay **identical across clients** for the `cross-client-genesis-root` gate (`factors.go:46-51`): same target → same synthetic entity set → same root. Any fix must keep the *entity counts* identical across clients and only change per-client *disk accounting/expectations* — or raise the global constant for all clients with a coordinated golden-root update.
- The plumbing for a per-client view already exists and is deliberately unused: `SizeApproximator.SlotsForBytes(client, …)` ignores its `client` param (`factors.go:3-8,71,80`).

## Also

`factors.go:13` points at `docs/CALIBRATION.md` for "calibration anchor and per-client flat-state overhead numbers" — **that file does not exist**. Whatever direction this issue lands, CALIBRATION.md should be authored and the per-client multipliers (ethrex ≈ 2×; others per their flat layouts) documented there.

Until fixed: size ethrex runs at ~2× the target on disk (350 GB target ⇒ ~700 GB + Phase-1 sort spill ≈ 0.4× co-resident at peak).

Contributor guide

Open the contributing guide

Research direction

Start with internal/sizecal/factors.go, especially SlotsForBytes and the bytesPerSlot documentation, then inspect the cross-client-genesis-root gate. Add the missing docs/CALIBRATION.md with per-client flat-state overheads and make disk accounting reflect ethrex's two rows per slot without changing entity counts or the shared genesis root.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.