package irmin-containers
Library
Module
Module type
Parameter
Class
Class type
Proofs are compact representations of Irmin trees
which can be shared between an Irmin node and a client.
The protocol is the following:
- The Irmin node runs a function
f
over a treet
. While performing this computation, the node records: the hash oft
(calledbefore
below), the hash off t
(calledafter
below) and a subset oft
which is needed to replayf
without any access to the node's storage. Once done, the node packs this into a proofp
and sends this to the client.
- The client generates an initial tree
t'
fromp
and computesf t'
. Once done, it comparest'
's hash andf t'
's hash tobefore
andafter
. If they match, they know that the result statef t'
is a valid state of Irmin, without having to have access to the full node's storage.
The type for (internal) inode proofs.
These proofs encode large directories into a more efficient tree-like structure.
Invariant are dependent on the backend.
length
is the total number of entries in the chidren of the inode. E.g. the size of the "flattened" version of that inode. This is used by some backend (like irmin-pack
) to efficiently implements paginated lists and an optimized lenght
function.
For irmin-pack
: proofs
have a length of at most Conf.entries
entries. This list can be sparse so every proof is indexed by their position between 0 ... (Conf.entries-1)
. For binary trees, this boolean index is a step of the left-right sequence / decision proof corresponding to the path in that binary tree.
val inode_t : 'a Irmin.Type.t -> 'a inode Irmin.Type.t
The type for inode extenders.
val inode_extender_t : 'a Irmin.Type.t -> 'a inode_extender Irmin.Type.t
type tree =
| Contents of contents * metadata
| Blinded_contents of hash * metadata
| Node of (step * tree) list
| Blinded_node of hash
| Inode of inode_tree inode
| Extender of inode_tree inode_extender
The type for compressed and partial Merkle tree proofs.
Tree proofs do not provide any guarantee with the ordering of computations. For instance, if two effects commute, they won't be distinguishable by this kind of proofs.
Blinded_node h
is a shallow pointer to a node having hash h
.
Node ls
is a "flat" node containing the list of files ls
. The length of ls
depends on the backend. For instance, it can be unbounded for most of the backends, while it is at most Conf.stable_hash
entries for irmin-pack
.
Inode i
is an optimized representation of a node as a tree. Pointers in that trees would refer to blinded nodes, nodes or to other inodes. E.g. Blinded content nor contents is not expected to appear directly in an inodes.
Blinded_contents (h, m)
is a shallow pointer to contents having hash h
and metadata m
.
Contents c
is the contents c
.
and inode_tree =
| Blinded_inode of hash
| Inode_values of (step * tree) list
| Inode_tree of inode_tree inode
| Inode_extender of inode_tree inode_extender
val tree_t : tree Irmin.Type.t
val inode_tree_t : inode_tree Irmin.Type.t
val kinded_hash_t : kinded_hash Irmin.Type.t
type elt =
| Contents of contents
| Node of (step * kinded_hash) list
| Inode of hash inode
| Inode_extender of hash inode_extender
val elt_t : elt Irmin.Type.t
type stream = elt Stdlib.Seq.t
The type for stream proofs. Stream poofs provides stronger ordering guarantees as the read effects have to happen in the exact same order and they are easier to verify.
val stream_t : stream Irmin.Type.t
val t : 'a Irmin.Type.t -> 'a t Irmin.Type.t
val v : before:kinded_hash -> after:kinded_hash -> 'a -> 'a t
v ~before ~after p
proves that the state advanced from before
to after
. p
's hash is before
, and p
contains the minimal information for the computation to reach after
.
val before : 'a t -> kinded_hash
before t
it the state's hash at the beginning of the computation.
val after : 'a t -> kinded_hash
after t
is the state's hash at the end of the computation.
val state : 'a t -> 'a
proof t
is a subset of the initial state needed to prove that the proven computation could run without performing any I/O.