mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
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:
committed by
Bastian Köcher
parent
cf80af9255
commit
79feb23a22
@@ -18,7 +18,7 @@ srml-aura = { path = "../../../srml/aura" }
|
||||
client = { package = "substrate-client", path = "../../client" }
|
||||
substrate-telemetry = { path = "../../telemetry" }
|
||||
consensus_common = { package = "substrate-consensus-common", path = "../common" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1" }
|
||||
futures-timer = "0.2.1"
|
||||
|
||||
@@ -8,16 +8,16 @@ edition = "2018"
|
||||
[dependencies]
|
||||
parity-codec = { version = "4.1.1", default-features = false }
|
||||
substrate-client = { path = "../../../client", default-features = false }
|
||||
substrate-primitives = { path = "../../../primitives", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives", default-features = false }
|
||||
sr-primitives = { path = "../../../sr-primitives", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"rstd/std",
|
||||
"parity-codec/std",
|
||||
"runtime_primitives/std",
|
||||
"sr-primitives/std",
|
||||
"substrate-client/std",
|
||||
"substrate-primitives/std",
|
||||
"primitives/std",
|
||||
]
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use parity_codec::{Encode, Decode, Codec};
|
||||
use substrate_client::decl_runtime_apis;
|
||||
use rstd::vec::Vec;
|
||||
use runtime_primitives::ConsensusEngineId;
|
||||
use sr_primitives::ConsensusEngineId;
|
||||
|
||||
/// The `ConsensusEngineId` of AuRa.
|
||||
pub const AURA_ENGINE_ID: ConsensusEngineId = [b'a', b'u', b'r', b'a'];
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
use primitives::Pair;
|
||||
use aura_primitives::AURA_ENGINE_ID;
|
||||
use runtime_primitives::generic::{DigestItem, OpaqueDigestItemId};
|
||||
use sr_primitives::generic::{DigestItem, OpaqueDigestItemId};
|
||||
use parity_codec::{Encode, Codec};
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ use client::{
|
||||
backend::AuxStore,
|
||||
};
|
||||
|
||||
use runtime_primitives::{generic::{self, BlockId, OpaqueDigestItemId}, Justification};
|
||||
use runtime_primitives::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member};
|
||||
use sr_primitives::{generic::{self, BlockId, OpaqueDigestItemId}, Justification};
|
||||
use sr_primitives::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member};
|
||||
|
||||
use primitives::Pair;
|
||||
use inherents::{InherentDataProviders, InherentData};
|
||||
@@ -716,7 +716,7 @@ mod tests {
|
||||
use consensus_common::NoNetwork as DummyOracle;
|
||||
use network::test::*;
|
||||
use network::test::{Block as TestBlock, PeersClient, PeersFullClient};
|
||||
use runtime_primitives::traits::{Block as BlockT, DigestFor};
|
||||
use sr_primitives::traits::{Block as BlockT, DigestFor};
|
||||
use network::config::ProtocolConfig;
|
||||
use parking_lot::Mutex;
|
||||
use tokio::runtime::current_thread;
|
||||
|
||||
@@ -21,7 +21,7 @@ srml-babe = { path = "../../../srml/babe" }
|
||||
client = { package = "substrate-client", path = "../../client" }
|
||||
consensus_common = { package = "substrate-consensus-common", path = "../common" }
|
||||
slots = { package = "substrate-consensus-slots", path = "../slots" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
fork-tree = { path = "../../utils/fork-tree" }
|
||||
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1" }
|
||||
|
||||
@@ -8,8 +8,8 @@ edition = "2018"
|
||||
[dependencies]
|
||||
substrate-client = { path = "../../../client", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives", default-features = false }
|
||||
substrate-primitives = { path = "../../../primitives", default-features = false }
|
||||
sr-primitives = { path = "../../../sr-primitives", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false }
|
||||
slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false }
|
||||
schnorrkel = { version = "0.1.1", optional = true }
|
||||
@@ -18,7 +18,7 @@ schnorrkel = { version = "0.1.1", optional = true }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"rstd/std",
|
||||
"runtime_primitives/std",
|
||||
"sr-primitives/std",
|
||||
"substrate-client/std",
|
||||
"parity-codec/std",
|
||||
"schnorrkel",
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
//! Private implementation details of BABE digests.
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use substrate_primitives::sr25519::Signature;
|
||||
use primitives::sr25519::Signature;
|
||||
#[cfg(feature = "std")]
|
||||
use super::{BABE_ENGINE_ID, Epoch};
|
||||
#[cfg(not(feature = "std"))]
|
||||
use super::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH};
|
||||
use super::SlotNumber;
|
||||
#[cfg(feature = "std")]
|
||||
use runtime_primitives::{DigestItem, generic::OpaqueDigestItemId};
|
||||
use sr_primitives::{DigestItem, generic::OpaqueDigestItemId};
|
||||
#[cfg(feature = "std")]
|
||||
use std::fmt::Debug;
|
||||
use parity_codec::{Decode, Encode};
|
||||
|
||||
@@ -23,8 +23,8 @@ mod digest;
|
||||
|
||||
use parity_codec::{Encode, Decode};
|
||||
use rstd::vec::Vec;
|
||||
use runtime_primitives::ConsensusEngineId;
|
||||
use substrate_primitives::sr25519;
|
||||
use sr_primitives::ConsensusEngineId;
|
||||
use primitives::sr25519;
|
||||
use substrate_client::decl_runtime_apis;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -21,7 +21,7 @@ use parity_codec::{Decode, Encode};
|
||||
|
||||
use client::backend::AuxStore;
|
||||
use client::error::{Result as ClientResult, Error as ClientError};
|
||||
use runtime_primitives::traits::Block as BlockT;
|
||||
use sr_primitives::traits::Block as BlockT;
|
||||
|
||||
use super::{EpochChanges, SharedEpochChanges};
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ use consensus_common::import_queue::{
|
||||
BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
use consensus_common::well_known_cache_keys::Id as CacheKeyId;
|
||||
use runtime_primitives::{generic, generic::{BlockId, OpaqueDigestItemId}, Justification};
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::{generic, generic::{BlockId, OpaqueDigestItemId}, Justification};
|
||||
use sr_primitives::traits::{
|
||||
Block as BlockT, Header, DigestItemFor, NumberFor, ProvideRuntimeApi,
|
||||
SimpleBitOps, Zero,
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ use client::{LongestChain, block_builder::BlockBuilder};
|
||||
use consensus_common::NoNetwork as DummyOracle;
|
||||
use network::test::*;
|
||||
use network::test::{Block as TestBlock, PeersClient};
|
||||
use runtime_primitives::traits::{Block as BlockT, DigestFor};
|
||||
use sr_primitives::traits::{Block as BlockT, DigestFor};
|
||||
use network::config::ProtocolConfig;
|
||||
use tokio::runtime::current_thread;
|
||||
use keyring::sr25519::Keyring;
|
||||
|
||||
@@ -15,7 +15,7 @@ futures-preview = "0.3.0-alpha.17"
|
||||
futures-timer = "0.2.1"
|
||||
rstd = { package = "sr-std", path = "../../sr-std" }
|
||||
runtime_version = { package = "sr-version", path = "../../sr-version" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
parity-codec = { version = "4.1.1", features = ["derive"] }
|
||||
parking_lot = "0.8.0"
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Block import helpers.
|
||||
|
||||
use runtime_primitives::traits::{Block as BlockT, DigestItemFor, Header as HeaderT, NumberFor};
|
||||
use runtime_primitives::Justification;
|
||||
use sr_primitives::traits::{Block as BlockT, DigestItemFor, Header as HeaderT, NumberFor};
|
||||
use sr_primitives::Justification;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use super::MAX_BLOCK_SIZE;
|
||||
|
||||
use parity_codec::Encode;
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion};
|
||||
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion};
|
||||
|
||||
// This is just a best effort to encode the number. None indicated that it's too big to encode
|
||||
// in a u128.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//! queues to be instantiated simply.
|
||||
|
||||
use std::{sync::Arc, collections::HashMap};
|
||||
use runtime_primitives::{Justification, traits::{Block as BlockT, Header as _, NumberFor}};
|
||||
use sr_primitives::{Justification, traits::{Block as BlockT, Header as _, NumberFor}};
|
||||
use crate::{error::Error as ConsensusError, well_known_cache_keys::Id as CacheKeyId};
|
||||
use crate::block_import::{
|
||||
BlockImport, BlockOrigin, BlockImportParams, ImportedAux, JustificationImport, ImportResult,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::{mem, pin::Pin, sync::Arc, time::Duration};
|
||||
use futures::{prelude::*, channel::mpsc, task::SpawnExt as _, task::Context, task::Poll};
|
||||
use futures_timer::Delay;
|
||||
use runtime_primitives::{Justification, traits::{Block as BlockT, Header as HeaderT, NumberFor}};
|
||||
use sr_primitives::{Justification, traits::{Block as BlockT, Header as HeaderT, NumberFor}};
|
||||
|
||||
use crate::block_import::BlockOrigin;
|
||||
use crate::import_queue::{
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
//!
|
||||
|
||||
use futures::{prelude::*, channel::mpsc};
|
||||
use runtime_primitives::traits::{Block as BlockT, NumberFor};
|
||||
use sr_primitives::traits::{Block as BlockT, NumberFor};
|
||||
use std::{pin::Pin, task::Context, task::Poll};
|
||||
use crate::import_queue::{Origin, Link, BlockImportResult, BlockImportError};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use runtime_primitives::traits::{Block as BlockT, DigestFor};
|
||||
use sr_primitives::traits::{Block as BlockT, DigestFor};
|
||||
use futures::prelude::*;
|
||||
pub use inherents::InherentData;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Substrate Consensus Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::error::Error;
|
||||
use runtime_primitives::traits::{Block as BlockT, NumberFor};
|
||||
use sr_primitives::traits::{Block as BlockT, NumberFor};
|
||||
|
||||
|
||||
/// The SelectChain trait defines the strategy upon which the head is chosen
|
||||
|
||||
@@ -15,7 +15,7 @@ client = { package = "substrate-client", path = "../../client" }
|
||||
transaction_pool = { package = "substrate-transaction-pool", path = "../../transaction-pool" }
|
||||
runtime_support = { package = "srml-support", path = "../../../srml/support" }
|
||||
srml-system = { path = "../../../srml/system" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
runtime_version = { package = "sr-version", path = "../../sr-version" }
|
||||
runtime_io = { package = "sr-io", path = "../../sr-io" }
|
||||
tokio = "0.1.7"
|
||||
@@ -32,6 +32,6 @@ default = ["std"]
|
||||
std = [
|
||||
"primitives/std",
|
||||
"runtime_support/std",
|
||||
"runtime_primitives/std",
|
||||
"sr-primitives/std",
|
||||
"runtime_version/std",
|
||||
]
|
||||
|
||||
@@ -46,13 +46,13 @@ use consensus::error::{ErrorKind as CommonErrorKind};
|
||||
use consensus::{Authorities, BlockImport, Environment, Proposer as BaseProposer};
|
||||
use client::{Client as SubstrateClient, CallExecutor};
|
||||
use client::runtime_api::{Core, BlockBuilder as BlockBuilderAPI, OldTxQueue, BlockBuilderError};
|
||||
use runtime_primitives::generic::{BlockId, Era, ImportResult, BlockImportParams, BlockOrigin};
|
||||
use runtime_primitives::traits::{Block, Header};
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::generic::{BlockId, Era, ImportResult, BlockImportParams, BlockOrigin};
|
||||
use sr_primitives::traits::{Block, Header};
|
||||
use sr_primitives::traits::{
|
||||
Block as BlockT, Hash as HashT, Header as HeaderT,
|
||||
BlockNumberToHash, SaturatedConversion
|
||||
};
|
||||
use runtime_primitives::Justification;
|
||||
use sr_primitives::Justification;
|
||||
use primitives::{AuthorityId, ed25519, Blake2Hasher, ed25519::LocalizedSignature};
|
||||
use srml_system::Trait as SystemT;
|
||||
|
||||
@@ -982,7 +982,7 @@ impl<N, C, A> consensus::Environment<<C as AuthoringApi>::Block> for ProposerFac
|
||||
authorities: &[AuthorityId],
|
||||
sign_with: Arc<ed25519::Pair>,
|
||||
) -> Result<Self::Proposer, Error> {
|
||||
use runtime_primitives::traits::Hash as HashT;
|
||||
use sr_primitives::traits::Hash as HashT;
|
||||
let parent_hash = parent_header.hash();
|
||||
|
||||
let id = BlockId::hash(parent_hash);
|
||||
@@ -1061,7 +1061,7 @@ impl<C, A> BaseProposer<<C as AuthoringApi>::Block> for Proposer<C, A> where
|
||||
type Evaluate = Box<Future<Item=bool, Error=Error>>;
|
||||
|
||||
fn propose(&self) -> Self::Create {
|
||||
use runtime_primitives::traits::BlakeTwo256;
|
||||
use sr_primitives::traits::BlakeTwo256;
|
||||
|
||||
const MAX_VOTE_OFFLINE_SECONDS: Duration = Duration::from_secs(60);
|
||||
|
||||
@@ -1237,7 +1237,7 @@ impl<C, A> LocalProposer<<C as AuthoringApi>::Block> for Proposer<C, A> where
|
||||
_misbehavior: Vec<(AuthorityId, Misbehavior<<<C as AuthoringApi>::Block as BlockT>::Hash>)>
|
||||
) {
|
||||
use rhododendron::Misbehavior as GenericMisbehavior;
|
||||
use runtime_primitives::bft::{MisbehaviorKind, MisbehaviorReport};
|
||||
use sr_primitives::bft::{MisbehaviorKind, MisbehaviorReport};
|
||||
use node_runtime::{Call, UncheckedExtrinsic, ConsensusCall};
|
||||
|
||||
let mut next_index = {
|
||||
@@ -1329,7 +1329,7 @@ mod tests {
|
||||
use std::collections::HashSet;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use runtime_primitives::testing::{Block as GenericTestBlock, Header as TestHeader};
|
||||
use sr_primitives::testing::{Block as GenericTestBlock, Header as TestHeader};
|
||||
use primitives::H256;
|
||||
use keyring::Ed25519Keyring;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ mod tests {
|
||||
use keyring::Ed25519Keyring;
|
||||
use rhododendron;
|
||||
|
||||
use runtime_primitives::testing::{H256, Block as RawBlock};
|
||||
use sr_primitives::testing::{H256, Block as RawBlock};
|
||||
|
||||
type Block = RawBlock<u64>;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use std::sync::Arc;
|
||||
use client::{BlockchainEvents, BlockBody};
|
||||
use futures::prelude::*;
|
||||
use transaction_pool::txpool::{Pool as TransactionPool, ChainApi as PoolChainApi};
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, BlockNumberToHash};
|
||||
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, BlockNumberToHash};
|
||||
|
||||
use tokio::executor::current_thread::TaskExecutor as LocalThreadHandle;
|
||||
use tokio::runtime::TaskExecutor as ThreadPoolHandle;
|
||||
|
||||
@@ -9,7 +9,7 @@ edition = "2018"
|
||||
codec = { package = "parity-codec", version = "4.1.1" }
|
||||
client = { package = "substrate-client", path = "../../client" }
|
||||
primitives = { package = "substrate-primitives", path = "../../primitives" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
consensus_common = { package = "substrate-consensus-common", path = "../common" }
|
||||
inherents = { package = "substrate-inherents", path = "../../inherents" }
|
||||
futures-preview = "0.3.0-alpha.17"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use codec::{Encode, Decode};
|
||||
use client::backend::AuxStore;
|
||||
use client::error::{Result as ClientResult, Error as ClientError};
|
||||
use runtime_primitives::traits::Header;
|
||||
use sr_primitives::traits::Header;
|
||||
|
||||
const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map";
|
||||
const SLOT_HEADER_START: &[u8] = b"slot_header_start";
|
||||
@@ -153,7 +153,7 @@ pub fn check_equivocation<C, H, P>(
|
||||
mod test {
|
||||
use primitives::{sr25519, Pair};
|
||||
use primitives::hash::H256;
|
||||
use runtime_primitives::testing::{Header as HeaderTest, Digest as DigestTest};
|
||||
use sr_primitives::testing::{Header as HeaderTest, Digest as DigestTest};
|
||||
use test_client;
|
||||
|
||||
use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation};
|
||||
|
||||
@@ -35,8 +35,8 @@ use consensus_common::{SyncOracle, SelectChain};
|
||||
use futures::{prelude::*, future::{self, Either}, task::Poll};
|
||||
use inherents::{InherentData, InherentDataProviders};
|
||||
use log::{debug, error, info, warn};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::{ApiRef, Block as BlockT, ProvideRuntimeApi};
|
||||
use sr_primitives::generic::BlockId;
|
||||
use sr_primitives::traits::{ApiRef, Block as BlockT, ProvideRuntimeApi};
|
||||
use std::{fmt::Debug, ops::Deref, panic, pin::Pin};
|
||||
|
||||
/// A worker that should be invoked at every new slot.
|
||||
@@ -208,7 +208,7 @@ impl<T: Clone> SlotDuration<T> {
|
||||
.into()
|
||||
}),
|
||||
None => {
|
||||
use runtime_primitives::traits::Zero;
|
||||
use sr_primitives::traits::Zero;
|
||||
let genesis_slot_duration =
|
||||
cb(client.runtime_api(), &BlockId::number(Zero::zero()))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user