erigontech / erigontech/erigon
cl/persistence/blob_storage: pruned blobs leave their kzg-commitment index rows behind forever
- Dominant language
- Go
- Stars
- 3.6k
- Forks
- 1.5k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 455
Description
`BlobStore.Prune` deletes bucket directories and never touches MDBX (`cl/persistence/blob_storage/blob_db.go:165-182`). The only delete of `kv.BlockRootToKzgCommitments` is in `RemoveBlobSidecars` (`:242`), which is per-root and called explicitly.
So every block whose sidecar files are pruned keeps its count row. One row per block with blobs — order 2.6M blocks a year at 12s slots — never removed. The row is small, a 32-byte key and a 4-byte value, but the growth is monotonic and unbounded in the caplin indexing DB.
Reads degrade correctly rather than lying: `ReadBlobSidecars` reads the count, opens index 0, gets `ErrFileNotFound` and returns `found=false` (`:140-148`). This is size, not correctness.
The fix belongs with the pruner — dropping files below a floor should drop their rows too. It needs a way to enumerate roots below that floor, and the obvious two options trade against each other: `kv.CanonicalBlockRoots` covers canonical blocks only, so non-canonical roots still leak; re-keying the index by `(slot, root)` makes it range-deletable but breaks the three call sites that have only a root (`peer_das.go:239`, `cmd/capcli/cli.go:428,1092`).
Adjacent, same function: the `tx.Delete` at `:242` discards its error.
Part of #23024, item 4.
Contributor guide
Research direction
Start in cl/persistence/blob_storage/blob_db.go, especially BlobStore.Prune and RemoveBlobSidecars, then inspect the root-only callers in peer_das.go and cmd/capcli/cli.go. Determine how pruning can identify all affected roots, including non-canonical ones, without breaking those callers; done means pruned blobs no longer leave index rows and the adjacent delete error is handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100