execution/commitment: compact the pbin branch record and convert pre-version datadirs - #23564
execution/commitment: compact the pbin branch record and convert pre-version datadirs#23564awskii wants to merge 33 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Compacts binary-trie commitment records, versions trie-state blobs, and adds an offline legacy-datadir converter.
Changes:
- Removes redundant branch headers, field lengths, and storage prefixes.
- Adds state-format validation and legacy decoding.
- Adds staged conversion with integrity checks and resume support.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
execution/commitment/pbin_witness_context.go |
Uses the new cell encoder. |
execution/commitment/pbin_verify_test.go |
Adapts verifier decoding. |
execution/commitment/pbin_unfold_test.go |
Updates record fixtures. |
execution/commitment/pbin_state.go |
Versions state blobs. |
execution/commitment/pbin_state_test.go |
Tests state versioning. |
execution/commitment/pbin_patricia_hashed.go |
Uses compact record decoding. |
execution/commitment/pbin_fold_test.go |
Tests compact folding behavior. |
execution/commitment/pbin_convert_legacy.go |
Implements legacy conversion. |
execution/commitment/pbin_convert_legacy_test.go |
Tests legacy conversion. |
execution/commitment/pbin_cell_test.go |
Expands codec validation tests. |
execution/commitment/pbin_branch.go |
Implements compact branch encoding. |
db/state/squeeze.go |
Validates rebuild state format. |
db/state/rebuild_variant_test.go |
Tests legacy-state rejection. |
db/state/rebuild_pbin_state_test.go |
Tests rebuild validation. |
db/state/commitment_convert_pbin.go |
Converts commitment shards. |
db/state/commitment_convert_pbin_test.go |
Tests conversion and recovery. |
db/state/commitment_convert_pbin_e2e_test.go |
Adds end-to-end conversion coverage. |
db/state/commitment_convert_export_test.go |
Exposes test hooks. |
db/seg/decompress.go |
Documents platform-specific field use. |
cmd/integration/Readme.md |
Documents conversion usage. |
cmd/integration/commands/flags.go |
Adds converter flags. |
cmd/integration/commands/commitment.go |
Adds the conversion command and staging. |
cmd/integration/commands/commitment_output_test.go |
Tests output staging safeguards. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
yperbasis
left a comment
There was a problem hiding this comment.
Reviewed head: 9086cc8eea61799d6c5a023a6a8b6112c866cc6b
Requesting changes for three migration correctness issues:
-
[P1] Convert the reserved root record.
convertPBinFilecopies key0x08because legacy detection only recognizes the zero-leading branch header. Legacy root cells also contain per-field lengths, so a legacy hashed root such as12 00 20 <hash>is unreadable by the new decoder, which expects12 00 <hash>. The legacy test fixture keeps this record in the current format, masking the failure. -
[P1] Migrate or reject commitment history.
linkCommitmentSnapshotshardlinks commitment history files unchanged, while conversion only rewrites domain.kvfiles. On history-enabled datadirs,GetAsOfwill return legacy pbin values to the new-only decoder. -
[P2] Keep
stateValuevalid through validation.RebuildCommitmentFilesrollsroTxback before callingvalidatePBinRebuildState(stateValue). KV read slices are valid only for the transaction lifetime. Validate before rollback or clone the value.
Also update docs/pbin-encoding.md, which still specifies the retired header and length fields.
…t record, reject commitment history
|
All three confirmed against the tree, fixed in 52c5073. Root record. Confirmed, and it had already shipped — checked the converted mainnet PBT datadir before touching anything, shard 9524-9526: Your reading of the shape is exact:
Commitment history. Confirmed. I took the reject half rather than the migrate half: stateValue past the rollback. Confirmed, validation now runs before docs/pbin-encoding.md. Rewritten — 5.2-5.6 and 7, against bytes produced by running the documented legacy records through the converter rather than re-derived by hand. Corpus sizes drop to 88 / 136 / 88 / 44 plus a 34-byte root, 5.5 keeps a |
…ommitment test, not only the pre-set one
…rocess-wide parallel-commitment default
…the scratch buffer is not shareable
…files, so the fixtures work on Windows
…ath unlinked a file it was still reading
…d commitment file
…uildFiles can return with mergeLoop still running
…ommitment-only trim rewrites files Windows has open
…che; the memo fields are not shareable
Drops the touchMap/afterMap header and the per-field lengths from every pbin branch record,
omits the prefix on storage leaves, and versions the trie state blob.
integration commitment convert-formatrewrites a pre-version datadir into a separate output datadir; the source ishardlinked in and never opened for writing.
snap-arb1, mainnet PBT datadir, 7 shards, 3,537,594,455 records, 2h37m:
commitment
.kv430,372,793,732 -> 369,063,989,152 B — 57.09 GiB, -14.2%(frozen
0-8192-14.9%; the three newest shards -22% to -24%)