Sharding Bitcoin Cash
How ordering transactions by hash could let a Bitcoin Cash node assemble blocks and check pending transactions across several workers.
Read the original at Bitcoin ABCThis illustrated adaptation revisits a 2018 design proposal. The problem was how to divide work inside a node so more CPU cores could help with larger blocks. Sharding gives each worker a portion of the data to process and defines where those workers still need to coordinate.
Give each worker a stable range
In a dependency-ordered block, a transaction that spends an output created in that block comes after the transaction that creates it. That order can interleave transactions from many hash ranges. A worker assigned one range can therefore have trouble building a complete section of the block’s hash tree on its own.
The proposal uses canonical ordering by transaction hash for the ordinary transactions. That gives every worker the same rule for which transactions belong together. Each worker can hash its range in parallel. A block assembler then combines the results and incorporates the coinbase hash, which represents the transaction that pays the miner.
Route pending transactions the same way
The mempool holds transactions waiting to be included in a block. A router can send each incoming transaction to the mempool worker responsible for its hash range. The worker checks that the outputs being spent exist and are available. Those checks can require a pending parent held by another worker or a lookup in the unspent transaction output (UTXO) database.
A block request processor could ask those workers for the range hashes it needs to build the transaction subtree. The design gives workers independent hashing work while preserving coordination for dependencies and spend checks.
Why the ordering change came first
The 2018 proposal argued for changing the consensus ordering ahead of building the sharded node. During the transition, Bitcoin ABC expected an extra sorting step to cost some time when building block templates. The proposed speedup depended on new node software, so the original article presented the architecture before production performance was available to measure.