Skip to content

Commit c742ee7

Browse files
committed
Merge origin/main into mh/trunk-pin-on-cachestack
Bring the cache stack current with main (parallel/streaming commitment correctness fixes #22184/#22113, nibblized-keccak cache #22185, erigondb.toml commitment referencing #21452, trie io.Writer trace #21859, etc.). One conflict in commitment_context.go's trieContext: keep both this branch's probeSd/probeTx (adaptive trunk-pin probe) and main's traceW (io.Writer trace).
2 parents 77c7800 + 69a814e commit c742ee7

165 files changed

Lines changed: 7835 additions & 4536 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/rules/comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ Default to **no comment**. Clear names and small functions should carry the mean
1919

2020
## When a comment is warranted
2121

22-
Keep it short and *why*-focused. If a reader could delete it without losing information, it shouldn't exist. Two tight lines beat a six-line essay.
22+
Keep it concise and *why*-focused, but err on the side of clarity: cut what only adds length, keep what saves the reader a wrong guess. If a reader could delete it without losing information, it shouldn't exist. Two clear sentences beat both a cryptic one-liner and a six-line essay.
2323

2424
Test docstrings get slightly more latitude (explaining a non-obvious scenario the test pins), but the same rules apply — no incident/scope/task narration.

.claude/skills/erigondb-sync-integration-test-plan/SKILL.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ All scenarios use `--prune.mode=archive`.
5151
```bash
5252
cat <clone-path>/snapshots/erigondb.toml
5353
```
54-
Expected: `step_size = 1562500`
54+
Expected: `step_size = 1562500` and `references_in_commitment_branches = true`
5555
6. Kill the process and clean up the ephemeral datadir.
5656

5757
## Scenario B: Fresh sync with downloader
@@ -102,16 +102,34 @@ All scenarios use `--prune.mode=archive`.
102102
```bash
103103
cat <empty-path>/snapshots/erigondb.toml
104104
```
105-
Expected: `step_size = 1562500` (code defaults, since no downloader to provide network settings)
105+
Expected: `step_size = 1562500` and `references_in_commitment_branches = true` (code defaults, since no downloader to provide network settings)
106106
5. Kill the process and clean up the ephemeral datadir.
107107

108108
## Success Criteria
109109

110-
| Scenario | Condition | Expected step_size | File timing |
111-
|----------|-----------|-------------------|-------------|
112-
| A (legacy) | `Creating erigondb.toml with LEGACY settings` log | 1,562,500 | Written immediately on startup |
113-
| B (fresh+downloader) | `erigondb.toml not found, using defaults` then `erigondb stepSize changed, propagating` | Code default 1,562,500 then network value (chain-dependent) | After downloader delivers it |
114-
| C (fresh+no-downloader) | `Initializing erigondb.toml with DEFAULT settings (nodownloader)` log | 1,562,500 | Written immediately on startup |
110+
| Scenario | Condition | Expected step_size | Expected references_in_commitment_branches | File timing |
111+
|----------|-----------|-------------------|--------------------------------------------|-------------|
112+
| A (legacy) | `Creating erigondb.toml with LEGACY settings` log | 1,562,500 | `true` (written explicitly) | Written immediately on startup |
113+
| B (fresh+downloader) | `erigondb.toml not found, using defaults` then `erigondb stepSize changed, propagating` | Code default 1,562,500 then network value (chain-dependent) | Resolves to `true` in memory until the downloader delivers the file; whatever the network publishes thereafter (a producer-published plain snapshot set ships `false`) | After downloader delivers it |
114+
| C (fresh+no-downloader) | `Initializing erigondb.toml with DEFAULT settings (nodownloader)` log | 1,562,500 | `true` (written explicitly) | Written immediately on startup |
115+
116+
### references_in_commitment_branches per scenario
117+
118+
The `references_in_commitment_branches` field governs whether new commitment merges write referenced (short-key) `.kv` files. It resolves identically to `step_size` across the three scenarios — absent field normalizes to `true` in memory, and a downloaded `erigondb.toml` is never rewritten (it is synced snapshot metadata, so a producer's published `false` survives). The resolution logic is unit-tested in `db/state/erigondb_settings_test.go` (`TestResolveErigonDBSettings*`); these runtime scenarios confirm the same behavior end-to-end.
119+
120+
- **A (legacy):** the generated file contains `references_in_commitment_branches = true`.
121+
- **B (fresh+downloader):** no file until the downloader delivers it; the in-memory resolved value is `true`. After delivery the field reflects the network's published value (a plain-snapshot producer ships `false`).
122+
- **C (fresh+no-downloader):** the immediately-written file contains `references_in_commitment_branches = true`.
123+
124+
## Producer workflow: publishing plain (unreferenced) snapshots
125+
126+
`references_in_commitment_branches` governs only *new* commitment merges; reads are version-aware and stay correct regardless of the flag (a `v2.0` commitment `.kv` whose range ≥ threshold is referenced/short-key; a `v2.1` file is plain). To publish a snapshot set whose commitment files carry no plain-key references:
127+
128+
1. In the producer datadir's `snapshots/erigondb.toml`, set `references_in_commitment_branches = false` **before** running merges.
129+
2. Run the node / merge so commitment merges produce plain `v2.2` `.kv` files. Existing `v2.1` referenced files convert to plain lazily as they are merged — no upfront migration.
130+
3. Ship the datadir's `erigondb.toml` with the snapshot set. Consumers read the file and inherit `false`; a downloaded `erigondb.toml` is never rewritten, so the producer's `false` survives.
131+
132+
This supersedes the build-time const flip (`awskii/36exp`): no binary divergence and no CLI flag. Default nodes (field absent → `true`) keep writing byte-compatible `v2.1` referenced files with no behavior change.
115133

116134
## Cleanup
117135

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
* @AskAlexSharov @yperbasis
22
/.github/workflows @mriccobene @lystopad
3-
/cl/ @domiwei @Giulio2002
3+
/cl/ @domiwei @Giulio2002 @sudeepdino008
44
/db/ @AskAlexSharov @sudeepdino008
55
/docs/ @bloxster @AskAlexSharov @yperbasis
66
/execution/ @yperbasis @mh0lt

.github/workflows/ci-gate.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: CI Gate
22

33
on:
44
pull_request:
5-
branches:
6-
- main
7-
- 'release/**'
8-
- performance
9-
- performance-stable
105
types:
116
- opened
127
- reopened
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
2-
RPC_VERSION=fix_expected_bn_as_hex_string
1+
RPC_VERSION=v2.21.0

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ Aligns Erigon with the `eth_simulateV1` error code specification ([NethermindEth
3636

3737
- If your tooling matches on error code `-32602` to detect base-fee-too-low conditions in `eth_simulateV1` responses, update it to match `-38012` instead.
3838

39+
### Added
40+
41+
#### CLI & Operations
42+
43+
- `--prune.distance.blocks` now accepts readable policy names — `keep-post-merge` and `keep-all` — instead of the raw `MaxUint64`-based magic numbers (`18446744073709551615` / `18446744073709551614`); `--prune.distance` likewise accepts `keep-all`. Numeric values still work (#22119) — by @yperbasis
44+
3945
---
4046

4147
# Erigon v3.5.0 — Tidal Tails — 2026-06-26

agents.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ A comment may be warranted for: a non-obvious invariant the types don't enforce;
132132

133133
When a comment is genuinely required, it MUST be:
134134

135-
- **One sentence; rarely two; never a paragraph.** No bulleted lists inside `//`. No multi-section block comments with `// Concurrency:` / `// Why:` / `// How to apply:` sub-headings. If the explanation doesn't fit in two sentences, the rest belongs in the commit message, the PR description, or a design doc — not in source, where it goes stale.
135+
- **Concise, but err on the side of clarity.** Most comments fit in a sentence or two; keep an extra sentence when cutting it would cost understanding, and cut it when it only adds length — two clear sentences beat both a cryptic one-liner and a six-line essay. An explanation that needs sub-headings (`// Concurrency:` / `// Why:`) or bullet lists to stay organized has outgrown source: put the full story in the commit message, the PR description, or a design doc, and keep the distilled why in the code.
136136
- **High-level, not scenario-specific.** Explain the invariant or gotcha in general terms. Don't walk through specific call sites, sequences of operations, or particular situations a reader could find with `grep`. The right level of abstraction is "what must remain true," not "what happened to me last Tuesday."
137137
- **Free of forensic detail.** Strip dates (`// found on 2026-05-21`), devnet/branch names (`// seen on bal-devnet-7`), PR/issue/review references (`// flagged in #21314 round-4 review`), incident anecdotes, and "used by X, Y, Z" callsite lists. That history belongs in the commit message and PR description, where it survives intact; in source it rots, misleads later readers, and bloats the file.
138138
- **Not a restatement of the code.** If a reader could delete the comment without losing information, delete it. Standard Go idioms and well-known library behavior don't need annotation.
@@ -168,7 +168,7 @@ Function docstrings follow the same rule: a one-line summary, plus param/return
168168

169169
`// TODO` notes are only acceptable with a linked tracking issue and an owner. Better: file the issue and don't add the TODO; or fix it now.
170170

171-
**For automated agents specifically:** previous iterations of this guidance were not enough — agents kept producing multi-paragraph block comments enumerating call sites and incident history. Treat the rules above as hard limits. If you catch yourself writing a third sentence in a comment, stop and either delete it, condense to one sentence, or move the content into the commit message.
171+
**For automated agents specifically:** previous iterations of this guidance were not enough — agents kept producing multi-paragraph block comments enumerating call sites and incident history. The forensic-detail and scenario rules above are hard limits; length is a judgment call with clarity as the tiebreaker. When a comment grows, look at what the growth is made of: call-site inventories and incident history move to the commit message; a sentence that saves the reader a wrong guess stays.
172172

173173
## Pull Requests & Workflows
174174

cmd/commitment-regime/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# commitment-regime
2+
3+
Reports whether a commitment domain `.kv` file stores **plain** full keys or
4+
**referenced** (shortened file-offset) keys in its branch values.
5+
6+
It reads every key/value pair in order and stops at the first branch that
7+
carries a shortened key:
8+
9+
- `referenced` — at least one shortened key found (prints the pair index where).
10+
- `plain` — every pair scanned, all keys are full account (20B) / storage (52B) keys.
11+
12+
A malformed branch or corrupt word stream is reported conservatively as
13+
`referenced`. Files are opened read-only, so a running node need not be stopped.
14+
15+
## Run
16+
17+
```sh
18+
go run ./cmd/commitment-regime <path/to/vX.Y-commitment.A-B.kv> [more.kv ...]
19+
```
20+
21+
or build once and point it at a datadir:
22+
23+
```sh
24+
go build -o /tmp/commitment-regime ./cmd/commitment-regime
25+
/tmp/commitment-regime <datadir>/snapshots/domain/*commitment*.kv
26+
```
27+
28+
Example output:
29+
30+
```
31+
v1.1-commitment.0-512.kv referenced (first shortened key at pair 4 of 4)
32+
v2.1-commitment.576-640.kv plain (scanned all 57763381 pairs)
33+
```

cmd/commitment-regime/main.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Command commitment-regime classifies a commitment .kv file as plain or referenced
2+
// (shortened keys). Temporary diagnostic tooling as-is — remove once the regime work
3+
// settles, or promote into cmd/integration.
4+
package main
5+
6+
import (
7+
"bytes"
8+
"fmt"
9+
"os"
10+
"path/filepath"
11+
12+
"github.com/erigontech/erigon/db/seg"
13+
"github.com/erigontech/erigon/execution/commitment"
14+
"github.com/erigontech/erigon/execution/commitment/commitmentdb"
15+
)
16+
17+
// scan reads every key/value pair greedily and stops at the first branch that
18+
// carries a shortened key. referenced=true means at least one shortened key was
19+
// found; firstAt is the 1-based pair index where it was found.
20+
func scan(path string) (referenced bool, firstAt, pairs uint64, err error) {
21+
d, derr := seg.NewDecompressor(path)
22+
if derr != nil {
23+
return false, 0, 0, derr
24+
}
25+
defer d.Close()
26+
27+
defer func() {
28+
if rec := recover(); rec != nil {
29+
referenced, err = true, fmt.Errorf("corrupt word stream: %v", rec)
30+
}
31+
}()
32+
33+
r := seg.NewReader(d.MakeGetter(), seg.CompressKeys)
34+
var keyBuf, valBuf []byte
35+
for r.HasNext() {
36+
keyBuf, _ = r.Next(keyBuf[:0])
37+
if !r.HasNext() {
38+
break
39+
}
40+
valBuf, _ = r.Next(valBuf[:0])
41+
pairs++
42+
if bytes.Equal(keyBuf, commitmentdb.KeyCommitmentState) {
43+
continue
44+
}
45+
if commitment.BranchData(valBuf).HasShortenedKeys() {
46+
return true, pairs, pairs, nil
47+
}
48+
}
49+
return false, 0, pairs, nil
50+
}
51+
52+
func main() {
53+
if len(os.Args) < 2 {
54+
fmt.Fprintln(os.Stderr, "usage: commitment-regime <commitment.kv> [more.kv ...]")
55+
os.Exit(2)
56+
}
57+
for _, path := range os.Args[1:] {
58+
referenced, firstAt, pairs, err := scan(path)
59+
name := filepath.Base(path)
60+
switch {
61+
case err != nil && referenced:
62+
fmt.Printf("%-40s referenced (%v, scanned %d)\n", name, err, pairs)
63+
case err != nil:
64+
fmt.Printf("%-40s ERROR %v\n", name, err)
65+
case referenced:
66+
fmt.Printf("%-40s referenced (first shortened key at pair %d of %d)\n", name, firstAt, pairs)
67+
default:
68+
fmt.Printf("%-40s plain (scanned all %d pairs)\n", name, pairs)
69+
}
70+
}
71+
}

cmd/integration/commands/commitment.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func commitmentRebuild(db kv.TemporalRwDB, ctx context.Context, logger log.Logge
394394
}
395395

396396
blockSnapBuildSema := semaphore.NewWeighted(int64(runtime.NumCPU()))
397-
agg.ForTestReplaceKeysInValues(kv.CommitmentDomain, false)
397+
agg.ForTestReferencesInCommitmentBranches(kv.CommitmentDomain, false)
398398
agg.SetSnapshotBuildSema(blockSnapBuildSema)
399399
agg.SetErigondbDomainStepsInFrozenFile(config3.UnboundedDomainMerge)
400400
agg.PresetOfflineMerge()
@@ -557,14 +557,6 @@ func commitmentConvert(db kv.TemporalRwDB, ctx context.Context, logger log.Logge
557557
agg.SetSnapshotBuildSema(semaphore.NewWeighted(int64(runtime.NumCPU())))
558558
agg.DisableAllDependencies()
559559
defer agg.MadvNormal().DisableReadAhead()
560-
// commitmentValTransformDomain (the squeeze path's value transformer)
561-
// short-circuits to pass-through when the live runtime flag is false.
562-
// Force-enable it for the duration of the converter run so --squeeze=true
563-
// works regardless of the operator's current schema config. Matches the
564-
// pattern in RebuildCommitmentFiles / RebuildCommitmentFilesWithHistory.
565-
if opts.TargetSqueeze {
566-
agg.ForTestReplaceKeysInValues(kv.CommitmentDomain, true)
567-
}
568560

569561
acRo := agg.BeginFilesRo()
570562
defer acRo.Close()

0 commit comments

Comments
 (0)