Skip to content

WIP: Add cache mechanism for carbonated storage

YunYan requested to merge marigold/tezos:yy@carbonated-storage-cache into master

Context

This MR introduces an in-memory cache mechanism for carbonated storage on to the protocol level so that the gas consumption be reduced significantly. Please read this TZIP draft for more detail.

Space limitation

Cache has a solid limitation on space usage - 2 GB; and, a testing mode - 1 MB.

Being across blocks

To be able to make cache be persisted across blocks, it's necessary to extract the cache from the previous block for preparing a new Alpha_context. This is, however, not feasible because the cache is defined within Alpha_context and thus cannot be identified or extracted from environment context - Context.t.

The way we handle right now in this MR is, we make the Alpha_context.prepare ready for getting a cache from the previous block, but, for now, we prepare a new Alpha_context with an empty cache. The ways to go for realizing cross-blocks cache could be:

  1. The cache can be put into Block_header.
  2. Create a new structure for collecting all cross-blocks data. This structure should be returned by functions like finalize_block and be passed to the next block in tezos shell. With this design, one can easily add more information for passing across blocks.
  3. Add cache into the Contect.t so that it can be identified within the protocol environment. This also requires some extra work for lib_storage.

New dependency

This MR requires library containers (>= 3.0.0) and containers-data (>= 3.0.0) which are included in opam-repository!147 (closed).

Manually testing the MR

To run all tests:

dune build @src/proto_alpha/lib_protocol/runtest

To run tests only for cache:

dune build @src/proto_alpha/lib_protocol/runtest_proto_alpha_cache

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Provide automatic testing (see the testing guide).
  • Add item in the Development Version section of CHANGES.md (only for new features and bug fixes).

Reviewers

@galfour

Replacing: !2355 (closed)

Edited by YunYan

Merge request reports