This proof-of-concept is based on my old proposal for a replacement to getblocktemplate: https://docs.google.com/document/d/10YVLdltuppEoizAVoovPTOZbqthbsa2t0MXHhaDo4bI/edit
Quick summary of the rationale:
getblocktemplate passes the entire block (including all transactions) to the mining software and
when a block is solved, the mining software passes that entire block back to the node via submitblock.
This cross-talk is unnecessary since the node typically dictates the contents and ordering of transactions.
As block sizes increase, this becomes a scaling bottleneck and actually poses risks to miners by delaying
block validation and propagation.
This patch introduces a working portion of submitblocksolution along with introducing a bare-bones
BlockTemplateManager class. While there remains a lot of work to be done, this patch gives a hint to
how mining with the new templating system may be done in the future:
- Miners call (a not yet implemented version of) getblocktemplate and receive a template ID along with some other fields. Among these fields is a merkle proof so that the merkleroot maybe determined.
- When a solution is found, the mining software passes the template ID and some modified fields back to the node software via submitblocksolution.
This process is intended to be similar to current mining processes in order for integration to be easy,
though some changes to the mining software will be necessary. You'll note in the tests that the current
getblocktemplate is still used in step 1 described above, demonstrating how similar they are.
The BlockTemplateManager class leaves even more to be desired. It currently stores nothing but the most
recent block template for testing purposes. In the future, it should be able to:
- Track template IDs
- Store multiple block templates
- Maintain the memory for those templates in a sane way, ideally through some mechanism for snapshotting the mempool
The API is not fully fleshed out. The current iteration was chosen as a compromise between where the API design is
heading and maintaining compatibility with the current getblocktemplate implementation.