Module tezos_smart_rollup::dac
source · Expand description
Encoding of DAC payload as a Merkle tree with an arbitrary branching factor greater or equal to 2. The serialization process works as follows:
-
A large sequence of bytes, the payload, is split into several pages of fixed size, each of which is prefixed with a small sequence of bytes (also of fixed size), which is referred to as the preamble of the page. Pages obtained directly from the original payload are referred to as
Contents pages. Contents pages constitute the leaves of the Merkle tree being built, -
Each contents page (each of which is a sequence of bytes consisting of the preamble followed by the actual contents from the original payload) is then hashed. The size of each hash is fixed. The hashes are concatenated together, and the resulting sequence of bytes is split into pages of the same size of
Hashes pages, each of which is prefixed with a preamble whose size is the same as in Contents pages. Hashes pages correspond to nodes of the Merkle tree being built, and the children of a hash page are the (either Payload or Hashes) pages whose hash appear into the former, -
Hashes pages are hashed using the same process described above, leading to a smaller list of hashes pages. To guarantee that the list of hashes pages is actually smaller than the original list of pages being hashed, we require the size of pages to be large enough to contain at least two hashes.
Merkle tree encodings of DAC pages are versioned, to allow for multiple hashing schemes to be used.
Structs
- A 32-byte hash corresponding to a preimage.
- Content page consisting of a dynamic number of bytes.
- Hash page consisting of a dynamic number of
PreimageHash. - Borrowing version of V0ContentPage.
- Borrowing version of V0HashPage.
Enums
- A Dac page: either a leaf node of contents, or node of hashes.
- A Dac Page that borrows the underlying buffer.
- Errors that may occur when dealing with SlicePage.
Constants
- Maximum size of dac pages is 4Kb.
Functions
- Fetches a page of data from file
hashintobufferusing Runtime::reveal_preimage. Returns a tuple of the raw page and remaining buffer. - Hashes
contentinto a preimage hash. - Generates the preimages of the given content.
- Recursively traverses a Merkle Tree of hashes up to
max_dac_levelsdepth where each hash corresponds to a preimage that can be revealed via Runtime::reveal_preimage. The closuresave_contentis applied on each content page found.