Categorygithub.com/mihongtech/iavl
modulepackage
0.0.0-20210729062709-74de68af3950
Repository: https://github.com/mihongtech/iavl.git
Documentation: pkg.go.dev

# README

IAVL+ Tree

version license API Reference codecov Lint Test Discord chat

Note: Requires Go 1.13+

A versioned, snapshottable (immutable) AVL+ tree for persistent data.

The purpose of this data structure is to provide persistent storage for key-value pairs (say to store account balances) such that a deterministic merkle root hash can be computed. The tree is balanced using a variant of the AVL algorithm so all operations are O(log(n)).

Nodes of this tree are immutable and indexed by their hash. Thus any node serves as an immutable snapshot which lets us stage uncommitted transactions from the mempool cheaply, and we can instantly roll back to the last committed state to process transactions of a newly committed block (which may not be the same set of transactions as those from the mempool).

In an AVL tree, the heights of the two child subtrees of any node differ by at most one. Whenever this condition is violated upon an update, the tree is rebalanced by creating O(log(n)) new nodes that point to unmodified nodes of the old tree. In the original AVL algorithm, inner nodes can also hold key-value pairs. The AVL+ algorithm (note the plus) modifies the AVL algorithm to keep all values on leaf nodes, while only using branch-nodes to store keys. This simplifies the algorithm while keeping the merkle hash trail short.

In Ethereum, the analog is Patricia tries. There are tradeoffs. Keys do not need to be hashed prior to insertion in IAVL+ trees, so this provides faster iteration in the key space which may benefit some applications. The logic is simpler to implement, requiring only two types of nodes -- inner nodes and leaf nodes. On the other hand, while IAVL+ trees provide a deterministic merkle root hash, it depends on the order of transactions. In practice this shouldn't be a problem, since you can efficiently encode the tree structure when serializing the tree contents.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
Package proto is a reverse proxy.
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
ColoredBytes takes in the byte that you would like to show as a string and byte and will display them in a human readable format.
No description provided by the author
DefaultOptions returns the default options for IAVL.
Returns VersionInfo with global vars filled in.
No description provided by the author
MakeNode constructs an *Node from an encoded byte slice.
No description provided by the author
NewImmutableTree creates both in-memory and persistent instances.
NewImmutableTreeWithOpts creates an ImmutableTree with the given options.
Create a []byte key format based on a single byte prefix and fixed width key segments each of whose length is specified by by the corresponding element of layout.
NewMutableTree returns a new tree with the specified cache size and datastore.
NewMutableTreeWithOpts returns a new tree with the specified options.
NewNode returns a new node from a key, value and version.
No description provided by the author
PrintTree prints the whole tree in an indented form.
rangeProofFromProto generates a RangeProof from a Protobuf RangeProof.
Repair013Orphans repairs incorrect orphan entries written by IAVL 0.13 pruning.
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Version of iavl.
Version of iavl.
ErrInvalidInputs is returned when the inputs passed to the function are invalid.
ErrInvalidProof is returned by Verify when a proof cannot be validated.
ErrInvalidRoot is returned when the root passed in does not match the proof's.
ErrNoImport is returned when calling methods on a closed importer.
ErrVersionDoesNotExist is returned if a requested version does not exist.
nolint:golint.
Version of iavl.

# Structs

IAVLAbsenceOp takes a key as its only argument If the produced root hash matches the expected hash, the proof is good.
Exporter exports nodes from an ImmutableTree.
ExportNode contains exported node data.
ImmutableTree contains the immutable tree at a given version.
Importer imports data into an empty MutableTree.
Provides a fixed-width lexicographically sortable []byte key format.
MutableTree is a persistent tree which keeps track of versions.
Node represents a node in a Tree.
Options define tree options.
No description provided by the author
No description provided by the author
No description provided by the author
IAVLValueOp takes a key and a single value as argument and produces the root hash.
VersionInfo contains useful versioning information in struct.

# Type aliases

NodeEncoder will take an id (hash, or key for leaf nodes), the depth of the node, and whether or not this is a leaf node.
PathToLeaf represents an inner path to a leaf node.