项目作者: tafia

项目描述 :
An implementation of a (merkle)patricia-trie
高级语言: Rust
项目地址: git://github.com/tafia/quick-patricia-trie.git
创建时间: 2018-09-06T01:58:33Z
项目社区:https://github.com/tafia/quick-patricia-trie

开源协议:

下载


quick-patricia-trie

A toy implementation of a patricia tree as used in ethereum.

The implementation is strongly inspired by parity patricia-trie.

Key difference

This is a total reimplementation from scratch so there are numerous differences.

The major ones are:

  • much less generic: everything is a &[u8] at some point. The only requirements is for
    the key/value being AsRef[u8]>.
  • use of Arena, a struct in charge of allocating all data. As a result, there is
    no need to use elastic-array or some other fixed array based crates. Everything is
    eventually stored in a unique Vec, all references are instead indexes that we can freely
    copy and lookups are thus very fast.
  • there is no backend database yet. While it will probably be done in the future, I wanted
    to implement the core idea of the Merkle Patricia Trie as defined in the ethereum doc
    and benchmark it against the parity one based on memory-db.
  • it is probably lacking many more features I are so far unecessary (like the iterator seek)

Benchmarks

So far results are promising. There is a criterion crate which tries to run the same
benches as written in the original parity crates.

Trie insertion mirror 1k

trie_insertion_mir_1k

Trie insertion random 1k

trie_insertion_mir_1k

Trie insertion six high

trie_insertion_six_high

Trie insertion six mid

trie_insertion_six_mid

Trie insertion random mid

trie_insertion_random_mid

Iterator

iter