Giter VIP home page Giter VIP logo

elixir-merkle-patricia-tree's Issues

Readme adjustments

Readme should reflect that this repo is not Ethereum compatible and is for Aeternity blockchain. (We changed hash and maybe something else)

Also the Installation section should be adjusted.

Implement lookup in proof

In order for elixir-node to sync with epoch 0.16 we need to implement lookup's in proofs as this is necessary to implement the POI's used by epoch.

Anyone can fake a proof

The proof verification logic does not check whether the hashes are correct - It is trivial to fake a proof. I added a test demonstrating this to the GH-9 branch.

Failing test on the GH-9 branch:

  1. test Check whether we actually check the hashes ;) (MerklePatriciaTreeProofTest)
    test/proof_test.exs:67
    Assertion with == failed
    code: assert false == Proof.verify_proof(bogus_key, bogus_val, trie.root_hash(), bogus_proof)
    left: false
    right: true
    stacktrace:
    test/proof_test.exs:79: (test)

Test failed (Ethereum Common Tests, root hash)

Found by @grzegorz225

1) test Ethereum Common Tests (MerklePatriciaTreeTest)
     test/merkle_patricia_tree_test.exs:11
     Assertion with == failed
     code:  assert trie.root_hash() == test["root"] |> hex_to_binary
     left:  <<29, 106, 144, 207, 179, 208, 47, 233, 11, 118, 195, 7, 121, 115,
              10, 90, 195, 211, 88, 113, 206, 45, 251, 7, 107, 129, 67, 190, 5,
              54, 237, 167>>
     right: <<138, 173, 120, 157, 255, 47, 83, 139, 202, 93, 142, 165, 110, 138,
              190, 16, 244, 199, 186, 58, 93, 234, 149, 254, 164, 205, 110, 124,
              58, 17, 104, 211>>
     stacktrace:
       test/merkle_patricia_tree_test.exs:33: anonymous fn/3 in MerklePatriciaTreeTest."test Ethereum Common Tests"/1
       (stdlib) lists.erl:1263: :lists.foldl/3
       test/merkle_patricia_tree_test.exs:13: anonymous fn/2 in MerklePatriciaTreeTest."test Ethereum Common Tests"/1
       (stdlib) lists.erl:1263: :lists.foldl/3
       test/merkle_patricia_tree_test.exs:12: (test)

Updating key when longer key exists

Root hash is wrong when we update a key when there exists a longer key:

Steps to reproduce:

db = MerklePatriciaTree.DB.ETS.random_ets_db()
trie1 = Trie.new(db)
trie2 = Trie.new(db)
trie1 = Trie.update(trie1, "key", "oldvalue")
trie1 = Trie.update(trie1, "key_loner", "loner_key_value")
trie1 = Trie.update(trie1, "key", "newvalue")
trie2 = Trie.update(trie2, "key", "newvalue")
trie2 = Trie.update(trie2, "key_loner", "loner_key_value")
trie1.root_hash == trie2.root_hash

Result: false

Expected result: true

I added a test that fails.

Note: Ethereum tests also fail - #10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.