Cleanup of the state-machine crate (#3524)

* Start refactoring state-machine crate

* More improvement to state-machine

* Fix tests compilation on master and remove warnings

* Fix compilation

* Apply suggestions from code review

Co-Authored-By: Sergei Pepyakin <sergei@parity.io>

* Update core/state-machine/src/basic.rs

Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>

* Line width

* Update core/primitives/src/storage.rs

Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com>

* Update core/state-machine/src/error.rs

Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com>

* Review feedback
This commit is contained in:
Bastian Köcher
2019-09-10 17:00:00 +02:00
committed by GitHub
parent 2beeda1488
commit 9607afd629
37 changed files with 781 additions and 674 deletions
@@ -128,9 +128,8 @@ impl<'a, S: 'a + TrieBackendStorage<H>, H: 'a + Hasher> ProvingBackend<'a, S, H>
}
}
/// Consume the backend, extracting the gathered proof in lexicographical order
/// by value.
pub fn extract_proof(self) -> Vec<Vec<u8>> {
/// Consume the backend, extracting the gathered proof in lexicographical order by value.
pub fn extract_proof(&self) -> Vec<Vec<u8>> {
self.proof_recorder
.borrow_mut()
.drain()
@@ -207,10 +206,6 @@ impl<'a, S, H> Backend<H> for ProvingBackend<'a, S, H>
{
self.backend.child_storage_root(storage_key, delta)
}
fn as_trie_backend(&mut self) -> Option<&TrieBackend<Self::TrieBackendStorage, H>> {
None
}
}
/// Create proof check backend.
@@ -249,8 +244,7 @@ mod tests {
use crate::backend::{InMemory};
use crate::trie_backend::tests::test_trie;
use super::*;
use primitives::{Blake2Hasher};
use crate::ChildStorageKey;
use primitives::{Blake2Hasher, child_storage_key::ChildStorageKey};
fn test_proving<'a>(
trie_backend: &'a TrieBackend<PrefixedMemoryDB<Blake2Hasher>,Blake2Hasher>,
@@ -315,12 +309,8 @@ mod tests {
#[test]
fn proof_recorded_and_checked_with_child() {
let subtrie1 = ChildStorageKey::<Blake2Hasher>::from_slice(
b":child_storage:default:sub1"
).unwrap();
let subtrie2 = ChildStorageKey::<Blake2Hasher>::from_slice(
b":child_storage:default:sub2"
).unwrap();
let subtrie1 = ChildStorageKey::from_slice(b":child_storage:default:sub1").unwrap();
let subtrie2 = ChildStorageKey::from_slice(b":child_storage:default:sub2").unwrap();
let own1 = subtrie1.into_owned();
let own2 = subtrie2.into_owned();
let contents = (0..64).map(|i| (None, vec![i], Some(vec![i])))