Files
zeekay 4fe6fa1c2a fix(pathdb): seed disk layer at EmptyRootHash on fresh DB
loadLayers() previously computed Keccak256Hash(nil) as the disk layer
root for an unwritten DB, producing 0xc5d2…a470 — the keccak of zero
bytes, NOT the canonical empty-trie root (0x56e81f…b421) that
core/Genesis.toBlock uses as parentRoot when committing genesis.

Consequence: layertree.add(root, parentRoot=EmptyRootHash) couldn't
find a parent in the layer tree (only Keccak256Hash(nil) was there)
and panicked with "triedb parent layer missing". Every fresh-launched
chain on this fork (lqd primary network's C-Chain, every Liquidity
local stack since the path-DB switch) failed to commit its genesis
block, leaving block 0's stateRoot pointing at an empty trie no matter
what `alloc` the genesis specified. Symptom: eth_getBalance "latest"
returned the genesis-allocation values from in-memory cache, but every
block-build saw "address has 0" and looped on BAD BLOCK.

Fix: when ReadAccountTrieNode returns nil (no persistent state yet),
short-circuit `root` to types.EmptyRootHash. Matches go-ethereum
upstream and the contract that Genesis.toBlock + layertree.add rely on.

Adds journal_freshdb_test.go with two regression tests:
  - the disk layer's root MUST be EmptyRootHash on a fresh DB
  - Update() onto EmptyRootHash parent succeeds (the genesis path)

Without this fix, any future refactor that re-introduces an
unconditional Keccak256Hash(nil) silently breaks fresh chains again.
2026-05-09 13:03:18 -07:00
..