WO-19 review — node storage redesign

Reviewer: Claude · Date: 17 October 2026 · Verdict: PASS, with four minor follow-ups (none blocking) Reviewed: public E46-Tessera, branch wo-19-storage, commit fae421c (base 2a70ba8) · builder report WO-19-REPORT.md

Scope check

  • Only src/node.cpp, include/e46/node.hpp, src/p2p.cpp changed in the source tree, plus tests, CMake and docs/P2P.md. Header/PoW, transaction, QTL, emission, Merkle, RL sources untouched. Nothing pushed or merged; local identity unchanged.

  • IndexEntry holds no coin set; State copy constructor and assignment are deleted; State next = parent.state is gone.

  • connect is exception-safe: any failure restores that block’s partial changes (catch (...) { restore(changes); }). Validation rules are carried over unchanged from the old accept_internal.

Acceptance criteria, re-run independently

#

Criterion

My result

1

Builds

dev and sanitize (-DE46_BUILD_STORAGE_TESTS=ON), 0 warnings

2

Differential

on my own fresh copy of the 274-block chain: 282 pairs, 0 differences, 0 empty, 0 errors, diffed by me file by file (not only the script’s summary). Old binary verified as clean 2a70ba8

3

Existing suites

P2P 22/22 dev and sanitize, 0 sanitizer diagnostics; datadir checks pass on both

4

Real-PoW reorgs

storage_reorg.py passes on dev and sanitize, 0 diagnostics. All 7 fixture blocks carry bits 0x1d7fffff (real target). Balances check: 2 × 35.09521485 = 70.19042970; 3 × = 105.28564455

5

Memory

RSS 11,424 → 5,792 KiB in my run; structure confirmed

6

Unchanged

fixture byte-identical to the original chain; GOLD not touched or copied

Surprise exam (tests the builder did not design)

Test

Result

Invalid branch delivered over P2P to a live daemon (A: 2 blocks; peer serves b1 → bad2 → bad3)

tried, rejected, rolled back; daemon alive; snapshot byte-identical to before; tip stays a2; log names the reason

Side block at height 1 offered to a node on the real 274-block chain

refused: “below the block-268 checkpoint”; still 274 files

kill -9 straight after a branch switch, cold restart

snapshot, getblock, balance, utxos, mempool identical to a cleanly built reference; stale control socket handled

INVENTORY of 1,000 random (unknown) IDs

12 ms, same as 2a70ba8 (hardening intact)

INVENTORY of 1,000 known confirmed txids

1 peer 14 ms; 8 peers 58 ms vs 11 ms on 2a70ba8 (see M1)

Cold start + snapshot, 274 blocks

23 ms vs 28 ms (faster)

Minor follow-ups (not blocking)

  • M1. Known-txid INVENTORY decodes a block per ID. Node::get_transaction now decodes the whole stored block (historical_block) and the P2P inventory/next-tx paths call it just to test membership. Eight peers flooding real txids: 58 ms (was 11 ms; still ~36× better than before the 15 Oct hardening). Fix: a membership-only has_transaction(txid) (index + mempool) for those checks.

  • M2. getblock <side-branch id> used to return the block; now ERR Block is not fully validated, even for a block that was valid while active (after a restart). Inherent to the design (decoding needs the branch’s coins) and documented; the message should say “side-branch block: body unavailable off the active chain”, and header fields could still be shown. No wallet or explorer path uses it.

  • M3. mark_invalid walks every stored block back toward genesis: O(blocks × height). Only runs when an invalid branch out-works the active chain, so not a practical attack; an ancestor set would make it linear.

  • M4. historical_coin takes the first indexed occurrence of a txid (front()), which can be a disconnected block. Only the spent coin’s creation height could differ; outputs are identical. Prefer the active occurrence.

Recommendation

Merge wo-19-storage into public main. M1–M4 can go in a small follow-up, M1 first (it is a few lines).