Do we really receive the genesis block from the p2p layer? I thought we just load it via LoadGenesisBlock()
. I just started a new node with no internet connectivity and used all the typical rpc on the genesis block (for example getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 2
) and they all worked, so it doesn’t seem like the data availability of the genesis block relies on p2p.
The scenario I described above is during pruning + manual block re-download. LoadGenesisBlock()
writes the genesis block only once to disk. It does not write it if the block index is in the chain state.
During pruning, we erase all block up to a certain point by deleting entire block files but we don’t delete the associated block index in the chain state. This means we also delete the genesis block data during the initial pruning but we keep the block index so LoadGenesisBlock()
will not re-write the genesis block to disk during next startup (you can verify this by calling getblock(genesis_hash)
in a prune node).
Now, the scenario I described: The user might decide to re-download all the prune blocks manually, by calling getblockfrompeer()
over all the chain state (including the genesis block, which as I described above, it will not be automatically re-written to disk after the initial pruning).
This will make the node recover the entire chain except for the genesis block. This is because our P2P layer ignores the genesis block when it receives it from the wire (due to the anti-DoS check, more precisely it retrieves too-little-chainwork
).
So, during any future startup, the node will have all the blocks content except for the genesis block content. Which will make the index crash internally because you are skipping the genesis block data availability check during init.