package irmin-bench

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Replayable_trace, a trace of Tezos's interactions with Irmin.

Interleaved Contexts and Commits

All the recorded operations in Tezos operate on (and create new) immutable records of type context. Most of the time, everything is linear (i.e. the input context to an operation is the latest output context), but there sometimes are several parallel chains of contexts, where all but one will end up being discarded.

Similarly to contexts, commits are not always linear, i.e. a checkout may choose a parent that is not the latest commit.

To solve this conundrum when replaying the trace, we need to remember all the context_id -> tree and trace commit hash -> real commit hash pairs to make sure an operation is operating on the right parent.

In the trace, the context indices and the commit hashes are 'scoped', meaning that they are tagged with a boolean information indicating if this is the very last occurence of that value in the trace. This way we can discard a recorded pair as soon as possible.

In practice, there is only 1 context and 1 commit in history, and sometimes 0 or 2, but the code is ready for more.

module V0 : sig ... end
module Latest = V0
include module type of struct include Latest end
val version : int
type header = unit
val header_t : unit Repr.t
type 'a scope = 'a V0.scope =
  1. | Forget of 'a
  2. | Keep of 'a
val scope_t : 'a Repr.t -> 'a scope Repr.t
type key = string list
val key_t : string list Repr.t
type hash = string
val hash_t : string Repr.t
type message = string
val message_t : string Repr.t
type context_id = int64
val context_id_t : int64 Repr.t
type add = V0.add = {
  1. key : key;
  2. value : string;
  3. in_ctx_id : context_id scope;
  4. out_ctx_id : context_id scope;
}
val add_t : add Repr.t
type copy = V0.copy = {
  1. key_src : key;
  2. key_dst : key;
  3. in_ctx_id : context_id scope;
  4. out_ctx_id : context_id scope;
}
val copy_t : copy Repr.t
type commit = V0.commit = {
  1. hash : hash scope;
  2. date : int64;
  3. message : message;
  4. parents : hash scope list;
  5. in_ctx_id : context_id scope;
}
val commit_t : commit Repr.t
type row = V0.row =
  1. | Checkout of hash scope * context_id scope
  2. | Add of add
  3. | Remove of key * context_id scope * context_id scope
  4. | Copy of copy
  5. | Find of key * bool * context_id scope
  6. | Mem of key * bool * context_id scope
  7. | Mem_tree of key * bool * context_id scope
  8. | Commit of commit
val row_t : row Repr.t
include sig ... end
val decode_i32 : int32 Repr.decode_bin
val encode_i32 : int32 Repr.encode_bin
val encode_lheader : unit Repr.encode_bin
val encode_lrow : V0.row Repr.encode_bin
val magic : Irmin_traces__Trace_common.Magic.t
val read_with_prefix_exn : (string -> int Stdlib.ref -> 'a) -> Stdlib.in_channel -> 'a
val decoded_seq_of_encoded_chan_with_prefixes : 'a Repr.ty -> Stdlib.in_channel -> unit -> 'a Stdlib__Seq.node
val open_reader : string -> unit * (unit -> V0.row Stdlib__Seq.node)
type writer = {
  1. path : string;
  2. channel : Stdlib.out_channel;
  3. buffer : Stdlib.Buffer.t;
}
val create_file : string -> unit -> writer
val append_row : writer -> V0.row -> unit
val flush : writer -> unit
val close : writer -> unit
val remove : writer -> unit
OCaml

Innovation. Community. Security.