HomePhabricator

[chronik] Add a struct to compute a block merkle tree

Description

[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:

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

Details

Provenance
PiRKAuthored on Aug 1 2024, 16:01
PiRKPushed on Thu, Aug 22, 14:06
Reviewer
Restricted Project
Differential Revision
D16571: [chronik] Add a struct to compute a block merkle tree
Parents
rABC4c13a54223ae: [ecash-lib] Fix fee estimation for signatories that depend on tx outputs
Branches
Unknown
Tags
Unknown