Module grin_chain::txhashset

source ·
Expand description

Utility structs to handle the 3 hashtrees (output, range proof, kernel) more conveniently and transactionally.

Structs§

  • The “bitmap accumulator” allows us to commit to a specific bitmap by splitting it into fragments and inserting these fragments into an MMR to produce an overall root hash. Leaves in the MMR are fragments of the bitmap consisting of 1024 contiguous bits from the overall bitmap. The first (leftmost) leaf in the MMR represents the first 1024 bits of the bitmap, the next leaf is the next 1024 bits of the bitmap etc.
  • A bitmap “chunk” representing 1024 contiguous bits of the overall bitmap. The first 1024 bits belong in one chunk. The next 1024 bits in the next chunk, etc.
  • Desegmenter for rebuilding a txhashset from PIBD segments
  • Allows the application of new blocks on top of the txhashset in a reversible manner within a unit of work provided by the extending function.
  • An extension “pair” consisting of a txhashet extension (outputs, rangeproofs, kernels) and the associated header extension.
  • A header extension to allow the header MMR to extend beyond the other MMRs individually. This is to allow headers to be validated against the MMR before we have the full block data.
  • Convenience wrapper around a single prunable MMR backend.
  • Rewindable (but readonly) view of the kernel set (based on kernel MMR).
  • Segmenter for generating PIBD segments.
  • An easy to manipulate structure holding the 3 MMRs necessary to validate blocks and capturing the output set, associated rangeproofs and the kernels. Also handles the index of Commitments to positions in the output and rangeproof MMRs.
  • Readonly view of the UTXO set (based on output MMR).

Functions§

  • Clean the txhashset folder
  • Starts a new unit of work to extend the chain with additional blocks, accepting a closure that will work within that unit of work. The closure has access to an Extension object that allows the addition of blocks to the txhashset and the checking of the current tree roots.
  • Starts a new unit of work to extend (or rewind) the chain with additional blocks. Accepts a closure that will operate within that unit of work. The closure has access to an Extension object that allows the addition of blocks to the txhashset and the checking of the current tree roots.
  • Start a new header MMR unit of work. This MMR can be extended individually beyond the other (output, rangeproof and kernel) MMRs to allow headers to be validated before we receive the full block data.
  • Start a new readonly header MMR extension. This MMR can be extended individually beyond the other (output, rangeproof and kernel) MMRs to allow headers to be validated before we receive the full block data.
  • Rewindable (but still readonly) view on the kernel MMR. The underlying backend is readonly. But we permit the PMMR to be “rewound” via size. We create a new db batch for this view and discard it (rollback) when we are done with the view.
  • Overwrite txhashset folders in “to” folder with “from” folder
  • Readonly view on the UTXO set. Based on the current txhashset output_pmmr.
  • Packages the txhashset data files into a zip and returns a Read to the resulting file
  • Extract the txhashset data from a zip file and writes the content into the txhashset storage dir