[chronik] Add a struct to compute a block merkle tree
Summary:
Block merkle trees are used by Electrum ABC and fulcrum for computing checkpoint data and the data needed to verify that an earlier block is part of the same chain as the checkpointed block.
The merkle root is computed the same way as the merkle root for transactions in a block, except that we use the ordered block hashes in the blockchain instead of the ordered transaction hashes in a block.
As a result, it is possible to reuse intermediate hashes from the merkle tree for a block to compute the merkle tree for other blocks, which improves the performance at the cost of some reasonable amount of memory (approximately 60 MB for a 1,000,000 blocks long chain).
This checkpoint data will optionally be returned by the block-header and block-headers endpoints. See:
- D16569
- https://electrum-cash-protocol.readthedocs.io/en/latest/protocol-methods.html#blockchain-block-header
Test Plan: ninja check-crates
Reviewers: #bitcoin_abc, tobias_ruck
Reviewed By: #bitcoin_abc, tobias_ruck
Subscribers: Fabien, tobias_ruck
Differential Revision: https://reviews.bitcoinabc.org/D16571