user131476: I am running a full node, bitcoin core 22. It is not in pruned mode.
But when I try to run RPC getblockstats call I get this.
$ bitcoin-cli getblockstats 0                                                                   
error code: -1
error message:
Can't read undo data from disk

I don't have any error with block 1.
And I tested it in two different nodes in two different machines, and I get the same error.
Why this happens?

user48884: This occurs because the genesis block is a special block. It is not written to disk like all other blocks are. It cannot be undone so there is no undo data for it. getblockstats uses the undo data (essentially a compact representation of the UTXOs spent by the transactions in a block) to calculate many of the block stats, but because the genesis block does not have undo data, you see this error.
The error could be improved, or a special case added for the genesis block. Regardless, this error is because of how the RPC is implemented, not with your nodes.

131476: <p>I am running a full node, bitcoin core 22. It is not in pruned mode.
But when I try to run RPC <code>getblockstats</code> call I get this.</p>
<pre><code>$ bitcoin-cli getblockstats 0                                                                   
error code: -1
error message:
Can't read undo data from disk
</code></pre>
<p>I don't have any error with block 1.
And I tested it in two different nodes in two different machines, and I get the same error.</p>
<p>Why this happens?</p>
 48884: <p>This occurs because the genesis block is a special block. It is not written to disk like all other blocks are. It cannot be undone so there is no undo data for it. <code>getblockstats</code> uses the undo data (essentially a compact representation of the UTXOs spent by the transactions in a block) to calculate many of the block stats, but because the genesis block does not have undo data, you see this error.</p>
<p>The error could be improved, or a special case added for the genesis block. Regardless, this error is because of how the RPC is implemented, not with your nodes.</p>
