Closed mohanson closed 5 years ago
[dependencies]
cita_trie = { path = "/src/cita-trie" }
hex = "*"
# parity_ethereum = { path = "/src/parity-ethereum" }
patricia-trie = "0.3.0"
patricia-trie-ethereum = { path = "/src/parity-ethereum/util/patricia-trie-ethereum" }
memorydb = "*"
ethereum-types = "*"
keccak-hasher = { path = "/src/parity-ethereum/util/keccak-hasher" }
kvdb = "0.1"
Full tests should be added. See: https://github.com/ethereum/tests/blob/develop/TrieTests
I will push a PR contains the tests in the near future.
CITA-trie
uses sha3 by default, and Keccak results are different.
OK.
I have switched to keccak and take a full test, assert failed at: https://github.com/ethereum/tests/blob/develop/TrieTests/trieanyorder.json#L8
and paniced at https://github.com/ethereum/tests/blob/develop/TrieTests/trietest.json#L97.
thread 'main' panicked at 'index out of bounds: the len is 16 but the index is 16', C:\src\cita-trie\src\node.rs:71:10
note: Run with `RUST_BACKTRACE=1` for a backtrace.
The hash algorithm used by this branch https://github.com/cryptape/cita-trie/tree/keccak has been modified to keccak and full test have been added(tests will fail at now).
I have switched to keccak and take a full test, assert failed at: https://github.com/ethereum/tests/blob/develop/TrieTests/trieanyorder.json#L8
and paniced at https://github.com/ethereum/tests/blob/develop/TrieTests/trietest.json#L97.
thread 'main' panicked at 'index out of bounds: the len is 16 but the index is 16', C:\src\cita-trie\src\node.rs:71:10 note: Run with `RUST_BACKTRACE=1` for a backtrace.
Found some implementation bugs:
ExtentionNode(shared_nibbles, LeafNode(prefix, value))
, the encode method now is RLP([HP(shared_nibbles), RLP([HP(prefix), value])])
, which should be RLP([HP(shared_nibbles), [HP(prefix), value]])
delete_at
method does not reformat the trie when needed. For example, after the deletion, if a branch node only have one branch, the node should be deleted.I fixed 1 and still working on 2.
When get the root hash from an empty trie, cita-trie might returns the wrong hash. See codes bellows:
The hash gives by parity equals with go-Ethereum: https://github.com/ethereum/go-ethereum/blob/master/trie/trie.go#L32, so I thought there are some bugs in cita-trie.