The different actions between BinaryTrie and HexaryTrie
- Vorherrschende Sprache
- Python
- Sterne
- 111
- Forks
- 54
- Ø Merge
- 27 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
* Version: 1.1.0 or the latest commit (4b78035f0dc1314cbda3c58070ae1fe074fe08a1)
* Python: 3.6
* OS: osx
### What was wrong?
When I was trying to switch the transaction and receipt trie from `HexaryTrie` to `BinaryTrie` for `ShardingVM` (https://github.com/ethereum/py-evm/issues/331), I found that the APIs results of these two tries are slightly different in dealing *not-found-in-dict*.
`HexaryTrie` returns `BLANK_NODE`
https://github.com/ethereum/py-trie/blob/4b78035f0dc1314cbda3c58070ae1fe074fe08a1/trie/hexary.py#L69-L79
`BinaryTrie` returns `None`
https://github.com/ethereum/py-trie/blob/4b78035f0dc1314cbda3c58070ae1fe074fe08a1/trie/binary.py#L57-L86
### What did you expect it to do?
#### Code to reproduce the error
```python
from trie import (
BinaryTrie,
HexaryTrie,
)
hexary_trie = HexaryTrie(db={})
assert b'hello' not in hexary_trie
binary_trie = BinaryTrie(db={})
assert b'hello' not in binary_trie
```
result:
```
Traceback (most recent call last):
File "hello.py", line 16, in
assert b'hello' not in binary_trie
AssertionError
```
^^^^ That's false.
I replaced `None` with `BLANK_NODE` in `trie._get()` function, and then the tests in py-evm are passed.
I'm afraid that I may break `BinaryTrie`, so I wanna check with @NIC619, could I simply replace `None` with `BLANK_NODE` in `BinaryTrie._get()` function?
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.