Meeshbhoombah / mpt

A Naive Modified Merkle Patricia Trie in ink!: Substrate’s Smart Contract Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mpt

Naive implementation of Modfied Merkle Patricia Trie.

Structure

The following ("key", "value") pairs...

("a711355", "dog")
("a77d337", "cat")
("a7f9365", "frog")
("a77d397", "bat")

Would result in:

|- "a7"
    |-"0"
    |-"1"
        |-"1355"
            |-"dog"
    |-"2"
    |-"3"
    |-"4"
    |-"5"
    |-"6"
    |-"7"
        |-"d3"
            |-"0"
            |-"1"
            |-"2"
            |-"3"
                |-"7"
                    |-"cat"
            |-"4"
            |-"5"
            |-"6"
            |-"7"
            |-"8"
            |-"9"
                |-"7"
                    |-"bat"
            |-"a"jj
            |-"b"
            |-"c"
            |-"d"
            |-"e"
            |-"f"
            |-"value"
    |-"8"
    |-"9"
    |-"a"
    |-"b"
    |-"c"
    |-"d"
    |-"e"
    |-"f"
        |-"9365"
    |-"value"

  1. Create a Trie
  2. Insert a key
  3. Get a value with the key
  4. Remove a value at key

Constraints

  • Strings only
  • One Trie per smart contract
  • No encoding
  • Ink

References

  1. Ethereum Wiki: Patricia Trie
  2. Ethereum Yellowpaper: Appendix D
  3. Nevous System's Clojure EVM
  4. Ethereum Wiki: RLP
  5. Vitalik Buterin's Merkling in Ethereum

Implementations

  1. go-ethereum
  2. begmaroman's
  3. ebuchman's

About

A Naive Modified Merkle Patricia Trie in ink!: Substrate’s Smart Contract Language

License:MIT License


Languages

Language:Rust 86.7%Language:Shell 13.3%