Remove the dependency on heapsize (#2459)

* Remove heapsize dependency

* Finish removing heapsize

* Revert accidental change

* Fix Cargo.lock
This commit is contained in:
Pierre Krieger
2019-05-04 13:59:59 +02:00
committed by Gavin Wood
parent 9fdd7df582
commit 5a820db7f5
23 changed files with 62 additions and 111 deletions
+4 -5
View File
@@ -26,7 +26,6 @@
use std::collections::HashSet;
use hash_db;
use heapsize::HeapSizeOf;
use trie;
use primitives::{H256, convert_hash};
@@ -88,7 +87,7 @@ pub fn build_proof<Header, Hasher, BlocksI, HashesI>(
where
Header: HeaderT,
Hasher: hash_db::Hasher,
Hasher::Out: Ord + HeapSizeOf,
Hasher::Out: Ord,
BlocksI: IntoIterator<Item=Header::Number>,
HashesI: IntoIterator<Item=ClientResult<Option<Header::Hash>>>,
{
@@ -120,7 +119,7 @@ pub fn check_proof<Header, Hasher>(
where
Header: HeaderT,
Hasher: hash_db::Hasher,
Hasher::Out: Ord + HeapSizeOf,
Hasher::Out: Ord,
{
do_check_proof::<Header, Hasher, _>(local_root, local_number, remote_hash, move |local_root, local_cht_key|
read_proof_check::<Hasher>(local_root, remote_proof,
@@ -137,7 +136,7 @@ pub fn check_proof_on_proving_backend<Header, Hasher>(
where
Header: HeaderT,
Hasher: hash_db::Hasher,
Hasher::Out: Ord + HeapSizeOf,
Hasher::Out: Ord,
{
do_check_proof::<Header, Hasher, _>(local_root, local_number, remote_hash, |_, local_cht_key|
read_proof_check_on_proving_backend::<Hasher>(
@@ -154,7 +153,7 @@ fn do_check_proof<Header, Hasher, F>(
where
Header: HeaderT,
Hasher: hash_db::Hasher,
Hasher::Out: Ord + HeapSizeOf,
Hasher::Out: Ord,
F: FnOnce(Hasher::Out, &[u8]) -> ClientResult<Option<Vec<u8>>>,
{
let root: Hasher::Out = convert_hash(&local_root);
+11 -12
View File
@@ -27,7 +27,6 @@ use runtime_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay};
use state_machine::backend::{Backend as StateBackend, InMemory, Consolidate};
use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId};
use hash_db::Hasher;
use heapsize::HeapSizeOf;
use trie::MemoryDB;
use consensus::well_known_cache_keys::Id as CacheKeyId;
@@ -446,7 +445,7 @@ where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
type State = InMemory<H>;
@@ -532,7 +531,7 @@ pub struct Backend<Block, H>
where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
states: RwLock<HashMap<Block::Hash, InMemory<H>>>,
changes_trie_storage: ChangesTrieStorage<H>,
@@ -543,7 +542,7 @@ impl<Block, H> Backend<Block, H>
where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
/// Create a new instance of in-mem backend.
pub fn new() -> Backend<Block, H> {
@@ -559,7 +558,7 @@ impl<Block, H> backend::AuxStore for Backend<Block, H>
where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
fn insert_aux<
'a,
@@ -580,7 +579,7 @@ impl<Block, H> backend::Backend<Block, H> for Backend<Block, H>
where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
type BlockImportOperation = BlockImportOperation<Block, H>;
type Blockchain = Blockchain<Block>;
@@ -682,14 +681,14 @@ impl<Block, H> backend::LocalBackend<Block, H> for Backend<Block, H>
where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{}
impl<Block, H> backend::RemoteBackend<Block, H> for Backend<Block, H>
where
Block: BlockT,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
fn is_local_state_available(&self, block: &BlockId<Block>) -> bool {
self.blockchain.expect_block_number_from_id(block)
@@ -699,20 +698,20 @@ where
}
/// Prunable in-memory changes trie storage.
pub struct ChangesTrieStorage<H: Hasher>(InMemoryChangesTrieStorage<H>) where H::Out: HeapSizeOf;
impl<H: Hasher> backend::PrunableStateChangesTrieStorage<H> for ChangesTrieStorage<H> where H::Out: HeapSizeOf {
pub struct ChangesTrieStorage<H: Hasher>(InMemoryChangesTrieStorage<H>);
impl<H: Hasher> backend::PrunableStateChangesTrieStorage<H> for ChangesTrieStorage<H> {
fn oldest_changes_trie_block(&self, _config: &ChangesTrieConfiguration, _best_finalized: u64) -> u64 {
0
}
}
impl<H: Hasher> state_machine::ChangesTrieRootsStorage<H> for ChangesTrieStorage<H> where H::Out: HeapSizeOf {
impl<H: Hasher> state_machine::ChangesTrieRootsStorage<H> for ChangesTrieStorage<H> {
fn root(&self, anchor: &ChangesTrieAnchorBlockId<H::Out>, block: u64) -> Result<Option<H::Out>, String> {
self.0.root(anchor, block)
}
}
impl<H: Hasher> state_machine::ChangesTrieStorage<H> for ChangesTrieStorage<H> where H::Out: HeapSizeOf {
impl<H: Hasher> state_machine::ChangesTrieStorage<H> for ChangesTrieStorage<H> {
fn get(&self, key: &H::Out, prefix: &[u8]) -> Result<Option<state_machine::DBValue>, String> {
self.0.get(key, prefix)
}
+4 -5
View File
@@ -33,7 +33,6 @@ use crate::light::blockchain::{Blockchain, Storage as BlockchainStorage};
use crate::light::fetcher::{Fetcher, RemoteReadRequest};
use hash_db::Hasher;
use trie::MemoryDB;
use heapsize::HeapSizeOf;
use consensus::well_known_cache_keys;
const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type and always suceeds; qed";
@@ -108,7 +107,7 @@ impl<S, F, Block, H> ClientBackend<Block, H> for Backend<S, F, H> where
S: BlockchainStorage<Block>,
F: Fetcher<Block>,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
type BlockImportOperation = ImportOperation<Block, S, F, H>;
type Blockchain = Blockchain<S, F>;
@@ -222,7 +221,7 @@ where
S: BlockchainStorage<Block>,
F: Fetcher<Block>,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
fn is_local_state_available(&self, block: &BlockId<Block>) -> bool {
self.genesis_state.read().is_some()
@@ -238,7 +237,7 @@ where
F: Fetcher<Block>,
S: BlockchainStorage<Block>,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
type State = OnDemandOrGenesisState<Block, S, F, H>;
@@ -390,7 +389,7 @@ where
F: Fetcher<Block>,
S: BlockchainStorage<Block>,
H: Hasher<Out=Block::Hash>,
H::Out: HeapSizeOf + Ord,
H::Out: Ord,
{
type Error = ClientError;
type Transaction = ();
@@ -41,7 +41,6 @@ use crate::call_executor::CallExecutor;
use crate::error::{Error as ClientError, Result as ClientResult};
use crate::light::fetcher::{Fetcher, RemoteCallRequest};
use executor::{RuntimeVersion, NativeVersion};
use heapsize::HeapSizeOf;
use trie::MemoryDB;
/// Call executor that executes methods on remote node, querying execution proof
@@ -436,7 +435,7 @@ pub fn check_execution_proof<Header, E, H>(
Header: HeaderT,
E: CodeExecutor<H>,
H: Hasher,
H::Out: Ord + HeapSizeOf,
H::Out: Ord,
{
let local_state_root = request.header.state_root();
let root: H::Out = convert_hash(&local_state_root);
+3 -4
View File
@@ -22,7 +22,6 @@ use std::marker::PhantomData;
use futures::IntoFuture;
use hash_db::{HashDB, Hasher};
use heapsize::HeapSizeOf;
use primitives::{ChangesTrieConfiguration, convert_hash};
use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, NumberFor};
use state_machine::{CodeExecutor, ChangesTrieRootsStorage, ChangesTrieAnchorBlockId,
@@ -188,7 +187,7 @@ impl<E, H, B: BlockT, S: BlockchainStorage<B>, F> LightDataChecker<E, H, B, S, F
) -> ClientResult<Vec<(NumberFor<B>, u32)>>
where
H: Hasher,
H::Out: Ord + HeapSizeOf,
H::Out: Ord,
{
// since we need roots of all changes tries for the range begin..max
// => remote node can't use max block greater that one that we have passed
@@ -259,7 +258,7 @@ impl<E, H, B: BlockT, S: BlockchainStorage<B>, F> LightDataChecker<E, H, B, S, F
) -> ClientResult<()>
where
H: Hasher,
H::Out: Ord + HeapSizeOf,
H::Out: Ord,
{
// all the checks are sharing the same storage
let storage = create_proof_check_backend_storage(remote_roots_proof);
@@ -309,7 +308,7 @@ impl<E, Block, H, S, F> FetchChecker<Block> for LightDataChecker<E, H, Block, S,
Block: BlockT,
E: CodeExecutor<H>,
H: Hasher,
H::Out: Ord + HeapSizeOf,
H::Out: Ord,
S: BlockchainStorage<Block>,
F: Send + Sync,
{