-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip out all merkleeyes-related code
- Loading branch information
Showing
52 changed files
with
43 additions
and
1,630 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Tendermint MerkleEyes | ||
Tendermint iavl | ||
Copyright (C) 2015 Tendermint | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
writing down, my checksum | ||
waiting for the, data to come | ||
no need to pray for integrity | ||
thats cuz I use, a merkle tree | ||
|
||
grab the root, with a quick hash run | ||
if the hash works out, | ||
it must have been done | ||
|
||
theres no need, for trust to arise | ||
thanks to the crypto | ||
now that I can merkleyes | ||
|
||
take that data, merklize | ||
ye, I merklize ... | ||
|
||
then the truth, begins to shine | ||
the inverse of a hash, you will never find | ||
and as I watch, the dataset grow | ||
producing a proof, is never slow | ||
|
||
Where do I find, the will to hash | ||
How do I teach it? | ||
It doesn't pay in cash | ||
Bitcoin, here, I've realized | ||
Thats what I need now, | ||
cuz real currencies merklize | ||
|
||
-EB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,13 @@ | ||
# merkleeyes | ||
## IAVL+ Tree | ||
|
||
[](https://circleci.com/gh/tendermint/merkleeyes) | ||
A snapshottable (immutable) AVL+ tree for persistent data | ||
|
||
A simple [ABCI application](http://github.com/tendermint/abci) serving a [merkle-tree key-value store](http://github.com/tendermint/merkleeyes/iavl) | ||
**Note** Please make sure you read the [caveat](https://github.com/tendermint/merkleeyes/blob/develop/iavl/iavl_tree.go#L34-L40) on `Copy`. If you have a backing DB and call `Save` to persist the state, all existing copies become potentially invalid and may panic if used. For safe coding, you must throw away all references upon save, and `Copy` again from the new, committed state. | ||
|
||
# Use | ||
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 algortihm](http://en.wikipedia.org/wiki/AVL_tree) so all operations are O(log(n)). | ||
|
||
Merkleeyes allows inserts and removes by key, and queries by key or index. | ||
Inserts and removes happen through the `DeliverTx` message, while queries happen through the `Query` message. | ||
`CheckTx` simply mirrors `DeliverTx`. | ||
Nodes of this tree are immutable and indexed by its 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). | ||
|
||
# Formatting | ||
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. | ||
|
||
## Byte arrays | ||
|
||
Byte-array `B` is serialized to `Encode(B)` as follows: | ||
|
||
``` | ||
Len(B) := Big-Endian encoded length of B | ||
Encode(B) = Len(Len(B)) | Len(B) | B | ||
``` | ||
|
||
So if `B = "eric"`, then `Encode(B) = 0x010465726963` | ||
|
||
## Transactions | ||
|
||
There are two types of transaction, each associated with a type-byte and a list of arguments: | ||
|
||
``` | ||
Set 0x01 Key, Value | ||
Remove 0x02 Key | ||
``` | ||
|
||
A transaction consists of the type-byte concatenated with the encoded arguments. | ||
|
||
For instance, to insert a key-value pair, you would submit `01 | Encode(key) | Encode(value)`. | ||
Thus, a transaction inserting the key-value pair `(eric, clapton)` would look like: | ||
|
||
``` | ||
0x010104657269630107636c6170746f6e | ||
``` | ||
|
||
|
||
Here's a session from the [abci-cli](https://tendermint.com/docs/getting-started/first-abci): | ||
|
||
``` | ||
> deliver_tx 0x010104657269630107636c6170746f6e | ||
> commit | ||
-> data: ��N��٢ek�X�!a�� | ||
-> data.hex: 978A4ED807D617D9A2651C6B0EC9588D2161C9E0 | ||
> query 0x65726963 | ||
-> height: 2 | ||
-> key: eric | ||
-> key.hex: 65726963 | ||
-> value: clapton | ||
-> value.hex: 636C6170746F6E | ||
``` | ||
|
||
# Poem | ||
|
||
``` | ||
writing down, my checksum | ||
waiting for the, data to come | ||
no need to pray for integrity | ||
thats cuz I use, a merkle tree | ||
grab the root, with a quick hash run | ||
if the hash works out, | ||
it must have been done | ||
theres no need, for trust to arise | ||
thanks to the crypto | ||
now that I can merkleyes | ||
take that data, merklize | ||
ye, I merklize ... | ||
then the truth, begins to shine | ||
the inverse of a hash, you will never find | ||
and as I watch, the dataset grow | ||
producing a proof, is never slow | ||
Where do I find, the will to hash | ||
How do I teach it? | ||
It doesn't pay in cash | ||
Bitcoin, here, I've realized | ||
Thats what I need now, | ||
cuz real currencies merklize | ||
-EB | ||
``` | ||
In Ethereum, the analog is [Patricia tries](http://en.wikipedia.org/wiki/Radix_tree). 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. |
Oops, something went wrong.