Issue Details
- Number
- 31512
- Title
- validation: CheckBlockIndex can fail in combination with pruning
- Description
- Found this situation while fuzzing validation / `CheckBlockIndex()`:
1) Full block C (child) is received, so `nTx`, but not `m_chain_tx_count` will be set because we only know the header of the previous block P (parent).
2) Block C gets pruned
3) We request / receive full data for parent P.
4) Error in `CheckBlockIndex()` - multiple checks in `CheckBlockIndex()` fail, for example we expect `m_chain_tx_count` to be set for C.
There is a simple functional test to trigger this in https://github.com/mzumsande/bitcoin/commit/b75577544c8f9e7e2b90d269de2a6d9bec438433.
This is mostly a theoretical issue:
- we don't usually request parents of already pruned blocks like in step 3, unless we do `getblockfrompeer` or similar - so it can't be triggered remotely
- also, situations where we have full data for a child block but no data for the parent tend to not persist for long.
- `CheckBlockIndex` is not active by default on mainnet
However I think it's good to understand the possible constellations in validation in depth and formulate our expectations (i.e. `CheckBlockIndex`) accordingly.
- URL
-
https://github.com/bitcoin/bitcoin/issue/31512
- Closed by
-
Back to List