Block processing fails with `error.UnknownSourceBlock` after node restart
- Dominant language
- Zig
- Stars
- 97
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
On a devnet we ran, Zeam restarted due to #698. After the node restarted, all processed blocks fail with `error.UnknownSourceBlock`.
The image was from commit: [`b0a28e0456003df152c2594992021108e4c0fa41`](https://github.com/blockblaz/zeam/commit/b0a28e0456003df152c2594992021108e4c0fa41) (tag `v0.4.8`, released as `devnet4`).
Looking at the code, it seems like it's caused by the proto-array not containing pre-finalized blocks at startup:
https://github.com/blockblaz/zeam/blob/b0a28e0456003df152c2594992021108e4c0fa41/pkgs/node/src/forkchoice.zig#L327-L390
`ForkChoice.init` is called with the anchor state recovered from RocksDB (the latest-finalized state). It builds a single `anchor_block` from the anchor state's header and calls `ProtoArray.init(allocator, anchor_block)`, so the proto-array contains exactly **one** node: the just-finalized block. Pre-finalized ancestors are present in RocksDB (`DbFinalizedSlotsNamespace`) but never rehydrated into the fork-choice tree.
This causes attestation validation to fail:
https://github.com/blockblaz/zeam/blob/b0a28e0456003df152c2594992021108e4c0fa41/pkgs/node/src/chain.zig#L1439-L1444
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at ForkChoice.init in pkgs/node/src/forkchoice.zig and trace how the anchor state is used to initialize the proto-array. Then inspect DbFinalizedSlotsNamespace and the attestation validation path in pkgs/node/src/chain.zig; done means a restarted node can process blocks without error.UnknownSourceBlock.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- zig
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100