Make HashDB generic (#8739)

The `patricia_trie` crate is generic over the hasher (by way of HashDB) and node encoding scheme. Adds a new `patricia_trie_ethereum` crate with concrete impls for Keccak/RLP.
This commit is contained in:
David
2018-07-02 18:50:05 +02:00
committed by GitHub
parent 202c54d423
commit 9caa868603
89 changed files with 1962 additions and 1282 deletions

View File

@@ -31,7 +31,7 @@ use ethjson;
use trace::{Tracer, NoopTracer};
use trace::{VMTracer, NoopVMTracer};
use bytes::{Bytes, BytesRef};
use trie;
use ethtrie;
use rlp::RlpStream;
use hash::keccak;
use machine::EthereumMachine as Machine;
@@ -93,7 +93,7 @@ impl<'a, T: 'a, V: 'a, B: 'a> TestExt<'a, T, V, B>
address: Address,
tracer: &'a mut T,
vm_tracer: &'a mut V,
) -> trie::Result<Self> {
) -> ethtrie::Result<Self> {
let static_call = false;
Ok(TestExt {
nonce: state.nonce(&address)?,

View File

@@ -16,8 +16,10 @@
use ethjson;
use trie::{TrieFactory, TrieSpec};
use ethtrie::RlpCodec;
use ethereum_types::H256;
use memorydb::MemoryDB;
use keccak_hasher::KeccakHasher;
use super::HookType;
@@ -28,13 +30,13 @@ pub use self::secure::run_test_file as run_secure_test_file;
fn test_trie<H: FnMut(&str, HookType)>(json: &[u8], trie: TrieSpec, start_stop_hook: &mut H) -> Vec<String> {
let tests = ethjson::trie::Test::load(json).unwrap();
let factory = TrieFactory::new(trie);
let factory = TrieFactory::<_, RlpCodec>::new(trie);
let mut result = vec![];
for (name, test) in tests.into_iter() {
start_stop_hook(&name, HookType::OnStart);
let mut memdb = MemoryDB::new();
let mut memdb = MemoryDB::<KeccakHasher>::new();
let mut root = H256::default();
let mut t = factory.create(&mut memdb, &mut root);