Refactor sr_primitives. (#3214)

* refactor sr_primitives.

* Fix try build error.

* Line-width

* Ui test.

* Final fixes.

* Fix build again.

* bring back ui test.

* Fix unsigned import.

* Another ui fix.

* Also refactor substrate-primitives

* Fix benchmarks.

* Fix doc test.

* fix doc tests
This commit is contained in:
Kian Paimani
2019-07-29 14:43:53 +02:00
committed by Bastian Köcher
parent cf80af9255
commit 79feb23a22
259 changed files with 667 additions and 665 deletions
+2 -2
View File
@@ -19,8 +19,8 @@
use std::collections::HashMap;
use crate::error;
use primitives::ChangesTrieConfiguration;
use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay};
use runtime_primitives::traits::{Block as BlockT, NumberFor};
use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay};
use sr_primitives::traits::{Block as BlockT, NumberFor};
use state_machine::backend::Backend as StateBackend;
use state_machine::ChangesTrieStorage as StateChangesTrieStorage;
use consensus::well_known_cache_keys;
@@ -16,7 +16,7 @@
//! The runtime api for building blocks.
use runtime_primitives::{traits::Block as BlockT, ApplyResult};
use sr_primitives::{traits::Block as BlockT, ApplyResult};
use rstd::vec::Vec;
use sr_api_macros::decl_runtime_apis;
pub use inherents::{InherentData, CheckInherentsResult};
@@ -17,9 +17,9 @@
use super::api::BlockBuilder as BlockBuilderApi;
use std::vec::Vec;
use parity_codec::Encode;
use runtime_primitives::ApplyOutcome;
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{
use sr_primitives::ApplyOutcome;
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{
Header as HeaderT, Hash, Block as BlockT, One, HashFor, ProvideRuntimeApi, ApiRef, DigestFor,
};
use primitives::{H256, ExecutionContext};
+4 -4
View File
@@ -18,9 +18,9 @@
use std::sync::Arc;
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use runtime_primitives::generic::BlockId;
use runtime_primitives::Justification;
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use sr_primitives::generic::BlockId;
use sr_primitives::Justification;
use consensus::well_known_cache_keys;
use crate::error::{Error, Result};
@@ -196,7 +196,7 @@ pub fn tree_route<Block: BlockT, Backend: HeaderBackend<Block>>(
from: BlockId<Block>,
to: BlockId<Block>,
) -> Result<TreeRoute<Block>> {
use runtime_primitives::traits::Header;
use sr_primitives::traits::Header;
let load_header = |id: BlockId<Block>| {
match backend.header(id) {
+1 -1
View File
@@ -16,7 +16,7 @@
use std::{sync::Arc, cmp::Ord, panic::UnwindSafe, result, cell::RefCell, rc::Rc};
use parity_codec::{Encode, Decode};
use runtime_primitives::{
use sr_primitives::{
generic::BlockId, traits::Block as BlockT,
};
use state_machine::{
+1 -1
View File
@@ -30,7 +30,7 @@ use parity_codec::Encode;
use trie;
use primitives::{H256, convert_hash};
use runtime_primitives::traits::{Header as HeaderT, SimpleArithmetic, Zero, One};
use sr_primitives::traits::{Header as HeaderT, SimpleArithmetic, Zero, One};
use state_machine::backend::InMemory as InMemoryState;
use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend,
prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend};
+5 -5
View File
@@ -24,7 +24,7 @@ use crate::error::Error;
use futures::channel::mpsc;
use parking_lot::{Mutex, RwLock};
use primitives::NativeOrEncoded;
use runtime_primitives::{
use sr_primitives::{
Justification,
generic::{BlockId, SignedBlock},
};
@@ -34,13 +34,13 @@ use consensus::{
well_known_cache_keys::Id as CacheKeyId,
SelectChain, self,
};
use runtime_primitives::traits::{
use sr_primitives::traits::{
Block as BlockT, Header as HeaderT, Zero, NumberFor, CurrentHeight,
BlockNumberToHash, ApiRef, ProvideRuntimeApi,
SaturatedConversion, One, DigestFor,
};
use runtime_primitives::generic::DigestItem;
use runtime_primitives::BuildStorage;
use sr_primitives::generic::DigestItem;
use sr_primitives::BuildStorage;
use crate::runtime_api::{
CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder,
InitializeBlock,
@@ -1851,7 +1851,7 @@ pub(crate) mod tests {
use std::collections::HashMap;
use super::*;
use primitives::blake2_256;
use runtime_primitives::DigestItem;
use sr_primitives::DigestItem;
use consensus::{BlockOrigin, SelectChain};
use test_client::{
prelude::*,
+1 -1
View File
@@ -18,7 +18,7 @@
use std::{self, error, result};
use state_machine;
use runtime_primitives::ApplyError;
use sr_primitives::ApplyError;
use consensus;
use derive_more::{Display, From};
+2 -2
View File
@@ -16,7 +16,7 @@
//! Tool for creating the genesis block.
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, Zero};
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, Zero};
/// Create a genesis block, given the initial storage.
pub fn construct_genesis_block<
@@ -49,7 +49,7 @@ mod tests {
runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest},
AccountKeyring, Sr25519Keyring,
};
use runtime_primitives::traits::BlakeTwo256;
use sr_primitives::traits::BlakeTwo256;
use primitives::Blake2Hasher;
use hex::*;
+3 -3
View File
@@ -20,9 +20,9 @@ use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::{RwLock, Mutex};
use primitives::{ChangesTrieConfiguration, storage::well_known_keys};
use runtime_primitives::generic::{BlockId, DigestItem};
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor};
use runtime_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay};
use sr_primitives::generic::{BlockId, DigestItem};
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor};
use sr_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay};
use state_machine::backend::{Backend as StateBackend, InMemory};
use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId};
use hash_db::Hasher;
+1 -1
View File
@@ -19,7 +19,7 @@
use std::collections::BTreeMap;
use std::cmp::Reverse;
use kvdb::{KeyValueDB, DBTransaction};
use runtime_primitives::traits::SimpleArithmetic;
use sr_primitives::traits::SimpleArithmetic;
use parity_codec::{Encode, Decode};
use crate::error;
+2 -2
View File
@@ -21,9 +21,9 @@ use std::collections::HashMap;
use std::sync::{Arc, Weak};
use parking_lot::{RwLock, Mutex};
use runtime_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay};
use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay};
use state_machine::{Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState};
use runtime_primitives::traits::{Block as BlockT, NumberFor, Zero, Header};
use sr_primitives::traits::{Block as BlockT, NumberFor, Zero, Header};
use crate::in_mem::{self, check_genesis_storage};
use crate::backend::{
AuxStore, Backend as ClientBackend, BlockImportOperation, RemoteBackend, NewBlockState,
@@ -20,8 +20,8 @@
use std::{sync::{Weak, Arc}, collections::HashMap};
use parking_lot::Mutex;
use runtime_primitives::{Justification, generic::BlockId};
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero};
use sr_primitives::{Justification, generic::BlockId};
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero};
use consensus::well_known_cache_keys;
use crate::backend::{AuxStore, NewBlockState};
@@ -24,8 +24,8 @@ use std::{
use parity_codec::{Encode, Decode};
use primitives::{offchain, H256, Blake2Hasher, convert_hash, NativeOrEncoded};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{One, Block as BlockT, Header as HeaderT};
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{One, Block as BlockT, Header as HeaderT};
use state_machine::{
self, Backend as StateBackend, CodeExecutor, OverlayedChanges,
ExecutionStrategy, create_proof_check_backend,
+2 -2
View File
@@ -24,7 +24,7 @@ use std::future::Future;
use hash_db::{HashDB, Hasher};
use parity_codec::{Decode, Encode};
use primitives::{ChangesTrieConfiguration, convert_hash};
use runtime_primitives::traits::{
use sr_primitives::traits::{
Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor,
SimpleArithmetic, CheckedConversion,
};
@@ -502,7 +502,7 @@ pub mod tests {
use crate::light::blockchain::tests::{DummyStorage, DummyBlockchain};
use primitives::{blake2_256, Blake2Hasher, H256};
use primitives::storage::{well_known_keys, StorageKey};
use runtime_primitives::generic::BlockId;
use sr_primitives::generic::BlockId;
use state_machine::Backend;
use super::*;
+2 -2
View File
@@ -25,8 +25,8 @@ use std::sync::Arc;
use executor::RuntimeInfo;
use primitives::{H256, Blake2Hasher};
use runtime_primitives::BuildStorage;
use runtime_primitives::traits::Block as BlockT;
use sr_primitives::BuildStorage;
use sr_primitives::traits::Block as BlockT;
use state_machine::CodeExecutor;
use crate::call_executor::LocalCallExecutor;
+2 -2
View File
@@ -24,7 +24,7 @@ use std::{
use fnv::{FnvHashSet, FnvHashMap};
use futures::channel::mpsc;
use primitives::storage::{StorageKey, StorageData};
use runtime_primitives::traits::Block as BlockT;
use sr_primitives::traits::Block as BlockT;
/// Storage change set
#[derive(Debug)]
@@ -307,7 +307,7 @@ impl<Block: BlockT> StorageNotifications<Block> {
#[cfg(test)]
mod tests {
use runtime_primitives::testing::{H256 as Hash, Block as RawBlock, ExtrinsicWrapper};
use sr_primitives::testing::{H256 as Hash, Block as RawBlock, ExtrinsicWrapper};
use super::*;
use std::iter::{empty, Empty};
+1 -1
View File
@@ -23,7 +23,7 @@ pub use state_machine::OverlayedChanges;
#[cfg(feature = "std")]
pub use primitives::NativeOrEncoded;
#[doc(hidden)]
pub use runtime_primitives::{
pub use sr_primitives::{
traits::{
Block as BlockT, GetNodeBlockType, GetRuntimeBlockType,
Header as HeaderT, ApiRef, RuntimeApiInfo, Hash as HashT,